Commit iniziale

This commit is contained in:
Paolo A
2025-02-18 22:59:07 +00:00
commit 4bbf35cefb
6879 changed files with 623784 additions and 0 deletions

21
node_modules/@azure/core-paging/LICENSE generated vendored Normal file
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.

61
node_modules/@azure/core-paging/README.md generated vendored Normal file
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,10 @@
import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models.js";
/**
* 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 @@
{"version":3,"file":"getPagedAsyncIterator.d.ts","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpF;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CACnC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY,EAC5B,KAAK,GAAG,MAAM,EAEd,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,GACpD,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAmB5D"}

View File

@@ -0,0 +1,102 @@
// 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 _a, e_1, _b, _c, _d, e_2, _e, _f;
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 _g = true, pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = yield __await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
_c = pages_1_1.value;
_g = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_g && !_a && (_b = pages_1.return)) yield __await(_b.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 _h = true, pages_2 = __asyncValues(pages), pages_2_1; pages_2_1 = yield __await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
_f = pages_2_1.value;
_h = false;
const page = _f;
// 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 (!_h && !_d && (_e = pages_2.return)) yield __await(_e.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,3 @@
export * from "./models.js";
export * from "./getPagedAsyncIterator.js";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}

View File

@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export * from "./models.js";
export * from "./getPagedAsyncIterator.js";
//# 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,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./models.js\";\nexport * from \"./getPagedAsyncIterator.js\";\n"]}

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 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 @@
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrF;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,EAAE,KAAK,GAAG,MAAM;IAC9E;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,CACP,QAAQ,EAAE,KAAK,EACf,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEpE;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}

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,3 @@
{
"type": "module"
}

View File

@@ -0,0 +1,10 @@
import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models.js";
/**
* 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 @@
{"version":3,"file":"getPagedAsyncIterator.d.ts","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpF;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CACnC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY,EAC5B,KAAK,GAAG,MAAM,EAEd,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,GACpD,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAmB5D"}

View File

@@ -0,0 +1,106 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPagedAsyncIterator = void 0;
const tslib_1 = require("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.
*/
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,
});
}),
};
}
exports.getPagedAsyncIterator = getPagedAsyncIterator;
function getItemAsyncIterator(pagedResult) {
return tslib_1.__asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
var _a, e_1, _b, _c, _d, e_2, _e, _f;
const pages = getPageAsyncIterator(pagedResult);
const firstVal = yield tslib_1.__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_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(firstVal.value))));
try {
for (var _g = true, pages_1 = tslib_1.__asyncValues(pages), pages_1_1; pages_1_1 = yield tslib_1.__await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
_c = pages_1_1.value;
_g = false;
const page = _c;
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_g && !_a && (_b = pages_1.return)) yield tslib_1.__await(_b.call(pages_1));
}
finally { if (e_1) throw e_1.error; }
}
}
else {
yield yield tslib_1.__await(firstVal.value);
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(pages)));
}
}
else {
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(firstVal.value)));
try {
for (var _h = true, pages_2 = tslib_1.__asyncValues(pages), pages_2_1; pages_2_1 = yield tslib_1.__await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
_f = pages_2_1.value;
_h = false;
const page = _f;
// 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_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_h && !_d && (_e = pages_2.return)) yield tslib_1.__await(_e.call(pages_2));
}
finally { if (e_2) throw e_2.error; }
}
}
});
}
function getPageAsyncIterator(pagedResult, options = {}) {
return tslib_1.__asyncGenerator(this, arguments, function* getPageAsyncIterator_1() {
const { pageLink, maxPageSize } = options;
let response = yield tslib_1.__await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink, maxPageSize));
if (!response) {
return yield tslib_1.__await(void 0);
}
yield yield tslib_1.__await(response.page);
while (response.nextPageLink) {
response = yield tslib_1.__await(pagedResult.getPage(response.nextPageLink, maxPageSize));
if (!response) {
return yield tslib_1.__await(void 0);
}
yield yield tslib_1.__await(response.page);
}
});
}
//# sourceMappingURL=getPagedAsyncIterator.js.map

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}

View File

@@ -0,0 +1,8 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./models.js"), exports);
tslib_1.__exportStar(require("./getPagedAsyncIterator.js"), exports);
//# 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,sDAA4B;AAC5B,qEAA2C","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./models.js\";\nexport * from \"./getPagedAsyncIterator.js\";\n"]}

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 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 @@
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrF;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,EAAE,KAAK,GAAG,MAAM;IAC9E;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,CACP,QAAQ,EAAE,KAAK,EACf,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEpE;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}

View File

@@ -0,0 +1,5 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
//# 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,3 @@
{
"type": "commonjs"
}

View File

@@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.43.1"
}
]
}

82
node_modules/@azure/core-paging/dist/core-paging.d.ts generated vendored Normal file
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 { }

View File

@@ -0,0 +1,10 @@
import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models.js";
/**
* 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 @@
{"version":3,"file":"getPagedAsyncIterator.d.ts","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpF;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CACnC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY,EAC5B,KAAK,GAAG,MAAM,EAEd,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,GACpD,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAmB5D"}

View File

@@ -0,0 +1,102 @@
// 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 _a, e_1, _b, _c, _d, e_2, _e, _f;
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 _g = true, pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = yield __await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
_c = pages_1_1.value;
_g = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_g && !_a && (_b = pages_1.return)) yield __await(_b.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 _h = true, pages_2 = __asyncValues(pages), pages_2_1; pages_2_1 = yield __await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
_f = pages_2_1.value;
_h = false;
const page = _f;
// 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 (!_h && !_d && (_e = pages_2.return)) yield __await(_e.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

3
node_modules/@azure/core-paging/dist/esm/index.d.ts generated vendored Normal file
View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}

5
node_modules/@azure/core-paging/dist/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export * from "./models.js";
export * from "./getPagedAsyncIterator.js";
//# 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,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./models.js\";\nexport * from \"./getPagedAsyncIterator.js\";\n"]}

69
node_modules/@azure/core-paging/dist/esm/models.d.ts generated vendored Normal file
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 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 @@
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrF;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,EAAE,KAAK,GAAG,MAAM;IAC9E;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,CACP,QAAQ,EAAE,KAAK,EACf,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEpE;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}

4
node_modules/@azure/core-paging/dist/esm/models.js generated vendored Normal file
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,3 @@
{
"type": "module"
}

View File

@@ -0,0 +1,10 @@
import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models.js";
/**
* 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 @@
{"version":3,"file":"getPagedAsyncIterator.d.ts","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpF;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CACnC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY,EAC5B,KAAK,GAAG,MAAM,EAEd,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,GACpD,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAmB5D"}

View File

@@ -0,0 +1,102 @@
// 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 _a, e_1, _b, _c, _d, e_2, _e, _f;
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 _g = true, pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = yield __await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
_c = pages_1_1.value;
_g = false;
const page = _c;
yield __await(yield* __asyncDelegator(__asyncValues(toElements(page))));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_g && !_a && (_b = pages_1.return)) yield __await(_b.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 _h = true, pages_2 = __asyncValues(pages), pages_2_1; pages_2_1 = yield __await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
_f = pages_2_1.value;
_h = false;
const page = _f;
// 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 (!_h && !_d && (_e = pages_2.return)) yield __await(_e.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,3 @@
export * from "./models.js";
export * from "./getPagedAsyncIterator.js";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}

View File

@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export * from "./models.js";
export * from "./getPagedAsyncIterator.js";
//# 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,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./models.js\";\nexport * from \"./getPagedAsyncIterator.js\";\n"]}

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 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 @@
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,0BAA0B,CACzC,QAAQ,EACR,KAAK,GAAG,QAAQ,EAAE,EAClB,aAAa,GAAG,YAAY;IAE5B;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C;;OAEG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACrF;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,EAAE,KAAK,GAAG,MAAM;IAC9E;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,CACP,QAAQ,EAAE,KAAK,EACf,WAAW,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,YAAY,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAChE;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,aAAa,KAAK,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEpE;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}

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,3 @@
{
"type": "module"
}

124
node_modules/@azure/core-paging/package.json generated vendored Normal file
View File

@@ -0,0 +1,124 @@
{
"name": "@azure/core-paging",
"author": "Microsoft Corporation",
"sdk-type": "client",
"version": "1.6.2",
"description": "Core types for paging async iterable iterators",
"type": "module",
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"browser": "./dist/browser/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"tags": [
"microsoft",
"clientruntime"
],
"keywords": [
"microsoft",
"clientruntime",
"azure",
"cloud"
],
"files": [
"dist/",
"LICENSE",
"README.md"
],
"engines": {
"node": ">=18.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"
},
"sideEffects": true,
"private": false,
"scripts": {
"build:samples": "echo Obsolete",
"build:test": "npm run clean && tshy && dev-tool run build-test",
"build": "npm run clean && tshy && api-extractor run --local",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
"clean": "rimraf --glob dist dist-* temp *.tgz types *.log",
"execute:samples": "echo skipped",
"extract-api": "tshy && api-extractor run --local",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"samples-dev/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,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 --ext .cts --ext .mts",
"lint:fix": "eslint package.json src --ext .ts --ext .cts --ext .mts --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 && tshy && npm run unit-test:node && npm run integration-test:node",
"test": "npm run clean && tshy && npm run unit-test:node && dev-tool run build-test && npm run unit-test:browser && npm run integration-test",
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --no-test-proxy --browser",
"unit-test:node": "dev-tool run test:vitest --no-test-proxy",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
},
"dependencies": {
"tslib": "^2.6.2"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@microsoft/api-extractor": "^7.40.3",
"@types/node": "^18.0.0",
"@vitest/browser": "^1.3.1",
"@vitest/coverage-istanbul": "^1.3.1",
"eslint": "^8.56.0",
"playwright": "^1.41.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"tshy": "^1.13.0",
"typescript": "~5.3.3",
"vitest": "^1.3.1"
},
"//metadata": {
"sampleConfiguration": {
"skipFolder": true,
"disableDocsMs": true,
"productName": "Azure SDK Core",
"productSlugs": [
"azure"
]
},
"migrationDate": "2023-03-08T18:36:03.000Z"
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
}
}