@azure-rest/ai-document-intelligence 1.0.0-beta.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +263 -0
- package/LICENSE +21 -0
- package/README.md +133 -7
- package/dist/browser/clientDefinitions.d.ts +175 -0
- package/dist/browser/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/clientDefinitions.js +4 -0
- package/dist/browser/clientDefinitions.js.map +1 -0
- package/dist/browser/documentIntelligence.d.ts +16 -0
- package/dist/browser/documentIntelligence.d.ts.map +1 -0
- package/dist/browser/documentIntelligence.js +44 -0
- package/dist/browser/documentIntelligence.js.map +1 -0
- package/dist/browser/index.d.ts +13 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +15 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/isUnexpected.d.ts +36 -0
- package/dist/browser/isUnexpected.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/isUnexpected.js +18 -7
- package/dist/browser/isUnexpected.js.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/logger.js +1 -1
- package/{dist-esm/src → dist/browser}/logger.js.map +1 -1
- package/dist/browser/models.d.ts +254 -0
- package/dist/browser/models.d.ts.map +1 -0
- package/dist/browser/models.js +4 -0
- package/dist/browser/models.js.map +1 -0
- package/dist/browser/outputModels.d.ts +914 -0
- package/dist/browser/outputModels.d.ts.map +1 -0
- package/dist/browser/outputModels.js +4 -0
- package/dist/browser/outputModels.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/paginateHelper.d.ts +68 -0
- package/dist/browser/paginateHelper.d.ts.map +1 -0
- package/dist/browser/paginateHelper.js +167 -0
- package/dist/browser/paginateHelper.js.map +1 -0
- package/dist/browser/parameters.d.ts +414 -0
- package/dist/browser/parameters.d.ts.map +1 -0
- package/dist/browser/parameters.js +4 -0
- package/dist/browser/parameters.js.map +1 -0
- package/dist/browser/pollingHelper.d.ts +40 -0
- package/dist/browser/pollingHelper.d.ts.map +1 -0
- package/dist/browser/pollingHelper.js +80 -0
- package/dist/browser/pollingHelper.js.map +1 -0
- package/dist/browser/responses.d.ts +473 -0
- package/dist/browser/responses.d.ts.map +1 -0
- package/dist/browser/responses.js +4 -0
- package/dist/browser/responses.js.map +1 -0
- package/dist/browser/utils.d.ts +5 -0
- package/dist/browser/utils.d.ts.map +1 -0
- package/dist/browser/utils.js +33 -0
- package/dist/browser/utils.js.map +1 -0
- package/dist/commonjs/clientDefinitions.d.ts +175 -0
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.js +5 -0
- package/dist/commonjs/clientDefinitions.js.map +1 -0
- package/dist/commonjs/documentIntelligence.d.ts +16 -0
- package/dist/commonjs/documentIntelligence.d.ts.map +1 -0
- package/dist/commonjs/documentIntelligence.js +47 -0
- package/dist/commonjs/documentIntelligence.js.map +1 -0
- package/dist/commonjs/index.d.ts +13 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +18 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/isUnexpected.d.ts +36 -0
- package/dist/commonjs/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/isUnexpected.js +107 -0
- package/dist/commonjs/isUnexpected.js.map +1 -0
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models.d.ts +254 -0
- package/dist/commonjs/models.d.ts.map +1 -0
- package/dist/commonjs/models.js +5 -0
- package/dist/commonjs/models.js.map +1 -0
- package/dist/commonjs/outputModels.d.ts +914 -0
- package/dist/commonjs/outputModels.d.ts.map +1 -0
- package/dist/commonjs/outputModels.js +5 -0
- package/dist/commonjs/outputModels.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/paginateHelper.d.ts +68 -0
- package/dist/commonjs/paginateHelper.d.ts.map +1 -0
- package/dist/commonjs/paginateHelper.js +170 -0
- package/dist/commonjs/paginateHelper.js.map +1 -0
- package/dist/commonjs/parameters.d.ts +414 -0
- package/dist/commonjs/parameters.d.ts.map +1 -0
- package/dist/commonjs/parameters.js +5 -0
- package/dist/commonjs/parameters.js.map +1 -0
- package/dist/commonjs/pollingHelper.d.ts +40 -0
- package/dist/commonjs/pollingHelper.d.ts.map +1 -0
- package/dist/commonjs/pollingHelper.js +84 -0
- package/dist/commonjs/pollingHelper.js.map +1 -0
- package/dist/commonjs/responses.d.ts +473 -0
- package/dist/commonjs/responses.d.ts.map +1 -0
- package/dist/commonjs/responses.js +5 -0
- package/dist/commonjs/responses.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/utils.d.ts +5 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +36 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/esm/clientDefinitions.d.ts +175 -0
- package/dist/esm/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/clientDefinitions.js +4 -0
- package/dist/esm/clientDefinitions.js.map +1 -0
- package/dist/esm/documentIntelligence.d.ts +16 -0
- package/dist/esm/documentIntelligence.d.ts.map +1 -0
- package/dist/esm/documentIntelligence.js +44 -0
- package/dist/esm/documentIntelligence.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/isUnexpected.d.ts +36 -0
- package/dist/esm/isUnexpected.d.ts.map +1 -0
- package/dist/esm/isUnexpected.js +104 -0
- package/dist/esm/isUnexpected.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models.d.ts +254 -0
- package/dist/esm/models.d.ts.map +1 -0
- package/dist/esm/models.js +4 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/outputModels.d.ts +914 -0
- package/dist/esm/outputModels.d.ts.map +1 -0
- package/dist/esm/outputModels.js +4 -0
- package/dist/esm/outputModels.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/paginateHelper.d.ts +68 -0
- package/dist/esm/paginateHelper.d.ts.map +1 -0
- package/dist/esm/paginateHelper.js +167 -0
- package/dist/esm/paginateHelper.js.map +1 -0
- package/dist/esm/parameters.d.ts +414 -0
- package/dist/esm/parameters.d.ts.map +1 -0
- package/dist/esm/parameters.js +4 -0
- package/dist/esm/parameters.js.map +1 -0
- package/dist/esm/pollingHelper.d.ts +40 -0
- package/dist/esm/pollingHelper.d.ts.map +1 -0
- package/dist/esm/pollingHelper.js +80 -0
- package/dist/esm/pollingHelper.js.map +1 -0
- package/dist/esm/responses.d.ts +473 -0
- package/dist/esm/responses.d.ts.map +1 -0
- package/dist/esm/responses.js +4 -0
- package/dist/esm/responses.js.map +1 -0
- package/dist/esm/utils.d.ts +5 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +33 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/react-native/clientDefinitions.d.ts +175 -0
- package/dist/react-native/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/clientDefinitions.js +4 -0
- package/dist/react-native/clientDefinitions.js.map +1 -0
- package/dist/react-native/documentIntelligence.d.ts +16 -0
- package/dist/react-native/documentIntelligence.d.ts.map +1 -0
- package/dist/react-native/documentIntelligence.js +44 -0
- package/dist/react-native/documentIntelligence.js.map +1 -0
- package/dist/react-native/index.d.ts +13 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +15 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/isUnexpected.d.ts +36 -0
- package/dist/react-native/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/isUnexpected.js +104 -0
- package/dist/react-native/isUnexpected.js.map +1 -0
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models.d.ts +254 -0
- package/dist/react-native/models.d.ts.map +1 -0
- package/dist/react-native/models.js +4 -0
- package/dist/react-native/models.js.map +1 -0
- package/dist/react-native/outputModels.d.ts +914 -0
- package/dist/react-native/outputModels.d.ts.map +1 -0
- package/dist/react-native/outputModels.js +4 -0
- package/dist/react-native/outputModels.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/paginateHelper.d.ts +68 -0
- package/dist/react-native/paginateHelper.d.ts.map +1 -0
- package/dist/react-native/paginateHelper.js +167 -0
- package/dist/react-native/paginateHelper.js.map +1 -0
- package/dist/react-native/parameters.d.ts +414 -0
- package/dist/react-native/parameters.d.ts.map +1 -0
- package/dist/react-native/parameters.js +4 -0
- package/dist/react-native/parameters.js.map +1 -0
- package/dist/react-native/pollingHelper.d.ts +40 -0
- package/dist/react-native/pollingHelper.d.ts.map +1 -0
- package/dist/react-native/pollingHelper.js +80 -0
- package/dist/react-native/pollingHelper.js.map +1 -0
- package/dist/react-native/responses.d.ts +473 -0
- package/dist/react-native/responses.d.ts.map +1 -0
- package/dist/react-native/responses.js +4 -0
- package/dist/react-native/responses.js.map +1 -0
- package/dist/react-native/utils.d.ts +5 -0
- package/dist/react-native/utils.d.ts.map +1 -0
- package/dist/react-native/utils.js +33 -0
- package/dist/react-native/utils.js.map +1 -0
- package/package.json +108 -92
- package/review/ai-document-intelligence.api.md +866 -225
- package/dist/index.js +0 -252
- package/dist/index.js.map +0 -1
- package/dist-esm/src/clientDefinitions.js +0 -4
- package/dist-esm/src/clientDefinitions.js.map +0 -1
- package/dist-esm/src/documentIntelligence.js +0 -30
- package/dist-esm/src/documentIntelligence.js.map +0 -1
- package/dist-esm/src/index.js +0 -14
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/isUnexpected.js.map +0 -1
- package/dist-esm/src/models.js +0 -4
- package/dist-esm/src/models.js.map +0 -1
- package/dist-esm/src/outputModels.js +0 -4
- package/dist-esm/src/outputModels.js.map +0 -1
- package/dist-esm/src/paginateHelper.js +0 -70
- package/dist-esm/src/paginateHelper.js.map +0 -1
- package/dist-esm/src/parameters.js +0 -4
- package/dist-esm/src/parameters.js.map +0 -1
- package/dist-esm/src/pollingHelper.js +0 -43
- package/dist-esm/src/pollingHelper.js.map +0 -1
- package/dist-esm/src/responses.js +0 -4
- package/dist-esm/src/responses.js.map +0 -1
- package/types/ai-document-intelligence.d.ts +0 -2003
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { getPagedAsyncIterator } from "@azure/core-paging";
|
|
4
|
-
import { createRestError } from "@azure-rest/core-client";
|
|
5
|
-
/**
|
|
6
|
-
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
7
|
-
* @param client - Client to use for sending the next page requests
|
|
8
|
-
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
9
|
-
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
10
|
-
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
11
|
-
*/
|
|
12
|
-
export function paginate(client, initialResponse, options = {}) {
|
|
13
|
-
let firstRun = true;
|
|
14
|
-
const itemName = "value";
|
|
15
|
-
const nextLinkName = "nextLink";
|
|
16
|
-
const { customGetPage } = options;
|
|
17
|
-
const pagedResult = {
|
|
18
|
-
firstPageLink: "",
|
|
19
|
-
getPage: typeof customGetPage === "function"
|
|
20
|
-
? customGetPage
|
|
21
|
-
: async (pageLink) => {
|
|
22
|
-
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
23
|
-
firstRun = false;
|
|
24
|
-
checkPagingRequest(result);
|
|
25
|
-
const nextLink = getNextLink(result.body, nextLinkName);
|
|
26
|
-
const values = getElements(result.body, itemName);
|
|
27
|
-
return {
|
|
28
|
-
page: values,
|
|
29
|
-
nextPageLink: nextLink,
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
return getPagedAsyncIterator(pagedResult);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Gets for the value of nextLink in the body
|
|
37
|
-
*/
|
|
38
|
-
function getNextLink(body, nextLinkName) {
|
|
39
|
-
if (!nextLinkName) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
const nextLink = body[nextLinkName];
|
|
43
|
-
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
44
|
-
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
45
|
-
}
|
|
46
|
-
return nextLink;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Gets the elements of the current request in the body.
|
|
50
|
-
*/
|
|
51
|
-
function getElements(body, itemName) {
|
|
52
|
-
const value = body[itemName];
|
|
53
|
-
// value has to be an array according to the x-ms-pageable extension.
|
|
54
|
-
// The fact that this must be an array is used above to calculate the
|
|
55
|
-
// type of elements in the page in PaginateReturn
|
|
56
|
-
if (!Array.isArray(value)) {
|
|
57
|
-
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
58
|
-
}
|
|
59
|
-
return value !== null && value !== void 0 ? value : [];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Checks if a request failed
|
|
63
|
-
*/
|
|
64
|
-
function checkPagingRequest(response) {
|
|
65
|
-
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
66
|
-
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
67
|
-
throw createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=paginateHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,qBAAqB,EAA2C,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAU,eAAe,EAAyB,MAAM,yBAAyB,CAAC;AAyCzF;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,eAA0B,EAC1B,UAAoC,EAAE;IAItC,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,MAAM,YAAY,GAAG,UAAU,CAAC;IAChC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,WAAW,GAA4B;QAC3C,aAAa,EAAE,EAAE;QACjB,OAAO,EACL,OAAO,aAAa,KAAK,UAAU;YACjC,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,KAAK,EAAE,QAAgB,EAAE,EAAE;gBACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;gBACvF,QAAQ,GAAG,KAAK,CAAC;gBACjB,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;gBACxD,MAAM,MAAM,GAAG,WAAW,CAAW,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC5D,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,YAAY,EAAE,QAAQ;iBACvB,CAAC;YACJ,CAAC;KACR,CAAC;IAEF,OAAO,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,YAAqB;IACvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAI,IAAgC,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,iBAAiB,YAAY,kCAAkC,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAc,IAAa,EAAE,QAAgB;IAC/D,MAAM,KAAK,GAAI,IAAgC,CAAC,QAAQ,CAAQ,CAAC;IAEjE,qEAAqE;IACrE,qEAAqE;IACrE,iDAAiD;IACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,kFAAkF,QAAQ,EAAE,CAC7F,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,QAA+B;IACzD,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAClG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,eAAe,CACnB,gDAAgD,QAAQ,CAAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number,\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport { RequestParameters } from \"@azure-rest/core-client\";\nimport {\n AnalyzeDocumentRequest,\n BuildDocumentModelRequest,\n ComposeDocumentModelRequest,\n AuthorizeCopyRequest,\n CopyAuthorization,\n BuildDocumentClassifierRequest,\n ClassifyDocumentRequest,\n} from \"./models\";\n\nexport interface ListOperationsHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface ListOperationsHeaderParam {\n headers?: RawHttpHeadersInput & ListOperationsHeaders;\n}\n\nexport type ListOperationsParameters = ListOperationsHeaderParam & RequestParameters;\n\nexport interface GetDocumentModelBuildOperationHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetDocumentModelBuildOperationHeaderParam {\n headers?: RawHttpHeadersInput & GetDocumentModelBuildOperationHeaders;\n}\n\nexport type GetDocumentModelBuildOperationParameters = GetDocumentModelBuildOperationHeaderParam &\n RequestParameters;\n\nexport interface GetDocumentModelComposeOperationHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetDocumentModelComposeOperationHeaderParam {\n headers?: RawHttpHeadersInput & GetDocumentModelComposeOperationHeaders;\n}\n\nexport type GetDocumentModelComposeOperationParameters =\n GetDocumentModelComposeOperationHeaderParam & RequestParameters;\n\nexport interface GetDocumentModelCopyToOperationHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetDocumentModelCopyToOperationHeaderParam {\n headers?: RawHttpHeadersInput & GetDocumentModelCopyToOperationHeaders;\n}\n\nexport type GetDocumentModelCopyToOperationParameters = GetDocumentModelCopyToOperationHeaderParam &\n RequestParameters;\n\nexport interface GetDocumentClassifierBuildOperationHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetDocumentClassifierBuildOperationHeaderParam {\n headers?: RawHttpHeadersInput & GetDocumentClassifierBuildOperationHeaders;\n}\n\nexport type GetDocumentClassifierBuildOperationParameters =\n GetDocumentClassifierBuildOperationHeaderParam & RequestParameters;\n\nexport interface GetOperationHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetOperationHeaderParam {\n headers?: RawHttpHeadersInput & GetOperationHeaders;\n}\n\nexport type GetOperationParameters = GetOperationHeaderParam & RequestParameters;\nexport type GetResourceInfoParameters = RequestParameters;\nexport type GetAnalyzeResultParameters = RequestParameters;\n\nexport interface AnalyzeDocumentFromStreamBodyParam {\n /**\n * Input content.\n *\n * Value may contain any sequence of octets\n */\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n}\n\nexport interface AnalyzeDocumentFromStreamQueryParamProperties {\n /** List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\" */\n pages?: string;\n /**\n * Locale hint for text recognition and document analysis. Value may contain only\n * the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n */\n locale?: string;\n /**\n * Method used to compute string offset and length.\n *\n * Possible values: \"textElements\", \"unicodeCodePoint\", \"utf16CodeUnit\"\n */\n stringIndexType?: string;\n /** List of optional analysis features. */\n features?: string[];\n /** List of additional fields to extract. Ex. \"NumberOfGuests,StoreNumber\" */\n queryFields?: string[];\n /**\n * Format of the analyze result top-level content.\n *\n * Possible values: \"text\", \"markdown\"\n */\n outputContentFormat?: string;\n}\n\nexport interface AnalyzeDocumentFromStreamQueryParam {\n queryParameters?: AnalyzeDocumentFromStreamQueryParamProperties;\n}\n\nexport interface AnalyzeDocumentFromStreamMediaTypesParam {\n /** Input content type. */\n contentType:\n | \"application/octet-stream\"\n | \"application/pdf\"\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/tiff\"\n | \"image/bmp\"\n | \"image/heif\"\n | \"text/html\"\n | \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n | \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n | \"application/vnd.openxmlformats-officedocument.presentationml.presentation\";\n}\n\nexport type AnalyzeDocumentFromStreamParameters = AnalyzeDocumentFromStreamQueryParam &\n AnalyzeDocumentFromStreamMediaTypesParam &\n AnalyzeDocumentFromStreamBodyParam &\n RequestParameters;\n\nexport interface AnalyzeDocumentBodyParam {\n /** Analyze request parameters. */\n body?: AnalyzeDocumentRequest;\n}\n\nexport interface AnalyzeDocumentQueryParamProperties {\n /** List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\" */\n pages?: string;\n /**\n * Locale hint for text recognition and document analysis. Value may contain only\n * the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n */\n locale?: string;\n /**\n * Method used to compute string offset and length.\n *\n * Possible values: \"textElements\", \"unicodeCodePoint\", \"utf16CodeUnit\"\n */\n stringIndexType?: string;\n /** List of optional analysis features. */\n features?: string[];\n /** List of additional fields to extract. Ex. \"NumberOfGuests,StoreNumber\" */\n queryFields?: string[];\n /**\n * Format of the analyze result top-level content.\n *\n * Possible values: \"text\", \"markdown\"\n */\n outputContentFormat?: string;\n}\n\nexport interface AnalyzeDocumentQueryParam {\n queryParameters?: AnalyzeDocumentQueryParamProperties;\n}\n\nexport interface AnalyzeDocumentMediaTypesParam {\n /** Input content type */\n contentType: \"application/json\";\n}\n\nexport type AnalyzeDocumentParameters = AnalyzeDocumentQueryParam &\n AnalyzeDocumentMediaTypesParam &\n AnalyzeDocumentBodyParam &\n RequestParameters;\n\nexport interface GetModelHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetModelHeaderParam {\n headers?: RawHttpHeadersInput & GetModelHeaders;\n}\n\nexport type GetModelParameters = GetModelHeaderParam & RequestParameters;\n\nexport interface BuildModelBodyParam {\n /** Build request parameters. */\n body: BuildDocumentModelRequest;\n}\n\nexport type BuildModelParameters = BuildModelBodyParam & RequestParameters;\n\nexport interface ComposeModelBodyParam {\n /** Compose request parameters. */\n body: ComposeDocumentModelRequest;\n}\n\nexport type ComposeModelParameters = ComposeModelBodyParam & RequestParameters;\n\nexport interface AuthorizeModelCopyBodyParam {\n /** Authorize copy request parameters. */\n body: AuthorizeCopyRequest;\n}\n\nexport type AuthorizeModelCopyParameters = AuthorizeModelCopyBodyParam & RequestParameters;\n\nexport interface CopyModelToBodyParam {\n /** Copy to request parameters. */\n body: CopyAuthorization;\n}\n\nexport type CopyModelToParameters = CopyModelToBodyParam & RequestParameters;\n\nexport interface ListModelsHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface ListModelsHeaderParam {\n headers?: RawHttpHeadersInput & ListModelsHeaders;\n}\n\nexport type ListModelsParameters = ListModelsHeaderParam & RequestParameters;\n\nexport interface DeleteModelHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface DeleteModelHeaderParam {\n headers?: RawHttpHeadersInput & DeleteModelHeaders;\n}\n\nexport type DeleteModelParameters = DeleteModelHeaderParam & RequestParameters;\n\nexport interface BuildClassifierBodyParam {\n /** Build request parameters. */\n body: BuildDocumentClassifierRequest;\n}\n\nexport type BuildClassifierParameters = BuildClassifierBodyParam & RequestParameters;\n\nexport interface ListClassifiersHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface ListClassifiersHeaderParam {\n headers?: RawHttpHeadersInput & ListClassifiersHeaders;\n}\n\nexport type ListClassifiersParameters = ListClassifiersHeaderParam & RequestParameters;\n\nexport interface GetClassifierHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface GetClassifierHeaderParam {\n headers?: RawHttpHeadersInput & GetClassifierHeaders;\n}\n\nexport type GetClassifierParameters = GetClassifierHeaderParam & RequestParameters;\n\nexport interface DeleteClassifierHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface DeleteClassifierHeaderParam {\n headers?: RawHttpHeadersInput & DeleteClassifierHeaders;\n}\n\nexport type DeleteClassifierParameters = DeleteClassifierHeaderParam & RequestParameters;\n\nexport interface ClassifyDocumentFromStreamBodyParam {\n /**\n * Input content.\n *\n * Value may contain any sequence of octets\n */\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n}\n\nexport interface ClassifyDocumentFromStreamQueryParamProperties {\n /**\n * Method used to compute string offset and length.\n *\n * Possible values: \"textElements\", \"unicodeCodePoint\", \"utf16CodeUnit\"\n */\n stringIndexType?: string;\n /**\n * Document splitting mode.\n *\n * Possible values: \"auto\", \"none\", \"perPage\"\n */\n split?: string;\n}\n\nexport interface ClassifyDocumentFromStreamQueryParam {\n queryParameters?: ClassifyDocumentFromStreamQueryParamProperties;\n}\n\nexport interface ClassifyDocumentFromStreamMediaTypesParam {\n /** Input content type. */\n contentType:\n | \"application/octet-stream\"\n | \"application/pdf\"\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/tiff\"\n | \"image/bmp\"\n | \"image/heif\"\n | \"text/html\"\n | \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n | \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n | \"application/vnd.openxmlformats-officedocument.presentationml.presentation\";\n}\n\nexport type ClassifyDocumentFromStreamParameters = ClassifyDocumentFromStreamQueryParam &\n ClassifyDocumentFromStreamMediaTypesParam &\n ClassifyDocumentFromStreamBodyParam &\n RequestParameters;\n\nexport interface ClassifyDocumentBodyParam {\n /** Classify request parameters. */\n body: ClassifyDocumentRequest;\n}\n\nexport interface ClassifyDocumentQueryParamProperties {\n /**\n * Method used to compute string offset and length.\n *\n * Possible values: \"textElements\", \"unicodeCodePoint\", \"utf16CodeUnit\"\n */\n stringIndexType?: string;\n /**\n * Document splitting mode.\n *\n * Possible values: \"auto\", \"none\", \"perPage\"\n */\n split?: string;\n}\n\nexport interface ClassifyDocumentQueryParam {\n queryParameters?: ClassifyDocumentQueryParamProperties;\n}\n\nexport interface ClassifyDocumentMediaTypesParam {\n /** Input content type */\n contentType: \"application/json\";\n}\n\nexport type ClassifyDocumentParameters = ClassifyDocumentQueryParam &\n ClassifyDocumentMediaTypesParam &\n ClassifyDocumentBodyParam &\n RequestParameters;\nexport type GetClassifyResultParameters = RequestParameters;\n"]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { createHttpPoller, } from "@azure/core-lro";
|
|
4
|
-
export async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
5
|
-
var _a;
|
|
6
|
-
const poller = {
|
|
7
|
-
requestMethod: initialResponse.request.method,
|
|
8
|
-
requestPath: initialResponse.request.url,
|
|
9
|
-
sendInitialRequest: async () => {
|
|
10
|
-
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
11
|
-
// we are not triggering the initial request here, just extracting the information from the
|
|
12
|
-
// response we were provided.
|
|
13
|
-
return getLroResponse(initialResponse);
|
|
14
|
-
},
|
|
15
|
-
sendPollRequest: async (path) => {
|
|
16
|
-
// This is the callback that is going to be called to poll the service
|
|
17
|
-
// to get the latest status. We use the client provided and the polling path
|
|
18
|
-
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
19
|
-
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
20
|
-
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
21
|
-
const lroResponse = getLroResponse(response);
|
|
22
|
-
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
23
|
-
return lroResponse;
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
27
|
-
return createHttpPoller(poller, options);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
31
|
-
* @param response - a rest client http response
|
|
32
|
-
* @returns - An LRO response that the LRO implementation understands
|
|
33
|
-
*/
|
|
34
|
-
function getLroResponse(response) {
|
|
35
|
-
if (Number.isNaN(response.status)) {
|
|
36
|
-
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
flatResponse: response,
|
|
40
|
-
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=pollingHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAML,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AA4EzB,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,eAAwB,EACxB,UAAqE,EAAE;;IAEvE,MAAM,MAAM,GAAkC;QAC5C,aAAa,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM;QAC7C,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG;QACxC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,sGAAsG;YACtG,2FAA2F;YAC3F,6BAA6B;YAC7B,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC9B,sEAAsE;YACtE,4EAA4E;YAC5E,0JAA0J;YAC1J,+GAA+G;YAC/G,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YACvF,MAAM,WAAW,GAAG,cAAc,CAAC,QAAmB,CAAC,CAAC;YACxD,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;YACnF,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,qBAAqB,mCAAI,IAAI,CAAC;IACtE,OAAO,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAA+B,QAAiB;IACrE,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,uDAAuD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,kCACN,QAAQ,KACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,GACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocumentFromStreamDefaultResponse,\n AnalyzeDocumentFromStreamLogicalResponse,\n BuildModel202Response,\n BuildModelDefaultResponse,\n BuildModelLogicalResponse,\n ComposeModel202Response,\n ComposeModelDefaultResponse,\n ComposeModelLogicalResponse,\n CopyModelTo202Response,\n CopyModelToDefaultResponse,\n CopyModelToLogicalResponse,\n BuildClassifier202Response,\n BuildClassifierDefaultResponse,\n BuildClassifierLogicalResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocumentFromStreamDefaultResponse,\n ClassifyDocumentFromStreamLogicalResponse,\n} from \"./responses\";\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport async function getLongRunningPoller<\n TResult extends BuildModelLogicalResponse | BuildModelDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildModel202Response | BuildModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n>(\n client: Client,\n initialResponse: ComposeModel202Response | ComposeModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n>(\n client: Client,\n initialResponse: CopyModelTo202Response | CopyModelToDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends BuildClassifierLogicalResponse | BuildClassifierDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildClassifier202Response | BuildClassifierDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse: AnalyzeDocumentFromStream202Response | AnalyzeDocumentFromStreamDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {},\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client.pathUnchecked(path ?? initialResponse.request.url).get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] = initialResponse.request.url;\n return lroResponse;\n },\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n return createHttpPoller(poller, options);\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(response: TResult): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { HttpResponse } from \"@azure-rest/core-client\";\nimport {\n PagedOperationDetailsOutput,\n ErrorResponseOutput,\n DocumentModelBuildOperationDetailsOutput,\n DocumentModelComposeOperationDetailsOutput,\n DocumentModelCopyToOperationDetailsOutput,\n DocumentClassifierBuildOperationDetailsOutput,\n OperationDetailsOutput,\n ResourceDetailsOutput,\n AnalyzeResultOperationOutput,\n DocumentModelDetailsOutput,\n CopyAuthorizationOutput,\n PagedDocumentModelDetailsOutput,\n PagedDocumentClassifierDetailsOutput,\n DocumentClassifierDetailsOutput,\n} from \"./outputModels\";\n\nexport interface ListOperations200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface ListOperations200Response extends HttpResponse {\n status: \"200\";\n body: PagedOperationDetailsOutput;\n headers: RawHttpHeaders & ListOperations200Headers;\n}\n\nexport interface ListOperationsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetDocumentModelBuildOperation200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentModelBuildOperation200Response extends HttpResponse {\n status: \"200\";\n body: DocumentModelBuildOperationDetailsOutput;\n headers: RawHttpHeaders & GetDocumentModelBuildOperation200Headers;\n}\n\nexport interface GetDocumentModelBuildOperationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetDocumentModelComposeOperation200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentModelComposeOperation200Response extends HttpResponse {\n status: \"200\";\n body: DocumentModelComposeOperationDetailsOutput;\n headers: RawHttpHeaders & GetDocumentModelComposeOperation200Headers;\n}\n\nexport interface GetDocumentModelComposeOperationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetDocumentModelCopyToOperation200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentModelCopyToOperation200Response extends HttpResponse {\n status: \"200\";\n body: DocumentModelCopyToOperationDetailsOutput;\n headers: RawHttpHeaders & GetDocumentModelCopyToOperation200Headers;\n}\n\nexport interface GetDocumentModelCopyToOperationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetDocumentClassifierBuildOperation200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentClassifierBuildOperation200Response extends HttpResponse {\n status: \"200\";\n body: DocumentClassifierBuildOperationDetailsOutput;\n headers: RawHttpHeaders & GetDocumentClassifierBuildOperation200Headers;\n}\n\nexport interface GetDocumentClassifierBuildOperationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetOperation200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetOperation200Response extends HttpResponse {\n status: \"200\";\n body: OperationDetailsOutput;\n headers: RawHttpHeaders & GetOperation200Headers;\n}\n\nexport interface GetOperationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The request has succeeded. */\nexport interface GetResourceInfo200Response extends HttpResponse {\n status: \"200\";\n body: ResourceDetailsOutput;\n}\n\nexport interface GetResourceInfoDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The request has succeeded. */\nexport interface GetAnalyzeResult200Response extends HttpResponse {\n status: \"200\";\n body: AnalyzeResultOperationOutput;\n}\n\nexport interface GetAnalyzeResultDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface AnalyzeDocumentFromStream202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface AnalyzeDocumentFromStream202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & AnalyzeDocumentFromStream202Headers;\n}\n\nexport interface AnalyzeDocumentFromStreamDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running analyzeDocumentFromStream operation */\nexport interface AnalyzeDocumentFromStreamLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface AnalyzeDocument202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface AnalyzeDocument202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & AnalyzeDocument202Headers;\n}\n\nexport interface AnalyzeDocumentDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running analyzeDocument operation */\nexport interface AnalyzeDocumentLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface GetModel200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetModel200Response extends HttpResponse {\n status: \"200\";\n body: DocumentModelDetailsOutput;\n headers: RawHttpHeaders & GetModel200Headers;\n}\n\nexport interface GetModelDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface BuildModel202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface BuildModel202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & BuildModel202Headers;\n}\n\nexport interface BuildModelDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running buildModel operation */\nexport interface BuildModelLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface ComposeModel202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface ComposeModel202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & ComposeModel202Headers;\n}\n\nexport interface ComposeModelDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running composeModel operation */\nexport interface ComposeModelLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\n/** The request has succeeded. */\nexport interface AuthorizeModelCopy200Response extends HttpResponse {\n status: \"200\";\n body: CopyAuthorizationOutput;\n}\n\nexport interface AuthorizeModelCopyDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface CopyModelTo202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface CopyModelTo202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & CopyModelTo202Headers;\n}\n\nexport interface CopyModelToDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running copyModelTo operation */\nexport interface CopyModelToLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface ListModels200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface ListModels200Response extends HttpResponse {\n status: \"200\";\n body: PagedDocumentModelDetailsOutput;\n headers: RawHttpHeaders & ListModels200Headers;\n}\n\nexport interface ListModelsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface DeleteModel204Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** There is no content to send for this request, but the headers may be useful. */\nexport interface DeleteModel204Response extends HttpResponse {\n status: \"204\";\n headers: RawHttpHeaders & DeleteModel204Headers;\n}\n\nexport interface DeleteModelDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface BuildClassifier202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface BuildClassifier202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & BuildClassifier202Headers;\n}\n\nexport interface BuildClassifierDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running buildClassifier operation */\nexport interface BuildClassifierLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface ListClassifiers200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface ListClassifiers200Response extends HttpResponse {\n status: \"200\";\n body: PagedDocumentClassifierDetailsOutput;\n headers: RawHttpHeaders & ListClassifiers200Headers;\n}\n\nexport interface ListClassifiersDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface GetClassifier200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** The request has succeeded. */\nexport interface GetClassifier200Response extends HttpResponse {\n status: \"200\";\n body: DocumentClassifierDetailsOutput;\n headers: RawHttpHeaders & GetClassifier200Headers;\n}\n\nexport interface GetClassifierDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface DeleteClassifier204Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\n/** There is no content to send for this request, but the headers may be useful. */\nexport interface DeleteClassifier204Response extends HttpResponse {\n status: \"204\";\n headers: RawHttpHeaders & DeleteClassifier204Headers;\n}\n\nexport interface DeleteClassifierDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\nexport interface ClassifyDocumentFromStream202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface ClassifyDocumentFromStream202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & ClassifyDocumentFromStream202Headers;\n}\n\nexport interface ClassifyDocumentFromStreamDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running classifyDocumentFromStream operation */\nexport interface ClassifyDocumentFromStreamLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\nexport interface ClassifyDocument202Headers {\n /** The Retry-After header can indicate how long the client should wait before polling the operation status. */\n \"retry-after\"?: number;\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface ClassifyDocument202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & ClassifyDocument202Headers;\n}\n\nexport interface ClassifyDocumentDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n\n/** The final response for long-running classifyDocument operation */\nexport interface ClassifyDocumentLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\n/** The request has succeeded. */\nexport interface GetClassifyResult200Response extends HttpResponse {\n status: \"200\";\n body: AnalyzeResultOperationOutput;\n}\n\nexport interface GetClassifyResultDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n"]}
|