@ibm-cloud/cloudant 0.8.2 → 0.8.3
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 +27 -27
- package/auth/couchdbSessionAuthenticator.js +23 -49
- package/auth/couchdbSessionAuthenticator.js.map +1 -1
- package/auth/index.d.ts +1 -1
- package/auth/index.js.map +1 -1
- package/auth/sessionTokenManager.js +35 -51
- package/auth/sessionTokenManager.js.map +1 -1
- package/cloudant/features/changesFollower.d.ts +14 -14
- package/cloudant/features/changesFollower.js +40 -34
- package/cloudant/features/changesFollower.js.map +1 -1
- package/cloudant/features/changesParamsHelper.js +28 -34
- package/cloudant/features/changesParamsHelper.js.map +1 -1
- package/cloudant/features/changesResultItemStream.js +11 -32
- package/cloudant/features/changesResultItemStream.js.map +1 -1
- package/cloudant/features/changesResultIterator.js +190 -240
- package/cloudant/features/changesResultIterator.js.map +1 -1
- package/cloudant/features/stream.js +15 -39
- package/cloudant/features/stream.js.map +1 -1
- package/cloudant/v1.d.ts +8 -0
- package/cloudant/v1.js +1405 -1426
- package/cloudant/v1.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/lib/cloudantBaseService.js +55 -78
- package/lib/cloudantBaseService.js.map +1 -1
- package/lib/common.js +34 -11
- package/lib/common.js.map +1 -1
- package/lib/getAuthenticatorFromEnvCloudantExtension.js +6 -6
- package/lib/getAuthenticatorFromEnvCloudantExtension.js.map +1 -1
- package/package.json +12 -11
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChangesFollower = exports.Mode = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const changesParamsHelper_1 = require("./changesParamsHelper");
|
|
5
|
+
const changesResultItemStream_1 = require("./changesResultItemStream");
|
|
6
|
+
const stream_1 = require("stream");
|
|
7
|
+
const changesResultIterator_1 = require("./changesResultIterator");
|
|
8
|
+
/** @internal */
|
|
8
9
|
var Mode;
|
|
9
10
|
(function (Mode) {
|
|
10
|
-
/** @internal */
|
|
11
11
|
Mode[Mode["FINITE"] = 0] = "FINITE";
|
|
12
12
|
Mode[Mode["LISTEN"] = 1] = "LISTEN";
|
|
13
13
|
})(Mode || (exports.Mode = Mode = {}));
|
|
@@ -15,18 +15,18 @@ var Mode;
|
|
|
15
15
|
* A helper for using the changes feed.
|
|
16
16
|
*
|
|
17
17
|
* There are two modes of operation:
|
|
18
|
-
* * {@link
|
|
18
|
+
* * {@link startOneOff} to fetch the changes from the supplied since sequence
|
|
19
19
|
* until there are no further pending changes.
|
|
20
|
-
* * {@link
|
|
20
|
+
* * {@link start} to fetch the changes from the supplied since sequence and
|
|
21
21
|
* then continuing to listen indefinitely for further new changes.
|
|
22
22
|
*
|
|
23
23
|
* The starting sequence ID can be changed for either mode by using
|
|
24
24
|
* {@link CloudantV1.PostChangesParams.since}. By default when using:
|
|
25
|
-
* * {@link
|
|
26
|
-
* * {@link
|
|
25
|
+
* * {@link startOneOff} the feed will start from the beginning.
|
|
26
|
+
* * {@link start} the feed will start from "now".
|
|
27
27
|
*
|
|
28
28
|
* In either mode the {@link Stream} of changes can be terminated early by calling
|
|
29
|
-
* {@link
|
|
29
|
+
* {@link stop}.
|
|
30
30
|
*
|
|
31
31
|
* By default {@link ChangesFollower} will suppress transient errors indefinitely and
|
|
32
32
|
* endeavour to run to completion or listen forever. For applications where that
|
|
@@ -65,7 +65,15 @@ var Mode;
|
|
|
65
65
|
* HTTP call and read timeouts of at least 1 minute. The default client
|
|
66
66
|
* configuration has sufficiently long timeouts.
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
class ChangesFollower {
|
|
69
|
+
/** @internal */
|
|
70
|
+
static BATCH_SIZE = 10000;
|
|
71
|
+
// Initialization fields
|
|
72
|
+
client;
|
|
73
|
+
params;
|
|
74
|
+
errorTolerance;
|
|
75
|
+
limit;
|
|
76
|
+
changesResultIterator;
|
|
69
77
|
/**
|
|
70
78
|
* Create a new {@link ChangesFollower} using the supplied client and params that
|
|
71
79
|
* suppress transient errors and retry for as long as the given `errorTolerance` duration.
|
|
@@ -78,7 +86,7 @@ var ChangesFollower = /** @class */ (function () {
|
|
|
78
86
|
*
|
|
79
87
|
* @throws {Error} if there are invalid params
|
|
80
88
|
*/
|
|
81
|
-
|
|
89
|
+
constructor(client, params, errorTolerance) {
|
|
82
90
|
// Validate supplied params
|
|
83
91
|
changesParamsHelper_1.ChangesParamsHelper.validateParams(params);
|
|
84
92
|
this.limit = params.limit;
|
|
@@ -96,10 +104,10 @@ var ChangesFollower = /** @class */ (function () {
|
|
|
96
104
|
this.errorTolerance = errorTolerance;
|
|
97
105
|
}
|
|
98
106
|
// Check the timeout is suitable
|
|
99
|
-
|
|
107
|
+
const readTimeout = this.client.getTimeout();
|
|
100
108
|
if (readTimeout > 0 &&
|
|
101
109
|
readTimeout < changesParamsHelper_1.ChangesParamsHelper.MIN_CLIENT_TIMEOUT) {
|
|
102
|
-
throw new Error(
|
|
110
|
+
throw new Error(`To use ChangesFollower the client read timeout must be at least ${changesParamsHelper_1.ChangesParamsHelper.MIN_CLIENT_TIMEOUT} ms. The client read timeout is ${readTimeout} ms.`);
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
113
|
/**
|
|
@@ -109,18 +117,18 @@ var ChangesFollower = /** @class */ (function () {
|
|
|
109
117
|
* * a terminal error (e.g. unauthorized client).
|
|
110
118
|
* * transient errors occur for longer than the error suppression duration.
|
|
111
119
|
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
112
|
-
* * {@link
|
|
120
|
+
* * {@link stop} is called.
|
|
113
121
|
*
|
|
114
122
|
* The same change may be received more than once.
|
|
115
123
|
*
|
|
116
124
|
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
117
125
|
* @throws {Error} if:
|
|
118
|
-
* * {@link
|
|
126
|
+
* * {@link start} or {@link startOneOff} was already called.
|
|
119
127
|
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
120
128
|
*/
|
|
121
|
-
|
|
129
|
+
start() {
|
|
122
130
|
return this.run(Mode.LISTEN);
|
|
123
|
-
}
|
|
131
|
+
}
|
|
124
132
|
/**
|
|
125
133
|
* Return all available changes until there are no further changes pending or
|
|
126
134
|
* reaching an end condition.
|
|
@@ -129,51 +137,49 @@ var ChangesFollower = /** @class */ (function () {
|
|
|
129
137
|
* * a terminal error (e.g. unauthorized client).
|
|
130
138
|
* * transient errors occur for longer than the error suppression duration.
|
|
131
139
|
* * the number of changes received reaches the limit specified in the {@link CloudantV1.PostChangesParams} used to instantiate this {@link ChangesFollower}.
|
|
132
|
-
* * {@link
|
|
140
|
+
* * {@link stop} is called.
|
|
133
141
|
*
|
|
134
142
|
* The same change may be received more than once.
|
|
135
143
|
*
|
|
136
144
|
* @return {Stream} at least one {@link ChangesResultItem} per change
|
|
137
145
|
* @throws {Error} if:
|
|
138
|
-
* * {@link
|
|
146
|
+
* * {@link start} or {@link startOneOff} was already called.
|
|
139
147
|
* * a terminal error or unsuppressed transient error is received from the service when fetching changes.
|
|
140
148
|
*/
|
|
141
|
-
|
|
149
|
+
startOneOff() {
|
|
142
150
|
return this.run(Mode.FINITE);
|
|
143
|
-
}
|
|
151
|
+
}
|
|
144
152
|
/**
|
|
145
153
|
* Stop this {@link ChangesFollower}.
|
|
146
154
|
*
|
|
147
|
-
* @throws {Error} if {@link
|
|
148
|
-
* or {@link
|
|
155
|
+
* @throws {Error} if {@link start}
|
|
156
|
+
* or {@link startOneOff} was not called first
|
|
149
157
|
*/
|
|
150
|
-
|
|
158
|
+
stop() {
|
|
151
159
|
if (this.changesResultIterator) {
|
|
152
160
|
this.changesResultIterator.return();
|
|
153
161
|
}
|
|
154
162
|
else {
|
|
155
163
|
throw new Error('Cannot stop a feed that is not running.');
|
|
156
164
|
}
|
|
157
|
-
}
|
|
165
|
+
}
|
|
158
166
|
/**
|
|
159
167
|
*
|
|
160
168
|
* @param mode the mode in which to run the ChangesFollower
|
|
161
169
|
* @private
|
|
162
170
|
*/
|
|
163
|
-
|
|
171
|
+
run(mode) {
|
|
164
172
|
if (!this.changesResultIterator) {
|
|
165
173
|
return this.createChangesResultItemsStream(mode);
|
|
166
174
|
}
|
|
167
175
|
else {
|
|
168
176
|
throw new Error('Cannot start a feed that has already started.');
|
|
169
177
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
178
|
+
}
|
|
179
|
+
createChangesResultItemsStream(mode) {
|
|
172
180
|
this.changesResultIterator = new changesResultIterator_1.ChangesResultIterableIterator(this.client, changesParamsHelper_1.ChangesParamsHelper.cloneParams(this.params), mode, this.errorTolerance);
|
|
173
|
-
return (0, stream_1.pipeline)(stream_1.Readable.from(this.changesResultIterator), new changesResultItemStream_1.ChangesResultItemStream(),
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return ChangesFollower;
|
|
177
|
-
}());
|
|
181
|
+
return (0, stream_1.pipeline)(stream_1.Readable.from(this.changesResultIterator), new changesResultItemStream_1.ChangesResultItemStream(), () => { });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
178
184
|
exports.ChangesFollower = ChangesFollower;
|
|
179
185
|
//# sourceMappingURL=changesFollower.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changesFollower.js","sourceRoot":"","sources":["../../../cloudant/features/changesFollower.ts"],"names":[],"mappings":";;;AAiBA
|
|
1
|
+
{"version":3,"file":"changesFollower.js","sourceRoot":"","sources":["../../../cloudant/features/changesFollower.ts"],"names":[],"mappings":";;;AAiBA,+DAA4D;AAC5D,uEAAoE;AACpE,mCAA4C;AAC5C,mEAAwE;AAGxE,gBAAgB;AAChB,IAAY,IAGX;AAHD,WAAY,IAAI;IACd,mCAAM,CAAA;IACN,mCAAM,CAAA;AACR,CAAC,EAHW,IAAI,oBAAJ,IAAI,QAGf;AAED;;;;;;;;;;;;;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C,CAAC;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC/B,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,GAAG,CAAC,IAAU;QACpB,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAEO,8BAA8B,CAAC,IAAU;QAC/C,IAAI,CAAC,qBAAqB,GAAG,IAAI,qDAA6B,CAC5D,IAAI,CAAC,MAAM,EACX,yCAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAC5C,IAAI,EACJ,IAAI,CAAC,cAAc,CACpB,CAAC;QAEF,OAAO,IAAA,iBAAQ,EACb,iBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,EACzC,IAAI,iDAAuB,EAAE,EAC7B,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;IACJ,CAAC;;AA5IH,0CA6IC"}
|
|
@@ -16,11 +16,21 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ChangesParamsHelper = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const v1_1 = require("../v1");
|
|
20
|
+
class ChangesParamsHelper {
|
|
21
|
+
/**
|
|
22
|
+
* Set minimum client timeout to 1 minute (= 60 000 ms).
|
|
23
|
+
* 1 minute is the sort of number that very likely to be used as a client timeout,
|
|
24
|
+
* so it makes sense to set as our minimum client timeout.
|
|
25
|
+
*/
|
|
26
|
+
static MIN_CLIENT_TIMEOUT = 60000;
|
|
27
|
+
/**
|
|
28
|
+
* Set longpoll timeout to {@link MIN_CLIENT_TIMEOUT} - 3 second (= 3000 ms).
|
|
29
|
+
* To give the changes request a chance to be answered before the client timeout
|
|
30
|
+
* it is set to 3 seconds less.
|
|
31
|
+
*/
|
|
32
|
+
static LONGPOLL_TIMEOUT = this.MIN_CLIENT_TIMEOUT - 3000;
|
|
33
|
+
static cloneParams(params, since, limit) {
|
|
24
34
|
return {
|
|
25
35
|
db: params.db,
|
|
26
36
|
attEncodingInfo: params.attEncodingInfo,
|
|
@@ -42,58 +52,42 @@ var ChangesParamsHelper = /** @class */ (function () {
|
|
|
42
52
|
timeout: this.LONGPOLL_TIMEOUT,
|
|
43
53
|
view: params.view,
|
|
44
54
|
};
|
|
45
|
-
}
|
|
46
|
-
|
|
55
|
+
}
|
|
56
|
+
static validateParams(params) {
|
|
47
57
|
if (!params) {
|
|
48
58
|
throw new Error('PostChangesParams configuration is required.');
|
|
49
59
|
}
|
|
50
60
|
if (!('db' in params) || !params.db) {
|
|
51
61
|
throw new Error('The param db is required for PostChangesParams.');
|
|
52
62
|
}
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
let invalidParams = [];
|
|
64
|
+
let paramsShouldBeUndefined = [
|
|
55
65
|
'descending',
|
|
56
66
|
'feed',
|
|
57
67
|
'heartbeat',
|
|
58
68
|
'lastEventId',
|
|
59
69
|
'timeout',
|
|
60
70
|
];
|
|
61
|
-
for (
|
|
62
|
-
var paramName = paramsShouldBeUndefined_1[_i];
|
|
71
|
+
for (let paramName of paramsShouldBeUndefined) {
|
|
63
72
|
if (paramName in params) {
|
|
64
|
-
invalidParams.push(
|
|
73
|
+
invalidParams.push(`'${paramName}'`);
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
if ('filter' in params && params.filter !== '_selector') {
|
|
68
|
-
invalidParams.push(
|
|
77
|
+
invalidParams.push(`'filter=${params.filter}'`);
|
|
69
78
|
}
|
|
70
|
-
|
|
79
|
+
let errorMsg = '';
|
|
71
80
|
if (invalidParams.length > 0) {
|
|
72
|
-
|
|
73
|
-
errorMsg =
|
|
81
|
+
const invalidParamsAsText = invalidParams.join(', ');
|
|
82
|
+
errorMsg = `The params ${invalidParamsAsText} are invalid when using ChangesFollower.`;
|
|
74
83
|
if (invalidParams.length === 1) {
|
|
75
|
-
errorMsg =
|
|
84
|
+
errorMsg = `The param ${invalidParamsAsText} is invalid when using ChangesFollower.`;
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
if (errorMsg.length > 0) {
|
|
79
88
|
throw new Error(errorMsg);
|
|
80
89
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
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
|
-
}());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
98
92
|
exports.ChangesParamsHelper = ChangesParamsHelper;
|
|
99
93
|
//# sourceMappingURL=changesParamsHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changesParamsHelper.js","sourceRoot":"","sources":["../../../cloudant/features/changesParamsHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"changesParamsHelper.js","sourceRoot":"","sources":["../../../cloudant/features/changesParamsHelper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8BAAgE;AAEhE,MAAa,mBAAmB;IAC9B;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,GAAW,KAAM,CAAC;IAE3C;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAEzD,MAAM,CAAC,WAAW,CAChB,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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QAAQ,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;;AA/EH,kDAgFC"}
|
|
@@ -14,48 +14,27 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
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
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
18
|
exports.ChangesResultItemStream = void 0;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
40
|
-
}
|
|
41
|
-
ChangesResultItemStream.prototype._transform = function (chunk, encoding, callback) {
|
|
42
|
-
var validationError = this.getValidationError(chunk);
|
|
19
|
+
const stream_1 = require("./stream");
|
|
20
|
+
const ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
|
|
21
|
+
class ChangesResultItemStream extends stream_1.Stream {
|
|
22
|
+
_transform(chunk, encoding, callback) {
|
|
23
|
+
const validationError = this.getValidationError(chunk);
|
|
43
24
|
if (validationError !== null) {
|
|
44
25
|
this.destroy(validationError);
|
|
45
26
|
}
|
|
46
27
|
else {
|
|
47
|
-
for (
|
|
48
|
-
var result = _a[_i];
|
|
28
|
+
for (let result of chunk.results) {
|
|
49
29
|
this.push(result);
|
|
50
30
|
}
|
|
51
31
|
}
|
|
52
32
|
callback();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
}
|
|
34
|
+
getValidationError(params) {
|
|
35
|
+
const requiredParams = ['last_seq', 'pending', 'results'];
|
|
56
36
|
return (0, ibm_cloud_sdk_core_1.validateParams)(params, requiredParams, requiredParams);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}(stream_1.Stream));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
60
39
|
exports.ChangesResultItemStream = ChangesResultItemStream;
|
|
61
40
|
//# sourceMappingURL=changesResultItemStream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changesResultItemStream.js","sourceRoot":"","sources":["../../../cloudant/features/changesResultItemStream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"changesResultItemStream.js","sourceRoot":"","sources":["../../../cloudant/features/changesResultItemStream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qCAAkC;AAElC,2DAAoD;AAGpD,MAAa,uBAAwB,SAAQ,eAAoC;IAC/E,UAAU,CACR,KAA+B,EAC/B,QAAwB,EACxB,QAA2B;QAE3B,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,CAAC;IACb,CAAC;IAEO,kBAAkB,CAAC,MAAM;QAC/B,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1D,OAAO,IAAA,mCAAc,EAAC,MAAM,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;CACF;AArBD,0DAqBC"}
|