Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Conversation

@smithsz
Copy link
Contributor

@smithsz smithsz commented Nov 5, 2018

Checklist

  • Tick to sign-off your agreement to the Developer Certificate of Origin (DCO) 1.1
  • Added tests for code changes or test/build only changes
  • Updated the change log file (CHANGES.md|CHANGELOG.md) or test/build only changes
  • Completed the PR template below:

Description

Use latest nano dependency.

Fixes #286.
Fixes #289.
Fixes #337.
Fixes #338.

Approach

Removed promises plugin logic. Allow Nano to directly pass a promise back to the user.

Schema & API Changes

Public API has changed. All functions now return a promise (except for the ...AsStream
functions).

Security and Privacy

No change.

Testing

Updated unit tests and removed redundant promise tests.

Monitoring and Logging

No change.

Copy link
Member

@ricellis ricellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial thoughts on this.

README.md Outdated
This feature interfaces with the Cloudant [authorization API][Authorization].
Use the authorization feature to generate new API keys to access your data. An API key is basically a username/password pair for granting others access to your data, without giving them the keys to the castle.
Use the authorization feature to generate new API keys to access your data. An
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just a formatting change and a bit unrelated to this PR, but perhaps we should make it more clear here that this is referring to Cloudant's legacy API keys to avoid confusion with IAM API keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll link to the IBM Cloudant Legacy vs IAM access controls docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See d7f5da2.

See [CORS] for further details.
## Virtual Hosts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated, we can probably remove it for v3, although that should probably happen in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I'll raise another PR for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #345.


// Specify the database we are going to use (alice)...
var alice = cloudant.db.use('alice')
asyncCall().then((data) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth pasting these async|promises|both snippets into the readme-examples.js test so we can validate they are working alongside the callback formats?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rm that legacy/readme-examples.js. It's incomplete. I'll add a new test file containing all code from README.md.

Copy link
Member

@ricellis ricellis Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smithsz as an FYI there were some necessary changes to that legacy code that I did recently to support parallel running (i.e. using a unique database name instead of alice or test or whatever. Pretty much just adding constants for the DB names instead of using the same string that was used in the examples.

const alice = `nodejs_cloudant_test_${uuid()}`
const my_db = `nodejs_cloudant_test_${uuid()}`

});

it('should return a stream', function(done) {
it('should return a promise', function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird because the whole purpose of the test appears to be to check that we get a stream when we need one. I think we need to test the behaviour of the asStream methods as well if these are now testing promises, unless you think the stream testing elsewhere is sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all legacy cruft. I just wanted to get it passing. There is no ...AsStream equivalent for the db info func. Perhaps I can use changesAsStream or something instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to add tests for the ...AsStream funcs. I think we have enough coverage with the Cloudant client tests:

  • client with a callback
  • client with event listeners
    - client that returns a promise (promise resolve/reject handled by nano)
  • piping of response body
  • piping request payload to a client

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added legacy stream tests here using cloudant.db.listAsStream func.

Copy link
Member

@ricellis ricellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple more things

CHANGES.md Outdated
@@ -1,3 +1,8 @@
# 3.0.0 UNRELEASED
- [FIXED] Expose `BasePlugin` type in Cloudant client.
- [REMOVED] Remove nodejs-cloudant TypeScript type definitions for `db.search`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change needs to explain that the Nano search types are used instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll add some detail.

CHANGES.md Outdated
# 3.0.0 UNRELEASED
- [FIXED] Expose `BasePlugin` type in Cloudant client.
- [REMOVED] Remove nodejs-cloudant TypeScript type definitions for `db.search`.
- [UPGRADED] Using nano==7.1.0 dependancy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependancy -> dependency

Also is it going to be 7.1.0 or do we need something newer with your PRs in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, excuse the typo. Yeah, I'll bump to 7.1.1. That's what's now in package.json.

@smithsz smithsz force-pushed the use-latest-nano branch 3 times, most recently from ccd25a5 to 5d64701 Compare November 14, 2018 15:15
@smithsz smithsz merged commit c1a3f71 into master Nov 16, 2018
@smithsz smithsz deleted the use-latest-nano branch November 16, 2018 10:52
@ricellis ricellis added this to the 3.0.0 milestone Nov 19, 2018
@wrumsby wrumsby mentioned this pull request Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BasePlugin not exported TypeScript: Support Promise return types. Set 'promises' plugin by default

2 participants