@azure-rest/ai-translation-document 1.0.0-alpha.20250227.1 → 1.0.0-alpha.20250303.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -167
- package/dist/browser/clientDefinitions.d.ts +191 -0
- package/dist/browser/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/documentTranslationClient.d.ts +16 -0
- package/dist/browser/documentTranslationClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/documentTranslationClient.js +1 -1
- package/dist/browser/documentTranslationClient.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/isUnexpected.d.ts +10 -0
- package/dist/browser/isUnexpected.d.ts.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/models.d.ts +112 -0
- package/dist/browser/models.d.ts.map +1 -0
- package/dist/browser/outputModels.d.ts +166 -0
- package/dist/browser/outputModels.d.ts.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/paginateHelper.d.ts +43 -0
- package/dist/browser/paginateHelper.d.ts.map +1 -0
- package/dist/browser/parameters.d.ts +184 -0
- package/dist/browser/parameters.d.ts.map +1 -0
- package/dist/browser/pollingHelper.d.ts +77 -0
- package/dist/browser/pollingHelper.d.ts.map +1 -0
- package/dist/browser/responses.d.ts +132 -0
- package/dist/browser/responses.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.d.ts +191 -0
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.js +3 -0
- package/dist/commonjs/clientDefinitions.js.map +1 -0
- package/dist/commonjs/documentTranslationClient.d.ts +16 -0
- package/dist/commonjs/documentTranslationClient.d.ts.map +1 -0
- package/dist/commonjs/documentTranslationClient.js +45 -0
- package/dist/commonjs/documentTranslationClient.js.map +1 -0
- package/dist/commonjs/index.d.ts +12 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +17 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/isUnexpected.d.ts +10 -0
- package/dist/commonjs/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/isUnexpected.js +78 -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 +112 -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 +166 -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 +43 -0
- package/dist/commonjs/paginateHelper.d.ts.map +1 -0
- package/dist/commonjs/paginateHelper.js +71 -0
- package/dist/commonjs/paginateHelper.js.map +1 -0
- package/dist/commonjs/parameters.d.ts +184 -0
- package/dist/commonjs/parameters.d.ts.map +1 -0
- package/dist/commonjs/parameters.js +3 -0
- package/dist/commonjs/parameters.js.map +1 -0
- package/dist/commonjs/pollingHelper.d.ts +77 -0
- package/dist/commonjs/pollingHelper.d.ts.map +1 -0
- package/dist/commonjs/pollingHelper.js +98 -0
- package/dist/commonjs/pollingHelper.js.map +1 -0
- package/dist/commonjs/responses.d.ts +132 -0
- package/dist/commonjs/responses.d.ts.map +1 -0
- package/dist/commonjs/responses.js +3 -0
- package/dist/commonjs/responses.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/clientDefinitions.d.ts +191 -0
- package/dist/esm/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/clientDefinitions.js +2 -0
- package/dist/esm/clientDefinitions.js.map +1 -0
- package/dist/esm/documentTranslationClient.d.ts +16 -0
- package/dist/esm/documentTranslationClient.d.ts.map +1 -0
- package/dist/esm/documentTranslationClient.js +42 -0
- package/dist/esm/documentTranslationClient.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/isUnexpected.d.ts +10 -0
- package/dist/esm/isUnexpected.d.ts.map +1 -0
- package/dist/esm/isUnexpected.js +75 -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 +112 -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 +166 -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 +43 -0
- package/dist/esm/paginateHelper.d.ts.map +1 -0
- package/dist/esm/paginateHelper.js +68 -0
- package/dist/esm/paginateHelper.js.map +1 -0
- package/dist/esm/parameters.d.ts +184 -0
- package/dist/esm/parameters.d.ts.map +1 -0
- package/dist/esm/parameters.js +2 -0
- package/dist/esm/parameters.js.map +1 -0
- package/dist/esm/pollingHelper.d.ts +77 -0
- package/dist/esm/pollingHelper.d.ts.map +1 -0
- package/dist/esm/pollingHelper.js +95 -0
- package/dist/esm/pollingHelper.js.map +1 -0
- package/dist/esm/responses.d.ts +132 -0
- package/dist/esm/responses.d.ts.map +1 -0
- package/dist/esm/responses.js +2 -0
- package/dist/esm/responses.js.map +1 -0
- package/dist/react-native/clientDefinitions.d.ts +191 -0
- package/dist/react-native/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/clientDefinitions.js +2 -0
- package/dist/react-native/clientDefinitions.js.map +1 -0
- package/dist/react-native/documentTranslationClient.d.ts +16 -0
- package/dist/react-native/documentTranslationClient.d.ts.map +1 -0
- package/dist/react-native/documentTranslationClient.js +42 -0
- package/dist/react-native/documentTranslationClient.js.map +1 -0
- package/dist/react-native/index.d.ts +12 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +14 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/isUnexpected.d.ts +10 -0
- package/dist/react-native/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/isUnexpected.js +75 -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 +112 -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 +166 -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 +43 -0
- package/dist/react-native/paginateHelper.d.ts.map +1 -0
- package/dist/react-native/paginateHelper.js +68 -0
- package/dist/react-native/paginateHelper.js.map +1 -0
- package/dist/react-native/parameters.d.ts +184 -0
- package/dist/react-native/parameters.d.ts.map +1 -0
- package/dist/react-native/parameters.js +2 -0
- package/dist/react-native/parameters.js.map +1 -0
- package/dist/react-native/pollingHelper.d.ts +77 -0
- package/dist/react-native/pollingHelper.d.ts.map +1 -0
- package/dist/react-native/pollingHelper.js +95 -0
- package/dist/react-native/pollingHelper.js.map +1 -0
- package/dist/react-native/responses.d.ts +132 -0
- package/dist/react-native/responses.d.ts.map +1 -0
- package/dist/react-native/responses.js +2 -0
- package/dist/react-native/responses.js.map +1 -0
- package/package.json +68 -43
- package/CHANGELOG.md +0 -34
- package/dist/index.js +0 -293
- package/dist/index.js.map +0 -1
- package/dist-esm/src/documentTranslationClient.js.map +0 -1
- package/dist-esm/src/index.js +0 -14
- package/dist-esm/src/index.js.map +0 -1
- package/types/ai-translation-document.d.ts +0 -1018
- /package/{dist-esm/src → dist/browser}/clientDefinitions.js +0 -0
- /package/{dist-esm/src → dist/browser}/clientDefinitions.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/isUnexpected.js +0 -0
- /package/{dist-esm/src → dist/browser}/isUnexpected.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/logger.js +0 -0
- /package/{dist-esm/src → dist/browser}/logger.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/models.js +0 -0
- /package/{dist-esm/src → dist/browser}/models.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/outputModels.js +0 -0
- /package/{dist-esm/src → dist/browser}/outputModels.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/paginateHelper.js +0 -0
- /package/{dist-esm/src → dist/browser}/paginateHelper.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/parameters.js +0 -0
- /package/{dist-esm/src → dist/browser}/parameters.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/pollingHelper.js +0 -0
- /package/{dist-esm/src → dist/browser}/pollingHelper.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/responses.js +0 -0
- /package/{dist-esm/src → dist/browser}/responses.js.map +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paginate = paginate;
|
|
4
|
+
const core_paging_1 = require("@azure/core-paging");
|
|
5
|
+
const core_client_1 = require("@azure-rest/core-client");
|
|
6
|
+
/**
|
|
7
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
8
|
+
* @param client - Client to use for sending the next page requests
|
|
9
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
10
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
11
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
12
|
+
*/
|
|
13
|
+
function paginate(client, initialResponse, options = {}) {
|
|
14
|
+
let firstRun = true;
|
|
15
|
+
const itemName = "value";
|
|
16
|
+
const nextLinkName = "nextLink";
|
|
17
|
+
const { customGetPage } = options;
|
|
18
|
+
const pagedResult = {
|
|
19
|
+
firstPageLink: "",
|
|
20
|
+
getPage: typeof customGetPage === "function"
|
|
21
|
+
? customGetPage
|
|
22
|
+
: async (pageLink) => {
|
|
23
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
24
|
+
firstRun = false;
|
|
25
|
+
checkPagingRequest(result);
|
|
26
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
27
|
+
const values = getElements(result.body, itemName);
|
|
28
|
+
return {
|
|
29
|
+
page: values,
|
|
30
|
+
nextPageLink: nextLink,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return (0, core_paging_1.getPagedAsyncIterator)(pagedResult);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets for the value of nextLink in the body
|
|
38
|
+
*/
|
|
39
|
+
function getNextLink(body, nextLinkName) {
|
|
40
|
+
if (!nextLinkName) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const nextLink = body[nextLinkName];
|
|
44
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
45
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
46
|
+
}
|
|
47
|
+
return nextLink;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the elements of the current request in the body.
|
|
51
|
+
*/
|
|
52
|
+
function getElements(body, itemName) {
|
|
53
|
+
const value = body[itemName];
|
|
54
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
55
|
+
// The fact that this must be an array is used above to calculate the
|
|
56
|
+
// type of elements in the page in PaginateReturn
|
|
57
|
+
if (!Array.isArray(value)) {
|
|
58
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
59
|
+
}
|
|
60
|
+
return value !== null && value !== void 0 ? value : [];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks if a request failed
|
|
64
|
+
*/
|
|
65
|
+
function checkPagingRequest(response) {
|
|
66
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
67
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
68
|
+
throw (0, core_client_1.createRestError)(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=paginateHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":";;AAqDA,4BA8BC;AAhFD,oDAA2D;AAE3D,yDAA0D;AAyC1D;;;;;;GAMG;AACH,SAAgB,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,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,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,IAAA,6BAAe,EACnB,gDAAgD,QAAQ,CAAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { getPagedAsyncIterator } from \"@azure/core-paging\";\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } 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"]}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
|
|
2
|
+
import type { RequestParameters } from "@azure-rest/core-client";
|
|
3
|
+
import type { DocumentTranslateContent, StartTranslationDetails, FileFormatType } from "./models.js";
|
|
4
|
+
export interface DocumentTranslateHeaders {
|
|
5
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
6
|
+
"x-ms-client-request-id"?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DocumentTranslateBodyParam {
|
|
9
|
+
/** Document Translate Request Content */
|
|
10
|
+
body: DocumentTranslateContent;
|
|
11
|
+
}
|
|
12
|
+
export interface DocumentTranslateQueryParamProperties {
|
|
13
|
+
/**
|
|
14
|
+
* Specifies source language of the input document.
|
|
15
|
+
* If this parameter isn't specified, automatic language detection is applied to determine the source language.
|
|
16
|
+
* For example if the source document is written in English, then use sourceLanguage=en
|
|
17
|
+
*/
|
|
18
|
+
sourceLanguage?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the language of the output document.
|
|
21
|
+
* The target language must be one of the supported languages included in the translation scope.
|
|
22
|
+
* For example if you want to translate the document in German language, then use targetLanguage=de
|
|
23
|
+
*/
|
|
24
|
+
targetLanguage: string;
|
|
25
|
+
/**
|
|
26
|
+
* A string specifying the category (domain) of the translation. This parameter is used to get translations
|
|
27
|
+
* from a customized system built with Custom Translator. Add the Category ID from your Custom Translator
|
|
28
|
+
* project details to this parameter to use your deployed customized system. Default value is: general.
|
|
29
|
+
*/
|
|
30
|
+
category?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.
|
|
33
|
+
* Possible values are: true (default) or false.
|
|
34
|
+
*/
|
|
35
|
+
allowFallback?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DocumentTranslateQueryParam {
|
|
38
|
+
queryParameters: DocumentTranslateQueryParamProperties;
|
|
39
|
+
}
|
|
40
|
+
export interface DocumentTranslateHeaderParam {
|
|
41
|
+
headers?: RawHttpHeadersInput & DocumentTranslateHeaders;
|
|
42
|
+
}
|
|
43
|
+
export interface DocumentTranslateMediaTypesParam {
|
|
44
|
+
/** Content Type as multipart/form-data */
|
|
45
|
+
contentType: "multipart/form-data";
|
|
46
|
+
}
|
|
47
|
+
export type DocumentTranslateParameters = DocumentTranslateQueryParam & DocumentTranslateHeaderParam & DocumentTranslateMediaTypesParam & DocumentTranslateBodyParam & RequestParameters;
|
|
48
|
+
export interface StartTranslationBodyParam {
|
|
49
|
+
/** Translation job submission batch request */
|
|
50
|
+
body: StartTranslationDetails;
|
|
51
|
+
}
|
|
52
|
+
export type StartTranslationParameters = StartTranslationBodyParam & RequestParameters;
|
|
53
|
+
export interface GetTranslationsStatusQueryParamProperties {
|
|
54
|
+
/**
|
|
55
|
+
* top indicates the total number of records the user wants to be returned across
|
|
56
|
+
* all pages.
|
|
57
|
+
*
|
|
58
|
+
* Clients MAY use top and skip query parameters to
|
|
59
|
+
* specify a number of results to return and an offset into the collection.
|
|
60
|
+
* When
|
|
61
|
+
* both top and skip are given by a client, the server SHOULD first apply skip
|
|
62
|
+
* and then top on the collection.
|
|
63
|
+
*
|
|
64
|
+
* Note: If the server can't honor
|
|
65
|
+
* top and/or skip, the server MUST return an error to the client informing
|
|
66
|
+
* about it instead of just ignoring the query options.
|
|
67
|
+
*/
|
|
68
|
+
top?: number;
|
|
69
|
+
/**
|
|
70
|
+
* skip indicates the number of records to skip from the list of records held by
|
|
71
|
+
* the server based on the sorting method specified. By default, we sort by
|
|
72
|
+
* descending start time.
|
|
73
|
+
*
|
|
74
|
+
* Clients MAY use top and skip query
|
|
75
|
+
* parameters to specify a number of results to return and an offset into the
|
|
76
|
+
* collection.
|
|
77
|
+
* When both top and skip are given by a client, the server SHOULD
|
|
78
|
+
* first apply skip and then top on the collection.
|
|
79
|
+
*
|
|
80
|
+
* Note: If the
|
|
81
|
+
* server can't honor top and/or skip, the server MUST return an error to the
|
|
82
|
+
* client informing about it instead of just ignoring the query options.
|
|
83
|
+
*/
|
|
84
|
+
skip?: number;
|
|
85
|
+
/**
|
|
86
|
+
* maxpagesize is the maximum items returned in a page. If more items are
|
|
87
|
+
* requested via top (or top is not specified and there are more items to be
|
|
88
|
+
* returned), @nextLink will contain the link to the next page.
|
|
89
|
+
*
|
|
90
|
+
*
|
|
91
|
+
* Clients MAY request server-driven paging with a specific page size by
|
|
92
|
+
* specifying a maxpagesize preference. The server SHOULD honor this preference
|
|
93
|
+
* if the specified page size is smaller than the server's default page size.
|
|
94
|
+
*/
|
|
95
|
+
maxpagesize?: number;
|
|
96
|
+
/** Ids to use in filtering */
|
|
97
|
+
ids?: string[];
|
|
98
|
+
/** Statuses to use in filtering */
|
|
99
|
+
statuses?: string[];
|
|
100
|
+
/** the start datetime to get items after */
|
|
101
|
+
createdDateTimeUtcStart?: Date | string;
|
|
102
|
+
/** the end datetime to get items before */
|
|
103
|
+
createdDateTimeUtcEnd?: Date | string;
|
|
104
|
+
/** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc') */
|
|
105
|
+
orderby?: string[];
|
|
106
|
+
}
|
|
107
|
+
export interface GetTranslationsStatusQueryParam {
|
|
108
|
+
queryParameters?: GetTranslationsStatusQueryParamProperties;
|
|
109
|
+
}
|
|
110
|
+
export type GetTranslationsStatusParameters = GetTranslationsStatusQueryParam & RequestParameters;
|
|
111
|
+
export type GetDocumentStatusParameters = RequestParameters;
|
|
112
|
+
export type GetTranslationStatusParameters = RequestParameters;
|
|
113
|
+
export type CancelTranslationParameters = RequestParameters;
|
|
114
|
+
export interface GetDocumentsStatusQueryParamProperties {
|
|
115
|
+
/**
|
|
116
|
+
* top indicates the total number of records the user wants to be returned across
|
|
117
|
+
* all pages.
|
|
118
|
+
*
|
|
119
|
+
* Clients MAY use top and skip query parameters to
|
|
120
|
+
* specify a number of results to return and an offset into the collection.
|
|
121
|
+
* When
|
|
122
|
+
* both top and skip are given by a client, the server SHOULD first apply skip
|
|
123
|
+
* and then top on the collection.
|
|
124
|
+
*
|
|
125
|
+
* Note: If the server can't honor
|
|
126
|
+
* top and/or skip, the server MUST return an error to the client informing
|
|
127
|
+
* about it instead of just ignoring the query options.
|
|
128
|
+
*/
|
|
129
|
+
top?: number;
|
|
130
|
+
/**
|
|
131
|
+
* skip indicates the number of records to skip from the list of records held by
|
|
132
|
+
* the server based on the sorting method specified. By default, we sort by
|
|
133
|
+
* descending start time.
|
|
134
|
+
*
|
|
135
|
+
* Clients MAY use top and skip query
|
|
136
|
+
* parameters to specify a number of results to return and an offset into the
|
|
137
|
+
* collection.
|
|
138
|
+
* When both top and skip are given by a client, the server SHOULD
|
|
139
|
+
* first apply skip and then top on the collection.
|
|
140
|
+
*
|
|
141
|
+
* Note: If the
|
|
142
|
+
* server can't honor top and/or skip, the server MUST return an error to the
|
|
143
|
+
* client informing about it instead of just ignoring the query options.
|
|
144
|
+
*/
|
|
145
|
+
skip?: number;
|
|
146
|
+
/**
|
|
147
|
+
* maxpagesize is the maximum items returned in a page. If more items are
|
|
148
|
+
* requested via top (or top is not specified and there are more items to be
|
|
149
|
+
* returned), @nextLink will contain the link to the next page.
|
|
150
|
+
*
|
|
151
|
+
*
|
|
152
|
+
* Clients MAY request server-driven paging with a specific page size by
|
|
153
|
+
* specifying a maxpagesize preference. The server SHOULD honor this preference
|
|
154
|
+
* if the specified page size is smaller than the server's default page size.
|
|
155
|
+
*/
|
|
156
|
+
maxpagesize?: number;
|
|
157
|
+
/** Ids to use in filtering */
|
|
158
|
+
ids?: string[];
|
|
159
|
+
/** Statuses to use in filtering */
|
|
160
|
+
statuses?: string[];
|
|
161
|
+
/** the start datetime to get items after */
|
|
162
|
+
createdDateTimeUtcStart?: Date | string;
|
|
163
|
+
/** the end datetime to get items before */
|
|
164
|
+
createdDateTimeUtcEnd?: Date | string;
|
|
165
|
+
/** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc') */
|
|
166
|
+
orderby?: string[];
|
|
167
|
+
}
|
|
168
|
+
export interface GetDocumentsStatusQueryParam {
|
|
169
|
+
queryParameters?: GetDocumentsStatusQueryParamProperties;
|
|
170
|
+
}
|
|
171
|
+
export type GetDocumentsStatusParameters = GetDocumentsStatusQueryParam & RequestParameters;
|
|
172
|
+
export interface GetSupportedFormatsQueryParamProperties {
|
|
173
|
+
/**
|
|
174
|
+
* the type of format like document or glossary
|
|
175
|
+
*
|
|
176
|
+
* Possible values: "document", "glossary"
|
|
177
|
+
*/
|
|
178
|
+
type?: FileFormatType;
|
|
179
|
+
}
|
|
180
|
+
export interface GetSupportedFormatsQueryParam {
|
|
181
|
+
queryParameters?: GetSupportedFormatsQueryParamProperties;
|
|
182
|
+
}
|
|
183
|
+
export type GetSupportedFormatsParameters = GetSupportedFormatsQueryParam & RequestParameters;
|
|
184
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,wBAAwB;IACvC,sFAAsF;IACtF,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,0BAA0B;IACzC,yCAAyC;IACzC,IAAI,EAAE,wBAAwB,CAAC;CAChC;AAED,MAAM,WAAW,qCAAqC;IACpD;;;;OAIG;IACH,cAAc,CAAC,EAAE,MA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,MAAM,MAAM,+BAA+B,GAAG,+BAA+B,GAAG,iBAAiB,CAAC;AAClG,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAC5D,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAAC;AAC/D,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAE5D,MAAM,WAAW,sCAAsC;IACrD;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4CAA4C;IAC5C,uBAAuB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxC,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACtC,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,sCAAsC,CAAC;CAC1D;AAED,MAAM,MAAM,4BAA4B,GAAG,4BAA4B,GAAG,iBAAiB,CAAC;AAE5F,MAAM,WAAW,uCAAuC;IACtD;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC5C,eAAe,CAAC,EAAE,uCAAuC,CAAC;CAC3D;AAED,MAAM,MAAM,6BAA6B,GAAG,6BAA6B,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\nimport type { RequestParameters } from \"@azure-rest/core-client\";\nimport type {\n DocumentTranslateContent,\n StartTranslationDetails,\n FileFormatType,\n} from \"./models.js\";\n\nexport interface DocumentTranslateHeaders {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n}\n\nexport interface DocumentTranslateBodyParam {\n /** Document Translate Request Content */\n body: DocumentTranslateContent;\n}\n\nexport interface DocumentTranslateQueryParamProperties {\n /**\n * Specifies source language of the input document.\n * If this parameter isn't specified, automatic language detection is applied to determine the source language.\n * For example if the source document is written in English, then use sourceLanguage=en\n */\n sourceLanguage?: string;\n /**\n * Specifies the language of the output document.\n * The target language must be one of the supported languages included in the translation scope.\n * For example if you want to translate the document in German language, then use targetLanguage=de\n */\n targetLanguage: string;\n /**\n * A string specifying the category (domain) of the translation. This parameter is used to get translations\n * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator\n * project details to this parameter to use your deployed customized system. Default value is: general.\n */\n category?: string;\n /**\n * Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.\n * Possible values are: true (default) or false.\n */\n allowFallback?: boolean;\n}\n\nexport interface DocumentTranslateQueryParam {\n queryParameters: DocumentTranslateQueryParamProperties;\n}\n\nexport interface DocumentTranslateHeaderParam {\n headers?: RawHttpHeadersInput & DocumentTranslateHeaders;\n}\n\nexport interface DocumentTranslateMediaTypesParam {\n /** Content Type as multipart/form-data */\n contentType: \"multipart/form-data\";\n}\n\nexport type DocumentTranslateParameters = DocumentTranslateQueryParam &\n DocumentTranslateHeaderParam &\n DocumentTranslateMediaTypesParam &\n DocumentTranslateBodyParam &\n RequestParameters;\n\nexport interface StartTranslationBodyParam {\n /** Translation job submission batch request */\n body: StartTranslationDetails;\n}\n\nexport type StartTranslationParameters = StartTranslationBodyParam & RequestParameters;\n\nexport interface GetTranslationsStatusQueryParamProperties {\n /**\n * top indicates the total number of records the user wants to be returned across\n * all pages.\n *\n * Clients MAY use top and skip query parameters to\n * specify a number of results to return and an offset into the collection.\n * When\n * both top and skip are given by a client, the server SHOULD first apply skip\n * and then top on the collection.\n *\n * Note: If the server can't honor\n * top and/or skip, the server MUST return an error to the client informing\n * about it instead of just ignoring the query options.\n */\n top?: number;\n /**\n * skip indicates the number of records to skip from the list of records held by\n * the server based on the sorting method specified. By default, we sort by\n * descending start time.\n *\n * Clients MAY use top and skip query\n * parameters to specify a number of results to return and an offset into the\n * collection.\n * When both top and skip are given by a client, the server SHOULD\n * first apply skip and then top on the collection.\n *\n * Note: If the\n * server can't honor top and/or skip, the server MUST return an error to the\n * client informing about it instead of just ignoring the query options.\n */\n skip?: number;\n /**\n * maxpagesize is the maximum items returned in a page. If more items are\n * requested via top (or top is not specified and there are more items to be\n * returned), @nextLink will contain the link to the next page.\n *\n *\n * Clients MAY request server-driven paging with a specific page size by\n * specifying a maxpagesize preference. The server SHOULD honor this preference\n * if the specified page size is smaller than the server's default page size.\n */\n maxpagesize?: number;\n /** Ids to use in filtering */\n ids?: string[];\n /** Statuses to use in filtering */\n statuses?: string[];\n /** the start datetime to get items after */\n createdDateTimeUtcStart?: Date | string;\n /** the end datetime to get items before */\n createdDateTimeUtcEnd?: Date | string;\n /** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc') */\n orderby?: string[];\n}\n\nexport interface GetTranslationsStatusQueryParam {\n queryParameters?: GetTranslationsStatusQueryParamProperties;\n}\n\nexport type GetTranslationsStatusParameters = GetTranslationsStatusQueryParam & RequestParameters;\nexport type GetDocumentStatusParameters = RequestParameters;\nexport type GetTranslationStatusParameters = RequestParameters;\nexport type CancelTranslationParameters = RequestParameters;\n\nexport interface GetDocumentsStatusQueryParamProperties {\n /**\n * top indicates the total number of records the user wants to be returned across\n * all pages.\n *\n * Clients MAY use top and skip query parameters to\n * specify a number of results to return and an offset into the collection.\n * When\n * both top and skip are given by a client, the server SHOULD first apply skip\n * and then top on the collection.\n *\n * Note: If the server can't honor\n * top and/or skip, the server MUST return an error to the client informing\n * about it instead of just ignoring the query options.\n */\n top?: number;\n /**\n * skip indicates the number of records to skip from the list of records held by\n * the server based on the sorting method specified. By default, we sort by\n * descending start time.\n *\n * Clients MAY use top and skip query\n * parameters to specify a number of results to return and an offset into the\n * collection.\n * When both top and skip are given by a client, the server SHOULD\n * first apply skip and then top on the collection.\n *\n * Note: If the\n * server can't honor top and/or skip, the server MUST return an error to the\n * client informing about it instead of just ignoring the query options.\n */\n skip?: number;\n /**\n * maxpagesize is the maximum items returned in a page. If more items are\n * requested via top (or top is not specified and there are more items to be\n * returned), @nextLink will contain the link to the next page.\n *\n *\n * Clients MAY request server-driven paging with a specific page size by\n * specifying a maxpagesize preference. The server SHOULD honor this preference\n * if the specified page size is smaller than the server's default page size.\n */\n maxpagesize?: number;\n /** Ids to use in filtering */\n ids?: string[];\n /** Statuses to use in filtering */\n statuses?: string[];\n /** the start datetime to get items after */\n createdDateTimeUtcStart?: Date | string;\n /** the end datetime to get items before */\n createdDateTimeUtcEnd?: Date | string;\n /** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc') */\n orderby?: string[];\n}\n\nexport interface GetDocumentsStatusQueryParam {\n queryParameters?: GetDocumentsStatusQueryParamProperties;\n}\n\nexport type GetDocumentsStatusParameters = GetDocumentsStatusQueryParam & RequestParameters;\n\nexport interface GetSupportedFormatsQueryParamProperties {\n /**\n * the type of format like document or glossary\n *\n * Possible values: \"document\", \"glossary\"\n */\n type?: FileFormatType;\n}\n\nexport interface GetSupportedFormatsQueryParam {\n queryParameters?: GetSupportedFormatsQueryParamProperties;\n}\n\nexport type GetSupportedFormatsParameters = GetSupportedFormatsQueryParam & RequestParameters;\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Client } from "@azure-rest/core-client";
|
|
2
|
+
import type { AbortSignalLike } from "@azure/abort-controller";
|
|
3
|
+
import type { CancelOnProgress, CreateHttpPollerOptions, OperationState } from "@azure/core-lro";
|
|
4
|
+
import type { StartTranslation202Response, StartTranslationDefaultResponse, StartTranslationLogicalResponse } from "./responses.js";
|
|
5
|
+
/**
|
|
6
|
+
* A simple poller that can be used to poll a long running operation.
|
|
7
|
+
*/
|
|
8
|
+
export interface SimplePollerLike<TState extends OperationState<TResult>, TResult> {
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the poller has finished polling.
|
|
11
|
+
*/
|
|
12
|
+
isDone(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the state of the operation.
|
|
15
|
+
*/
|
|
16
|
+
getOperationState(): TState;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the result value of the operation,
|
|
19
|
+
* regardless of the state of the poller.
|
|
20
|
+
* It can return undefined or an incomplete form of the final TResult value
|
|
21
|
+
* depending on the implementation.
|
|
22
|
+
*/
|
|
23
|
+
getResult(): TResult | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a promise that will resolve once a single polling request finishes.
|
|
26
|
+
* It does this by calling the update method of the Poller's operation.
|
|
27
|
+
*/
|
|
28
|
+
poll(options?: {
|
|
29
|
+
abortSignal?: AbortSignalLike;
|
|
30
|
+
}): Promise<TState>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a promise that will resolve once the underlying operation is completed.
|
|
33
|
+
*/
|
|
34
|
+
pollUntilDone(pollOptions?: {
|
|
35
|
+
abortSignal?: AbortSignalLike;
|
|
36
|
+
}): Promise<TResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Invokes the provided callback after each polling is completed,
|
|
39
|
+
* sending the current state of the poller's operation.
|
|
40
|
+
*
|
|
41
|
+
* It returns a method that can be used to stop receiving updates on the given callback function.
|
|
42
|
+
*/
|
|
43
|
+
onProgress(callback: (state: TState) => void): CancelOnProgress;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a promise that could be used for serialized version of the poller's operation
|
|
46
|
+
* by invoking the operation's serialize method.
|
|
47
|
+
*/
|
|
48
|
+
serialize(): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Wait the poller to be submitted.
|
|
51
|
+
*/
|
|
52
|
+
submitted(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a string representation of the poller's operation. Similar to serialize but returns a string.
|
|
55
|
+
* @deprecated Use serialize() instead.
|
|
56
|
+
*/
|
|
57
|
+
toString(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Stops the poller from continuing to poll. Please note this will only stop the client-side polling
|
|
60
|
+
* @deprecated Use abortSignal to stop polling instead.
|
|
61
|
+
*/
|
|
62
|
+
stopPolling(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the poller is stopped.
|
|
65
|
+
* @deprecated Use abortSignal status to track this instead.
|
|
66
|
+
*/
|
|
67
|
+
isStopped(): boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Helper function that builds a Poller object to help polling a long running operation.
|
|
71
|
+
* @param client - Client to use for sending the request to get additional pages.
|
|
72
|
+
* @param initialResponse - The initial response.
|
|
73
|
+
* @param options - Options to set a resume state or custom polling interval.
|
|
74
|
+
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getLongRunningPoller<TResult extends StartTranslationLogicalResponse | StartTranslationDefaultResponse>(client: Client, initialResponse: StartTranslation202Response | StartTranslationDefaultResponse, options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;
|
|
77
|
+
//# sourceMappingURL=pollingHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollingHelper.d.ts","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EAGvB,cAAc,EACf,MAAM,iBAAiB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AO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLongRunningPoller = getLongRunningPoller;
|
|
4
|
+
const core_lro_1 = require("@azure/core-lro");
|
|
5
|
+
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
6
|
+
var _a;
|
|
7
|
+
const abortController = new AbortController();
|
|
8
|
+
const poller = {
|
|
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, pollOptions) => {
|
|
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
|
+
function abortListener() {
|
|
21
|
+
abortController.abort();
|
|
22
|
+
}
|
|
23
|
+
const inputAbortSignal = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal;
|
|
24
|
+
const abortSignal = abortController.signal;
|
|
25
|
+
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
|
|
26
|
+
abortController.abort();
|
|
27
|
+
}
|
|
28
|
+
else if (!abortSignal.aborted) {
|
|
29
|
+
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, {
|
|
30
|
+
once: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
response = await client
|
|
36
|
+
.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url)
|
|
37
|
+
.get({ abortSignal });
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
|
|
41
|
+
}
|
|
42
|
+
const lroResponse = getLroResponse(response);
|
|
43
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
44
|
+
return lroResponse;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
48
|
+
const httpPoller = (0, core_lro_1.createHttpPoller)(poller, options);
|
|
49
|
+
const simplePoller = {
|
|
50
|
+
isDone() {
|
|
51
|
+
return httpPoller.isDone;
|
|
52
|
+
},
|
|
53
|
+
isStopped() {
|
|
54
|
+
return abortController.signal.aborted;
|
|
55
|
+
},
|
|
56
|
+
getOperationState() {
|
|
57
|
+
if (!httpPoller.operationState) {
|
|
58
|
+
throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
|
|
59
|
+
}
|
|
60
|
+
return httpPoller.operationState;
|
|
61
|
+
},
|
|
62
|
+
getResult() {
|
|
63
|
+
return httpPoller.result;
|
|
64
|
+
},
|
|
65
|
+
toString() {
|
|
66
|
+
if (!httpPoller.operationState) {
|
|
67
|
+
throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
|
|
68
|
+
}
|
|
69
|
+
return JSON.stringify({
|
|
70
|
+
state: httpPoller.operationState,
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
stopPolling() {
|
|
74
|
+
abortController.abort();
|
|
75
|
+
},
|
|
76
|
+
onProgress: httpPoller.onProgress,
|
|
77
|
+
poll: httpPoller.poll,
|
|
78
|
+
pollUntilDone: httpPoller.pollUntilDone,
|
|
79
|
+
serialize: httpPoller.serialize,
|
|
80
|
+
submitted: httpPoller.submitted,
|
|
81
|
+
};
|
|
82
|
+
return simplePoller;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
86
|
+
* @param response - a rest client http response
|
|
87
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
88
|
+
*/
|
|
89
|
+
function getLroResponse(response) {
|
|
90
|
+
if (Number.isNaN(response.status)) {
|
|
91
|
+
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
flatResponse: response,
|
|
95
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=pollingHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":";;AAkGA,oDAoFC;AA3KD,8CAAmD;AAuF5C,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,eAAwB,EACxB,UAAqE,EAAE;;IAEvE,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,MAAM,GAA8B;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,IAAY,EAAE,WAA+C,EAAE,EAAE;YACvF,sEAAsE;YACtE,4EAA4E;YAC5E,0JAA0J;YAC1J,+GAA+G;YAC/G,SAAS,aAAa;gBACpB,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YACD,MAAM,gBAAgB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC;YAClD,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC;YAC3C,IAAI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C;gBAC/B,MAAM,IAAI,KAAK,CACb,4IAA4I,CAC7I,CAAC;YACJ,CAAC;YACD,OAAO,UAAU,CAAC,cAAc,CAAC;QACnC,CAAC;QACD,SAAS;YACP,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B,CAAC;QACD,QAAQ;YACN,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CACb,4IAA4I,CAC7I,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,UAAU,CAAC,cAAc;aACjC,CAAC,CAAC;QACL,CAAC;QACD,WAAW;YACT,eAAe,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,QAAiB;IAEjB,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.\nimport type { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n} from \"@azure/core-lro\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport type {\n StartTranslation202Response,\n StartTranslationDefaultResponse,\n StartTranslationLogicalResponse,\n} from \"./responses.js\";\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<TState extends OperationState<TResult>, TResult> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n\n /**\n * Returns true if the poller is stopped.\n * @deprecated Use abortSignal status to track this instead.\n */\n isStopped(): boolean;\n}\n\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 StartTranslationLogicalResponse | StartTranslationDefaultResponse,\n>(\n client: Client,\n initialResponse: StartTranslation202Response | StartTranslationDefaultResponse,\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 abortController = new AbortController();\n const poller: RunningOperation<TResult> = {\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: string, pollOptions?: { abortSignal?: AbortSignalLike }) => {\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 function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = pollOptions?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\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 const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return abortController.signal.aborted;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState,\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted,\n };\n return simplePoller;\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>(\n response: TResult,\n): OperationResponse<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"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { RawHttpHeaders } from "@azure/core-rest-pipeline";
|
|
2
|
+
import type { HttpResponse, ErrorResponse } from "@azure-rest/core-client";
|
|
3
|
+
import type { TranslationsStatusOutput, DocumentStatusOutput, TranslationStatusOutput, DocumentsStatusOutput, SupportedFileFormatsOutput } from "./outputModels.js";
|
|
4
|
+
export interface DocumentTranslate200Headers {
|
|
5
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
6
|
+
"x-ms-client-request-id"?: string;
|
|
7
|
+
/** response content type */
|
|
8
|
+
"content-type": "application/octet-stream";
|
|
9
|
+
}
|
|
10
|
+
/** The request has succeeded. */
|
|
11
|
+
export interface DocumentTranslate200Response extends HttpResponse {
|
|
12
|
+
status: "200";
|
|
13
|
+
/** Value may contain any sequence of octets */
|
|
14
|
+
body: Uint8Array;
|
|
15
|
+
headers: RawHttpHeaders & DocumentTranslate200Headers;
|
|
16
|
+
}
|
|
17
|
+
export interface DocumentTranslateDefaultHeaders {
|
|
18
|
+
/** String error code indicating what went wrong. */
|
|
19
|
+
"x-ms-error-code"?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DocumentTranslateDefaultResponse extends HttpResponse {
|
|
22
|
+
status: string;
|
|
23
|
+
body: ErrorResponse;
|
|
24
|
+
headers: RawHttpHeaders & DocumentTranslateDefaultHeaders;
|
|
25
|
+
}
|
|
26
|
+
export interface StartTranslation202Headers {
|
|
27
|
+
/** Link to the translation operation status */
|
|
28
|
+
"operation-location": string;
|
|
29
|
+
}
|
|
30
|
+
/** The request has been accepted for processing, but processing has not yet completed. */
|
|
31
|
+
export interface StartTranslation202Response extends HttpResponse {
|
|
32
|
+
status: "202";
|
|
33
|
+
headers: RawHttpHeaders & StartTranslation202Headers;
|
|
34
|
+
}
|
|
35
|
+
export interface StartTranslationDefaultHeaders {
|
|
36
|
+
/** String error code indicating what went wrong. */
|
|
37
|
+
"x-ms-error-code"?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface StartTranslationDefaultResponse extends HttpResponse {
|
|
40
|
+
status: string;
|
|
41
|
+
body: ErrorResponse;
|
|
42
|
+
headers: RawHttpHeaders & StartTranslationDefaultHeaders;
|
|
43
|
+
}
|
|
44
|
+
/** The final response for long-running startTranslation operation */
|
|
45
|
+
export interface StartTranslationLogicalResponse extends HttpResponse {
|
|
46
|
+
status: "200";
|
|
47
|
+
}
|
|
48
|
+
/** The request has succeeded. */
|
|
49
|
+
export interface GetTranslationsStatus200Response extends HttpResponse {
|
|
50
|
+
status: "200";
|
|
51
|
+
body: TranslationsStatusOutput;
|
|
52
|
+
}
|
|
53
|
+
export interface GetTranslationsStatusDefaultHeaders {
|
|
54
|
+
/** String error code indicating what went wrong. */
|
|
55
|
+
"x-ms-error-code"?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface GetTranslationsStatusDefaultResponse extends HttpResponse {
|
|
58
|
+
status: string;
|
|
59
|
+
body: ErrorResponse;
|
|
60
|
+
headers: RawHttpHeaders & GetTranslationsStatusDefaultHeaders;
|
|
61
|
+
}
|
|
62
|
+
/** The request has succeeded. */
|
|
63
|
+
export interface GetDocumentStatus200Response extends HttpResponse {
|
|
64
|
+
status: "200";
|
|
65
|
+
body: DocumentStatusOutput;
|
|
66
|
+
}
|
|
67
|
+
export interface GetDocumentStatusDefaultHeaders {
|
|
68
|
+
/** String error code indicating what went wrong. */
|
|
69
|
+
"x-ms-error-code"?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface GetDocumentStatusDefaultResponse extends HttpResponse {
|
|
72
|
+
status: string;
|
|
73
|
+
body: ErrorResponse;
|
|
74
|
+
headers: RawHttpHeaders & GetDocumentStatusDefaultHeaders;
|
|
75
|
+
}
|
|
76
|
+
/** The request has succeeded. */
|
|
77
|
+
export interface GetTranslationStatus200Response extends HttpResponse {
|
|
78
|
+
status: "200";
|
|
79
|
+
body: TranslationStatusOutput;
|
|
80
|
+
}
|
|
81
|
+
export interface GetTranslationStatusDefaultHeaders {
|
|
82
|
+
/** String error code indicating what went wrong. */
|
|
83
|
+
"x-ms-error-code"?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface GetTranslationStatusDefaultResponse extends HttpResponse {
|
|
86
|
+
status: string;
|
|
87
|
+
body: ErrorResponse;
|
|
88
|
+
headers: RawHttpHeaders & GetTranslationStatusDefaultHeaders;
|
|
89
|
+
}
|
|
90
|
+
/** The request has succeeded. */
|
|
91
|
+
export interface CancelTranslation200Response extends HttpResponse {
|
|
92
|
+
status: "200";
|
|
93
|
+
body: TranslationStatusOutput;
|
|
94
|
+
}
|
|
95
|
+
export interface CancelTranslationDefaultHeaders {
|
|
96
|
+
/** String error code indicating what went wrong. */
|
|
97
|
+
"x-ms-error-code"?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface CancelTranslationDefaultResponse extends HttpResponse {
|
|
100
|
+
status: string;
|
|
101
|
+
body: ErrorResponse;
|
|
102
|
+
headers: RawHttpHeaders & CancelTranslationDefaultHeaders;
|
|
103
|
+
}
|
|
104
|
+
/** The request has succeeded. */
|
|
105
|
+
export interface GetDocumentsStatus200Response extends HttpResponse {
|
|
106
|
+
status: "200";
|
|
107
|
+
body: DocumentsStatusOutput;
|
|
108
|
+
}
|
|
109
|
+
export interface GetDocumentsStatusDefaultHeaders {
|
|
110
|
+
/** String error code indicating what went wrong. */
|
|
111
|
+
"x-ms-error-code"?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface GetDocumentsStatusDefaultResponse extends HttpResponse {
|
|
114
|
+
status: string;
|
|
115
|
+
body: ErrorResponse;
|
|
116
|
+
headers: RawHttpHeaders & GetDocumentsStatusDefaultHeaders;
|
|
117
|
+
}
|
|
118
|
+
/** The request has succeeded. */
|
|
119
|
+
export interface GetSupportedFormats200Response extends HttpResponse {
|
|
120
|
+
status: "200";
|
|
121
|
+
body: SupportedFileFormatsOutput;
|
|
122
|
+
}
|
|
123
|
+
export interface GetSupportedFormatsDefaultHeaders {
|
|
124
|
+
/** String error code indicating what went wrong. */
|
|
125
|
+
"x-ms-error-code"?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface GetSupportedFormatsDefaultResponse extends HttpResponse {
|
|
128
|
+
status: string;
|
|
129
|
+
body: ErrorResponse;
|
|
130
|
+
headers: RawHttpHeaders & GetSupportedFormatsDefaultHeaders;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/responses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EACV,w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