@ibm-cloud/cloudant 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -106
- package/auth/sessionTokenManager.d.ts +0 -1
- package/cloudant/features/changesResultItemStream.d.ts +0 -2
- package/cloudant/features/stream.d.ts +0 -2
- package/cloudant/v1.d.ts +17 -11
- package/cloudant/v1.js +38 -6
- package/cloudant/v1.js.map +1 -1
- package/lib/common.js +1 -2
- package/lib/common.js.map +1 -1
- package/lib/getAuthenticatorFromEnvCloudantExtension.js +1 -1
- package/lib/getAuthenticatorFromEnvCloudantExtension.js.map +1 -1
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://github.com/IBM/cloudant-node-sdk/releases/latest)
|
|
3
3
|
[](https://ibm.github.io/cloudant-node-sdk/)
|
|
4
4
|
|
|
5
|
-
# IBM Cloudant Node.js SDK Version 0.
|
|
5
|
+
# IBM Cloudant Node.js SDK Version 0.10.0
|
|
6
6
|
|
|
7
7
|
IBM Cloudant Node.js SDK is a client library that interacts with the
|
|
8
8
|
[IBM Cloudant APIs](https://cloud.ibm.com/apidocs/cloudant?code=node).
|
|
@@ -18,16 +18,7 @@ to avoid surprises.
|
|
|
18
18
|
<details>
|
|
19
19
|
<summary>Table of Contents</summary>
|
|
20
20
|
|
|
21
|
-
<!--
|
|
22
|
-
The TOC below is generated using the `markdown-toc` node package.
|
|
23
|
-
|
|
24
|
-
https://github.com/jonschlinkert/markdown-toc
|
|
25
|
-
|
|
26
|
-
npx markdown-toc -i README.md
|
|
27
|
-
-->
|
|
28
|
-
|
|
29
21
|
<!-- toc -->
|
|
30
|
-
|
|
31
22
|
- [Overview](#overview)
|
|
32
23
|
- [Features](#features)
|
|
33
24
|
- [Prerequisites](#prerequisites)
|
|
@@ -75,8 +66,6 @@ to avoid surprises.
|
|
|
75
66
|
- [Contributing](#contributing)
|
|
76
67
|
- [License](#license)
|
|
77
68
|
|
|
78
|
-
<!-- tocstop -->
|
|
79
|
-
|
|
80
69
|
</details>
|
|
81
70
|
|
|
82
71
|
## Overview
|
|
@@ -97,8 +86,8 @@ project:
|
|
|
97
86
|
|
|
98
87
|
- Supported by IBM Cloudant.
|
|
99
88
|
- Server compatibility with:
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
- IBM Cloudant.
|
|
90
|
+
- [Apache CouchDB 3.x](https://docs.couchdb.org/en/stable/) for data operations.
|
|
102
91
|
- Includes all the most popular and latest supported endpoints for
|
|
103
92
|
applications.
|
|
104
93
|
- Handles the authentication.
|
|
@@ -118,57 +107,41 @@ project:
|
|
|
118
107
|
server.
|
|
119
108
|
- Node.js 18 or 20.
|
|
120
109
|
|
|
121
|
-
|
|
122
110
|
## Installation
|
|
123
111
|
|
|
124
112
|
```sh
|
|
125
113
|
npm install @ibm-cloud/cloudant
|
|
126
114
|
```
|
|
127
115
|
|
|
128
|
-
|
|
129
116
|
## Using the SDK
|
|
130
117
|
|
|
131
118
|
For fundamental SDK usage information and config options, please see the common [IBM Cloud SDK](https://github.com/IBM/ibm-cloud-sdk-common/blob/main/README.md) documentation.
|
|
132
119
|
|
|
133
120
|
This library requires configuration with a service URL and
|
|
134
|
-
[Cloudant service credentials]
|
|
121
|
+
[Cloudant service credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials) to authenticate with your
|
|
135
122
|
account.
|
|
136
123
|
|
|
137
124
|
There are several ways to **set** these authentication properties:
|
|
138
125
|
|
|
139
126
|
1. As [environment variables](#authentication-with-environment-variables)
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
2. The [programmatic approach](#programmatic-authentication)
|
|
128
|
+
3. With an [external credentials file](#authentication-with-external-configuration)
|
|
142
129
|
|
|
143
130
|
The following section describes the different authentication types and provides environment variable examples.
|
|
144
131
|
Examples for other configuration methods are available by following the provided links.
|
|
145
132
|
|
|
146
133
|
### Authentication
|
|
147
134
|
|
|
148
|
-
[service-credentials]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials
|
|
149
|
-
[cloud-IAM-mgmt]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant#introduction-iam-ai
|
|
150
|
-
[couch-cookie-auth]: https://docs.couchdb.org/en/stable/api/server/authn.html#cookie-authentication
|
|
151
|
-
[cloudant-cookie-auth]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#cookie-authentication
|
|
152
|
-
[couch-basic-auth]: https://docs.couchdb.org/en/stable/api/server/authn.html#basic-authentication
|
|
153
|
-
[couch-jwt-auth]: https://docs.couchdb.org/en/stable/api/server/authn.html#jwt-authentication
|
|
154
|
-
[cloudant-basic-auth]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#basic-authentication
|
|
155
|
-
[cloudant-legacy-api-keys]: https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#api-keys
|
|
156
|
-
[core-container-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#container-authentication
|
|
157
|
-
[core-vpc-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#vpc-instance-authentication
|
|
158
|
-
[core-iam-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#identity-and-access-management-iam-authentication
|
|
159
|
-
[core-bearer-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#bearer-token-authentication
|
|
160
|
-
[core-basic-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#basic-authentication
|
|
161
|
-
[core-no-auth]: https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#no-auth-authentication
|
|
162
135
|
|
|
163
136
|
This library requires credentials to authenticate with IBM Cloudant. These credentials may be:
|
|
164
137
|
* IBM Cloud IAM credentials (can be used with authentication types `CONTAINER`, `VPC` and `IAM`)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
* [IBM Cloud account](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-managing-access-for-cloudant#introduction-iam-ai) user, service ID or trusted profile credentials
|
|
139
|
+
that have been granted access to the IBM Cloud Cloudant resource instance.
|
|
140
|
+
* [IBM Cloudant service credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials) generated by the IBM Cloud Cloudant resource instance.
|
|
168
141
|
* Username and password credentials (can be used with authentication types `COUCHDB_SESSION` and `BASIC`)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
* [IBM Cloudant service credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials) generated for an IBM Cloud Cloudant resource instance not configured as `IAM only`.
|
|
143
|
+
* IBM Cloudant [legacy credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#basic-authentication) (i.e. username and password) for instances not in IBM Cloud.
|
|
144
|
+
* IBM Cloudant [legacy API keys](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#api-keys).
|
|
172
145
|
|
|
173
146
|
For other compatible APIs that are not Cloudant accounts (e.g. Apache CouchDB) non-IAM based authentication types
|
|
174
147
|
must be used.
|
|
@@ -179,13 +152,13 @@ from the first row in the table that is compatible with your environment.
|
|
|
179
152
|
|
|
180
153
|
| Authentication type | Recommended for | `AUTH_TYPE` | Description |
|
|
181
154
|
| --- | --- | --- | --- |
|
|
182
|
-
| IAM Trusted Profiles compute resource ([container]
|
|
183
|
-
| IAM Trusted Profiles compute resource ([VPC]
|
|
184
|
-
| [IAM API key]
|
|
185
|
-
| [Session cookie](#session-cookie-authentication) | [Cloudant]
|
|
186
|
-
| [Bearer token]
|
|
187
|
-
| [Basic]
|
|
188
|
-
| [None]
|
|
155
|
+
| IAM Trusted Profiles compute resource ([container](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#container-authentication)) | Cloudant<BR>(SDK running in IBM Cloud IKS) | `CONTAINER` | Obtains a compute resource (CR) token from the container.<BR>Exchanges the CR token for an IAM `access_token`.<BR>Adds an `Authorization: Bearer <access_token>` header to each HTTP request.<BR>Automatically renews the access token when needed. |
|
|
156
|
+
| IAM Trusted Profiles compute resource ([VPC](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#vpc-instance-authentication)) | Cloudant<BR>(SDK running in IBM Cloud VPC) | `VPC` | Obtains an identity token from the VPC instance metadata.<BR>Exchanges the identity token for an IAM `access_token`.<BR>Adds an `Authorization: Bearer <access_token>` header to each HTTP request.<BR>Automatically renews the access token when needed. |
|
|
157
|
+
| [IAM API key](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#identity-and-access-management-iam-authentication) | Cloudant | `IAM` | Exchanges an IAM API key for an IAM `access_token`.<BR>Adds an `Authorization: Bearer <access_token>` header to each HTTP request.<BR>Automatically renews the access token when needed. |
|
|
158
|
+
| [Session cookie](#session-cookie-authentication) | [Cloudant](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-work-with-your-account#cookie-authentication)<BR>(legacy credentials & instances without IAM)<BR><BR>[Apache CouchDB](https://docs.couchdb.org/en/stable/api/server/authn.html#cookie-authentication) | `COUCHDB_SESSION` | Exchanges credentials with `/_session` endpoint to retrieve a cookie.<BR>Adds `Cookie` header and content to each HTTP request.<BR>Automatically renews session when needed. |
|
|
159
|
+
| [Bearer token](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#bearer-token-authentication) | [Apache CouchDB](https://docs.couchdb.org/en/stable/api/server/authn.html#jwt-authentication)<BR>(using JWT authentication) | `BEARERTOKEN` | Adds an `Authorization: Bearer <token>` to each HTTP request.<BR>No token management or renewal.<BR>Also compatible with IAM access tokens managed independently of the SDK. |
|
|
160
|
+
| [Basic](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#basic-authentication) | [Apache CouchDB](https://docs.couchdb.org/en/stable/api/server/authn.html#basic-authentication)<BR>(if cookies are not enabled) | `BASIC` | Adds an `Authorization: Basic <encoded username and password>` header to each HTTP request. |
|
|
161
|
+
| [None](https://github.com/IBM/node-sdk-core/blob/main/Authentication.md#no-auth-authentication) | - | `NOAUTH` | Note that this authentication type only works for operations against a database allowing access for unauthenticated users. |
|
|
189
162
|
|
|
190
163
|
The default authentication type for the SDK is `CONTAINER` unless `APIKEY` configuration is supplied, which changes the default authentication type to `IAM`.
|
|
191
164
|
|
|
@@ -200,7 +173,7 @@ and the same prefix is used for all configuration options.
|
|
|
200
173
|
|
|
201
174
|
For Cloudant *IAM API key authentication*, set the following environmental variables by
|
|
202
175
|
replacing the `<url>` and `<apikey>` with your proper
|
|
203
|
-
[service credentials]
|
|
176
|
+
[service credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials). There is no need to set
|
|
204
177
|
`CLOUDANT_AUTH_TYPE` to `IAM` because it is the default when an `APIKEY` is set.
|
|
205
178
|
|
|
206
179
|
```bash
|
|
@@ -238,7 +211,7 @@ Alternatively a profile CRN may be used instead of an ID by replacing `CLOUDANT_
|
|
|
238
211
|
|
|
239
212
|
For `COUCHDB_SESSION` authentication, set the following environmental variables
|
|
240
213
|
by replacing the `<url>`, `<username>` and `<password>` with your proper
|
|
241
|
-
[service credentials]
|
|
214
|
+
[service credentials](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-locating-your-service-credentials).
|
|
242
215
|
|
|
243
216
|
```bash
|
|
244
217
|
CLOUDANT_AUTH_TYPE=COUCHDB_SESSION
|
|
@@ -305,7 +278,6 @@ Once the environment variables are set, you can try out the code examples.
|
|
|
305
278
|
```ts
|
|
306
279
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
307
280
|
```
|
|
308
|
-
[embedmd]:# (test/examples/src/ts/CreateDbAndDoc.ts /interface/ $)
|
|
309
281
|
```ts
|
|
310
282
|
interface OrderDocument extends CloudantV1.Document {
|
|
311
283
|
name?: string;
|
|
@@ -385,7 +357,6 @@ createDb.then(() => {
|
|
|
385
357
|
```js
|
|
386
358
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
387
359
|
```
|
|
388
|
-
[embedmd]:# (test/examples/src/js/CreateDbAndDoc.js /const createDbAndDoc/ /createDbAndDoc\(\);\n\}/)
|
|
389
360
|
```js
|
|
390
361
|
const createDbAndDoc = async () => {
|
|
391
362
|
// 1. Create a client with `CLOUDANT` default service name ====================
|
|
@@ -457,7 +428,6 @@ if (require.main === module) {
|
|
|
457
428
|
|
|
458
429
|
When you run the code, you see a result similar to the following output.
|
|
459
430
|
|
|
460
|
-
[embedmd]:# (test/examples/output/CreateDbAndDoc.txt)
|
|
461
431
|
```txt
|
|
462
432
|
"orders" database created.
|
|
463
433
|
You have created the document:
|
|
@@ -486,7 +456,6 @@ database or 'example' document was not found."
|
|
|
486
456
|
```ts
|
|
487
457
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
488
458
|
```
|
|
489
|
-
[embedmd]:# (test/examples/src/ts/GetInfoFromExistingDatabase.ts /\/\/ 1./ $)
|
|
490
459
|
```ts
|
|
491
460
|
// 1. Create a client with `CLOUDANT` default service name =====================
|
|
492
461
|
const client = CloudantV1.newInstance({});
|
|
@@ -535,7 +504,6 @@ client.getDocument(getDocParams).then((documentExample) => {
|
|
|
535
504
|
```js
|
|
536
505
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
537
506
|
```
|
|
538
|
-
[embedmd]:# (test/examples/src/js/GetInfoFromExistingDatabase.js /const getInfoFromExistingDatabase/ /getInfoFromExistingDatabase\(\);\n\}/)
|
|
539
507
|
```js
|
|
540
508
|
const getInfoFromExistingDatabase = async () => {
|
|
541
509
|
// 1. Create a client with `CLOUDANT` default service name ===================
|
|
@@ -580,11 +548,9 @@ if (require.main === module) {
|
|
|
580
548
|
|
|
581
549
|
</details>
|
|
582
550
|
|
|
583
|
-
|
|
584
551
|
</details>
|
|
585
552
|
When you run the code, you see a result similar to the following output.
|
|
586
553
|
|
|
587
|
-
[embedmd]:# (test/examples/output/GetInfoFromExistingDatabase.txt)
|
|
588
554
|
```txt
|
|
589
555
|
Server version 3.2.1
|
|
590
556
|
Document count in "orders" database is 1.
|
|
@@ -614,7 +580,6 @@ database or 'example' document was not found."
|
|
|
614
580
|
```ts
|
|
615
581
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
616
582
|
```
|
|
617
|
-
[embedmd]:# (test/examples/src/ts/UpdateDoc.ts /interface/ $)
|
|
618
583
|
```ts
|
|
619
584
|
interface OrderDocument extends CloudantV1.Document {
|
|
620
585
|
address?: string;
|
|
@@ -709,7 +674,6 @@ client
|
|
|
709
674
|
```js
|
|
710
675
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
711
676
|
```
|
|
712
|
-
[embedmd]:# (test/examples/src/js/UpdateDoc.js /const updateDoc/ /updateDoc\(\);\n\}/)
|
|
713
677
|
```js
|
|
714
678
|
const updateDoc = async () => {
|
|
715
679
|
// 1. Create a client with `CLOUDANT` default service name ====================
|
|
@@ -801,11 +765,9 @@ if (require.main === module) {
|
|
|
801
765
|
```
|
|
802
766
|
</details>
|
|
803
767
|
|
|
804
|
-
|
|
805
768
|
</details>
|
|
806
769
|
When you run the code, you see a result similar to the following output.
|
|
807
770
|
|
|
808
|
-
[embedmd]:# (test/examples/output/UpdateDoc.txt)
|
|
809
771
|
```txt
|
|
810
772
|
You have updated the document:
|
|
811
773
|
{
|
|
@@ -833,7 +795,6 @@ database or 'example' document was not found."
|
|
|
833
795
|
```ts
|
|
834
796
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
835
797
|
```
|
|
836
|
-
[embedmd]:# (test/examples/src/ts/DeleteDoc.ts /interface/ $)
|
|
837
798
|
```ts
|
|
838
799
|
interface OrderDocument extends CloudantV1.Document {
|
|
839
800
|
name?: string;
|
|
@@ -889,7 +850,6 @@ client
|
|
|
889
850
|
```js
|
|
890
851
|
import { CloudantV1 } from '@ibm-cloud/cloudant';
|
|
891
852
|
```
|
|
892
|
-
[embedmd]:# (test/examples/src/js/DeleteDoc.js /const deleteDoc/ /deleteDoc\(\);\n\}/)
|
|
893
853
|
```js
|
|
894
854
|
const deleteDoc = async () => {
|
|
895
855
|
// 1. Create a client with `CLOUDANT` default service name ====================
|
|
@@ -931,18 +891,16 @@ if (require.main === module) {
|
|
|
931
891
|
```
|
|
932
892
|
</details>
|
|
933
893
|
|
|
934
|
-
|
|
935
894
|
</details>
|
|
936
895
|
When you run the code, you see the following output.
|
|
937
896
|
|
|
938
|
-
[embedmd]:# (test/examples/output/DeleteDoc.txt)
|
|
939
897
|
```txt
|
|
940
898
|
You have deleted the document.
|
|
941
899
|
```
|
|
942
900
|
|
|
943
901
|
#### Further code examples
|
|
944
902
|
|
|
945
|
-
For a complete list of code examples, see the [examples directory](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
903
|
+
For a complete list of code examples, see the [examples directory](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/examples#examples-for-node).
|
|
946
904
|
|
|
947
905
|
### Error handling
|
|
948
906
|
|
|
@@ -980,7 +938,6 @@ Expand them to see examples of:
|
|
|
980
938
|
- [Query a list of all documents in a database](https://cloud.ibm.com/apidocs/cloudant?code=node#postalldocs)
|
|
981
939
|
- [Query the database document changes feed](https://cloud.ibm.com/apidocs/cloudant?code=node#postchanges)
|
|
982
940
|
|
|
983
|
-
|
|
984
941
|
### Further resources
|
|
985
942
|
|
|
986
943
|
- [Cloudant API docs](https://cloud.ibm.com/apidocs/cloudant?code=node):
|
|
@@ -1010,13 +967,13 @@ to get a better understanding of the limitations and suitable use-cases before u
|
|
|
1010
967
|
|
|
1011
968
|
There are two modes of operation:
|
|
1012
969
|
* Start mode
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
970
|
+
* Fetches the changes from the supplied `since` sequence (by default the feed will start from `now`).
|
|
971
|
+
* Fetches all available changes and then continues listening for new changes indefinitely unless encountering an end condition.
|
|
972
|
+
* An example use case for this mode is event driven workloads.
|
|
1016
973
|
* Start one-off mode
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
974
|
+
* Fetches the changes from the supplied `since` sequence (by default the feed will start from the beginning).
|
|
975
|
+
* Fetches all available changes and then stops when either there are no further changes pending or encountering an end condition.
|
|
976
|
+
* An example use case for this mode is ETL style workloads.
|
|
1020
977
|
|
|
1021
978
|
#### Configuring the changes follower
|
|
1022
979
|
|
|
@@ -1040,7 +997,7 @@ The changes follower requires the client to have HTTP timeouts of at least 1 min
|
|
|
1040
997
|
instantiation if it is insufficient. The default client configuration has sufficiently long timeouts.
|
|
1041
998
|
|
|
1042
999
|
For use-cases where these configuration limitations are deemed too restrictive then it is recommended to
|
|
1043
|
-
write code to use the SDK's [POST `_changes` API](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
1000
|
+
write code to use the SDK's [POST `_changes` API](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/examples#postchanges) instead of the follower.
|
|
1044
1001
|
|
|
1045
1002
|
#### Error suppression
|
|
1046
1003
|
|
|
@@ -1061,12 +1018,12 @@ There are some additional points to consider for error suppression:
|
|
|
1061
1018
|
|
|
1062
1019
|
For both modes:
|
|
1063
1020
|
* The end conditions are:
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1021
|
+
* A terminal error (HTTP codes `400`, `401`, `403` `404`).
|
|
1022
|
+
* Transient errors occur for longer than the error tolerance duration. Transient errors are all other HTTP status codes and connection errors.
|
|
1023
|
+
* The number of changes received reaches the configured `limit`.
|
|
1024
|
+
* The feed is terminated early by calling stop.
|
|
1068
1025
|
|
|
1069
|
-
As is true for the `_changes` endpoint change items have
|
|
1026
|
+
As is true for the `_changes` endpoint change items have *at least once* delivery and an individual item
|
|
1070
1027
|
may be received multiple times. When using the follower change items may be repeated even within a limited
|
|
1071
1028
|
number of changes (i.e. using the `limit` option) this is a minor difference from using `limit` on the HTTP native API.
|
|
1072
1029
|
|
|
@@ -1075,7 +1032,7 @@ The follower is not optimized for some use cases and it is not recommended to us
|
|
|
1075
1032
|
* The volume of changes is very high (if the rate of changes in the database exceeds the follower's rate of pulling them it will never catch-up).
|
|
1076
1033
|
|
|
1077
1034
|
In these cases use-case specific control over the number of change requests made and the content size of the responses
|
|
1078
|
-
may be achieved by using the SDK's [POST `_changes` API](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
1035
|
+
may be achieved by using the SDK's [POST `_changes` API](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/examples#postchanges).
|
|
1079
1036
|
|
|
1080
1037
|
#### Checkpointing
|
|
1081
1038
|
|
|
@@ -1087,9 +1044,9 @@ to store the sequence IDs to have appropriate checkpoints and to re-initialize t
|
|
|
1087
1044
|
The frequency and conditions for checkpointing are application specific and some applications may be tolerant
|
|
1088
1045
|
of dropped changes. This section is intended only to provide general guidance on how to avoid missing changes.
|
|
1089
1046
|
|
|
1090
|
-
To guarantee processing of all changes the sequence ID from a change item must not be persisted until
|
|
1047
|
+
To guarantee processing of all changes the sequence ID from a change item must not be persisted until *after*
|
|
1091
1048
|
the processing of the change item by the application has completed. As indicated previously change items are
|
|
1092
|
-
delivered
|
|
1049
|
+
delivered *at least once* so application code must be able to handle repeated changes already and it is
|
|
1093
1050
|
preferable to restart from an older `since` value and receive changes again than risk missing them.
|
|
1094
1051
|
|
|
1095
1052
|
The sequence IDs are available on each change item by default, but may be omitted from some change items when
|
|
@@ -1110,7 +1067,6 @@ is a considerable risk of missing changes on a restart if the sequence is record
|
|
|
1110
1067
|
import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
1111
1068
|
import { PostChangesParams } from '@ibm-cloud/cloudant/cloudant/v1';
|
|
1112
1069
|
```
|
|
1113
|
-
[embedmd]:# (test/examples/src/features/ts/initialize.ts /const client/ $)
|
|
1114
1070
|
```ts
|
|
1115
1071
|
const client = CloudantV1.newInstance({});
|
|
1116
1072
|
const changesParams: PostChangesParams = {
|
|
@@ -1133,7 +1089,6 @@ const changesFollower: ChangesFollower = new ChangesFollower(
|
|
|
1133
1089
|
```js
|
|
1134
1090
|
import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
1135
1091
|
```
|
|
1136
|
-
[embedmd]:# (test/examples/src/features/js/initialize.js /const client/ $)
|
|
1137
1092
|
```js
|
|
1138
1093
|
const client = CloudantV1.newInstance();
|
|
1139
1094
|
const changesParams = {
|
|
@@ -1149,7 +1104,6 @@ const changesFollower = new ChangesFollower(
|
|
|
1149
1104
|
```
|
|
1150
1105
|
</details>
|
|
1151
1106
|
|
|
1152
|
-
|
|
1153
1107
|
##### Starting the changes follower
|
|
1154
1108
|
|
|
1155
1109
|
###### Start mode for continuous listening
|
|
@@ -1160,7 +1114,6 @@ const changesFollower = new ChangesFollower(
|
|
|
1160
1114
|
import { ChangesFollower, CloudantV1, Stream } from '@ibm-cloud/cloudant';
|
|
1161
1115
|
import { ChangesResultItem, PostChangesParams } from '@ibm-cloud/cloudant/cloudant/v1';
|
|
1162
1116
|
```
|
|
1163
|
-
[embedmd]:# (test/examples/src/features/ts/start.ts /const client/ $)
|
|
1164
1117
|
```ts
|
|
1165
1118
|
const client = CloudantV1.newInstance({});
|
|
1166
1119
|
const changesParams: PostChangesParams = {
|
|
@@ -1179,7 +1132,6 @@ const changesItemsStream: Stream<ChangesResultItem> = changesFollower.start();
|
|
|
1179
1132
|
```js
|
|
1180
1133
|
import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
1181
1134
|
```
|
|
1182
|
-
[embedmd]:# (test/examples/src/features/js/start.js /const client/ $)
|
|
1183
1135
|
```js
|
|
1184
1136
|
const client = CloudantV1.newInstance();
|
|
1185
1137
|
const changesParams = {
|
|
@@ -1192,7 +1144,6 @@ const changesItemsStream = changesFollower.start();
|
|
|
1192
1144
|
```
|
|
1193
1145
|
</details>
|
|
1194
1146
|
|
|
1195
|
-
|
|
1196
1147
|
###### Start mode for one-off fetching
|
|
1197
1148
|
<details open>
|
|
1198
1149
|
<summary>TypeScript:</summary>
|
|
@@ -1201,7 +1152,6 @@ const changesItemsStream = changesFollower.start();
|
|
|
1201
1152
|
import { ChangesFollower, CloudantV1, Stream } from '@ibm-cloud/cloudant';
|
|
1202
1153
|
import { ChangesResultItem, PostChangesParams } from '@ibm-cloud/cloudant/cloudant/v1';
|
|
1203
1154
|
```
|
|
1204
|
-
[embedmd]:# (test/examples/src/features/ts/startOneOff.ts /const client/ $)
|
|
1205
1155
|
```ts
|
|
1206
1156
|
const client = CloudantV1.newInstance({});
|
|
1207
1157
|
const changesParams: PostChangesParams = {
|
|
@@ -1220,7 +1170,6 @@ const changesItemsStream: Stream<ChangesResultItem> = changesFollower.startOneOf
|
|
|
1220
1170
|
```js
|
|
1221
1171
|
import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
1222
1172
|
```
|
|
1223
|
-
[embedmd]:# (test/examples/src/features/js/startOneOff.js /const client/ $)
|
|
1224
1173
|
```js
|
|
1225
1174
|
const client = CloudantV1.newInstance();
|
|
1226
1175
|
const changesParams = {
|
|
@@ -1233,7 +1182,6 @@ const changesItemsStream = changesFollower.startOneOff();
|
|
|
1233
1182
|
```
|
|
1234
1183
|
</details>
|
|
1235
1184
|
|
|
1236
|
-
|
|
1237
1185
|
##### Processing changes
|
|
1238
1186
|
|
|
1239
1187
|
###### Process continuous changes
|
|
@@ -1246,7 +1194,6 @@ import { ChangesResultItem, PostChangesParams } from '@ibm-cloud/cloudant/clouda
|
|
|
1246
1194
|
import { Writable } from 'node:stream';
|
|
1247
1195
|
import { pipeline } from 'node:stream/promises';
|
|
1248
1196
|
```
|
|
1249
|
-
[embedmd]:# (test/examples/src/features/ts/startAndProcess.ts /const client/ $)
|
|
1250
1197
|
```ts
|
|
1251
1198
|
const client = CloudantV1.newInstance({});
|
|
1252
1199
|
// Start from a previously persisted seq
|
|
@@ -1279,7 +1226,7 @@ const destinationStream = new Writable({
|
|
|
1279
1226
|
// A pipeline to keep processing changes until the follower is stopped or some other stop condition is reached
|
|
1280
1227
|
pipeline(changesItemsStream, destinationStream)
|
|
1281
1228
|
.then(() => {
|
|
1282
|
-
console.log('Stopped');
|
|
1229
|
+
console.log('Stopped');
|
|
1283
1230
|
})
|
|
1284
1231
|
.catch((err) => {
|
|
1285
1232
|
console.log(err);
|
|
@@ -1295,7 +1242,6 @@ import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
|
1295
1242
|
import { Writable } from 'node:stream';
|
|
1296
1243
|
import { pipeline } from 'node:stream/promises';
|
|
1297
1244
|
```
|
|
1298
|
-
[embedmd]:# (test/examples/src/features/js/startAndProcess.js /const client/ $)
|
|
1299
1245
|
```js
|
|
1300
1246
|
const client = CloudantV1.newInstance();
|
|
1301
1247
|
// Start from a previously persisted seq
|
|
@@ -1328,7 +1274,7 @@ const destinationStream = new Writable({
|
|
|
1328
1274
|
// A pipeline to keep processing changes until the follower is stopped or some other stop condition is reached
|
|
1329
1275
|
pipeline(changesItemsStream, destinationStream)
|
|
1330
1276
|
.then(() => {
|
|
1331
|
-
console.log('Stopped');
|
|
1277
|
+
console.log('Stopped');
|
|
1332
1278
|
})
|
|
1333
1279
|
.catch((err) => {
|
|
1334
1280
|
console.log(err);
|
|
@@ -1336,7 +1282,6 @@ pipeline(changesItemsStream, destinationStream)
|
|
|
1336
1282
|
```
|
|
1337
1283
|
</details>
|
|
1338
1284
|
|
|
1339
|
-
|
|
1340
1285
|
###### Process one-off changes
|
|
1341
1286
|
<details open>
|
|
1342
1287
|
<summary>TypeScript:</summary>
|
|
@@ -1347,7 +1292,6 @@ import { ChangesResultItem, PostChangesParams } from '@ibm-cloud/cloudant/clouda
|
|
|
1347
1292
|
import { Writable } from 'node:stream';
|
|
1348
1293
|
import { pipeline } from 'node:stream/promises';
|
|
1349
1294
|
```
|
|
1350
|
-
[embedmd]:# (test/examples/src/features/ts/startOneOffAndProcess.ts /const client/ $)
|
|
1351
1295
|
```ts
|
|
1352
1296
|
const client = CloudantV1.newInstance({});
|
|
1353
1297
|
// Start from a previously persisted seq
|
|
@@ -1414,7 +1358,6 @@ import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
|
1414
1358
|
import { Writable } from 'node:stream';
|
|
1415
1359
|
import { pipeline } from 'node:stream/promises';
|
|
1416
1360
|
```
|
|
1417
|
-
[embedmd]:# (test/examples/src/features/js/startOneOffAndProcess.js /const client/ $)
|
|
1418
1361
|
```js
|
|
1419
1362
|
const client = CloudantV1.newInstance();
|
|
1420
1363
|
// Start from a previously persisted seq
|
|
@@ -1473,7 +1416,6 @@ async function getChangesFromFollower(changesItemsStream) {
|
|
|
1473
1416
|
```
|
|
1474
1417
|
</details>
|
|
1475
1418
|
|
|
1476
|
-
|
|
1477
1419
|
##### Stopping the changes follower
|
|
1478
1420
|
<details open>
|
|
1479
1421
|
<summary>TypeScript:</summary>
|
|
@@ -1484,7 +1426,6 @@ import { ChangesResultItem, PostChangesParams } from '@ibm-cloud/cloudant/clouda
|
|
|
1484
1426
|
import { Writable } from 'node:stream';
|
|
1485
1427
|
import { pipeline } from 'node:stream/promises';
|
|
1486
1428
|
```
|
|
1487
|
-
[embedmd]:# (test/examples/src/features/ts/stop.ts /const client/ $)
|
|
1488
1429
|
```ts
|
|
1489
1430
|
const client = CloudantV1.newInstance({});
|
|
1490
1431
|
const changesParams: PostChangesParams = {
|
|
@@ -1507,7 +1448,7 @@ const destinationStream = new Writable({
|
|
|
1507
1448
|
|
|
1508
1449
|
pipeline(changesItemsStream, destinationStream)
|
|
1509
1450
|
.then(() => {
|
|
1510
|
-
console.log('Stopped');
|
|
1451
|
+
console.log('Stopped');
|
|
1511
1452
|
})
|
|
1512
1453
|
.catch((err) => {
|
|
1513
1454
|
console.log(err);
|
|
@@ -1532,7 +1473,6 @@ import { ChangesFollower, CloudantV1 } from '@ibm-cloud/cloudant';
|
|
|
1532
1473
|
import { Writable } from 'node:stream';
|
|
1533
1474
|
import { pipeline } from 'node:stream/promises';
|
|
1534
1475
|
```
|
|
1535
|
-
[embedmd]:# (test/examples/src/features/js/stop.js /const client/ $)
|
|
1536
1476
|
```js
|
|
1537
1477
|
const client = CloudantV1.newInstance();
|
|
1538
1478
|
const changesParams = {
|
|
@@ -1555,7 +1495,7 @@ const destinationStream = new Writable({
|
|
|
1555
1495
|
|
|
1556
1496
|
pipeline(changesItemsStream, destinationStream)
|
|
1557
1497
|
.then(() =>{
|
|
1558
|
-
console.log('Stopped');
|
|
1498
|
+
console.log('Stopped');
|
|
1559
1499
|
})
|
|
1560
1500
|
.catch((err) => {
|
|
1561
1501
|
console.log(err);
|
|
@@ -1572,7 +1512,6 @@ setTimeout(() => {
|
|
|
1572
1512
|
```
|
|
1573
1513
|
</details>
|
|
1574
1514
|
|
|
1575
|
-
|
|
1576
1515
|
## Questions
|
|
1577
1516
|
|
|
1578
1517
|
If you are having difficulties using this SDK or have a question about the
|
|
@@ -1586,7 +1525,7 @@ If you encounter an issue with the project, you are welcome to submit a
|
|
|
1586
1525
|
|
|
1587
1526
|
Before you submit a bug report, search for
|
|
1588
1527
|
[similar issues](https://github.com/IBM/cloudant-node-sdk/issues?q=is%3Aissue) and review the
|
|
1589
|
-
[KNOWN_ISSUES file](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
1528
|
+
[KNOWN_ISSUES file](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/KNOWN_ISSUES.md) to verify that your issue hasn't been reported yet.
|
|
1590
1529
|
|
|
1591
1530
|
Please consult the [security policy](https://github.com/IBM/cloudant-node-sdk/security/policy) before opening security related issues.
|
|
1592
1531
|
|
|
@@ -1608,7 +1547,7 @@ When language LTS versions move out of support the following will happen:
|
|
|
1608
1547
|
* Existing SDK releases will continue to run on obsolete language versions, but will no longer be supported.
|
|
1609
1548
|
* The minimum language version supported by the SDK will be updated to the next available LTS.
|
|
1610
1549
|
* New language features may be added in subsequent SDK releases that will cause breaking changes
|
|
1611
|
-
|
|
1550
|
+
if the new releases of the SDK are used with older, now unsupported, language levels.
|
|
1612
1551
|
|
|
1613
1552
|
## Open source at IBM
|
|
1614
1553
|
|
|
@@ -1616,8 +1555,8 @@ Find more open source projects on the [IBM GitHub](http://ibm.github.io/) page.
|
|
|
1616
1555
|
|
|
1617
1556
|
## Contributing
|
|
1618
1557
|
|
|
1619
|
-
For more information, see [CONTRIBUTING](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
1558
|
+
For more information, see [CONTRIBUTING](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/CONTRIBUTING.md).
|
|
1620
1559
|
|
|
1621
1560
|
## License
|
|
1622
1561
|
|
|
1623
|
-
This SDK is released under the Apache 2.0 license. To read the full text of the license, see [LICENSE](https://github.com/IBM/cloudant-node-sdk/tree/v0.
|
|
1562
|
+
This SDK is released under the Apache 2.0 license. To read the full text of the license, see [LICENSE](https://github.com/IBM/cloudant-node-sdk/tree/v0.10.0/LICENSE).
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
/// <reference types="node" />
|
|
17
16
|
import { OutgoingHttpHeaders } from 'http';
|
|
18
17
|
import { TokenManager, UserOptions } from 'ibm-cloud-sdk-core';
|
|
19
18
|
/** Configuration options for CouchDB session token retrieval. */
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
/// <reference types="node" />
|
|
17
|
-
/// <reference types="node" />
|
|
18
16
|
import { Stream } from './stream';
|
|
19
17
|
import { TransformCallback } from 'stream';
|
|
20
18
|
import CloudantV1 = require('../v1');
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
/// <reference types="node" />
|
|
17
|
-
/// <reference types="node" />
|
|
18
16
|
import { Transform, TransformOptions } from 'stream';
|
|
19
17
|
export declare class Stream<T> extends Transform {
|
|
20
18
|
constructor(opts?: TransformOptions);
|
package/cloudant/v1.d.ts
CHANGED
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
/// <reference types="node" />
|
|
17
|
-
/// <reference types="node" />
|
|
18
|
-
/// <reference types="node" />
|
|
19
16
|
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
|
|
20
17
|
import { SDKLogger, UserOptions } from 'ibm-cloud-sdk-core';
|
|
21
18
|
import CloudantBaseService from '../lib/cloudantBaseService';
|
|
@@ -1929,9 +1926,9 @@ declare class CloudantV1 extends CloudantBaseService {
|
|
|
1929
1926
|
/**
|
|
1930
1927
|
* Retrieve information about all indexes.
|
|
1931
1928
|
*
|
|
1932
|
-
* When you make a GET request to `/db/_index`, you get a list of all indexes
|
|
1933
|
-
*
|
|
1934
|
-
* the `indexes` property of design documents.
|
|
1929
|
+
* When you make a GET request to `/db/_index`, you get a list of all the indexes using `"language":"query"` in the
|
|
1930
|
+
* database and the primary index. In addition to the information available through this API, the indexes are stored
|
|
1931
|
+
* in the `indexes` property of their respective design documents.
|
|
1935
1932
|
*
|
|
1936
1933
|
* @param {Object} params - The parameters to send to the service.
|
|
1937
1934
|
* @param {string} params.db - Path parameter to specify the database name.
|
|
@@ -6066,7 +6063,7 @@ declare namespace CloudantV1 {
|
|
|
6066
6063
|
* `attachments=true` or `atts_since`. Note that when used with a view or changes feed `include_docs` must also be
|
|
6067
6064
|
* `true`.
|
|
6068
6065
|
*/
|
|
6069
|
-
data?:
|
|
6066
|
+
data?: Buffer;
|
|
6070
6067
|
/** Content hash digest. It starts with prefix which announce hash type (e.g. `md5-`) and continues with
|
|
6071
6068
|
* Base64-encoded hash digest.
|
|
6072
6069
|
*/
|
|
@@ -7628,6 +7625,10 @@ declare namespace CloudantV1 {
|
|
|
7628
7625
|
filter?: string;
|
|
7629
7626
|
/** Maximum number of HTTP connections per replication. */
|
|
7630
7627
|
httpConnections?: number;
|
|
7628
|
+
/** The replication document owner. The server sets an appropriate value if the field is unset when writing a
|
|
7629
|
+
* replication document. Only administrators can modify the value to an owner other than themselves.
|
|
7630
|
+
*/
|
|
7631
|
+
owner?: string;
|
|
7631
7632
|
/** Schema for a map of string key value pairs, such as query parameters. */
|
|
7632
7633
|
queryParams?: JsonObject;
|
|
7633
7634
|
/** Number of times a replication request is retried. The requests are retried with a doubling exponential
|
|
@@ -7735,6 +7736,7 @@ declare namespace CloudantV1 {
|
|
|
7735
7736
|
doc_ids?: string[];
|
|
7736
7737
|
filter?: string;
|
|
7737
7738
|
http_connections?: number;
|
|
7739
|
+
owner?: string;
|
|
7738
7740
|
query_params?: JsonObject;
|
|
7739
7741
|
retries_per_request?: number;
|
|
7740
7742
|
selector?: JsonObject;
|
|
@@ -8264,17 +8266,21 @@ declare namespace CloudantV1 {
|
|
|
8264
8266
|
/** Vendor name. */
|
|
8265
8267
|
name: string;
|
|
8266
8268
|
/** Vendor variant. */
|
|
8267
|
-
variant
|
|
8269
|
+
variant: string;
|
|
8268
8270
|
/** Vendor version. */
|
|
8269
|
-
version
|
|
8271
|
+
version: string;
|
|
8272
|
+
/** ServerVendor accepts additional properties. */
|
|
8273
|
+
[propName: string]: any;
|
|
8270
8274
|
static serialize(obj: any): ServerVendor.Transport;
|
|
8271
8275
|
static deserialize(obj: any): ServerVendor;
|
|
8272
8276
|
}
|
|
8273
8277
|
namespace ServerVendor {
|
|
8274
8278
|
interface Transport {
|
|
8275
8279
|
name: string;
|
|
8276
|
-
variant
|
|
8277
|
-
version
|
|
8280
|
+
variant: string;
|
|
8281
|
+
version: string;
|
|
8282
|
+
/** ServerVendor.ServerVendor.Transport accepts additional properties. */
|
|
8283
|
+
[propName: string]: any;
|
|
8278
8284
|
}
|
|
8279
8285
|
}
|
|
8280
8286
|
/** Schema for session authentication information. */
|