@ibm-cloud/cloudant 0.5.4 → 0.6.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 +695 -65
- package/auth/couchdbSessionAuthenticator.js +2 -1
- package/auth/couchdbSessionAuthenticator.js.map +1 -1
- package/cloudant/features/changesFollower.d.ts +148 -0
- package/cloudant/features/changesFollower.js +178 -0
- package/cloudant/features/changesFollower.js.map +1 -0
- package/cloudant/features/changesParamsHelper.d.ts +32 -0
- package/cloudant/features/changesParamsHelper.js +99 -0
- package/cloudant/features/changesParamsHelper.js.map +1 -0
- package/cloudant/features/changesResultItemStream.d.ts +24 -0
- package/cloudant/features/changesResultItemStream.js +61 -0
- package/cloudant/features/changesResultItemStream.js.map +1 -0
- package/cloudant/features/changesResultIterator.d.ts +46 -0
- package/cloudant/features/changesResultIterator.js +296 -0
- package/cloudant/features/changesResultIterator.js.map +1 -0
- package/cloudant/features/stream.d.ts +23 -0
- package/cloudant/features/stream.js +60 -0
- package/cloudant/features/stream.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/lib/cloudantBaseService.d.ts +3 -2
- package/lib/cloudantBaseService.js +7 -6
- package/lib/cloudantBaseService.js.map +1 -1
- package/package.json +22 -22
|
@@ -56,7 +56,7 @@ var sessionTokenManager_1 = require("./sessionTokenManager");
|
|
|
56
56
|
* Version=1; Path=/; HttpOnly; Secure
|
|
57
57
|
*
|
|
58
58
|
*/
|
|
59
|
-
var CouchdbSessionAuthenticator =
|
|
59
|
+
var CouchdbSessionAuthenticator = /** @class */ (function (_super) {
|
|
60
60
|
__extends(CouchdbSessionAuthenticator, _super);
|
|
61
61
|
/**
|
|
62
62
|
* Create a new CouchdbSessionAuthenticator instance.
|
|
@@ -143,4 +143,5 @@ var CouchdbSessionAuthenticator = exports.CouchdbSessionAuthenticator = /** @cla
|
|
|
143
143
|
CouchdbSessionAuthenticator.AUTHTYPE_COUCHDB_SESSION = 'COUCHDB_SESSION';
|
|
144
144
|
return CouchdbSessionAuthenticator;
|
|
145
145
|
}(ibm_cloud_sdk_core_1.Authenticator));
|
|
146
|
+
exports.CouchdbSessionAuthenticator = CouchdbSessionAuthenticator;
|
|
146
147
|
//# sourceMappingURL=couchdbSessionAuthenticator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"couchdbSessionAuthenticator.js","sourceRoot":"","sources":["../../auth/couchdbSessionAuthenticator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA+E;AAC/E,6DAG+B;AAoB/B;;;;;;;;;;;GAWG;AACH;IAAiD,+CAAa;IAS5D;;;;;;;OAOG;IACH,qCAAY,OAA2C;QAAvD,YACE,iBAAO,SAGR;QAFC,IAAA,kCAAa,EAAC,OAAO,EAAE,KAAI,CAAC,eAAe,CAAC,CAAC;QAC7C,KAAI,CAAC,YAAY,gBAAQ,OAAO,CAAE,CAAC;;IACrC,CAAC;IAED;;;;;;;;OAQG;IACI,kDAAY,GAAnB,UAAoB,cAAsB;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACI,+CAAS,GAAhB,UAAiB,WAAwB;QACvC,oBAAoB;QACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAE9C,+EAA+E;QAC/E,yCAAyC;QACzC,IAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAuB,CAAC;QAC5D,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YACzC,wBAAwB;YACxB,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC;YAC/B,uFAAuF;YACvF,IAAM,wBAAsB,GAAG,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC;YAC5D,SAAS,CAAC,KAAK,CAAC,YAAY,GAAG,SAAS,YAAY,CAClD,SAAS,EACT,SAAwB,EACxB,EAAE;gBAEF,2DAA2D;gBAC3D,SAAS,CAAC,uBAAuB,GAAG,IAAI,IAAI,EAAE,CAAC;gBAC/C,sFAAsF;gBACtF,iDAAiD;gBACjD,IAAM,oBAAoB,GAAG,SAAS,CAAC,UAAU,CAAC;gBAClD,SAAS,CAAC,UAAU,GAAG,SAAS,UAAU,CAAC,GAAG;oBAC5C,qEAAqE;oBACrE,2BAA2B;oBAC3B,mDAAmD;oBACnD,kBAAkB;oBAClB,uGAAuG;oBACvG,uDAAuD;oBACvD,OAAO,oBAAoB,CAAC,IAAI,CAC9B,SAAS,EACT,SAAS,CAAC,uBAAuB,IAAI,GAAG,CACzC,CAAC;gBACJ,CAAC,CAAC;gBACF,qGAAqG;gBACrG,uGAAuG;gBACvG,+CAA+C;gBAC/C,IAAI,wBAAsB,EAAE;oBAC1B,wBAAsB,CAAC,IAAI,CACzB,SAAS,CAAC,KAAK,EACf,SAAS,EACT,SAAS,EACT,EAAE,CACH,CAAC;iBACH;qBAAM;oBACL,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;iBAChE;YACH,CAAC,CAAC;SACH;QACD,8BAA8B;QAE9B,wBAAwB;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACH,kDAAkD;IAC3C,wDAAkB,GAAzB;QACE,OAAO,2BAA2B,CAAC,wBAAwB,CAAC;IAC9D,CAAC;IAlGe,oDAAwB,GAAG,iBAAiB,CAAC;IAmG/D,kCAAC;CAAA,AA1GD,CAAiD,kCAAa,GA0G7D"}
|
|
1
|
+
{"version":3,"file":"couchdbSessionAuthenticator.js","sourceRoot":"","sources":["../../auth/couchdbSessionAuthenticator.ts"],"names":[],"mappings":";AAAA;;;;;;;;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AClB,uGAAuG;oBACvG,uDAAuD;oBACvD,OAAO,oBAAoB,CAAC,IAAI,CAC9B,SAAS,EACT,SAAS,CAAC,uBAAuB,IAAI,GAAG,CACzC,CAAC;gBACJ,CAAC,CAAC;gBACF,qGAAqG;gBACrG,uGAAuG;gBACvG,+CAA+C;gBAC/C,IAAI,wBAAsB,EAAE;oBAC1B,wBAAsB,CAAC,IAAI,CACzB,SAAS,CAAC,KAAK,EACf,SAAS,EACT,SAAS,EACT,EAAE,CACH,CAAC;iBACH;qBAAM;oBACL,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;iBAChE;YACH,CAAC,CAAC;SACH;QACD,8BAA8B;QAE9B,wBAAwB;QACxB,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACH,kDAAkD;IAC3C,wDAAkB,GAAzB;QACE,OAAO,2BAA2B,CAAC,wBAAwB,CAAC;IAC9D,CAAC;IAlGe,oDAAwB,GAAG,iBAAiB,CAAC;IAmG/D,kCAAC;CAAA,AA1GD,CAAiD,kCAAa,GA0G7D;AA1GY,kEAA2B"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2022. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ChangesResultItem } from '../v1';
|
|
17
|
+
import { Stream } from './stream';
|
|
18
|
+
import { ChangesResultIterableIterator } from './changesResultIterator';
|
|
19
|
+
import CloudantV1 = require('../v1');
|
|
20
|
+
export declare enum Mode {
|
|
21
|
+
/** @internal */
|
|
22
|
+
FINITE = 0,
|
|
23
|
+
LISTEN = 1
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A helper for using the changes feed.
|
|
27
|
+
*
|
|
28
|
+
* There are two modes of operation:
|
|
29
|
+
* * {@link #startOneOff()} to fetch the changes from the supplied since sequence
|
|
30
|
+
* until there are no further pending changes.
|
|
31
|
+
* * {@link #start()} to fetch the changes from the supplied since sequence and
|
|
32
|
+
* then continuing to listen indefinitely for further new changes.
|
|
33
|
+
*
|
|
34
|
+
* The starting sequence ID can be changed for either mode by using
|
|
35
|
+
* {@link CloudantV1.PostChangesParams.since}. By default when using:
|
|
36
|
+
* * {@link #startOneOff()} the feed will start from the beginning.
|
|
37
|
+
* * {@link #start()} the feed will start from "now".
|
|
38
|
+
*
|
|
39
|
+
* In either mode the {@link Stream} of changes can be terminated early by calling
|
|
40
|
+
* {@link #stop()}.
|
|
41
|
+
*
|
|
42
|
+
* By default {@link ChangesFollower} will suppress transient errors indefinitely and
|
|
43
|
+
* endeavour to run to completion or listen forever. For applications where that
|
|
44
|
+
* behaviour is not desirable an alternate constructor is available where a
|
|
45
|
+
* {@link errorTolerance} may be specified to limit the time since the last successful
|
|
46
|
+
* response that transient errors will be suppressed.
|
|
47
|
+
*
|
|
48
|
+
* It should be noted that errors considered terminal, for example, the database not
|
|
49
|
+
* existing or invalid credentials are never suppressed and will throw an exception
|
|
50
|
+
* immediately.
|
|
51
|
+
*
|
|
52
|
+
* The {@link CloudantV1.PostChangesParams} model of changes feed options is used to configure
|
|
53
|
+
* the behaviour of the {@link ChangesFollower}. However, a subset of the options are
|
|
54
|
+
* invalid as they are configured internally by the implementation and will cause
|
|
55
|
+
* an {@link Error} to be thrown if supplied. These invalid
|
|
56
|
+
* options are:
|
|
57
|
+
* * {@link CloudantV1.PostChangesParams.descending}
|
|
58
|
+
* * {@link CloudantV1.PostChangesParams.feed}
|
|
59
|
+
* * {@link CloudantV1.PostChangesParams.heartbeat}
|
|
60
|
+
* * {@link CloudantV1.PostChangesParams.lastEventId}
|
|
61
|
+
* (use {@link CloudantV1.PostChangesParams.since} instead)
|
|
62
|
+
* * {@link CloudantV1.PostChangesParams.timeout}
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* Only the value of `_selector` is permitted for
|
|
66
|
+
* the {@link CloudantV1.PostChangesParams.filter} option.
|
|
67
|
+
* Selector based filters perform better than JS based filters and using one
|
|
68
|
+
* of the alternative JS based
|
|
69
|
+
* filter types will cause {@link ChangesFollower} to throw an {@link Error}.
|
|
70
|
+
*
|
|
71
|
+
* It should also be noted that the {@link CloudantV1.PostChangesParams.limit}
|
|
72
|
+
* parameter will truncate the stream at the given number of changes in either
|
|
73
|
+
* operating mode.
|
|
74
|
+
*
|
|
75
|
+
* The {@link ChangesFollower} requires the {@link CloudantV1} client to have
|
|
76
|
+
* HTTP call and read timeouts of at least 1 minute. The default client
|
|
77
|
+
* configuration has sufficiently long timeouts.
|
|
78
|
+
*/
|
|
79
|
+
export declare class ChangesFollower {
|
|
80
|
+
static BATCH_SIZE: number;
|
|
81
|
+
private readonly client;
|
|
82
|
+
private readonly params;
|
|
83
|
+
private readonly errorTolerance?;
|
|
84
|
+
private limit;
|
|
85
|
+
changesResultIterator: ChangesResultIterableIterator;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new {@link ChangesFollower} using the supplied client and params that
|
|
88
|
+
* suppress transient errors and retry for as long as the given `errorTolerance` duration.
|
|
89
|
+
*
|
|
90
|
+
* @param client - {@link CloudantV1} client instance to use to make requests
|
|
91
|
+
* @param params - Changes feed params
|
|
92
|
+
* @param errorTolerance - the duration to suppress errors, measured from the previous
|
|
93
|
+
* successful request. Use `0` to disable error suppression and terminate this {@link ChangesFollower}
|
|
94
|
+
* on any failed request.
|
|
95
|
+
*
|
|
96
|
+
* @throws {Error} if there are invalid params
|
|
97
|
+
*/
|
|
98
|
+
constructor(client: CloudantV1, params: CloudantV1.PostChangesParams, errorTolerance?: number);
|
|
99
|
+
/**
|
|
100
|
+
* Return all available changes and keep listening for new changes until reaching an end condition.
|
|
101
|
+
*
|
|
102
|
+
* The end conditions are:
|
|
103
|
+
* * a terminal error (e.g. unauthorized client).
|
|
104
|
+
* * transient errors occur for longer than the error suppression duration.
|
|
105
|
+
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
106
|
+
* * {@link ChangesFollower#stop()} is called.
|
|
107
|
+
*
|
|
108
|
+
* The same change may be received more than once.
|
|
109
|
+
*
|
|
110
|
+
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
111
|
+
* @throws {Error} if:
|
|
112
|
+
* * {@link ChangesFollower#start} or {@link ChangesFollower#startOneOff} was already called.
|
|
113
|
+
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
114
|
+
*/
|
|
115
|
+
start(): Stream<ChangesResultItem>;
|
|
116
|
+
/**
|
|
117
|
+
* Return all available changes until there are no further changes pending or
|
|
118
|
+
* reaching an end condition.
|
|
119
|
+
*
|
|
120
|
+
* The end conditions are:
|
|
121
|
+
* * a terminal error (e.g. unauthorized client).
|
|
122
|
+
* * transient errors occur for longer than the error suppression duration.
|
|
123
|
+
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
124
|
+
* * {@link ChangesFollower#stop} is called.
|
|
125
|
+
*
|
|
126
|
+
* The same change may be received more than once.
|
|
127
|
+
*
|
|
128
|
+
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
129
|
+
* @throws {Error} if:
|
|
130
|
+
* * {@link ChangesFollower#start} or {@link ChangesFollower#startOneOff} was already called.
|
|
131
|
+
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
132
|
+
*/
|
|
133
|
+
startOneOff(): Stream<ChangesResultItem>;
|
|
134
|
+
/**
|
|
135
|
+
* Stop this {@link ChangesFollower}.
|
|
136
|
+
*
|
|
137
|
+
* @throws {Error} if {@link ChangesFollower#start}
|
|
138
|
+
* or {@link ChangesFollower#startOneOff} was not called first
|
|
139
|
+
*/
|
|
140
|
+
stop(): void;
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @param mode the mode in which to run the ChangesFollower
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private run;
|
|
147
|
+
private createChangesResultItemsStream;
|
|
148
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangesFollower = exports.Mode = void 0;
|
|
4
|
+
var changesParamsHelper_1 = require("./changesParamsHelper");
|
|
5
|
+
var changesResultItemStream_1 = require("./changesResultItemStream");
|
|
6
|
+
var stream_1 = require("stream");
|
|
7
|
+
var changesResultIterator_1 = require("./changesResultIterator");
|
|
8
|
+
var Mode;
|
|
9
|
+
(function (Mode) {
|
|
10
|
+
/** @internal */
|
|
11
|
+
Mode[Mode["FINITE"] = 0] = "FINITE";
|
|
12
|
+
Mode[Mode["LISTEN"] = 1] = "LISTEN";
|
|
13
|
+
})(Mode || (exports.Mode = Mode = {}));
|
|
14
|
+
/**
|
|
15
|
+
* A helper for using the changes feed.
|
|
16
|
+
*
|
|
17
|
+
* There are two modes of operation:
|
|
18
|
+
* * {@link #startOneOff()} to fetch the changes from the supplied since sequence
|
|
19
|
+
* until there are no further pending changes.
|
|
20
|
+
* * {@link #start()} to fetch the changes from the supplied since sequence and
|
|
21
|
+
* then continuing to listen indefinitely for further new changes.
|
|
22
|
+
*
|
|
23
|
+
* The starting sequence ID can be changed for either mode by using
|
|
24
|
+
* {@link CloudantV1.PostChangesParams.since}. By default when using:
|
|
25
|
+
* * {@link #startOneOff()} the feed will start from the beginning.
|
|
26
|
+
* * {@link #start()} the feed will start from "now".
|
|
27
|
+
*
|
|
28
|
+
* In either mode the {@link Stream} of changes can be terminated early by calling
|
|
29
|
+
* {@link #stop()}.
|
|
30
|
+
*
|
|
31
|
+
* By default {@link ChangesFollower} will suppress transient errors indefinitely and
|
|
32
|
+
* endeavour to run to completion or listen forever. For applications where that
|
|
33
|
+
* behaviour is not desirable an alternate constructor is available where a
|
|
34
|
+
* {@link errorTolerance} may be specified to limit the time since the last successful
|
|
35
|
+
* response that transient errors will be suppressed.
|
|
36
|
+
*
|
|
37
|
+
* It should be noted that errors considered terminal, for example, the database not
|
|
38
|
+
* existing or invalid credentials are never suppressed and will throw an exception
|
|
39
|
+
* immediately.
|
|
40
|
+
*
|
|
41
|
+
* The {@link CloudantV1.PostChangesParams} model of changes feed options is used to configure
|
|
42
|
+
* the behaviour of the {@link ChangesFollower}. However, a subset of the options are
|
|
43
|
+
* invalid as they are configured internally by the implementation and will cause
|
|
44
|
+
* an {@link Error} to be thrown if supplied. These invalid
|
|
45
|
+
* options are:
|
|
46
|
+
* * {@link CloudantV1.PostChangesParams.descending}
|
|
47
|
+
* * {@link CloudantV1.PostChangesParams.feed}
|
|
48
|
+
* * {@link CloudantV1.PostChangesParams.heartbeat}
|
|
49
|
+
* * {@link CloudantV1.PostChangesParams.lastEventId}
|
|
50
|
+
* (use {@link CloudantV1.PostChangesParams.since} instead)
|
|
51
|
+
* * {@link CloudantV1.PostChangesParams.timeout}
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* Only the value of `_selector` is permitted for
|
|
55
|
+
* the {@link CloudantV1.PostChangesParams.filter} option.
|
|
56
|
+
* Selector based filters perform better than JS based filters and using one
|
|
57
|
+
* of the alternative JS based
|
|
58
|
+
* filter types will cause {@link ChangesFollower} to throw an {@link Error}.
|
|
59
|
+
*
|
|
60
|
+
* It should also be noted that the {@link CloudantV1.PostChangesParams.limit}
|
|
61
|
+
* parameter will truncate the stream at the given number of changes in either
|
|
62
|
+
* operating mode.
|
|
63
|
+
*
|
|
64
|
+
* The {@link ChangesFollower} requires the {@link CloudantV1} client to have
|
|
65
|
+
* HTTP call and read timeouts of at least 1 minute. The default client
|
|
66
|
+
* configuration has sufficiently long timeouts.
|
|
67
|
+
*/
|
|
68
|
+
var ChangesFollower = /** @class */ (function () {
|
|
69
|
+
/**
|
|
70
|
+
* Create a new {@link ChangesFollower} using the supplied client and params that
|
|
71
|
+
* suppress transient errors and retry for as long as the given `errorTolerance` duration.
|
|
72
|
+
*
|
|
73
|
+
* @param client - {@link CloudantV1} client instance to use to make requests
|
|
74
|
+
* @param params - Changes feed params
|
|
75
|
+
* @param errorTolerance - the duration to suppress errors, measured from the previous
|
|
76
|
+
* successful request. Use `0` to disable error suppression and terminate this {@link ChangesFollower}
|
|
77
|
+
* on any failed request.
|
|
78
|
+
*
|
|
79
|
+
* @throws {Error} if there are invalid params
|
|
80
|
+
*/
|
|
81
|
+
function ChangesFollower(client, params, errorTolerance) {
|
|
82
|
+
// Validate supplied params
|
|
83
|
+
changesParamsHelper_1.ChangesParamsHelper.validateParams(params);
|
|
84
|
+
this.limit = params.limit;
|
|
85
|
+
// Setup with the required defaults and merges of user params
|
|
86
|
+
this.params = changesParamsHelper_1.ChangesParamsHelper.cloneParams(params);
|
|
87
|
+
this.client = client;
|
|
88
|
+
if (errorTolerance < 0) {
|
|
89
|
+
throw new Error('Error tolerance duration must not be negative.');
|
|
90
|
+
}
|
|
91
|
+
if (errorTolerance === undefined) {
|
|
92
|
+
this.errorTolerance = Number.MAX_VALUE;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.errorTolerance = errorTolerance;
|
|
96
|
+
}
|
|
97
|
+
// Check the timeout is suitable
|
|
98
|
+
var readTimeout = this.client.getTimeout();
|
|
99
|
+
if (readTimeout > 0 &&
|
|
100
|
+
readTimeout < changesParamsHelper_1.ChangesParamsHelper.MIN_CLIENT_TIMEOUT) {
|
|
101
|
+
throw new Error("To use ChangesFollower the client read timeout must be at least ".concat(changesParamsHelper_1.ChangesParamsHelper.MIN_CLIENT_TIMEOUT, " ms. The client read timeout is ").concat(readTimeout, " ms."));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Return all available changes and keep listening for new changes until reaching an end condition.
|
|
106
|
+
*
|
|
107
|
+
* The end conditions are:
|
|
108
|
+
* * a terminal error (e.g. unauthorized client).
|
|
109
|
+
* * transient errors occur for longer than the error suppression duration.
|
|
110
|
+
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
111
|
+
* * {@link ChangesFollower#stop()} is called.
|
|
112
|
+
*
|
|
113
|
+
* The same change may be received more than once.
|
|
114
|
+
*
|
|
115
|
+
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
116
|
+
* @throws {Error} if:
|
|
117
|
+
* * {@link ChangesFollower#start} or {@link ChangesFollower#startOneOff} was already called.
|
|
118
|
+
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
119
|
+
*/
|
|
120
|
+
ChangesFollower.prototype.start = function () {
|
|
121
|
+
return this.run(Mode.LISTEN);
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Return all available changes until there are no further changes pending or
|
|
125
|
+
* reaching an end condition.
|
|
126
|
+
*
|
|
127
|
+
* The end conditions are:
|
|
128
|
+
* * a terminal error (e.g. unauthorized client).
|
|
129
|
+
* * transient errors occur for longer than the error suppression duration.
|
|
130
|
+
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
131
|
+
* * {@link ChangesFollower#stop} is called.
|
|
132
|
+
*
|
|
133
|
+
* The same change may be received more than once.
|
|
134
|
+
*
|
|
135
|
+
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
136
|
+
* @throws {Error} if:
|
|
137
|
+
* * {@link ChangesFollower#start} or {@link ChangesFollower#startOneOff} was already called.
|
|
138
|
+
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
139
|
+
*/
|
|
140
|
+
ChangesFollower.prototype.startOneOff = function () {
|
|
141
|
+
return this.run(Mode.FINITE);
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Stop this {@link ChangesFollower}.
|
|
145
|
+
*
|
|
146
|
+
* @throws {Error} if {@link ChangesFollower#start}
|
|
147
|
+
* or {@link ChangesFollower#startOneOff} was not called first
|
|
148
|
+
*/
|
|
149
|
+
ChangesFollower.prototype.stop = function () {
|
|
150
|
+
if (this.changesResultIterator) {
|
|
151
|
+
this.changesResultIterator.return();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
throw new Error('Cannot stop a feed that is not running.');
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
* @param mode the mode in which to run the ChangesFollower
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
ChangesFollower.prototype.run = function (mode) {
|
|
163
|
+
if (!this.changesResultIterator) {
|
|
164
|
+
return this.createChangesResultItemsStream(mode);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
throw new Error('Cannot start a feed that has already started.');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
ChangesFollower.prototype.createChangesResultItemsStream = function (mode) {
|
|
171
|
+
this.changesResultIterator = new changesResultIterator_1.ChangesResultIterableIterator(this.client, changesParamsHelper_1.ChangesParamsHelper.cloneParams(this.params), mode, this.errorTolerance);
|
|
172
|
+
return (0, stream_1.pipeline)(stream_1.Readable.from(this.changesResultIterator), new changesResultItemStream_1.ChangesResultItemStream(), function () { });
|
|
173
|
+
};
|
|
174
|
+
ChangesFollower.BATCH_SIZE = 10000;
|
|
175
|
+
return ChangesFollower;
|
|
176
|
+
}());
|
|
177
|
+
exports.ChangesFollower = ChangesFollower;
|
|
178
|
+
//# sourceMappingURL=changesFollower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changesFollower.js","sourceRoot":"","sources":["../../../cloudant/features/changesFollower.ts"],"names":[],"mappings":";;;AAiBA,6DAA4D;AAC5D,qEAAoE;AACpE,iCAA4C;AAC5C,iEAAwE;AAGxE,IAAY,IAIX;AAJD,WAAY,IAAI;IACd,gBAAgB;IAChB,mCAAM,CAAA;IACN,mCAAM,CAAA;AACR,CAAC,EAJW,IAAI,oBAAJ,IAAI,QAIf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH;IAcE;;;;;;;;;;;OAWG;IACH,yBACE,MAAkB,EAClB,MAAoC,EACpC,cAAuB;QAEvB,2BAA2B;QAC3B,yCAAmB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,6DAA6D;QAC7D,IAAI,CAAC,MAAM,GAAG,yCAAmB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,cAAc,GAAG,CAAC,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;QACD,IAAI,cAAc,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC;SACxC;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;SACtC;QACD,gCAAgC;QAChC,IAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,IACE,WAAW,GAAG,CAAC;YACf,WAAW,GAAG,yCAAmB,CAAC,kBAAkB,EACpD;YACA,MAAM,IAAI,KAAK,CACb,0EAAmE,yCAAmB,CAAC,kBAAkB,6CAAmC,WAAW,SAAM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022, 2023. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { PostChangesParams } from '../v1';
|
|
17
|
+
export declare class ChangesParamsHelper {
|
|
18
|
+
/**
|
|
19
|
+
* Set minimum client timeout to 1 minute (= 60 000 ms).
|
|
20
|
+
* 1 minute is the sort of number that very likely to be used as a client timeout,
|
|
21
|
+
* so it makes sense to set as our minimum client timeout.
|
|
22
|
+
*/
|
|
23
|
+
static MIN_CLIENT_TIMEOUT: number;
|
|
24
|
+
/**
|
|
25
|
+
* Set longpoll timeout to {@link MIN_CLIENT_TIMEOUT} - 3 second (= 3000 ms).
|
|
26
|
+
* To give the changes request a chance to be answered before the client timeout
|
|
27
|
+
* it is set to 3 seconds less.
|
|
28
|
+
*/
|
|
29
|
+
static LONGPOLL_TIMEOUT: number;
|
|
30
|
+
static cloneParams(params: PostChangesParams, since?: string, limit?: number): PostChangesParams;
|
|
31
|
+
static validateParams(params: PostChangesParams): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2022, 2023. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ChangesParamsHelper = void 0;
|
|
19
|
+
var v1_1 = require("../v1");
|
|
20
|
+
var ChangesParamsHelper = /** @class */ (function () {
|
|
21
|
+
function ChangesParamsHelper() {
|
|
22
|
+
}
|
|
23
|
+
ChangesParamsHelper.cloneParams = function (params, since, limit) {
|
|
24
|
+
return {
|
|
25
|
+
db: params.db,
|
|
26
|
+
attEncodingInfo: params.attEncodingInfo,
|
|
27
|
+
attachments: params.attachments,
|
|
28
|
+
conflicts: params.conflicts,
|
|
29
|
+
// no descending
|
|
30
|
+
docIds: params.docIds,
|
|
31
|
+
feed: v1_1.PostChangesConstants.Feed.LONGPOLL,
|
|
32
|
+
fields: params.fields,
|
|
33
|
+
filter: params.filter,
|
|
34
|
+
// no heartbeat
|
|
35
|
+
includeDocs: params.includeDocs,
|
|
36
|
+
// no lastEventId
|
|
37
|
+
limit: limit ? limit : params.limit,
|
|
38
|
+
selector: params.selector,
|
|
39
|
+
seqInterval: params.seqInterval,
|
|
40
|
+
since: since ? since : params.since,
|
|
41
|
+
style: params.style,
|
|
42
|
+
timeout: this.LONGPOLL_TIMEOUT,
|
|
43
|
+
view: params.view,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
ChangesParamsHelper.validateParams = function (params) {
|
|
47
|
+
if (!params) {
|
|
48
|
+
throw new Error('PostChangesParams configuration is required.');
|
|
49
|
+
}
|
|
50
|
+
if (!('db' in params) || !params.db) {
|
|
51
|
+
throw new Error('The param db is required for PostChangesParams.');
|
|
52
|
+
}
|
|
53
|
+
var invalidParams = [];
|
|
54
|
+
var paramsShouldBeUndefined = [
|
|
55
|
+
'descending',
|
|
56
|
+
'feed',
|
|
57
|
+
'heartbeat',
|
|
58
|
+
'lastEventId',
|
|
59
|
+
'timeout',
|
|
60
|
+
];
|
|
61
|
+
for (var _i = 0, paramsShouldBeUndefined_1 = paramsShouldBeUndefined; _i < paramsShouldBeUndefined_1.length; _i++) {
|
|
62
|
+
var paramName = paramsShouldBeUndefined_1[_i];
|
|
63
|
+
if (paramName in params) {
|
|
64
|
+
invalidParams.push("'".concat(paramName, "'"));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if ('filter' in params && params.filter !== '_selector') {
|
|
68
|
+
invalidParams.push("'filter=".concat(params.filter, "'"));
|
|
69
|
+
}
|
|
70
|
+
var errorMsg = '';
|
|
71
|
+
if (invalidParams.length > 0) {
|
|
72
|
+
var invalidParamsAsText = invalidParams.join(', ');
|
|
73
|
+
errorMsg = "The params ".concat(invalidParamsAsText, " are invalid when using ChangesFollower.");
|
|
74
|
+
if (invalidParams.length === 1) {
|
|
75
|
+
errorMsg = "The param ".concat(invalidParamsAsText, " is invalid when using ChangesFollower.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (errorMsg.length > 0) {
|
|
79
|
+
throw new Error(errorMsg);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var _a;
|
|
83
|
+
_a = ChangesParamsHelper;
|
|
84
|
+
/**
|
|
85
|
+
* Set minimum client timeout to 1 minute (= 60 000 ms).
|
|
86
|
+
* 1 minute is the sort of number that very likely to be used as a client timeout,
|
|
87
|
+
* so it makes sense to set as our minimum client timeout.
|
|
88
|
+
*/
|
|
89
|
+
ChangesParamsHelper.MIN_CLIENT_TIMEOUT = 60000;
|
|
90
|
+
/**
|
|
91
|
+
* Set longpoll timeout to {@link MIN_CLIENT_TIMEOUT} - 3 second (= 3000 ms).
|
|
92
|
+
* To give the changes request a chance to be answered before the client timeout
|
|
93
|
+
* it is set to 3 seconds less.
|
|
94
|
+
*/
|
|
95
|
+
ChangesParamsHelper.LONGPOLL_TIMEOUT = _a.MIN_CLIENT_TIMEOUT - 3000;
|
|
96
|
+
return ChangesParamsHelper;
|
|
97
|
+
}());
|
|
98
|
+
exports.ChangesParamsHelper = ChangesParamsHelper;
|
|
99
|
+
//# sourceMappingURL=changesParamsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changesParamsHelper.js","sourceRoot":"","sources":["../../../cloudant/features/changesParamsHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4BAAgE;AAEhE;IAAA;IAgFA,CAAC;IAjEQ,+BAAW,GAAlB,UACE,MAAyB,EACzB,KAAc,EACd,KAAc;QAEd,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,gBAAgB;YAChB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,yBAAoB,CAAC,IAAI,CAAC,QAAQ;YACxC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,eAAe;YACf,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,iBAAiB;YACjB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;YACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;YACnC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,IAAI,CAAC,gBAAgB;YAC9B,IAAI,EAAE,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OAIG;IACI,sCAAkB,GAAW,KAAM,AAAjB,CAAkB;IAE3C;;;;OAIG;IACI,oCAAgB,GAAG,EAAI,CAAC,kBAAkB,GAAG,IAAI,AAAjC,CAAkC;IAmE3D,0BAAC;CAAA,AAhFD,IAgFC;AAhFY,kDAAmB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2022. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="node" />
|
|
17
|
+
/// <reference types="node" />
|
|
18
|
+
import { Stream } from './stream';
|
|
19
|
+
import { TransformCallback } from 'stream';
|
|
20
|
+
import CloudantV1 = require('../v1');
|
|
21
|
+
export declare class ChangesResultItemStream extends Stream<CloudantV1.ChangesResultItem> {
|
|
22
|
+
_transform(chunk: CloudantV1.ChangesResult, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
23
|
+
private getValidationError;
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2022. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __extends = (this && this.__extends) || (function () {
|
|
18
|
+
var extendStatics = function (d, b) {
|
|
19
|
+
extendStatics = Object.setPrototypeOf ||
|
|
20
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
21
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
22
|
+
return extendStatics(d, b);
|
|
23
|
+
};
|
|
24
|
+
return function (d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null)
|
|
26
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
27
|
+
extendStatics(d, b);
|
|
28
|
+
function __() { this.constructor = d; }
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
};
|
|
31
|
+
})();
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.ChangesResultItemStream = void 0;
|
|
34
|
+
var stream_1 = require("./stream");
|
|
35
|
+
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
|
|
36
|
+
var ChangesResultItemStream = /** @class */ (function (_super) {
|
|
37
|
+
__extends(ChangesResultItemStream, _super);
|
|
38
|
+
function ChangesResultItemStream() {
|
|
39
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
40
|
+
}
|
|
41
|
+
ChangesResultItemStream.prototype._transform = function (chunk, encoding, callback) {
|
|
42
|
+
var validationError = this.getValidationError(chunk);
|
|
43
|
+
if (validationError !== null) {
|
|
44
|
+
this.destroy(validationError);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
for (var _i = 0, _a = chunk.results; _i < _a.length; _i++) {
|
|
48
|
+
var result = _a[_i];
|
|
49
|
+
this.push(result);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
callback();
|
|
53
|
+
};
|
|
54
|
+
ChangesResultItemStream.prototype.getValidationError = function (params) {
|
|
55
|
+
var requiredParams = ['last_seq', 'pending', 'results'];
|
|
56
|
+
return (0, ibm_cloud_sdk_core_1.validateParams)(params, requiredParams, requiredParams);
|
|
57
|
+
};
|
|
58
|
+
return ChangesResultItemStream;
|
|
59
|
+
}(stream_1.Stream));
|
|
60
|
+
exports.ChangesResultItemStream = ChangesResultItemStream;
|
|
61
|
+
//# sourceMappingURL=changesResultItemStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changesResultItemStream.js","sourceRoot":"","sources":["../../../cloudant/features/changesResultItemStream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;AAEH,mCAAkC;AAElC,yDAAoD;AAGpD;IAA6C,2CAAoC;IAAjF;;IAqBA,CAAC;IApBC,4CAAU,GAAV,UACE,KAA+B,EAC/B,QAAwB,EACxB,QAA2B;QAE3B,IAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;SAC/B;aAAM;YACL,KAAmB,UAAa,EAAb,KAAA,KAAK,CAAC,OAAO,EAAb,cAAa,EAAb,IAAa,EAAE;gBAA7B,IAAI,MAAM,SAAA;gBACb,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACnB;SACF;QACD,QAAQ,EAAE,CAAC;IACb,CAAC;IAEO,oDAAkB,GAA1B,UAA2B,MAAM;QAC/B,IAAM,cAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1D,OAAO,IAAA,mCAAc,EAAC,MAAM,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;IACH,8BAAC;AAAD,CAAC,AArBD,CAA6C,eAAM,GAqBlD;AArBY,0DAAuB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2022, 2023. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Mode } from './changesFollower';
|
|
17
|
+
import { PostChangesParams } from '../v1';
|
|
18
|
+
import CloudantV1 = require('../v1');
|
|
19
|
+
export declare class ChangesResultIterableIterator implements AsyncIterableIterator<CloudantV1.ChangesResult> {
|
|
20
|
+
private readonly cancellable;
|
|
21
|
+
private readonly timeoutPromise;
|
|
22
|
+
private readonly cancelToken;
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly doneResult;
|
|
25
|
+
private readonly errorTolerance?;
|
|
26
|
+
private readonly logger;
|
|
27
|
+
private readonly mode;
|
|
28
|
+
private readonly promisedConfig;
|
|
29
|
+
private readonly transientErrorSuppression;
|
|
30
|
+
private readonly baseDelay;
|
|
31
|
+
private readonly expRetryGate;
|
|
32
|
+
private cancel;
|
|
33
|
+
private countDown;
|
|
34
|
+
private inflight;
|
|
35
|
+
private params;
|
|
36
|
+
private pending;
|
|
37
|
+
private since;
|
|
38
|
+
private stopped;
|
|
39
|
+
private successTimestamp;
|
|
40
|
+
private retry;
|
|
41
|
+
constructor(client: CloudantV1, params: PostChangesParams, mode: Mode, errorTolerance?: number);
|
|
42
|
+
configure(): Promise<void>;
|
|
43
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<CloudantV1.ChangesResult>;
|
|
44
|
+
return(value?: any): Promise<IteratorResult<CloudantV1.ChangesResult>>;
|
|
45
|
+
next(value?: any): Promise<IteratorResult<CloudantV1.ChangesResult>>;
|
|
46
|
+
}
|