initial commit of actions

This commit is contained in:
Dominik Polakovics Polakovics 2026-01-31 18:56:04 +01:00
commit 949ece5785
44660 changed files with 12034344 additions and 0 deletions

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2020 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,61 @@
# Azure Core Paging client library for JavaScript
This library provides core types for paging async iterable iterators.
## Getting started
### Installation
If using this as part of another project in the [azure-sdk-for-js](https://github.com/Azure/azure-sdk-for-js) repo,
then run `rush install` after cloning the repo.
Otherwise, use npm to install this package in your application as follows
```javascript
npm install @azure/core-paging
```
## Key concepts
You can find an explanation of how this repository's code works by going to our [architecture overview](https://github.com/Azure/ms-rest-js/blob/master/docs/architectureOverview.md).
## Examples
Example of building with the types:
```typescript
public listSecrets(
options: ListSecretsOptions = {}
): PagedAsyncIterableIterator<SecretAttributes> {
const iter = this.listSecretsAll(options);
return {
async next() { return iter.next(); },
[Symbol.asyncIterator]() { return this; },
byPage: (settings: PageSettings = {}) => this.listSecretsPage(settings, options),
};
}
```
And using the types:
```
for await (let page of client.listSecrets().byPage({ maxPageSize: 2 })) {
for (const secret of page) {
console.log("secret: ", secret);
}
}
```
## Next steps
Try out this package in your application when dealing with async iterable iterators and provide feedback!
## Troubleshooting
Log an issue at https://github.com/Azure/azure-sdk-for-js/issues
## Contributing
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-paging%2FREADME.png)

View file

@ -0,0 +1,98 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export function getPagedAsyncIterator(pagedResult) {
var _a;
const iter = getItemAsyncIterator(pagedResult);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
const { continuationToken, maxPageSize } = settings !== null && settings !== void 0 ? settings : {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
maxPageSize,
});
}),
};
}
function getItemAsyncIterator(pagedResult) {
return __asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
var e_1, _a, e_2, _b;
const pages = getPageAsyncIterator(pagedResult);
const firstVal = yield __await(pages.next());
// if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
if (!Array.isArray(firstVal.value)) {
// can extract elements from this page
const { toElements } = pagedResult;
if (toElements) {
yield __await(yield* __asyncDelegator(__asyncValues(toElements(firstVal.value))));
try {
for (var pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = yield __await(pages_1.next()), !pages_1_1.done;) {
const page = pages_1_1.value;
yield __await(yield* __asyncDelegator(__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (pages_1_1 && !pages_1_1.done && (_a = pages_1.return)) yield __await(_a.call(pages_1));
}
finally { if (e_1) throw e_1.error; }
}
}
else {
yield yield __await(firstVal.value);
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
yield __await(yield* __asyncDelegator(__asyncValues(pages)));
}
}
else {
yield __await(yield* __asyncDelegator(__asyncValues(firstVal.value)));
try {
for (var pages_2 = __asyncValues(pages), pages_2_1; pages_2_1 = yield __await(pages_2.next()), !pages_2_1.done;) {
const page = pages_2_1.value;
// pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
// it must be the case that `TPage = TElement[]`
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (pages_2_1 && !pages_2_1.done && (_b = pages_2.return)) yield __await(_b.call(pages_2));
}
finally { if (e_2) throw e_2.error; }
}
}
});
}
function getPageAsyncIterator(pagedResult, options = {}) {
return __asyncGenerator(this, arguments, function* getPageAsyncIterator_1() {
const { pageLink, maxPageSize } = options;
let response = yield __await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink, maxPageSize));
if (!response) {
return yield __await(void 0);
}
yield yield __await(response.page);
while (response.nextPageLink) {
response = yield __await(pagedResult.getPage(response.nextPageLink, maxPageSize));
if (!response) {
return yield __await(void 0);
}
yield yield __await(response.page);
}
});
}
//# sourceMappingURL=getPagedAsyncIterator.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export * from "./models";
export * from "./getPagedAsyncIterator";
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./models\";\nexport * from \"./getPagedAsyncIterator\";\n"]}

View file

@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export {};
//# sourceMappingURL=models.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n /**\n * The size of the page during paged iteration\n */\n maxPageSize?: number;\n}\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings\n> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<TElement>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\nexport interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (\n pageLink: TLink,\n maxPageSize?: number\n ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>;\n /**\n * a function to implement the `byPage` method on the paged async iterator. The default is\n * one that sets the `maxPageSizeParam` from `settings.maxPageSize`.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n\n /**\n * A function to extract elements from a page.\n */\n toElements?: (page: TPage) => unknown[];\n}\n\n/**\n * Paged collection of T items\n */\nexport type Paged<T> = {\n /**\n * The T items on this page\n */\n value: T[];\n /**\n * The link to the next page of items\n */\n nextLink?: string;\n};\n"]}

View file

@ -0,0 +1,104 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
// Copyright (c) Microsoft Corporation.
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
function getPagedAsyncIterator(pagedResult) {
var _a;
const iter = getItemAsyncIterator(pagedResult);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
const { continuationToken, maxPageSize } = settings !== null && settings !== void 0 ? settings : {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
maxPageSize,
});
}),
};
}
function getItemAsyncIterator(pagedResult) {
return tslib.__asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
var e_1, _a, e_2, _b;
const pages = getPageAsyncIterator(pagedResult);
const firstVal = yield tslib.__await(pages.next());
// if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
if (!Array.isArray(firstVal.value)) {
// can extract elements from this page
const { toElements } = pagedResult;
if (toElements) {
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(toElements(firstVal.value))));
try {
for (var pages_1 = tslib.__asyncValues(pages), pages_1_1; pages_1_1 = yield tslib.__await(pages_1.next()), !pages_1_1.done;) {
const page = pages_1_1.value;
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (pages_1_1 && !pages_1_1.done && (_a = pages_1.return)) yield tslib.__await(_a.call(pages_1));
}
finally { if (e_1) throw e_1.error; }
}
}
else {
yield yield tslib.__await(firstVal.value);
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(pages)));
}
}
else {
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(firstVal.value)));
try {
for (var pages_2 = tslib.__asyncValues(pages), pages_2_1; pages_2_1 = yield tslib.__await(pages_2.next()), !pages_2_1.done;) {
const page = pages_2_1.value;
// pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
// it must be the case that `TPage = TElement[]`
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (pages_2_1 && !pages_2_1.done && (_b = pages_2.return)) yield tslib.__await(_b.call(pages_2));
}
finally { if (e_2) throw e_2.error; }
}
}
});
}
function getPageAsyncIterator(pagedResult, options = {}) {
return tslib.__asyncGenerator(this, arguments, function* getPageAsyncIterator_1() {
const { pageLink, maxPageSize } = options;
let response = yield tslib.__await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink, maxPageSize));
if (!response) {
return yield tslib.__await(void 0);
}
yield yield tslib.__await(response.page);
while (response.nextPageLink) {
response = yield tslib.__await(pagedResult.getPage(response.nextPageLink, maxPageSize));
if (!response) {
return yield tslib.__await(void 0);
}
yield yield tslib.__await(response.page);
}
});
}
exports.getPagedAsyncIterator = getPagedAsyncIterator;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,108 @@
{
"name": "@azure/core-paging",
"author": "Microsoft Corporation",
"sdk-type": "client",
"version": "1.5.0",
"description": "Core types for paging async iterable iterators",
"tags": [
"microsoft",
"clientruntime"
],
"keywords": [
"microsoft",
"clientruntime",
"azure",
"cloud"
],
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"types": "./types/latest/core-paging.d.ts",
"typesVersions": {
"<3.6": {
"types/latest/*": [
"types/3.1/*"
]
}
},
"files": [
"types/latest/core-paging.d.ts",
"types/3.1",
"dist/",
"dist-esm/src/",
"LICENSE",
"README.md"
],
"engines": {
"node": ">=14.0.0"
},
"license": "MIT",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:samples": "echo Obsolete",
"build:test": "echo skipped",
"build:types": "downlevel-dts types/latest/ types/3.1/",
"build": "npm run clean && tsc -p . && dev-tool run bundle && api-extractor run --local && npm run build:types",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* temp *.tgz types *.log",
"execute:samples": "echo skipped",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint": "eslint package.json src --ext .ts",
"lint:fix": "eslint package.json src --ext .ts --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node",
"test": "npm run clean && tsc -p . && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 50000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
},
"sideEffects": true,
"private": false,
"dependencies": {
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
"@microsoft/api-extractor": "^7.31.1",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.0",
"chai": "^4.2.0",
"downlevel-dts": "^0.10.0",
"eslint": "^8.0.0",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-edge-launcher": "^0.4.2",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^2.0.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"typescript": "~4.8.0"
},
"//sampleConfiguration": {
"skipFolder": true,
"disableDocsMs": true,
"productName": "Azure SDK Core",
"productSlugs": [
"azure"
]
}
}

View file

@ -0,0 +1,77 @@
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export declare function getPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings = PageSettings, TLink = string>(pagedResult: PagedResult<TPage, TPageSettings, TLink>): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Paged collection of T items
*/
export declare type Paged<T> = {
/**
* The T items on this page
*/
value: T[];
/**
* The link to the next page of items
*/
nextLink?: string;
};
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export declare interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<TElement>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
}
/**
* An interface that describes how to communicate with the service.
*/
export declare interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {
/**
* Link to the first page of results.
*/
firstPageLink: TLink;
/**
* A method that returns a page of results.
*/
getPage: (pageLink: TLink, maxPageSize?: number) => Promise<{
page: TPage;
nextPageLink?: TLink;
} | undefined>;
/**
* a function to implement the `byPage` method on the paged async iterator. The default is
* one that sets the `maxPageSizeParam` from `settings.maxPageSize`.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
/**
* A function to extract elements from a page.
*/
toElements?: (page: TPage) => unknown[];
}
/**
* An interface that tracks the settings for paged iteration
*/
export declare interface PageSettings {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* The size of the page during paged iteration
*/
maxPageSize?: number;
}
export {};

View file

@ -0,0 +1,2 @@
export declare function main(): Promise<void>;
//# sourceMappingURL=getPagedAsyncIteratorSample.d.ts.map

View file

@ -0,0 +1,10 @@
import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models";
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export declare function getPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings = PageSettings, TLink = string>(pagedResult: PagedResult<TPage, TPageSettings, TLink>): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
//# sourceMappingURL=getPagedAsyncIterator.d.ts.map

View file

@ -0,0 +1,3 @@
export * from "./models";
export * from "./getPagedAsyncIterator";
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,69 @@
/**
* An interface that tracks the settings for paged iteration
*/
export interface PageSettings {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* The size of the page during paged iteration
*/
maxPageSize?: number;
}
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<TElement>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
}
/**
* An interface that describes how to communicate with the service.
*/
export interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {
/**
* Link to the first page of results.
*/
firstPageLink: TLink;
/**
* A method that returns a page of results.
*/
getPage: (pageLink: TLink, maxPageSize?: number) => Promise<{
page: TPage;
nextPageLink?: TLink;
} | undefined>;
/**
* a function to implement the `byPage` method on the paged async iterator. The default is
* one that sets the `maxPageSizeParam` from `settings.maxPageSize`.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
/**
* A function to extract elements from a page.
*/
toElements?: (page: TPage) => unknown[];
}
/**
* Paged collection of T items
*/
export declare type Paged<T> = {
/**
* The T items on this page
*/
value: T[];
/**
* The link to the next page of items
*/
nextLink?: string;
};
//# sourceMappingURL=models.d.ts.map

View file

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=getPagedAsyncIterator.spec.d.ts.map

View file

@ -0,0 +1,82 @@
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export declare function getPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings = PageSettings, TLink = string>(pagedResult: PagedResult<TPage, TPageSettings, TLink>): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Paged collection of T items
*/
export declare type Paged<T> = {
/**
* The T items on this page
*/
value: T[];
/**
* The link to the next page of items
*/
nextLink?: string;
};
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export declare interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<TElement>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
}
/**
* An interface that describes how to communicate with the service.
*/
export declare interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {
/**
* Link to the first page of results.
*/
firstPageLink: TLink;
/**
* A method that returns a page of results.
*/
getPage: (pageLink: TLink, maxPageSize?: number) => Promise<{
page: TPage;
nextPageLink?: TLink;
} | undefined>;
/**
* a function to implement the `byPage` method on the paged async iterator. The default is
* one that sets the `maxPageSizeParam` from `settings.maxPageSize`.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
/**
* A function to extract elements from a page.
*/
toElements?: (page: TPage) => unknown[];
}
/**
* An interface that tracks the settings for paged iteration
*/
export declare interface PageSettings {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* The size of the page during paged iteration
*/
maxPageSize?: number;
}
export { }