@ibm-cloud/cloudant 0.12.3 → 0.12.5
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 +649 -75
- package/cloudant/features/changesFollower.js +3 -2
- package/cloudant/features/changesFollower.js.map +1 -1
- package/cloudant/features/pagination/allDocsBasePageIterator.d.ts +29 -0
- package/cloudant/features/pagination/allDocsBasePageIterator.js +47 -0
- package/cloudant/features/pagination/allDocsBasePageIterator.js.map +1 -0
- package/cloudant/features/pagination/allDocsPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/allDocsPageIterator.js +30 -0
- package/cloudant/features/pagination/allDocsPageIterator.js.map +1 -0
- package/cloudant/features/pagination/allDocsPartitionPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/allDocsPartitionPageIterator.js +30 -0
- package/cloudant/features/pagination/allDocsPartitionPageIterator.js.map +1 -0
- package/cloudant/features/pagination/basePageIterator.d.ts +39 -0
- package/cloudant/features/pagination/basePageIterator.js +84 -0
- package/cloudant/features/pagination/basePageIterator.js.map +1 -0
- package/cloudant/features/pagination/bookmarkPageIterator.d.ts +25 -0
- package/cloudant/features/pagination/bookmarkPageIterator.js +37 -0
- package/cloudant/features/pagination/bookmarkPageIterator.js.map +1 -0
- package/cloudant/features/pagination/designDocsPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/designDocsPageIterator.js +30 -0
- package/cloudant/features/pagination/designDocsPageIterator.js.map +1 -0
- package/cloudant/features/pagination/findBasePageIterator.d.ts +23 -0
- package/cloudant/features/pagination/findBasePageIterator.js +36 -0
- package/cloudant/features/pagination/findBasePageIterator.js.map +1 -0
- package/cloudant/features/pagination/findPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/findPageIterator.js +30 -0
- package/cloudant/features/pagination/findPageIterator.js.map +1 -0
- package/cloudant/features/pagination/findPartitionPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/findPartitionPageIterator.js +30 -0
- package/cloudant/features/pagination/findPartitionPageIterator.js.map +1 -0
- package/cloudant/features/pagination/iteratorPager.d.ts +32 -0
- package/cloudant/features/pagination/iteratorPager.js +58 -0
- package/cloudant/features/pagination/iteratorPager.js.map +1 -0
- package/cloudant/features/pagination/keyPageIterator.d.ts +33 -0
- package/cloudant/features/pagination/keyPageIterator.js +75 -0
- package/cloudant/features/pagination/keyPageIterator.js.map +1 -0
- package/cloudant/features/{changesResultItemStream.d.ts → pagination/pageIterator.d.ts} +4 -7
- package/cloudant/features/pagination/pageIterator.js +3 -0
- package/cloudant/features/pagination/pageIterator.js.map +1 -0
- package/cloudant/features/pagination/pager.d.ts +28 -0
- package/cloudant/features/pagination/pager.js +18 -0
- package/cloudant/features/pagination/pager.js.map +1 -0
- package/cloudant/features/pagination/pagination.d.ts +185 -0
- package/cloudant/features/pagination/pagination.js +148 -0
- package/cloudant/features/pagination/pagination.js.map +1 -0
- package/cloudant/features/pagination/searchBasePageIterator.d.ts +22 -0
- package/cloudant/features/pagination/searchBasePageIterator.js +30 -0
- package/cloudant/features/pagination/searchBasePageIterator.js.map +1 -0
- package/cloudant/features/pagination/searchPageIterator.d.ts +22 -0
- package/cloudant/features/pagination/searchPageIterator.js +40 -0
- package/cloudant/features/pagination/searchPageIterator.js.map +1 -0
- package/cloudant/features/pagination/searchPartitionPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/searchPartitionPageIterator.js +30 -0
- package/cloudant/features/pagination/searchPartitionPageIterator.js.map +1 -0
- package/cloudant/features/pagination/viewBasePageIterator.d.ts +25 -0
- package/cloudant/features/pagination/viewBasePageIterator.js +57 -0
- package/cloudant/features/pagination/viewBasePageIterator.js.map +1 -0
- package/cloudant/features/pagination/viewPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/viewPageIterator.js +30 -0
- package/cloudant/features/pagination/viewPageIterator.js.map +1 -0
- package/cloudant/features/pagination/viewPartitionPageIterator.d.ts +21 -0
- package/cloudant/features/pagination/viewPartitionPageIterator.js +30 -0
- package/cloudant/features/pagination/viewPartitionPageIterator.js.map +1 -0
- package/cloudant/features/stream.d.ts +4 -3
- package/cloudant/features/stream.js +6 -3
- package/cloudant/features/stream.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +5 -2
- package/index.js.map +1 -1
- package/package.json +17 -17
- package/cloudant/features/changesResultItemStream.js +0 -40
- package/cloudant/features/changesResultItemStream.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2025. 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.FindPartitionPageIterator = void 0;
|
|
19
|
+
const findBasePageIterator_1 = require("./findBasePageIterator");
|
|
20
|
+
class FindPartitionPageIterator extends findBasePageIterator_1.FindBasePageIterator {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
22
|
+
constructor(client, params) {
|
|
23
|
+
super(client, params);
|
|
24
|
+
}
|
|
25
|
+
nextRequestFunction() {
|
|
26
|
+
return this.client.postPartitionFind;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.FindPartitionPageIterator = FindPartitionPageIterator;
|
|
30
|
+
//# sourceMappingURL=findPartitionPageIterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPartitionPageIterator.js","sourceRoot":"","sources":["../../../../cloudant/features/pagination/findPartitionPageIterator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAQH,iEAA8D;AAE9D,MAAa,yBAA0B,SAAQ,2CAA6C;IAC1F,qEAAqE;IACrE,YAAY,MAAkB,EAAE,MAA+B;QAC7D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAES,mBAAmB;QAG3B,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACvC,CAAC;CACF;AAXD,8DAWC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2025. 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 { PageIterator } from './pageIterator';
|
|
17
|
+
import { Pager } from './pager';
|
|
18
|
+
export declare class IteratorPager<I> implements Pager<I> {
|
|
19
|
+
private pageIterableIterator;
|
|
20
|
+
private state;
|
|
21
|
+
constructor(pageIterableIterator: PageIterator<I>);
|
|
22
|
+
hasNext(): boolean;
|
|
23
|
+
getNext(): Promise<ReadonlyArray<I>>;
|
|
24
|
+
getAll(): Promise<ReadonlyArray<I>>;
|
|
25
|
+
private checkState;
|
|
26
|
+
}
|
|
27
|
+
export declare enum State {
|
|
28
|
+
NEW = 0,
|
|
29
|
+
GET_NEXT = 1,
|
|
30
|
+
GET_ALL = 2,
|
|
31
|
+
CONSUMED = 3
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.State = exports.IteratorPager = void 0;
|
|
4
|
+
class IteratorPager {
|
|
5
|
+
pageIterableIterator;
|
|
6
|
+
state = State.NEW;
|
|
7
|
+
constructor(pageIterableIterator) {
|
|
8
|
+
this.pageIterableIterator = pageIterableIterator;
|
|
9
|
+
}
|
|
10
|
+
hasNext() {
|
|
11
|
+
return this.pageIterableIterator.hasNext();
|
|
12
|
+
}
|
|
13
|
+
async getNext() {
|
|
14
|
+
this.checkState(State.GET_NEXT);
|
|
15
|
+
const nextElement = await this.pageIterableIterator.next();
|
|
16
|
+
if (!this.hasNext()) {
|
|
17
|
+
this.state = State.CONSUMED;
|
|
18
|
+
}
|
|
19
|
+
if (nextElement.done) {
|
|
20
|
+
throw new Error('No more results available.');
|
|
21
|
+
}
|
|
22
|
+
return nextElement.value;
|
|
23
|
+
}
|
|
24
|
+
async getAll() {
|
|
25
|
+
this.checkState(State.GET_ALL);
|
|
26
|
+
let items = [];
|
|
27
|
+
for await (const page of this.pageIterableIterator) {
|
|
28
|
+
items.push(...page);
|
|
29
|
+
}
|
|
30
|
+
// If it didn't throw we can set the consumed state
|
|
31
|
+
this.state = State.CONSUMED;
|
|
32
|
+
const readOnlyItems = [...items];
|
|
33
|
+
return readOnlyItems;
|
|
34
|
+
}
|
|
35
|
+
checkState(state) {
|
|
36
|
+
if (this.state === state) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
switch (this.state) {
|
|
40
|
+
case State.NEW:
|
|
41
|
+
this.state = state;
|
|
42
|
+
break;
|
|
43
|
+
case State.CONSUMED:
|
|
44
|
+
throw new Error('This pager has been consumed, use a new Pager.');
|
|
45
|
+
default:
|
|
46
|
+
throw new Error('Cannot mix getAll() and getNext(), use only one method or get a a new Pager.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.IteratorPager = IteratorPager;
|
|
51
|
+
var State;
|
|
52
|
+
(function (State) {
|
|
53
|
+
State[State["NEW"] = 0] = "NEW";
|
|
54
|
+
State[State["GET_NEXT"] = 1] = "GET_NEXT";
|
|
55
|
+
State[State["GET_ALL"] = 2] = "GET_ALL";
|
|
56
|
+
State[State["CONSUMED"] = 3] = "CONSUMED";
|
|
57
|
+
})(State || (exports.State = State = {}));
|
|
58
|
+
//# sourceMappingURL=iteratorPager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteratorPager.js","sourceRoot":"","sources":["../../../../cloudant/features/pagination/iteratorPager.ts"],"names":[],"mappings":";;;AAkBA,MAAa,aAAa;IAChB,oBAAoB,CAAkB;IACtC,KAAK,GAAU,KAAK,CAAC,GAAG,CAAC;IAEjC,YAAY,oBAAqC;QAC/C,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;QAC3D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC9B,CAAC;QACD,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,IAAI,KAAK,GAAa,EAAE,CAAC;QACzB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YACnD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACtB,CAAC;QACD,mDAAmD;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC5B,MAAM,aAAa,GAAqB,CAAC,GAAG,KAAK,CAAC,CAAC;QACnD,OAAO,aAAa,CAAC;IACvB,CAAC;IAEO,UAAU,CAAC,KAAY;QAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;QACD,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,KAAK,KAAK,CAAC,GAAG;gBACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,MAAM;YACR,KAAK,KAAK,CAAC,QAAQ;gBACjB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACpE;gBACE,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;QACN,CAAC;IACH,CAAC;CACF;AApDD,sCAoDC;AAED,IAAY,KAKX;AALD,WAAY,KAAK;IACf,+BAAG,CAAA;IACH,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,yCAAQ,CAAA;AACV,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2025. 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 { BasePageIterator } from './basePageIterator';
|
|
17
|
+
import { default as CloudantV1, Response } from '../../v1';
|
|
18
|
+
export declare abstract class KeyPageIterator<K, P extends CloudantV1.PostAllDocsParams | CloudantV1.PostPartitionAllDocsParams | CloudantV1.PostDesignDocsParams | CloudantV1.PostViewParams | CloudantV1.PostPartitionViewParams, R extends CloudantV1.AllDocsResult | CloudantV1.ViewResult, I extends CloudantV1.DocsResultRow | CloudantV1.ViewResultRow> extends BasePageIterator<P, R, I> {
|
|
19
|
+
private boundaryFailure;
|
|
20
|
+
constructor(client: CloudantV1, params: P);
|
|
21
|
+
protected setNextKey(params: P, startKey: K): void;
|
|
22
|
+
protected getNextKey(item: I): K;
|
|
23
|
+
protected abstract setNextKeyId(params: P, startKeyDocId: string): any;
|
|
24
|
+
protected getNextKeyId(item: I): string;
|
|
25
|
+
protected setLimit(params: P, limit: number): void;
|
|
26
|
+
protected abstract getItems(result: R): Array<I>;
|
|
27
|
+
protected abstract nextRequestFunction(): (params: P) => Promise<Response<R>>;
|
|
28
|
+
protected setNextPageParams(params: P, result: R): void;
|
|
29
|
+
protected nextRequest(): Promise<Array<I>>;
|
|
30
|
+
protected getPageSize(params: P): number;
|
|
31
|
+
protected abstract checkBoundary(penultimateItem: I, lastItem: I): any;
|
|
32
|
+
protected validate(params: P): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2025. 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.KeyPageIterator = void 0;
|
|
19
|
+
const basePageIterator_1 = require("./basePageIterator");
|
|
20
|
+
class KeyPageIterator extends basePageIterator_1.BasePageIterator {
|
|
21
|
+
boundaryFailure = null;
|
|
22
|
+
constructor(client, params) {
|
|
23
|
+
super(client, params);
|
|
24
|
+
this.setLimit(this.nextPageParams, this.getPageSize(params)); // n+1 items per request
|
|
25
|
+
}
|
|
26
|
+
setNextKey(params, startKey) {
|
|
27
|
+
params.startKey = startKey;
|
|
28
|
+
}
|
|
29
|
+
getNextKey(item) {
|
|
30
|
+
return item.key;
|
|
31
|
+
}
|
|
32
|
+
getNextKeyId(item) {
|
|
33
|
+
return item.id;
|
|
34
|
+
}
|
|
35
|
+
setLimit(params, limit) {
|
|
36
|
+
params.limit = limit;
|
|
37
|
+
}
|
|
38
|
+
setNextPageParams(params, result) {
|
|
39
|
+
const items = this.getItems(result);
|
|
40
|
+
const lastItem = items[items.length - 1];
|
|
41
|
+
const nextKey = this.getNextKey(lastItem);
|
|
42
|
+
const nextKeyId = this.getNextKeyId(lastItem);
|
|
43
|
+
this.setNextKey(params, nextKey);
|
|
44
|
+
this.setNextKeyId(params, nextKeyId);
|
|
45
|
+
if (params.skip) {
|
|
46
|
+
delete params.skip;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async nextRequest() {
|
|
50
|
+
// If the previous request had the duplicate boundary error
|
|
51
|
+
// throw it now because we cannot safely get the next page.
|
|
52
|
+
if (this.boundaryFailure) {
|
|
53
|
+
throw new Error(this.boundaryFailure);
|
|
54
|
+
}
|
|
55
|
+
const items = await super.nextRequest();
|
|
56
|
+
if (this._hasNext) {
|
|
57
|
+
const lastItem = items.pop();
|
|
58
|
+
if (items.length > 0) {
|
|
59
|
+
const penultimateItem = items[items.length - 1];
|
|
60
|
+
// Defer a throw for a boundary failure to the next request
|
|
61
|
+
this.boundaryFailure = this.checkBoundary(penultimateItem, lastItem);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return items;
|
|
65
|
+
}
|
|
66
|
+
getPageSize(params) {
|
|
67
|
+
return super.getPageSize(params) + 1;
|
|
68
|
+
}
|
|
69
|
+
validate(params) {
|
|
70
|
+
super.validate(params);
|
|
71
|
+
this.validateParamsAbsent(params, ['keys', 'key']);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.KeyPageIterator = KeyPageIterator;
|
|
75
|
+
//# sourceMappingURL=keyPageIterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyPageIterator.js","sourceRoot":"","sources":["../../../../cloudant/features/pagination/keyPageIterator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yDAAsD;AAGtD,MAAsB,eAUpB,SAAQ,mCAAyB;IACzB,eAAe,GAAG,IAAI,CAAC;IAC/B,YAAY,MAAkB,EAAE,MAAS;QACvC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,wBAAwB;IACxF,CAAC;IAES,UAAU,CAAC,MAAS,EAAE,QAAW;QACzC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAES,UAAU,CAAC,IAAO;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAGS,YAAY,CAAC,IAAO;QAC5B,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAES,QAAQ,CAAC,MAAS,EAAE,KAAa;QACzC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAKS,iBAAiB,CAAC,MAAS,EAAE,MAAS;QAC9C,MAAM,KAAK,GAAa,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAM,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAQ,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAW,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,2DAA2D;QAC3D,2DAA2D;QAC3D,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,KAAK,GAAa,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAClD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAChD,2DAA2D;gBAC3D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAES,WAAW,CAAC,MAAS;QAC7B,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAIS,QAAQ,CAAC,MAAS;QAC1B,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;CACF;AA7ED,0CA6EC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* © Copyright IBM Corporation
|
|
2
|
+
* © Copyright IBM Corporation 2025. All Rights Reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,10 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export declare class ChangesResultItemStream extends Stream<CloudantV1.ChangesResultItem> {
|
|
20
|
-
_transform(chunk: CloudantV1.ChangesResult, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
21
|
-
private getValidationError;
|
|
16
|
+
import { default as CloudantV1 } from '../../v1';
|
|
17
|
+
export interface PageIterator<I extends CloudantV1.DocsResultRow | CloudantV1.Document | CloudantV1.SearchResultRow | CloudantV1.ViewResultRow> extends AsyncIterableIterator<ReadonlyArray<I>> {
|
|
18
|
+
hasNext(): boolean;
|
|
22
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageIterator.js","sourceRoot":"","sources":["../../../../cloudant/features/pagination/pageIterator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2025. 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
|
+
/**
|
|
17
|
+
* Interface for pagination of database operations.
|
|
18
|
+
*
|
|
19
|
+
* Use the static methods to instantiate a Pager instance for
|
|
20
|
+
* the required operation.
|
|
21
|
+
*
|
|
22
|
+
* @param <I> the item type of the page rows.
|
|
23
|
+
*/
|
|
24
|
+
export interface Pager<I> {
|
|
25
|
+
hasNext(): boolean;
|
|
26
|
+
getNext(): Promise<ReadonlyArray<I>>;
|
|
27
|
+
getAll(): Promise<ReadonlyArray<I>>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2025. 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
|
+
//# sourceMappingURL=pager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pager.js","sourceRoot":"","sources":["../../../../cloudant/features/pagination/pager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © Copyright IBM Corporation 2025. 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 { default as CloudantV1, DocsResultRow, Document, PostAllDocsParams, PostDesignDocsParams, PostFindParams, PostPartitionAllDocsParams, PostPartitionFindParams, PostPartitionSearchParams, PostPartitionViewParams, PostSearchParams, PostViewParams, SearchResultRow, ViewResultRow } from '../../v1';
|
|
17
|
+
import { Pager } from './pager';
|
|
18
|
+
import { Stream } from '../stream';
|
|
19
|
+
/**
|
|
20
|
+
* {@link Pagination} is the entry point for pagination features.
|
|
21
|
+
*
|
|
22
|
+
* Use the static methods to create new {@link Pagination} instances. The instances in turn can be
|
|
23
|
+
* used to create:
|
|
24
|
+
* * {@link Stream} of result rows via {@link rowStream()}
|
|
25
|
+
* * {@link Stream} of pages via {@link pageStream()}
|
|
26
|
+
* * {@link AsyncIterableIterator} of result rows via {@link rows()}
|
|
27
|
+
* * {@link AsyncIterableIterator}s of pages via {@link pages()}
|
|
28
|
+
* * IBM Cloud SDK style {@link Pager}s via {@link pager()}
|
|
29
|
+
*
|
|
30
|
+
* @param <I> the result row type of the operation.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Pagination<I> {
|
|
33
|
+
private pageIterableIterator;
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Get a new IBM Cloud SDK style Pager for the operation.
|
|
37
|
+
*
|
|
38
|
+
* This type is useful for retrieving one page at a time through a function call.
|
|
39
|
+
*
|
|
40
|
+
* @return a new IBM Cloud SDK style Pager
|
|
41
|
+
*/
|
|
42
|
+
pager(): Pager<I>;
|
|
43
|
+
/**
|
|
44
|
+
* Get an AsyncIterableIterator for all the pages.
|
|
45
|
+
*
|
|
46
|
+
* This function is useful for handling pages in an enhanced for loop e.g.
|
|
47
|
+
* ```ts
|
|
48
|
+
* for await (const row: ReadonlyArray<DocsResultRow> of Pagination.newPagination(client, PagerType.POST_ALL_DOCS, allDocsParams).pages()){
|
|
49
|
+
* ...
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @return an {@link Iterable} over all the pages
|
|
54
|
+
*/
|
|
55
|
+
pages(): AsyncIterableIterator<ReadonlyArray<I>>;
|
|
56
|
+
/**
|
|
57
|
+
* Get a page by page stream of all the pages.
|
|
58
|
+
*
|
|
59
|
+
* @return a {@link Stream} of all the pages
|
|
60
|
+
*/
|
|
61
|
+
pageStream(): Stream<ReadonlyArray<I>>;
|
|
62
|
+
/**
|
|
63
|
+
* Get an AsyncIterableIterator for all the rows from all the pages.
|
|
64
|
+
*
|
|
65
|
+
* This function is useful for handling rows in an enhanced for loop e.g.
|
|
66
|
+
* ```ts
|
|
67
|
+
* for await (const row: DocsResultRow of Pagination.newPagination(client, PagerType.POST_ALL_DOCS, allDocsParams).rows()) {
|
|
68
|
+
* ...
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @return an {@link AsyncIterableIterator} over all the result rows
|
|
73
|
+
*/
|
|
74
|
+
rows(): AsyncIterableIterator<I>;
|
|
75
|
+
/**
|
|
76
|
+
* Get a row by row stream of all the rows from all the pages.
|
|
77
|
+
*
|
|
78
|
+
* @return a {@link Stream} of all the result rows
|
|
79
|
+
*/
|
|
80
|
+
rowStream(): Stream<I>;
|
|
81
|
+
/**
|
|
82
|
+
* Get a {@link Pagination} for the `postAllDocs` operation.
|
|
83
|
+
* The page size is configured with the limit parameter of the params.
|
|
84
|
+
*
|
|
85
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
86
|
+
* @param type - {@link PagerType.POST_ALL_DOCS} the operation type to paginate
|
|
87
|
+
* @param params - {@link PostAllDocsParams} for the query
|
|
88
|
+
* @return a {@link DocsResultRow} pager for all the documents in the database
|
|
89
|
+
*/
|
|
90
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_ALL_DOCS, params: PostAllDocsParams): Pagination<DocsResultRow>;
|
|
91
|
+
/**
|
|
92
|
+
* Get a {@link Pagination} for the `postPartitionAllDocs` operation.
|
|
93
|
+
* The page size is configured with the limit parameter of the params.
|
|
94
|
+
*
|
|
95
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
96
|
+
* @param type - {@link PagerType.POST_PARTITION_ALL_DOCS} the operation type to paginate
|
|
97
|
+
* @param params - {@link PostPartitionAllDocsParams} for the query
|
|
98
|
+
* @return a {@link DocsResultRow} pager for all the documents in a database partition
|
|
99
|
+
*/
|
|
100
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_PARTITION_ALL_DOCS, params: PostPartitionAllDocsParams): Pagination<DocsResultRow>;
|
|
101
|
+
/**
|
|
102
|
+
* Get a {@link Pagination} for the `postDesignDocs` operation.
|
|
103
|
+
* The page size is configured with the limit parameter of the params.
|
|
104
|
+
*
|
|
105
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
106
|
+
* @param type - {@link PagerType.POST_DESIGN_DOCS} the operation type to paginate
|
|
107
|
+
* @param params - {@link PostDesignDocsParams} for the query
|
|
108
|
+
* @return a {@link DocsResultRow} pager for all the design documents in a database
|
|
109
|
+
*/
|
|
110
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_DESIGN_DOCS, params: PostDesignDocsParams): Pagination<DocsResultRow>;
|
|
111
|
+
/**
|
|
112
|
+
* Get a {@link Pagination} for the `postFind` operation.
|
|
113
|
+
* The page size is configured with the limit parameter of the params.
|
|
114
|
+
*
|
|
115
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
116
|
+
* @param type - {@link PagerType.POST_FIND} the operation type to paginate
|
|
117
|
+
* @param params - {@link PostFindParams} for the query
|
|
118
|
+
* @return a {@link Document} pager for the result of a find query
|
|
119
|
+
*/
|
|
120
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_FIND, params: PostFindParams): Pagination<Document>;
|
|
121
|
+
/**
|
|
122
|
+
* Get a {@link Pagination} for the `postPartitionFind` operation.
|
|
123
|
+
* The page size is configured with the limit parameter of the params.
|
|
124
|
+
*
|
|
125
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
126
|
+
* @param type - {@link PagerType.POST_PARTITION_FIND} the operation type to paginate
|
|
127
|
+
* @param params - {@link PostPartitionFindParams} for the query
|
|
128
|
+
* @return a {@link Document} pager for the result of a partition find query
|
|
129
|
+
*/
|
|
130
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_PARTITION_FIND, params: PostPartitionFindParams): Pagination<Document>;
|
|
131
|
+
/**
|
|
132
|
+
* Get a {@link Pagination} for the `postSearch` operation.
|
|
133
|
+
* The page size is configured with the limit parameter of the params.
|
|
134
|
+
*
|
|
135
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
136
|
+
* @param type - {@link PagerType.POST_SEARCH} the operation type to paginate
|
|
137
|
+
* @param params - {@link PostSearchParams} for the query
|
|
138
|
+
* @return a {@link SearchResultRow} pager for the result of a search query
|
|
139
|
+
*/
|
|
140
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_SEARCH, params: PostSearchParams): Pagination<SearchResultRow>;
|
|
141
|
+
/**
|
|
142
|
+
* Get a {@link Pagination} for the `postPartitionSearch` operation.
|
|
143
|
+
* The page size is configured with the limit parameter of the params.
|
|
144
|
+
*
|
|
145
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
146
|
+
* @param type - {@link PagerType.POST_PARTITION_SEARCH} the operation type to paginate
|
|
147
|
+
* @param params - {@link PostPartitionSearchParams} for the query
|
|
148
|
+
* @return a {@link SearchResultRow} pager for the result of a partition search query
|
|
149
|
+
*/
|
|
150
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_PARTITION_SEARCH, params: PostPartitionSearchParams): Pagination<SearchResultRow>;
|
|
151
|
+
/**
|
|
152
|
+
* Get a {@link Pagination} for the `postView` operation.
|
|
153
|
+
* The page size is configured with the limit parameter of the params.
|
|
154
|
+
*
|
|
155
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
156
|
+
* @param type - {@link PagerType.POST_VIEW} the operation type to paginate
|
|
157
|
+
* @param params - {@link PostViewParams} for the query
|
|
158
|
+
* @return a {@link ViewResultRow} pager for the result of a view query
|
|
159
|
+
*/
|
|
160
|
+
static newPagination(client: CloudantV1, pagerType: PagerType.POST_VIEW, params: PostViewParams): Pagination<ViewResultRow>;
|
|
161
|
+
/**
|
|
162
|
+
* Get a {@link Pagination} for the `postPartitionView` operation.
|
|
163
|
+
* The page size is configured with the limit parameter of the params.
|
|
164
|
+
*
|
|
165
|
+
* @param client- {@link CloudantV1} client instance to use to make requests
|
|
166
|
+
* @param type - {@link PagerType.POST_PARTITION_VIEW} the operation type to paginate
|
|
167
|
+
* @param params - {@link PostPartitionViewParams} for the query
|
|
168
|
+
* @return a {@link ViewResultRow} pager for the result of a partition view query
|
|
169
|
+
*/
|
|
170
|
+
static newPagination(client: CloudantV1, pagerType: PagerType, params: PostPartitionViewParams): Pagination<ViewResultRow>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Enumeration of the available Pager types
|
|
174
|
+
*/
|
|
175
|
+
export declare enum PagerType {
|
|
176
|
+
POST_ALL_DOCS = 0,
|
|
177
|
+
POST_DESIGN_DOCS = 1,
|
|
178
|
+
POST_FIND = 2,
|
|
179
|
+
POST_PARTITION_ALL_DOCS = 3,
|
|
180
|
+
POST_PARTITION_FIND = 4,
|
|
181
|
+
POST_PARTITION_SEARCH = 5,
|
|
182
|
+
POST_PARTITION_VIEW = 6,
|
|
183
|
+
POST_SEARCH = 7,
|
|
184
|
+
POST_VIEW = 8
|
|
185
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* © Copyright IBM Corporation 2025. 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.PagerType = exports.Pagination = void 0;
|
|
19
|
+
const iteratorPager_1 = require("./iteratorPager");
|
|
20
|
+
const allDocsPageIterator_1 = require("./allDocsPageIterator");
|
|
21
|
+
const stream_1 = require("../stream");
|
|
22
|
+
const node_stream_1 = require("node:stream");
|
|
23
|
+
const designDocsPageIterator_1 = require("./designDocsPageIterator");
|
|
24
|
+
const findPageIterator_1 = require("./findPageIterator");
|
|
25
|
+
const allDocsPartitionPageIterator_1 = require("./allDocsPartitionPageIterator");
|
|
26
|
+
const findPartitionPageIterator_1 = require("./findPartitionPageIterator");
|
|
27
|
+
const searchPartitionPageIterator_1 = require("./searchPartitionPageIterator");
|
|
28
|
+
const viewPageIterator_1 = require("./viewPageIterator");
|
|
29
|
+
const searchPageIterator_1 = require("./searchPageIterator");
|
|
30
|
+
const viewPartitionPageIterator_1 = require("./viewPartitionPageIterator");
|
|
31
|
+
/**
|
|
32
|
+
* {@link Pagination} is the entry point for pagination features.
|
|
33
|
+
*
|
|
34
|
+
* Use the static methods to create new {@link Pagination} instances. The instances in turn can be
|
|
35
|
+
* used to create:
|
|
36
|
+
* * {@link Stream} of result rows via {@link rowStream()}
|
|
37
|
+
* * {@link Stream} of pages via {@link pageStream()}
|
|
38
|
+
* * {@link AsyncIterableIterator} of result rows via {@link rows()}
|
|
39
|
+
* * {@link AsyncIterableIterator}s of pages via {@link pages()}
|
|
40
|
+
* * IBM Cloud SDK style {@link Pager}s via {@link pager()}
|
|
41
|
+
*
|
|
42
|
+
* @param <I> the result row type of the operation.
|
|
43
|
+
*/
|
|
44
|
+
class Pagination {
|
|
45
|
+
pageIterableIterator;
|
|
46
|
+
constructor(pageIterableIterator) {
|
|
47
|
+
this.pageIterableIterator = pageIterableIterator;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get a new IBM Cloud SDK style Pager for the operation.
|
|
51
|
+
*
|
|
52
|
+
* This type is useful for retrieving one page at a time through a function call.
|
|
53
|
+
*
|
|
54
|
+
* @return a new IBM Cloud SDK style Pager
|
|
55
|
+
*/
|
|
56
|
+
pager() {
|
|
57
|
+
return new iteratorPager_1.IteratorPager(this.pageIterableIterator);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get an AsyncIterableIterator for all the pages.
|
|
61
|
+
*
|
|
62
|
+
* This function is useful for handling pages in an enhanced for loop e.g.
|
|
63
|
+
* ```ts
|
|
64
|
+
* for await (const row: ReadonlyArray<DocsResultRow> of Pagination.newPagination(client, PagerType.POST_ALL_DOCS, allDocsParams).pages()){
|
|
65
|
+
* ...
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @return an {@link Iterable} over all the pages
|
|
70
|
+
*/
|
|
71
|
+
pages() {
|
|
72
|
+
return this.pageIterableIterator;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get a page by page stream of all the pages.
|
|
76
|
+
*
|
|
77
|
+
* @return a {@link Stream} of all the pages
|
|
78
|
+
*/
|
|
79
|
+
pageStream() {
|
|
80
|
+
return (0, node_stream_1.pipeline)(node_stream_1.Readable.from(this.pages()), new stream_1.Stream(), () => { });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get an AsyncIterableIterator for all the rows from all the pages.
|
|
84
|
+
*
|
|
85
|
+
* This function is useful for handling rows in an enhanced for loop e.g.
|
|
86
|
+
* ```ts
|
|
87
|
+
* for await (const row: DocsResultRow of Pagination.newPagination(client, PagerType.POST_ALL_DOCS, allDocsParams).rows()) {
|
|
88
|
+
* ...
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @return an {@link AsyncIterableIterator} over all the result rows
|
|
93
|
+
*/
|
|
94
|
+
async *rows() {
|
|
95
|
+
for await (let row of this.rowStream()) {
|
|
96
|
+
yield row;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get a row by row stream of all the rows from all the pages.
|
|
101
|
+
*
|
|
102
|
+
* @return a {@link Stream} of all the result rows
|
|
103
|
+
*/
|
|
104
|
+
rowStream() {
|
|
105
|
+
return (0, node_stream_1.pipeline)(node_stream_1.Readable.from(this.pages()).flatMap((item) => item), new stream_1.Stream(), () => { });
|
|
106
|
+
}
|
|
107
|
+
static newPagination(client, type, params) {
|
|
108
|
+
switch (type) {
|
|
109
|
+
case PagerType.POST_ALL_DOCS:
|
|
110
|
+
return new Pagination(new allDocsPageIterator_1.AllDocsPageIterator(client, params));
|
|
111
|
+
case PagerType.POST_DESIGN_DOCS:
|
|
112
|
+
return new Pagination(new designDocsPageIterator_1.DesignDocsPageIterator(client, params));
|
|
113
|
+
case PagerType.POST_FIND:
|
|
114
|
+
return new Pagination(new findPageIterator_1.FindPageIterator(client, params));
|
|
115
|
+
case PagerType.POST_PARTITION_ALL_DOCS:
|
|
116
|
+
return new Pagination(new allDocsPartitionPageIterator_1.AllDocsPartitionPageIterator(client, params));
|
|
117
|
+
case PagerType.POST_PARTITION_FIND:
|
|
118
|
+
return new Pagination(new findPartitionPageIterator_1.FindPartitionPageIterator(client, params));
|
|
119
|
+
case PagerType.POST_PARTITION_SEARCH:
|
|
120
|
+
return new Pagination(new searchPartitionPageIterator_1.SearchPartitionPageIterator(client, params));
|
|
121
|
+
case PagerType.POST_PARTITION_VIEW:
|
|
122
|
+
return new Pagination(new viewPartitionPageIterator_1.ViewPartitionPageIterator(client, params));
|
|
123
|
+
case PagerType.POST_SEARCH:
|
|
124
|
+
return new Pagination(new searchPageIterator_1.SearchPageIterator(client, params));
|
|
125
|
+
case PagerType.POST_VIEW:
|
|
126
|
+
return new Pagination(new viewPageIterator_1.ViewPageIterator(client, params));
|
|
127
|
+
default:
|
|
128
|
+
throw new Error(`No implementation available for PagerType ${type}.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.Pagination = Pagination;
|
|
133
|
+
/**
|
|
134
|
+
* Enumeration of the available Pager types
|
|
135
|
+
*/
|
|
136
|
+
var PagerType;
|
|
137
|
+
(function (PagerType) {
|
|
138
|
+
PagerType[PagerType["POST_ALL_DOCS"] = 0] = "POST_ALL_DOCS";
|
|
139
|
+
PagerType[PagerType["POST_DESIGN_DOCS"] = 1] = "POST_DESIGN_DOCS";
|
|
140
|
+
PagerType[PagerType["POST_FIND"] = 2] = "POST_FIND";
|
|
141
|
+
PagerType[PagerType["POST_PARTITION_ALL_DOCS"] = 3] = "POST_PARTITION_ALL_DOCS";
|
|
142
|
+
PagerType[PagerType["POST_PARTITION_FIND"] = 4] = "POST_PARTITION_FIND";
|
|
143
|
+
PagerType[PagerType["POST_PARTITION_SEARCH"] = 5] = "POST_PARTITION_SEARCH";
|
|
144
|
+
PagerType[PagerType["POST_PARTITION_VIEW"] = 6] = "POST_PARTITION_VIEW";
|
|
145
|
+
PagerType[PagerType["POST_SEARCH"] = 7] = "POST_SEARCH";
|
|
146
|
+
PagerType[PagerType["POST_VIEW"] = 8] = "POST_VIEW";
|
|
147
|
+
})(PagerType || (exports.PagerType = PagerType = {}));
|
|
148
|
+
//# sourceMappingURL=pagination.js.map
|