@azure-rest/ai-translation-document 1.0.0-beta.2 → 2.0.0-alpha.20240911.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/CHANGELOG.md CHANGED
@@ -1,4 +1,19 @@
1
1
  # Release History
2
+
3
+ ## 2.0.0-beta.1 (Unreleased)
4
+
5
+ ### Features Added
6
+
7
+ ### Breaking Changes
8
+
9
+ ### Bugs Fixed
10
+
11
+ ### Other Changes
12
+
13
+ ## 2.0.0 (Unreleased)
14
+ ### Other Changes
15
+ This is a GA release. No new features added.
16
+
2
17
  ## 1.0.0-beta.2 (2024-07-01)
3
18
 
4
19
  ### Other Changes
package/README.md CHANGED
@@ -53,6 +53,11 @@ npm install @azure-rest/ai-translation-document
53
53
 
54
54
  You can create Translator resource following [Create a Translator resource][translator_resource_create].
55
55
 
56
+ #### Setup Azure Blob Storage Account
57
+ For more information about creating an Azure Blob Storage account see [here][azure_blob_storage_account]. For creating containers for your source and target files see [here][container]. Make sure to authorize your Translation resource storage access, more info [here][storage_container_authorization].
58
+
59
+ When "Allow Storage Account Key Access" is disabled on the storage account , Managed Identity is enabled on the Translator resource and it is assigned the role "Storage Blob Data Contributor" on the storage account, then you can use the container URLs directly and no SAS URIs will be need to be generated.
60
+
56
61
  ### Create a `DocumentTranslationClient` using an endpoint URL and API key `KeyCredential`
57
62
 
58
63
  Once you have the value for API key, create a credential
@@ -344,3 +349,6 @@ Please refer to the service documentation for a conceptual discussion of [langua
344
349
  [translator_resource_create]: https://learn.microsoft.com/azure/cognitive-services/Translator/create-translator-resource
345
350
  [documentTranslationClient_class]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/translation/ai-translation-document-rest/src/documentTranslationClient.ts
346
351
  [pre_requisities]: https://learn.microsoft.com/azure/ai-services/translator/document-translation/how-to-guides/use-rest-api-programmatically?tabs=csharp#prerequisites
352
+ [azure_blob_storage_account]: https://ms.portal.azure.com/#create/Microsoft.StorageAccount
353
+ [container]: https://learn.microsoft.com/azure/storage/blobs/storage-quickstart-blobs-portal#create-a-container
354
+ [storage_container_authorization]: https://learn.microsoft.com/azure/ai-services/translator/document-translation/quickstarts/client-library-sdks?tabs=dotnet&pivots=programming-language-csharp#storage-container-authorization
package/dist/index.js CHANGED
@@ -2,29 +2,31 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var tslib = require('tslib');
5
6
  var coreClient = require('@azure-rest/core-client');
6
7
  var logger$1 = require('@azure/logger');
7
8
  var corePaging = require('@azure/core-paging');
8
9
  var coreLro = require('@azure/core-lro');
9
- var coreRestPipeline = require('@azure/core-rest-pipeline');
10
10
 
11
+ // Copyright (c) Microsoft Corporation.
12
+ // Licensed under the MIT License.
11
13
  // Copyright (c) Microsoft Corporation.
12
14
  // Licensed under the MIT license.
13
15
  const logger = logger$1.createClientLogger("ai-translation-document");
14
16
 
15
17
  // Copyright (c) Microsoft Corporation.
16
- // Licensed under the MIT license.
18
+ // Licensed under the MIT License.
17
19
  /**
18
20
  * Initialize a new instance of `DocumentTranslationClient`
19
21
  * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
20
22
  * @param credentials - uniquely identify client credential
21
23
  * @param options - the parameter for all optional parameters
22
24
  */
23
- function createClient(endpointParam, credentials, options = {}) {
24
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
25
- const endpointUrl = (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUrl) !== null && _b !== void 0 ? _b : `${endpointParam}/translator`;
26
- options.apiVersion = (_c = options.apiVersion) !== null && _c !== void 0 ? _c : "2024-05-01";
27
- const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;
25
+ function createClient(endpointParam, credentials, _a = {}) {
26
+ var _b, _c, _d, _e, _f, _g, _h, _j;
27
+ var { apiVersion = "2024-05-01" } = _a, options = tslib.__rest(_a, ["apiVersion"]);
28
+ const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `${endpointParam}/translator`;
29
+ const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
28
30
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
29
31
  ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
30
32
  : `${userAgentInfo}`;
@@ -37,11 +39,24 @@ function createClient(endpointParam, credentials, options = {}) {
37
39
  apiKeyHeaderName: (_j = (_h = options.credentials) === null || _h === void 0 ? void 0 : _h.apiKeyHeaderName) !== null && _j !== void 0 ? _j : "Ocp-Apim-Subscription-Key",
38
40
  } });
39
41
  const client = coreClient.getClient(endpointUrl, credentials, options);
42
+ client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
43
+ client.pipeline.addPolicy({
44
+ name: "ClientApiVersionPolicy",
45
+ sendRequest: (req, next) => {
46
+ // Use the apiVersion defined in request url directly
47
+ // Append one if there is no apiVersion and we have one at client options
48
+ const url = new URL(req.url);
49
+ if (!url.searchParams.get("api-version") && apiVersion) {
50
+ req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
51
+ }
52
+ return next(req);
53
+ },
54
+ });
40
55
  return client;
41
56
  }
42
57
 
43
58
  // Copyright (c) Microsoft Corporation.
44
- // Licensed under the MIT license.
59
+ // Licensed under the MIT License.
45
60
  const responseMap = {
46
61
  "POST /document:translate": ["200"],
47
62
  "GET /document/batches": ["200"],
@@ -117,6 +132,8 @@ function getPathFromMapKey(mapKey) {
117
132
  return mapKey.slice(pathStart);
118
133
  }
119
134
 
135
+ // Copyright (c) Microsoft Corporation.
136
+ // Licensed under the MIT License.
120
137
  // Copyright (c) Microsoft Corporation.
121
138
  // Licensed under the MIT license.
122
139
  /**
@@ -186,7 +203,7 @@ function checkPagingRequest(response) {
186
203
  }
187
204
 
188
205
  // Copyright (c) Microsoft Corporation.
189
- // Licensed under the MIT license.
206
+ // Licensed under the MIT License.
190
207
  async function getLongRunningPoller(client, initialResponse, options = {}) {
191
208
  var _a;
192
209
  const abortController = new AbortController();
@@ -197,7 +214,7 @@ async function getLongRunningPoller(client, initialResponse, options = {}) {
197
214
  // response we were provided.
198
215
  return getLroResponse(initialResponse);
199
216
  },
200
- sendPollRequest: async (path, sendPollRequestOptions) => {
217
+ sendPollRequest: async (path, pollOptions) => {
201
218
  // This is the callback that is going to be called to poll the service
202
219
  // to get the latest status. We use the client provided and the polling path
203
220
  // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
@@ -205,7 +222,7 @@ async function getLongRunningPoller(client, initialResponse, options = {}) {
205
222
  function abortListener() {
206
223
  abortController.abort();
207
224
  }
208
- const inputAbortSignal = sendPollRequestOptions === null || sendPollRequestOptions === void 0 ? void 0 : sendPollRequestOptions.abortSignal;
225
+ const inputAbortSignal = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal;
209
226
  const abortSignal = abortController.signal;
210
227
  if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
211
228
  abortController.abort();
@@ -236,7 +253,7 @@ async function getLongRunningPoller(client, initialResponse, options = {}) {
236
253
  return httpPoller.isDone;
237
254
  },
238
255
  isStopped() {
239
- return httpPoller.isStopped;
256
+ return abortController.signal.aborted;
240
257
  },
241
258
  getOperationState() {
242
259
  if (!httpPoller.operationState) {
@@ -281,17 +298,11 @@ function getLroResponse(response) {
281
298
  };
282
299
  }
283
300
 
301
+ // Copyright (c) Microsoft Corporation.
302
+ // Licensed under the MIT License.
284
303
  // Copyright (c) Microsoft Corporation.
285
304
  // Licensed under the MIT license.
286
305
 
287
- Object.defineProperty(exports, "createFile", {
288
- enumerable: true,
289
- get: function () { return coreRestPipeline.createFile; }
290
- });
291
- Object.defineProperty(exports, "createFileFromStream", {
292
- enumerable: true,
293
- get: function () { return coreRestPipeline.createFileFromStream; }
294
- });
295
306
  exports.default = createClient;
296
307
  exports.getLongRunningPoller = getLongRunningPoller;
297
308
  exports.isUnexpected = isUnexpected;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/documentTranslationClient.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n options.apiVersion = options.apiVersion ?? \"2024-05-01\";\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationLogicalResponse,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /document:translate\": [\"200\"],\n \"GET /document/batches\": [\"200\"],\n \"POST /document/batches\": [\"202\"],\n \"GET /document/batches/{id}/documents/{documentId}\": [\"200\"],\n \"GET /document/batches/{id}\": [\"200\"],\n \"DELETE /document/batches/{id}\": [\"200\"],\n \"GET /document/batches/{id}/documents\": [\"200\"],\n \"GET /document/formats\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DocumentTranslate200Response | DocumentTranslateDefaultResponse,\n): response is DocumentTranslateDefaultResponse;\nexport function isUnexpected(\n response:\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse,\n): response is StartTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse,\n): response is GetTranslationsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentStatus200Response | GetDocumentStatusDefaultResponse,\n): response is GetDocumentStatusDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationStatus200Response | GetTranslationStatusDefaultResponse,\n): response is GetTranslationStatusDefaultResponse;\nexport function isUnexpected(\n response: CancelTranslation200Response | CancelTranslationDefaultResponse,\n): response is CancelTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse,\n): response is GetDocumentsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse,\n): response is GetSupportedFormatsDefaultResponse;\nexport function isUnexpected(\n response:\n | DocumentTranslate200Response\n | DocumentTranslateDefaultResponse\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatus200Response\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatus200Response\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatus200Response\n | GetTranslationStatusDefaultResponse\n | CancelTranslation200Response\n | CancelTranslationDefaultResponse\n | GetDocumentsStatus200Response\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormats200Response\n | GetSupportedFormatsDefaultResponse,\n): response is\n | DocumentTranslateDefaultResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatusDefaultResponse\n | CancelTranslationDefaultResponse\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormatsDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// 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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n LongRunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\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 true if the poller is stopped.\n */\n isStopped(): 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/**\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: LongRunningOperation<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, sendPollRequestOptions?: { 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 = sendPollRequestOptions?.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 httpPoller.isStopped;\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\nexport {\n createFile,\n createFileFromStream,\n type CreateFileOptions,\n type CreateFileFromStreamOptions,\n} from \"@azure/core-rest-pipeline\";\n\nexport default DocumentTranslationClient;\n"],"names":["createClientLogger","getClient","getPagedAsyncIterator","createRestError","createHttpPoller"],"mappings":";;;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,yBAAyB,CAAC;;ACJnE;AACA;AAOA;;;;;AAKG;AACW,SAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,OAAA,GAAyB,EAAE,EAAA;;AAE3B,IAAA,MAAM,WAAW,GAAG,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,QAAQ,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAG,EAAA,aAAa,aAAa,CAAC;IACzF,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,YAAY,CAAC;IACxD,MAAM,aAAa,GAAG,CAAA,kDAAA,CAAoD,CAAC;IAC3E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;AAChE,UAAE,CAAA,EAAG,aAAa,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,QAAQ,GAAA;AACN,YAAA,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;AAC9B,gBAAA,MAAM,IAAI,KAAK,CACb,4IAA4I,CAC7I,CAAC;aACH;YACD,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,UAAU,CAAC,cAAc;AACjC,aAAA,CAAC,CAAC;SACJ;QACD,WAAW,GAAA;YACT,eAAe,CAAC,KAAK,EAAE,CAAC;SACzB;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;AACF,IAAA,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;AAIG;AACH,SAAS,cAAc,CACrB,QAAiB,EAAA;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;KAC/F;IAED,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,kCACN,QAAQ,CAAA,EAAA,EACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EACpB,CAAA;KACF,CAAC;AACJ;;AC3MA;AACA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/documentTranslationClient.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface DocumentTranslationClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n { apiVersion = \"2024-05-01\", ...options }: DocumentTranslationClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationLogicalResponse,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /document:translate\": [\"200\"],\n \"GET /document/batches\": [\"200\"],\n \"POST /document/batches\": [\"202\"],\n \"GET /document/batches/{id}/documents/{documentId}\": [\"200\"],\n \"GET /document/batches/{id}\": [\"200\"],\n \"DELETE /document/batches/{id}\": [\"200\"],\n \"GET /document/batches/{id}/documents\": [\"200\"],\n \"GET /document/formats\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DocumentTranslate200Response | DocumentTranslateDefaultResponse,\n): response is DocumentTranslateDefaultResponse;\nexport function isUnexpected(\n response:\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse,\n): response is StartTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse,\n): response is GetTranslationsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentStatus200Response | GetDocumentStatusDefaultResponse,\n): response is GetDocumentStatusDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationStatus200Response | GetTranslationStatusDefaultResponse,\n): response is GetTranslationStatusDefaultResponse;\nexport function isUnexpected(\n response: CancelTranslation200Response | CancelTranslationDefaultResponse,\n): response is CancelTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse,\n): response is GetDocumentsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse,\n): response is GetSupportedFormatsDefaultResponse;\nexport function isUnexpected(\n response:\n | DocumentTranslate200Response\n | DocumentTranslateDefaultResponse\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatus200Response\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatus200Response\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatus200Response\n | GetTranslationStatusDefaultResponse\n | CancelTranslation200Response\n | CancelTranslationDefaultResponse\n | GetDocumentsStatus200Response\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormats200Response\n | GetSupportedFormatsDefaultResponse,\n): response is\n | DocumentTranslateDefaultResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatusDefaultResponse\n | CancelTranslationDefaultResponse\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormatsDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// 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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default DocumentTranslationClient;\n"],"names":["createClientLogger","__rest","getClient","getPagedAsyncIterator","createRestError","createHttpPoller"],"mappings":";;;;;;;;;;AAAA;AACA;AAEA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,yBAAyB,CAAC;;ACPnE;AACA;AAgBA;;;;;AAKG;AACW,SAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,EAAA,GAA8E,EAAE,EAAA;;QAAhF,EAAE,UAAU,GAAG,YAAY,EAAA,GAAA,EAAqD,EAAhD,OAAO,GAAAC,YAAA,CAAA,EAAA,EAAvC,cAAyC,CAAF,CAAA;AAEvC,IAAA,MAAM,WAAW,GAAG,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,QAAQ,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAG,EAAA,aAAa,aAAa,CAAC;IACzF,MAAM,aAAa,GAAG,CAAA,kDAAA,CAAoD,C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C,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;AACF,IAAA,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;AAIG;AACH,SAAS,cAAc,CACrB,QAAiB,EAAA;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;KAC/F;IAED,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,kCACN,QAAQ,CAAA,EAAA,EACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EACpB,CAAA;KACF,CAAC;AACJ;;AChNA;AACA;AAEA;AACA;;;;;;;"}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export {};
4
4
  //# sourceMappingURL=clientDefinitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslateParameters,\n StartTranslationParameters,\n GetTranslationsStatusParameters,\n GetDocumentStatusParameters,\n GetTranslationStatusParameters,\n CancelTranslationParameters,\n GetDocumentsStatusParameters,\n GetSupportedFormatsParameters,\n} from \"./parameters.js\";\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface DocumentTranslate {\n /** Use this API to submit a single translation request to the Document Translation Service. */\n post(\n options: DocumentTranslateParameters,\n ): StreamableMethod<DocumentTranslate200Response | DocumentTranslateDefaultResponse>;\n}\n\nexport interface StartTranslation {\n /**\n * Use this API to submit a bulk (batch) translation request to the Document\n * Translation service.\n * Each request can contain multiple documents and must\n * contain a source and destination container for each document.\n *\n * The\n * prefix and suffix filter (if supplied) are used to filter folders. The prefix\n * is applied to the subpath after the container name.\n *\n * Glossaries /\n * Translation memory can be included in the request and are applied by the\n * service when the document is translated.\n *\n * If the glossary is\n * invalid or unreachable during translation, an error is indicated in the\n * document status.\n * If a file with the same name already exists at the\n * destination, it will be overwritten. The targetUrl for each target language\n * must be unique.\n */\n post(\n options?: StartTranslationParameters,\n ): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;\n /**\n * Returns a list of batch requests submitted and the status for each\n * request.\n * This list only contains batch requests submitted by the user (based on\n * the resource).\n *\n * If the number of requests exceeds our paging limit,\n * server-side paging is used. Paginated responses indicate a partial result and\n * include a continuation token in the response.\n * The absence of a continuation\n * token means that no additional pages are available.\n *\n * top, skip\n * and maxpagesize query parameters can be used to specify a number of results to\n * return and an offset for the collection.\n *\n * top indicates the total\n * number of records the user wants to be returned across all pages.\n * skip\n * indicates the number of records to skip from the list of batches based on the\n * sorting method specified. By default, we sort by descending start\n * time.\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 * orderby query parameter can be used to sort the returned list (ex\n * \"orderby=createdDateTimeUtc asc\" or \"orderby=createdDateTimeUtc\n * desc\").\n * The default sorting is descending by createdDateTimeUtc.\n * Some query\n * parameters can be used to filter the returned list (ex:\n * \"status=Succeeded,Cancelled\") will only return succeeded and cancelled\n * operations.\n * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used\n * combined or separately to specify a range of datetime to filter the returned\n * list by.\n * The supported filtering query parameters are (status, ids,\n * createdDateTimeUtcStart, createdDateTimeUtcEnd).\n *\n * The server honors\n * the values specified by the client. However, clients must be prepared to handle\n * responses that contain a different page size or contain a continuation token.\n *\n *\n * When both top and skip are included, the server should first apply\n * skip and then top on the collection.\n * Note: If the server can't honor top\n * and/or skip, the server must return an error to the client informing about it\n * instead of just ignoring the query options.\n * This reduces the risk of the client\n * making assumptions about the data returned.\n */\n get(\n options?: GetTranslationsStatusParameters,\n ): StreamableMethod<GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse>;\n}\n\nexport interface GetDocumentStatus {\n /**\n * Returns the translation status for a specific document based on the request Id\n * and document Id.\n */\n get(\n options?: GetDocumentStatusParameters,\n ): StreamableMethod<GetDocumentStatus200Response | GetDocumentStatusDefaultResponse>;\n}\n\nexport interface GetTranslationStatus {\n /**\n * Returns the status for a document translation request.\n * The status includes the\n * overall request status, as well as the status for documents that are being\n * translated as part of that request.\n */\n get(\n options?: GetTranslationStatusParameters,\n ): StreamableMethod<GetTranslationStatus200Response | GetTranslationStatusDefaultResponse>;\n /**\n * Cancel a currently processing or queued translation.\n * A translation will not be\n * cancelled if it is already completed or failed or cancelling. A bad request\n * will be returned.\n * All documents that have completed translation will not be\n * cancelled and will be charged.\n * All pending documents will be cancelled if\n * possible.\n */\n delete(\n options?: CancelTranslationParameters,\n ): StreamableMethod<CancelTranslation200Response | CancelTranslationDefaultResponse>;\n}\n\nexport interface GetDocumentsStatus {\n /**\n * Returns the status for all documents in a batch document translation request.\n *\n *\n * If the number of documents in the response exceeds our paging limit,\n * server-side paging is used.\n * Paginated responses indicate a partial result and\n * include a continuation token in the response. The absence of a continuation\n * token means that no additional pages are available.\n *\n * top, skip\n * and maxpagesize query parameters can be used to specify a number of results to\n * return and an offset for the collection.\n *\n * top indicates the total\n * number of records the user wants to be returned across all pages.\n * skip\n * indicates the number of records to skip from the list of document status held\n * by the server based on the sorting method specified. By default, we sort by\n * descending start time.\n * maxpagesize is the maximum items returned in a page.\n * If more items are requested via top (or top is not specified and there are\n * more items to be returned), @nextLink will contain the link to the next page.\n *\n *\n * orderby query parameter can be used to sort the returned list (ex\n * \"orderby=createdDateTimeUtc asc\" or \"orderby=createdDateTimeUtc\n * desc\").\n * The default sorting is descending by createdDateTimeUtc.\n * Some query\n * parameters can be used to filter the returned list (ex:\n * \"status=Succeeded,Cancelled\") will only return succeeded and cancelled\n * documents.\n * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used\n * combined or separately to specify a range of datetime to filter the returned\n * list by.\n * The supported filtering query parameters are (status, ids,\n * createdDateTimeUtcStart, createdDateTimeUtcEnd).\n *\n * When both top\n * and skip are included, the server should first apply skip and then top on\n * the collection.\n * Note: If the server can't honor top and/or skip, the server\n * must return an error to the client informing about it instead of just ignoring\n * the query options.\n * This reduces the risk of the client making assumptions about\n * the data returned.\n */\n get(\n options?: GetDocumentsStatusParameters,\n ): StreamableMethod<GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse>;\n}\n\nexport interface GetSupportedFormats {\n /**\n * The list of supported formats supported by the Document Translation\n * service.\n * The list includes the common file extension, as well as the\n * content-type if using the upload API.\n */\n get(\n options?: GetSupportedFormatsParameters,\n ): StreamableMethod<GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/document:translate' has methods for the following verbs: post */\n (path: \"/document:translate\"): DocumentTranslate;\n /** Resource for '/document/batches' has methods for the following verbs: post, get */\n (path: \"/document/batches\"): StartTranslation;\n /** Resource for '/document/batches/\\{id\\}/documents/\\{documentId\\}' has methods for the following verbs: get */\n (\n path: \"/document/batches/{id}/documents/{documentId}\",\n id: string,\n documentId: string,\n ): GetDocumentStatus;\n /** Resource for '/document/batches/\\{id\\}' has methods for the following verbs: get, delete */\n (path: \"/document/batches/{id}\", id: string): GetTranslationStatus;\n /** Resource for '/document/batches/\\{id\\}/documents' has methods for the following verbs: get */\n (path: \"/document/batches/{id}/documents\", id: string): GetDocumentsStatus;\n /** Resource for '/document/formats' has methods for the following verbs: get */\n (path: \"/document/formats\"): GetSupportedFormats;\n}\n\nexport type DocumentTranslationClient = Client & {\n path: Routes;\n};\n"]}
1
+ {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslateParameters,\n StartTranslationParameters,\n GetTranslationsStatusParameters,\n GetDocumentStatusParameters,\n GetTranslationStatusParameters,\n CancelTranslationParameters,\n GetDocumentsStatusParameters,\n GetSupportedFormatsParameters,\n} from \"./parameters.js\";\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface DocumentTranslate {\n /** Use this API to submit a single translation request to the Document Translation Service. */\n post(\n options: DocumentTranslateParameters,\n ): StreamableMethod<DocumentTranslate200Response | DocumentTranslateDefaultResponse>;\n}\n\nexport interface StartTranslation {\n /**\n * Use this API to submit a bulk (batch) translation request to the Document\n * Translation service.\n * Each request can contain multiple documents and must\n * contain a source and destination container for each document.\n *\n * The\n * prefix and suffix filter (if supplied) are used to filter folders. The prefix\n * is applied to the subpath after the container name.\n *\n * Glossaries /\n * Translation memory can be included in the request and are applied by the\n * service when the document is translated.\n *\n * If the glossary is\n * invalid or unreachable during translation, an error is indicated in the\n * document status.\n * If a file with the same name already exists at the\n * destination, it will be overwritten. The targetUrl for each target language\n * must be unique.\n */\n post(\n options: StartTranslationParameters,\n ): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;\n /**\n * Returns a list of batch requests submitted and the status for each\n * request.\n * This list only contains batch requests submitted by the user (based on\n * the resource).\n *\n * If the number of requests exceeds our paging limit,\n * server-side paging is used. Paginated responses indicate a partial result and\n * include a continuation token in the response.\n * The absence of a continuation\n * token means that no additional pages are available.\n *\n * top, skip\n * and maxpagesize query parameters can be used to specify a number of results to\n * return and an offset for the collection.\n *\n * top indicates the total\n * number of records the user wants to be returned across all pages.\n * skip\n * indicates the number of records to skip from the list of batches based on the\n * sorting method specified. By default, we sort by descending start\n * time.\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 * orderby query parameter can be used to sort the returned list (ex\n * \"orderby=createdDateTimeUtc asc\" or \"orderby=createdDateTimeUtc\n * desc\").\n * The default sorting is descending by createdDateTimeUtc.\n * Some query\n * parameters can be used to filter the returned list (ex:\n * \"status=Succeeded,Cancelled\") will only return succeeded and cancelled\n * operations.\n * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used\n * combined or separately to specify a range of datetime to filter the returned\n * list by.\n * The supported filtering query parameters are (status, ids,\n * createdDateTimeUtcStart, createdDateTimeUtcEnd).\n *\n * The server honors\n * the values specified by the client. However, clients must be prepared to handle\n * responses that contain a different page size or contain a continuation token.\n *\n *\n * When both top and skip are included, the server should first apply\n * skip and then top on the collection.\n * Note: If the server can't honor top\n * and/or skip, the server must return an error to the client informing about it\n * instead of just ignoring the query options.\n * This reduces the risk of the client\n * making assumptions about the data returned.\n */\n get(\n options?: GetTranslationsStatusParameters,\n ): StreamableMethod<GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse>;\n}\n\nexport interface GetDocumentStatus {\n /**\n * Returns the translation status for a specific document based on the request Id\n * and document Id.\n */\n get(\n options?: GetDocumentStatusParameters,\n ): StreamableMethod<GetDocumentStatus200Response | GetDocumentStatusDefaultResponse>;\n}\n\nexport interface GetTranslationStatus {\n /**\n * Returns the status for a document translation request.\n * The status includes the\n * overall request status, as well as the status for documents that are being\n * translated as part of that request.\n */\n get(\n options?: GetTranslationStatusParameters,\n ): StreamableMethod<GetTranslationStatus200Response | GetTranslationStatusDefaultResponse>;\n /**\n * Cancel a currently processing or queued translation.\n * A translation will not be\n * cancelled if it is already completed or failed or cancelling. A bad request\n * will be returned.\n * All documents that have completed translation will not be\n * cancelled and will be charged.\n * All pending documents will be cancelled if\n * possible.\n */\n delete(\n options?: CancelTranslationParameters,\n ): StreamableMethod<CancelTranslation200Response | CancelTranslationDefaultResponse>;\n}\n\nexport interface GetDocumentsStatus {\n /**\n * Returns the status for all documents in a batch document translation request.\n *\n *\n * If the number of documents in the response exceeds our paging limit,\n * server-side paging is used.\n * Paginated responses indicate a partial result and\n * include a continuation token in the response. The absence of a continuation\n * token means that no additional pages are available.\n *\n * top, skip\n * and maxpagesize query parameters can be used to specify a number of results to\n * return and an offset for the collection.\n *\n * top indicates the total\n * number of records the user wants to be returned across all pages.\n * skip\n * indicates the number of records to skip from the list of document status held\n * by the server based on the sorting method specified. By default, we sort by\n * descending start time.\n * maxpagesize is the maximum items returned in a page.\n * If more items are requested via top (or top is not specified and there are\n * more items to be returned), @nextLink will contain the link to the next page.\n *\n *\n * orderby query parameter can be used to sort the returned list (ex\n * \"orderby=createdDateTimeUtc asc\" or \"orderby=createdDateTimeUtc\n * desc\").\n * The default sorting is descending by createdDateTimeUtc.\n * Some query\n * parameters can be used to filter the returned list (ex:\n * \"status=Succeeded,Cancelled\") will only return succeeded and cancelled\n * documents.\n * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used\n * combined or separately to specify a range of datetime to filter the returned\n * list by.\n * The supported filtering query parameters are (status, ids,\n * createdDateTimeUtcStart, createdDateTimeUtcEnd).\n *\n * When both top\n * and skip are included, the server should first apply skip and then top on\n * the collection.\n * Note: If the server can't honor top and/or skip, the server\n * must return an error to the client informing about it instead of just ignoring\n * the query options.\n * This reduces the risk of the client making assumptions about\n * the data returned.\n */\n get(\n options?: GetDocumentsStatusParameters,\n ): StreamableMethod<GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse>;\n}\n\nexport interface GetSupportedFormats {\n /**\n * The list of supported formats supported by the Document Translation\n * service.\n * The list includes the common file extension, as well as the\n * content-type if using the upload API.\n */\n get(\n options?: GetSupportedFormatsParameters,\n ): StreamableMethod<GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/document:translate' has methods for the following verbs: post */\n (path: \"/document:translate\"): DocumentTranslate;\n /** Resource for '/document/batches' has methods for the following verbs: post, get */\n (path: \"/document/batches\"): StartTranslation;\n /** Resource for '/document/batches/\\{id\\}/documents/\\{documentId\\}' has methods for the following verbs: get */\n (\n path: \"/document/batches/{id}/documents/{documentId}\",\n id: string,\n documentId: string,\n ): GetDocumentStatus;\n /** Resource for '/document/batches/\\{id\\}' has methods for the following verbs: get, delete */\n (path: \"/document/batches/{id}\", id: string): GetTranslationStatus;\n /** Resource for '/document/batches/\\{id\\}/documents' has methods for the following verbs: get */\n (path: \"/document/batches/{id}/documents\", id: string): GetDocumentsStatus;\n /** Resource for '/document/formats' has methods for the following verbs: get */\n (path: \"/document/formats\"): GetSupportedFormats;\n}\n\nexport type DocumentTranslationClient = Client & {\n path: Routes;\n};\n"]}
@@ -1,4 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { __rest } from "tslib";
4
+ // Copyright (c) Microsoft Corporation.
2
5
  // Licensed under the MIT license.
3
6
  import { getClient } from "@azure-rest/core-client";
4
7
  import { logger } from "./logger";
@@ -8,11 +11,11 @@ import { logger } from "./logger";
8
11
  * @param credentials - uniquely identify client credential
9
12
  * @param options - the parameter for all optional parameters
10
13
  */
11
- export default function createClient(endpointParam, credentials, options = {}) {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
13
- const endpointUrl = (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUrl) !== null && _b !== void 0 ? _b : `${endpointParam}/translator`;
14
- options.apiVersion = (_c = options.apiVersion) !== null && _c !== void 0 ? _c : "2024-05-01";
15
- const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;
14
+ export default function createClient(endpointParam, credentials, _a = {}) {
15
+ var _b, _c, _d, _e, _f, _g, _h, _j;
16
+ var { apiVersion = "2024-05-01" } = _a, options = __rest(_a, ["apiVersion"]);
17
+ const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `${endpointParam}/translator`;
18
+ const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
16
19
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
17
20
  ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
18
21
  : `${userAgentInfo}`;
@@ -25,6 +28,19 @@ export default function createClient(endpointParam, credentials, options = {}) {
25
28
  apiKeyHeaderName: (_j = (_h = options.credentials) === null || _h === void 0 ? void 0 : _h.apiKeyHeaderName) !== null && _j !== void 0 ? _j : "Ocp-Apim-Subscription-Key",
26
29
  } });
27
30
  const client = getClient(endpointUrl, credentials, options);
31
+ client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
32
+ client.pipeline.addPolicy({
33
+ name: "ClientApiVersionPolicy",
34
+ sendRequest: (req, next) => {
35
+ // Use the apiVersion defined in request url directly
36
+ // Append one if there is no apiVersion and we have one at client options
37
+ const url = new URL(req.url);
38
+ if (!url.searchParams.get("api-version") && apiVersion) {
39
+ req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
40
+ }
41
+ return next(req);
42
+ },
43
+ });
28
44
  return client;
29
45
  }
30
46
  //# sourceMappingURL=documentTranslationClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentTranslationClient.js","sourceRoot":"","sources":["../../src/documentTranslationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,UAAyB,EAAE;;IAE3B,MAAM,WAAW,GAAG,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,GAAG,aAAa,aAAa,CAAC;IACzF,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,YAAY,CAAC;IACxD,MAAM,aAAa,GAAG,oDAAoD,CAAC;IAC3E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,EACD,cAAc,EAAE;YACd,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI;SACtD,EACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,8CAA8C,CAAC;YACvF,gBAAgB,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,gBAAgB,mCAAI,2BAA2B;SACvF,GACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAA8B,CAAC;IAEzF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n options.apiVersion = options.apiVersion ?? \"2024-05-01\";\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n return client;\n}\n"]}
1
+ {"version":3,"file":"documentTranslationClient.js","sourceRoot":"","sources":["../../src/documentTranslationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUlC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,KAA8E,EAAE;;QAAhF,EAAE,UAAU,GAAG,YAAY,OAAqD,EAAhD,OAAO,cAAvC,cAAyC,CAAF;IAEvC,MAAM,WAAW,GAAG,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,GAAG,aAAa,aAAa,CAAC;IACzF,MAAM,aAAa,GAAG,oDAAoD,CAAC;IAC3E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,EACD,cAAc,EAAE;YACd,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI;SACtD,EACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,8CAA8C,CAAC;YACvF,gBAAgB,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,gBAAgB,mCAAI,2BAA2B;SACvF,GACF,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAA8B,CAAC;IAEzF,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface DocumentTranslationClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n { apiVersion = \"2024-05-01\", ...options }: DocumentTranslationClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ // Copyright (c) Microsoft Corporation.
2
4
  // Licensed under the MIT license.
3
5
  import DocumentTranslationClient from "./documentTranslationClient";
4
6
  export * from "./documentTranslationClient";
@@ -10,6 +12,5 @@ export * from "./models";
10
12
  export * from "./outputModels";
11
13
  export * from "./paginateHelper";
12
14
  export * from "./pollingHelper";
13
- export { createFile, createFileFromStream, } from "@azure/core-rest-pipeline";
14
15
  export default DocumentTranslationClient;
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,UAAU,EACV,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AAEnC,eAAe,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\nexport {\n createFile,\n createFileFromStream,\n type CreateFileOptions,\n type CreateFileFromStreamOptions,\n} from \"@azure/core-rest-pipeline\";\n\nexport default DocumentTranslationClient;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,eAAe,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default DocumentTranslationClient;\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  const responseMap = {
4
4
  "POST /document:translate": ["200"],
5
5
  "GET /document/batches": ["200"],
@@ -1 +1 @@
1
- {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsBlC,MAAM,WAAW,GAA6B;IAC5C,0BAA0B,EAAE,CAAC,KAAK,CAAC;IACnC,uBAAuB,EAAE,CAAC,KAAK,CAAC;IAChC,wBAAwB,EAAE,CAAC,KAAK,CAAC;IACjC,mDAAmD,EAAE,CAAC,KAAK,CAAC;IAC5D,4BAA4B,EAAE,CAAC,KAAK,CAAC;IACrC,+BAA+B,EAAE,CAAC,KAAK,CAAC;IACxC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,uBAAuB,EAAE,CAAC,KAAK,CAAC;CACjC,CAAC;AA6BF,MAAM,UAAU,YAAY,CAC1B,QAiBsC;IAUtC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,OAAO,CAAC,GAA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AAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationLogicalResponse,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /document:translate\": [\"200\"],\n \"GET /document/batches\": [\"200\"],\n \"POST /document/batches\": [\"202\"],\n \"GET /document/batches/{id}/documents/{documentId}\": [\"200\"],\n \"GET /document/batches/{id}\": [\"200\"],\n \"DELETE /document/batches/{id}\": [\"200\"],\n \"GET /document/batches/{id}/documents\": [\"200\"],\n \"GET /document/formats\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DocumentTranslate200Response | DocumentTranslateDefaultResponse,\n): response is DocumentTranslateDefaultResponse;\nexport function isUnexpected(\n response:\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse,\n): response is StartTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse,\n): response is GetTranslationsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentStatus200Response | GetDocumentStatusDefaultResponse,\n): response is GetDocumentStatusDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationStatus200Response | GetTranslationStatusDefaultResponse,\n): response is GetTranslationStatusDefaultResponse;\nexport function isUnexpected(\n response: CancelTranslation200Response | CancelTranslationDefaultResponse,\n): response is CancelTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse,\n): response is GetDocumentsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse,\n): response is GetSupportedFormatsDefaultResponse;\nexport function isUnexpected(\n response:\n | DocumentTranslate200Response\n | DocumentTranslateDefaultResponse\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatus200Response\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatus200Response\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatus200Response\n | GetTranslationStatusDefaultResponse\n | CancelTranslation200Response\n | CancelTranslationDefaultResponse\n | GetDocumentsStatus200Response\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormats200Response\n | GetSupportedFormatsDefaultResponse,\n): response is\n | DocumentTranslateDefaultResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatusDefaultResponse\n | CancelTranslationDefaultResponse\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormatsDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyBlC,MAAM,WAAW,GAA6B;IAC5C,0BAA0B,EAAE,CAAC,KAAK,CAAC;IACnC,uBAAuB,EAAE,CAAC,KAAK,CAAC;IAChC,wBAAwB,EAAE,CAAC,KAAK,CAAC;IACjC,mDAAmD,EAAE,CAAC,KAAK,CAAC;IAC5D,4BAA4B,EAAE,CAAC,KAAK,CAAC;IACrC,+BAA+B,EAAE,CAAC,KAAK,CAAC;IACxC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,uBAAuB,EAAE,CAAC,KAAK,CAAC;CACjC,CAAC;AA6BF,MAAM,UAAU,YAAY,CAC1B,QAiBsC;IAUtC,MAAM,WAAW,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AK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DocumentTranslate200Response,\n DocumentTranslateDefaultResponse,\n StartTranslation202Response,\n StartTranslationLogicalResponse,\n StartTranslationDefaultResponse,\n GetTranslationsStatus200Response,\n GetTranslationsStatusDefaultResponse,\n GetDocumentStatus200Response,\n GetDocumentStatusDefaultResponse,\n GetTranslationStatus200Response,\n GetTranslationStatusDefaultResponse,\n CancelTranslation200Response,\n CancelTranslationDefaultResponse,\n GetDocumentsStatus200Response,\n GetDocumentsStatusDefaultResponse,\n GetSupportedFormats200Response,\n GetSupportedFormatsDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /document:translate\": [\"200\"],\n \"GET /document/batches\": [\"200\"],\n \"POST /document/batches\": [\"202\"],\n \"GET /document/batches/{id}/documents/{documentId}\": [\"200\"],\n \"GET /document/batches/{id}\": [\"200\"],\n \"DELETE /document/batches/{id}\": [\"200\"],\n \"GET /document/batches/{id}/documents\": [\"200\"],\n \"GET /document/formats\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DocumentTranslate200Response | DocumentTranslateDefaultResponse,\n): response is DocumentTranslateDefaultResponse;\nexport function isUnexpected(\n response:\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse,\n): response is StartTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse,\n): response is GetTranslationsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentStatus200Response | GetDocumentStatusDefaultResponse,\n): response is GetDocumentStatusDefaultResponse;\nexport function isUnexpected(\n response: GetTranslationStatus200Response | GetTranslationStatusDefaultResponse,\n): response is GetTranslationStatusDefaultResponse;\nexport function isUnexpected(\n response: CancelTranslation200Response | CancelTranslationDefaultResponse,\n): response is CancelTranslationDefaultResponse;\nexport function isUnexpected(\n response: GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse,\n): response is GetDocumentsStatusDefaultResponse;\nexport function isUnexpected(\n response: GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse,\n): response is GetSupportedFormatsDefaultResponse;\nexport function isUnexpected(\n response:\n | DocumentTranslate200Response\n | DocumentTranslateDefaultResponse\n | StartTranslation202Response\n | StartTranslationLogicalResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatus200Response\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatus200Response\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatus200Response\n | GetTranslationStatusDefaultResponse\n | CancelTranslation200Response\n | CancelTranslationDefaultResponse\n | GetDocumentsStatus200Response\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormats200Response\n | GetSupportedFormatsDefaultResponse,\n): response is\n | DocumentTranslateDefaultResponse\n | StartTranslationDefaultResponse\n | GetTranslationsStatusDefaultResponse\n | GetDocumentStatusDefaultResponse\n | GetTranslationStatusDefaultResponse\n | CancelTranslationDefaultResponse\n | GetDocumentsStatusDefaultResponse\n | GetSupportedFormatsDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ // Copyright (c) Microsoft Corporation.
2
4
  // Licensed under the MIT license.
3
5
  import { createClientLogger } from "@azure/logger";
4
6
  export const logger = createClientLogger("ai-translation-document");
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export {};
4
4
  //# sourceMappingURL=models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface DocumentTranslateContentDocumentPartDescriptor {\n name: \"document\";\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;\n filename?: string;\n contentType?: string;\n}\n\nexport interface DocumentTranslateContentGlossaryPartDescriptor {\n name: \"glossary\";\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;\n filename?: string;\n contentType?: string;\n}\n\n/** Translation job submission batch request */\nexport interface StartTranslationDetails {\n /** The input list of documents or folders containing documents */\n inputs: Array<BatchRequest>;\n}\n\n/** Definition for the input batch translation request */\nexport interface BatchRequest {\n /** Source of the input documents */\n source: SourceInput;\n /** Location of the destination for the output */\n targets: Array<TargetInput>;\n /** Storage type of the input documents source string */\n storageType?: StorageInputType;\n}\n\n/** Source of the input documents */\nexport interface SourceInput {\n /** Location of the folder / container or single file with your documents */\n sourceUrl: string;\n /** Document filter */\n filter?: DocumentFilter;\n /**\n * Language code\n * If none is specified, we will perform auto detect on the document\n */\n language?: string;\n /** Storage Source */\n storageSource?: StorageSource;\n}\n\n/** Document filter */\nexport interface DocumentFilter {\n /**\n * A case-sensitive prefix string to filter documents in the source path for\n * translation.\n * For example, when using a Azure storage blob Uri, use the prefix\n * to restrict sub folders for translation.\n */\n prefix?: string;\n /**\n * A case-sensitive suffix string to filter documents in the source path for\n * translation.\n * This is most often use for file extensions\n */\n suffix?: string;\n}\n\n/** Destination for the finished translated documents */\nexport interface TargetInput {\n /** Location of the folder / container with your documents */\n targetUrl: string;\n /** Category / custom system for translation request */\n category?: string;\n /** Target Language */\n language: string;\n /** List of Glossary */\n glossaries?: Array<Glossary>;\n /** Storage Source */\n storageSource?: StorageSource;\n}\n\n/** Glossary / translation memory for the request */\nexport interface Glossary {\n /**\n * Location of the glossary.\n * We will use the file extension to extract the\n * formatting if the format parameter is not supplied.\n *\n * If the translation\n * language pair is not present in the glossary, it will not be applied\n */\n glossaryUrl: string;\n /** Format */\n format: string;\n /** Optional Version. If not specified, default is used. */\n version?: string;\n /** Storage Source */\n storageSource?: StorageSource;\n}\n\n/** Document Translate Request Content */\nexport type DocumentTranslateContent =\n | FormData\n | Array<\n | DocumentTranslateContentDocumentPartDescriptor\n | DocumentTranslateContentGlossaryPartDescriptor\n >;\n/** Alias for StorageSource */\nexport type StorageSource = \"AzureBlob\" | string;\n/** Alias for StorageInputType */\nexport type StorageInputType = \"Folder\" | \"File\" | string;\n/** Alias for FileFormatType */\nexport type FileFormatType = \"document\" | \"glossary\" | string;\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface DocumentTranslateContentDocumentPartDescriptor {\n name: \"document\";\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;\n filename?: string;\n contentType?: string;\n}\n\nexport interface DocumentTranslateContentGlossaryPartDescriptor {\n name: \"glossary\";\n body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;\n filename?: string;\n contentType?: string;\n}\n\n/** Translation job submission batch request */\nexport interface StartTranslationDetails {\n /** The input list of documents or folders containing documents */\n inputs: Array<BatchRequest>;\n}\n\n/** Definition for the input batch translation request */\nexport interface BatchRequest {\n /** Source of the input documents */\n source: SourceInput;\n /** Location of the destination for the output */\n targets: Array<TargetInput>;\n /**\n * Storage type of the input documents source string\n *\n * Possible values: \"Folder\", \"File\"\n */\n storageType?: StorageInputType;\n}\n\n/** Source of the input documents */\nexport interface SourceInput {\n /** Location of the folder / container or single file with your documents */\n sourceUrl: string;\n /** Document filter */\n filter?: DocumentFilter;\n /**\n * Language code\n * If none is specified, we will perform auto detect on the document\n */\n language?: string;\n /**\n * Storage Source\n *\n * Possible values: \"AzureBlob\"\n */\n storageSource?: StorageSource;\n}\n\n/** Document filter */\nexport interface DocumentFilter {\n /**\n * A case-sensitive prefix string to filter documents in the source path for\n * translation.\n * For example, when using a Azure storage blob Uri, use the prefix\n * to restrict sub folders for translation.\n */\n prefix?: string;\n /**\n * A case-sensitive suffix string to filter documents in the source path for\n * translation.\n * This is most often use for file extensions\n */\n suffix?: string;\n}\n\n/** Destination for the finished translated documents */\nexport interface TargetInput {\n /** Location of the folder / container with your documents */\n targetUrl: string;\n /** Category / custom system for translation request */\n category?: string;\n /** Target Language */\n language: string;\n /** List of Glossary */\n glossaries?: Array<Glossary>;\n /**\n * Storage Source\n *\n * Possible values: \"AzureBlob\"\n */\n storageSource?: StorageSource;\n}\n\n/** Glossary / translation memory for the request */\nexport interface Glossary {\n /**\n * Location of the glossary.\n * We will use the file extension to extract the\n * formatting if the format parameter is not supplied.\n *\n * If the translation\n * language pair is not present in the glossary, it will not be applied\n */\n glossaryUrl: string;\n /** Format */\n format: string;\n /** Optional Version. If not specified, default is used. */\n version?: string;\n /**\n * Storage Source\n *\n * Possible values: \"AzureBlob\"\n */\n storageSource?: StorageSource;\n}\n\n/** Document Translate Request Content */\nexport type DocumentTranslateContent =\n | FormData\n | Array<\n | DocumentTranslateContentDocumentPartDescriptor\n | DocumentTranslateContentGlossaryPartDescriptor\n >;\n/** Alias for StorageSource */\nexport type StorageSource = string;\n/** Alias for StorageInputType */\nexport type StorageInputType = string;\n/** Alias for FileFormatType */\nexport type FileFormatType = string;\n"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export {};
4
4
  //# sourceMappingURL=outputModels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../src/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** Translation job Status Response */\nexport interface TranslationsStatusOutput {\n /** The summary status of individual operation */\n value: Array<TranslationStatusOutput>;\n /** Url for the next page. Null if no more pages available */\n nextLink?: string;\n}\n\n/** Translation job status response */\nexport interface TranslationStatusOutput {\n /** Id of the operation. */\n id: string;\n /** Operation created date time */\n createdDateTimeUtc: string;\n /** Date time in which the operation's status has been updated */\n lastActionDateTimeUtc: string;\n /** List of possible statuses for job or document */\n status: StatusOutput;\n /**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\n error?: TranslationErrorOutput;\n /** Status Summary */\n summary: StatusSummaryOutput;\n}\n\n/**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\nexport interface TranslationErrorOutput {\n /** Enums containing high level error codes. */\n code: TranslationErrorCodeOutput;\n /** Gets high level error message. */\n message: string;\n /**\n * Gets the source of the error.\n * For example it would be \"documents\" or\n * \"document id\" in case of invalid document.\n */\n readonly target?: string;\n /**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\n innerError?: InnerTranslationErrorOutput;\n}\n\n/**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\nexport interface InnerTranslationErrorOutput {\n /** Gets code error string. */\n code: string;\n /** Gets high level error message. */\n message: string;\n /**\n * Gets the source of the error.\n * For example it would be \"documents\" or\n * \"document id\" in case of invalid document.\n */\n readonly target?: string;\n /**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\n innerError?: InnerTranslationErrorOutput;\n}\n\n/** Status Summary */\nexport interface StatusSummaryOutput {\n /** Total count */\n total: number;\n /** Failed count */\n failed: number;\n /** Number of Success */\n success: number;\n /** Number of in progress */\n inProgress: number;\n /** Count of not yet started */\n notYetStarted: number;\n /** Number of cancelled */\n cancelled: number;\n /** Total characters charged by the API */\n totalCharacterCharged: number;\n}\n\n/** Document Status Response */\nexport interface DocumentStatusOutput {\n /** Location of the document or folder */\n path?: string;\n /** Location of the source document */\n sourcePath: string;\n /** Operation created date time */\n createdDateTimeUtc: string;\n /** Date time in which the operation's status has been updated */\n lastActionDateTimeUtc: string;\n /** List of possible statuses for job or document */\n status: StatusOutput;\n /** To language */\n to: string;\n /**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\n error?: TranslationErrorOutput;\n /** Progress of the translation if available */\n progress: number;\n /** Document Id */\n id: string;\n /** Character charged by the API */\n characterCharged?: number;\n}\n\n/** Documents Status Response */\nexport interface DocumentsStatusOutput {\n /** The detail status of individual documents */\n value: Array<DocumentStatusOutput>;\n /** Url for the next page. Null if no more pages available */\n nextLink?: string;\n}\n\n/** List of supported file formats */\nexport interface SupportedFileFormatsOutput {\n /** list of objects */\n value: Array<FileFormatOutput>;\n}\n\n/** File Format */\nexport interface FileFormatOutput {\n /** Name of the format */\n format: string;\n /** Supported file extension for this format */\n fileExtensions: string[];\n /** Supported Content-Types for this format */\n contentTypes: string[];\n /** Default version if none is specified */\n defaultVersion?: string;\n /** Supported Version */\n versions?: string[];\n /** Supported Type for this format */\n type?: string;\n}\n\n/** Alias for StatusOutput */\nexport type StatusOutput =\n | \"NotStarted\"\n | \"Running\"\n | \"Succeeded\"\n | \"Failed\"\n | \"Cancelled\"\n | \"Cancelling\"\n | \"ValidationFailed\"\n | string;\n/** Alias for TranslationErrorCodeOutput */\nexport type TranslationErrorCodeOutput =\n | \"InvalidRequest\"\n | \"InvalidArgument\"\n | \"InternalServerError\"\n | \"ServiceUnavailable\"\n | \"ResourceNotFound\"\n | \"Unauthorized\"\n | \"RequestRateTooHigh\"\n | string;\n"]}
1
+ {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../src/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** Translation job Status Response */\nexport interface TranslationsStatusOutput {\n /** The summary status of individual operation */\n value: Array<TranslationStatusOutput>;\n /** Url for the next page. Null if no more pages available */\n nextLink?: string;\n}\n\n/** Translation job status response */\nexport interface TranslationStatusOutput {\n /** Id of the operation. */\n id: string;\n /** Operation created date time */\n createdDateTimeUtc: string;\n /** Date time in which the operation's status has been updated */\n lastActionDateTimeUtc: string;\n /**\n * List of possible statuses for job or document\n *\n * Possible values: \"NotStarted\", \"Running\", \"Succeeded\", \"Failed\", \"Cancelled\", \"Cancelling\", \"ValidationFailed\"\n */\n status: StatusOutput;\n /**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\n error?: TranslationErrorOutput;\n /** Status Summary */\n summary: StatusSummaryOutput;\n}\n\n/**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\nexport interface TranslationErrorOutput {\n /**\n * Enums containing high level error codes.\n *\n * Possible values: \"InvalidRequest\", \"InvalidArgument\", \"InternalServerError\", \"ServiceUnavailable\", \"ResourceNotFound\", \"Unauthorized\", \"RequestRateTooHigh\"\n */\n code: TranslationErrorCodeOutput;\n /** Gets high level error message. */\n message: string;\n /**\n * Gets the source of the error.\n * For example it would be \"documents\" or\n * \"document id\" in case of invalid document.\n */\n readonly target?: string;\n /**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\n innerError?: InnerTranslationErrorOutput;\n}\n\n/**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\nexport interface InnerTranslationErrorOutput {\n /** Gets code error string. */\n code: string;\n /** Gets high level error message. */\n message: string;\n /**\n * Gets the source of the error.\n * For example it would be \"documents\" or\n * \"document id\" in case of invalid document.\n */\n readonly target?: string;\n /**\n * New Inner Error format which conforms to Cognitive Services API Guidelines\n * which is available at\n * https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\n * This\n * contains required properties ErrorCode, message and optional properties target,\n * details(key value pair), inner error(this can be nested).\n */\n innerError?: InnerTranslationErrorOutput;\n}\n\n/** Status Summary */\nexport interface StatusSummaryOutput {\n /** Total count */\n total: number;\n /** Failed count */\n failed: number;\n /** Number of Success */\n success: number;\n /** Number of in progress */\n inProgress: number;\n /** Count of not yet started */\n notYetStarted: number;\n /** Number of cancelled */\n cancelled: number;\n /** Total characters charged by the API */\n totalCharacterCharged: number;\n}\n\n/** Document Status Response */\nexport interface DocumentStatusOutput {\n /** Location of the document or folder */\n path?: string;\n /** Location of the source document */\n sourcePath: string;\n /** Operation created date time */\n createdDateTimeUtc: string;\n /** Date time in which the operation's status has been updated */\n lastActionDateTimeUtc: string;\n /**\n * List of possible statuses for job or document\n *\n * Possible values: \"NotStarted\", \"Running\", \"Succeeded\", \"Failed\", \"Cancelled\", \"Cancelling\", \"ValidationFailed\"\n */\n status: StatusOutput;\n /** To language */\n to: string;\n /**\n * This contains an outer error with error code, message, details, target and an\n * inner error with more descriptive details.\n */\n error?: TranslationErrorOutput;\n /** Progress of the translation if available */\n progress: number;\n /** Document Id */\n id: string;\n /** Character charged by the API */\n characterCharged?: number;\n}\n\n/** Documents Status Response */\nexport interface DocumentsStatusOutput {\n /** The detail status of individual documents */\n value: Array<DocumentStatusOutput>;\n /** Url for the next page. Null if no more pages available */\n nextLink?: string;\n}\n\n/** List of supported file formats */\nexport interface SupportedFileFormatsOutput {\n /** list of objects */\n value: Array<FileFormatOutput>;\n}\n\n/** File Format */\nexport interface FileFormatOutput {\n /** Name of the format */\n format: string;\n /** Supported file extension for this format */\n fileExtensions: string[];\n /** Supported Content-Types for this format */\n contentTypes: string[];\n /** Default version if none is specified */\n defaultVersion?: string;\n /** Supported Version */\n versions?: string[];\n /** Supported Type for this format */\n type?: string;\n}\n\n/** Alias for StatusOutput */\nexport type StatusOutput = string;\n/** Alias for TranslationErrorCodeOutput */\nexport type TranslationErrorCodeOutput = string;\n"]}
@@ -1,4 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ // Copyright (c) Microsoft Corporation.
2
4
  // Licensed under the MIT license.
3
5
  import { getPagedAsyncIterator } from "@azure/core-paging";
4
6
  import { createRestError } from "@azure-rest/core-client";
@@ -1 +1 @@
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;gB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L,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
+ {"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,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,YA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,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// 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,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export {};
4
4
  //# sourceMappingURL=parameters.js.map
@@ -1 +1 @@
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 { DocumentTranslateContent, StartTranslationDetails, FileFormatType } 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 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 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 /** the type of format like document or glossary */\n type?: FileFormatType;\n}\n\nexport interface GetSupportedFormatsQueryParam {\n queryParameters?: GetSupportedFormatsQueryParamProperties;\n}\n\nexport type GetSupportedFormatsParameters = GetSupportedFormatsQueryParam & RequestParameters;\n"]}
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\n// 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 { DocumentTranslateContent, StartTranslationDetails, FileFormatType } 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"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import { createHttpPoller, } from "@azure/core-lro";
4
4
  export async function getLongRunningPoller(client, initialResponse, options = {}) {
5
5
  var _a;
@@ -11,7 +11,7 @@ export async function getLongRunningPoller(client, initialResponse, options = {}
11
11
  // response we were provided.
12
12
  return getLroResponse(initialResponse);
13
13
  },
14
- sendPollRequest: async (path, sendPollRequestOptions) => {
14
+ sendPollRequest: async (path, pollOptions) => {
15
15
  // This is the callback that is going to be called to poll the service
16
16
  // to get the latest status. We use the client provided and the polling path
17
17
  // 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,7 +19,7 @@ export async function getLongRunningPoller(client, initialResponse, options = {}
19
19
  function abortListener() {
20
20
  abortController.abort();
21
21
  }
22
- const inputAbortSignal = sendPollRequestOptions === null || sendPollRequestOptions === void 0 ? void 0 : sendPollRequestOptions.abortSignal;
22
+ const inputAbortSignal = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal;
23
23
  const abortSignal = abortController.signal;
24
24
  if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
25
25
  abortController.abort();
@@ -50,7 +50,7 @@ export async function getLongRunningPoller(client, initialResponse, options = {}
50
50
  return httpPoller.isDone;
51
51
  },
52
52
  isStopped() {
53
- return httpPoller.isStopped;
53
+ return abortController.signal.aborted;
54
54
  },
55
55
  getOperationState() {
56
56
  if (!httpPoller.operationState) {
@@ -1 +1 @@
1
- {"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAML,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAqFzB,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,eAAwB,EACxB,UAAqE,EAAE;;IAEvE,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAkC;QAC5C,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,sGAAsG;YACtG,2FAA2F;YAC3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AQ,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 { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n LongRunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\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 true if the poller is stopped.\n */\n isStopped(): 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/**\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: LongRunningOperation<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, sendPollRequestOptions?: { 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 = sendPollRequestOptions?.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 httpPoller.isStopped;\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"]}
1
+ {"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAML,gBAAgB,GACjB,MAAM,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S;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.\n\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\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"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export {};
4
4
  //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
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, ErrorResponse } from \"@azure-rest/core-client\";\nimport {\n TranslationsStatusOutput,\n DocumentStatusOutput,\n TranslationStatusOutput,\n DocumentsStatusOutput,\n SupportedFileFormatsOutput,\n} from \"./outputModels.js\";\n\nexport interface DocumentTranslate200Headers {\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 DocumentTranslate200Response extends HttpResponse {\n status: \"200\";\n /** Value may contain any sequence of octets */\n body: Uint8Array;\n headers: RawHttpHeaders & DocumentTranslate200Headers;\n}\n\nexport interface DocumentTranslateDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface DocumentTranslateDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & DocumentTranslateDefaultHeaders;\n}\n\nexport interface StartTranslation202Headers {\n /** Link to the translation operation status */\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface StartTranslation202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & StartTranslation202Headers;\n}\n\nexport interface StartTranslationDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface StartTranslationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & StartTranslationDefaultHeaders;\n}\n\n/** The final response for long-running startTranslation operation */\nexport interface StartTranslationLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\n/** The request has succeeded. */\nexport interface GetTranslationsStatus200Response extends HttpResponse {\n status: \"200\";\n body: TranslationsStatusOutput;\n}\n\nexport interface GetTranslationsStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetTranslationsStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetTranslationsStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentStatus200Response extends HttpResponse {\n status: \"200\";\n body: DocumentStatusOutput;\n}\n\nexport interface GetDocumentStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetDocumentStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetDocumentStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetTranslationStatus200Response extends HttpResponse {\n status: \"200\";\n body: TranslationStatusOutput;\n}\n\nexport interface GetTranslationStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetTranslationStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetTranslationStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface CancelTranslation200Response extends HttpResponse {\n status: \"200\";\n body: TranslationStatusOutput;\n}\n\nexport interface CancelTranslationDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface CancelTranslationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & CancelTranslationDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentsStatus200Response extends HttpResponse {\n status: \"200\";\n body: DocumentsStatusOutput;\n}\n\nexport interface GetDocumentsStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetDocumentsStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetDocumentsStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetSupportedFormats200Response extends HttpResponse {\n status: \"200\";\n body: SupportedFileFormatsOutput;\n}\n\nexport interface GetSupportedFormatsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetSupportedFormatsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetSupportedFormatsDefaultHeaders;\n}\n"]}
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\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport { HttpResponse, ErrorResponse } from \"@azure-rest/core-client\";\nimport {\n TranslationsStatusOutput,\n DocumentStatusOutput,\n TranslationStatusOutput,\n DocumentsStatusOutput,\n SupportedFileFormatsOutput,\n} from \"./outputModels.js\";\n\nexport interface DocumentTranslate200Headers {\n /** An opaque, globally-unique, client-generated string identifier for the request. */\n \"x-ms-client-request-id\"?: string;\n /** response content type */\n \"content-type\": \"application/octet-stream\";\n}\n\n/** The request has succeeded. */\nexport interface DocumentTranslate200Response extends HttpResponse {\n status: \"200\";\n /** Value may contain any sequence of octets */\n body: Uint8Array;\n headers: RawHttpHeaders & DocumentTranslate200Headers;\n}\n\nexport interface DocumentTranslateDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface DocumentTranslateDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & DocumentTranslateDefaultHeaders;\n}\n\nexport interface StartTranslation202Headers {\n /** Link to the translation operation status */\n \"operation-location\": string;\n}\n\n/** The request has been accepted for processing, but processing has not yet completed. */\nexport interface StartTranslation202Response extends HttpResponse {\n status: \"202\";\n headers: RawHttpHeaders & StartTranslation202Headers;\n}\n\nexport interface StartTranslationDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface StartTranslationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & StartTranslationDefaultHeaders;\n}\n\n/** The final response for long-running startTranslation operation */\nexport interface StartTranslationLogicalResponse extends HttpResponse {\n status: \"200\";\n}\n\n/** The request has succeeded. */\nexport interface GetTranslationsStatus200Response extends HttpResponse {\n status: \"200\";\n body: TranslationsStatusOutput;\n}\n\nexport interface GetTranslationsStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetTranslationsStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetTranslationsStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentStatus200Response extends HttpResponse {\n status: \"200\";\n body: DocumentStatusOutput;\n}\n\nexport interface GetDocumentStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetDocumentStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetDocumentStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetTranslationStatus200Response extends HttpResponse {\n status: \"200\";\n body: TranslationStatusOutput;\n}\n\nexport interface GetTranslationStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetTranslationStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetTranslationStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface CancelTranslation200Response extends HttpResponse {\n status: \"200\";\n body: TranslationStatusOutput;\n}\n\nexport interface CancelTranslationDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface CancelTranslationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & CancelTranslationDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetDocumentsStatus200Response extends HttpResponse {\n status: \"200\";\n body: DocumentsStatusOutput;\n}\n\nexport interface GetDocumentsStatusDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetDocumentsStatusDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetDocumentsStatusDefaultHeaders;\n}\n\n/** The request has succeeded. */\nexport interface GetSupportedFormats200Response extends HttpResponse {\n status: \"200\";\n body: SupportedFileFormatsOutput;\n}\n\nexport interface GetSupportedFormatsDefaultHeaders {\n /** String error code indicating what went wrong. */\n \"x-ms-error-code\"?: string;\n}\n\nexport interface GetSupportedFormatsDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponse;\n headers: RawHttpHeaders & GetSupportedFormatsDefaultHeaders;\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "A generated SDK for DocumentTranslationClient.",
6
- "version": "1.0.0-beta.2",
6
+ "version": "2.0.0-alpha.20240911.1",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",
@@ -46,14 +46,14 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@azure/core-rest-pipeline": "^1.8.0",
49
+ "@azure/core-rest-pipeline": "^1.16.3",
50
50
  "@azure/logger": "^1.0.0",
51
- "@azure/core-paging": "^1.2.0",
51
+ "@azure/core-paging": "^1.5.0",
52
52
  "@azure-rest/core-client": "^2.0.0",
53
53
  "@azure/core-auth": "^1.6.0",
54
54
  "tslib": "^2.6.2",
55
- "@azure/core-lro": "3.0.0-beta.1",
56
- "@azure/abort-controller": "^2.0.0"
55
+ "@azure/core-lro": "^3.0.0",
56
+ "@azure/abort-controller": "^2.1.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@azure/storage-blob": "^12.23.0",
@@ -62,12 +62,12 @@
62
62
  "autorest": "latest",
63
63
  "@types/node": "^18.0.0",
64
64
  "dotenv": "^16.0.0",
65
- "eslint": "^8.55.0",
65
+ "eslint": "^9.9.0",
66
66
  "mkdirp": "^3.0.1",
67
67
  "source-map-support": "^0.5.9",
68
- "typescript": "~5.4.5",
69
- "@azure/dev-tool": "^1.0.0",
70
- "@azure/eslint-plugin-azure-sdk": "^3.0.0",
68
+ "typescript": "~5.5.3",
69
+ "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
70
+ "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
71
71
  "@azure-tools/test-credential": "^1.0.0",
72
72
  "@azure/identity": "^4.0.1",
73
73
  "@azure-tools/test-recorder": "^3.5.2",
@@ -88,8 +88,7 @@
88
88
  "karma": "^6.2.0",
89
89
  "nyc": "^17.0.0",
90
90
  "ts-node": "^10.0.0",
91
- "prettier": "^3.2.5",
92
- "tshy": "1.15.1"
91
+ "tshy": "^2.0.0"
93
92
  },
94
93
  "scripts": {
95
94
  "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
@@ -107,8 +106,8 @@
107
106
  "integration-test:browser": "dev-tool run test:browser",
108
107
  "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
109
108
  "integration-test": "npm run integration-test:node && npm run integration-test:browser",
110
- "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
111
- "lint": "eslint package.json api-extractor.json src test --ext .ts",
109
+ "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
110
+ "lint": "eslint package.json api-extractor.json src test",
112
111
  "pack": "npm pack 2>&1",
113
112
  "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
114
113
  "test:node": "npm run clean && npm run build:test && npm run unit-test:node",
@@ -1,13 +1,7 @@
1
- /// <reference types="node" />
2
-
3
1
  import { AbortSignalLike } from '@azure/abort-controller';
4
2
  import { CancelOnProgress } from '@azure/core-lro';
5
3
  import { Client } from '@azure-rest/core-client';
6
4
  import { ClientOptions } from '@azure-rest/core-client';
7
- import { createFile } from '@azure/core-rest-pipeline';
8
- import { createFileFromStream } from '@azure/core-rest-pipeline';
9
- import { CreateFileFromStreamOptions } from '@azure/core-rest-pipeline';
10
- import { CreateFileOptions } from '@azure/core-rest-pipeline';
11
5
  import { CreateHttpPollerOptions } from '@azure/core-lro';
12
6
  import { ErrorResponse } from '@azure-rest/core-client';
13
7
  import { HttpResponse } from '@azure-rest/core-client';
@@ -27,7 +21,11 @@ export declare interface BatchRequest {
27
21
  source: SourceInput;
28
22
  /** Location of the destination for the output */
29
23
  targets: Array<TargetInput>;
30
- /** Storage type of the input documents source string */
24
+ /**
25
+ * Storage type of the input documents source string
26
+ *
27
+ * Possible values: "Folder", "File"
28
+ */
31
29
  storageType?: StorageInputType;
32
30
  }
33
31
 
@@ -56,17 +54,9 @@ export declare type CancelTranslationParameters = RequestParameters;
56
54
  * @param credentials - uniquely identify client credential
57
55
  * @param options - the parameter for all optional parameters
58
56
  */
59
- declare function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient;
57
+ declare function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, { apiVersion, ...options }?: DocumentTranslationClientOptions): DocumentTranslationClient;
60
58
  export default createClient;
61
59
 
62
- export { createFile }
63
-
64
- export { createFileFromStream }
65
-
66
- export { CreateFileFromStreamOptions }
67
-
68
- export { CreateFileOptions }
69
-
70
60
  /** Document filter */
71
61
  export declare interface DocumentFilter {
72
62
  /**
@@ -102,7 +92,11 @@ export declare interface DocumentStatusOutput {
102
92
  createdDateTimeUtc: string;
103
93
  /** Date time in which the operation's status has been updated */
104
94
  lastActionDateTimeUtc: string;
105
- /** List of possible statuses for job or document */
95
+ /**
96
+ * List of possible statuses for job or document
97
+ *
98
+ * Possible values: "NotStarted", "Running", "Succeeded", "Failed", "Cancelled", "Cancelling", "ValidationFailed"
99
+ */
106
100
  status: StatusOutput;
107
101
  /** To language */
108
102
  to: string;
@@ -127,6 +121,8 @@ export declare interface DocumentTranslate {
127
121
  export declare interface DocumentTranslate200Headers {
128
122
  /** An opaque, globally-unique, client-generated string identifier for the request. */
129
123
  "x-ms-client-request-id"?: string;
124
+ /** response content type */
125
+ "content-type": "application/octet-stream";
130
126
  }
131
127
 
132
128
  /** The request has succeeded. */
@@ -138,7 +134,8 @@ export declare interface DocumentTranslate200Response extends HttpResponse {
138
134
  }
139
135
 
140
136
  export declare interface DocumentTranslateBodyParam {
141
- body?: DocumentTranslateContent;
137
+ /** Document Translate Request Content */
138
+ body: DocumentTranslateContent;
142
139
  }
143
140
 
144
141
  /** Document Translate Request Content */
@@ -219,6 +216,12 @@ export declare type DocumentTranslationClient = Client & {
219
216
  path: Routes;
220
217
  };
221
218
 
219
+ /** The optional parameters for the client */
220
+ export declare interface DocumentTranslationClientOptions extends ClientOptions {
221
+ /** The api version option of the client */
222
+ apiVersion?: string;
223
+ }
224
+
222
225
  /** File Format */
223
226
  export declare interface FileFormatOutput {
224
227
  /** Name of the format */
@@ -236,7 +239,7 @@ export declare interface FileFormatOutput {
236
239
  }
237
240
 
238
241
  /** Alias for FileFormatType */
239
- export declare type FileFormatType = "document" | "glossary" | string;
242
+ export declare type FileFormatType = string;
240
243
 
241
244
  /**
242
245
  * Helper type to extract the type of an array
@@ -451,7 +454,11 @@ export declare interface GetSupportedFormatsQueryParam {
451
454
  }
452
455
 
453
456
  export declare interface GetSupportedFormatsQueryParamProperties {
454
- /** the type of format like document or glossary */
457
+ /**
458
+ * the type of format like document or glossary
459
+ *
460
+ * Possible values: "document", "glossary"
461
+ */
455
462
  type?: FileFormatType;
456
463
  }
457
464
 
@@ -588,7 +595,11 @@ export declare interface Glossary {
588
595
  format: string;
589
596
  /** Optional Version. If not specified, default is used. */
590
597
  version?: string;
591
- /** Storage Source */
598
+ /**
599
+ * Storage Source
600
+ *
601
+ * Possible values: "AzureBlob"
602
+ */
592
603
  storageSource?: StorageSource;
593
604
  }
594
605
 
@@ -693,10 +704,6 @@ export declare interface SimplePollerLike<TState extends OperationState<TResult>
693
704
  * Returns true if the poller has finished polling.
694
705
  */
695
706
  isDone(): boolean;
696
- /**
697
- * Returns true if the poller is stopped.
698
- */
699
- isStopped(): boolean;
700
707
  /**
701
708
  * Returns the state of the operation.
702
709
  */
@@ -747,6 +754,11 @@ export declare interface SimplePollerLike<TState extends OperationState<TResult>
747
754
  * @deprecated Use abortSignal to stop polling instead.
748
755
  */
749
756
  stopPolling(): void;
757
+ /**
758
+ * Returns true if the poller is stopped.
759
+ * @deprecated Use abortSignal status to track this instead.
760
+ */
761
+ isStopped(): boolean;
750
762
  }
751
763
 
752
764
  /** Source of the input documents */
@@ -760,7 +772,11 @@ export declare interface SourceInput {
760
772
  * If none is specified, we will perform auto detect on the document
761
773
  */
762
774
  language?: string;
763
- /** Storage Source */
775
+ /**
776
+ * Storage Source
777
+ *
778
+ * Possible values: "AzureBlob"
779
+ */
764
780
  storageSource?: StorageSource;
765
781
  }
766
782
 
@@ -786,7 +802,7 @@ export declare interface StartTranslation {
786
802
  * destination, it will be overwritten. The targetUrl for each target language
787
803
  * must be unique.
788
804
  */
789
- post(options?: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
805
+ post(options: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
790
806
  /**
791
807
  * Returns a list of batch requests submitted and the status for each
792
808
  * request.
@@ -856,7 +872,8 @@ export declare interface StartTranslation202Response extends HttpResponse {
856
872
  }
857
873
 
858
874
  export declare interface StartTranslationBodyParam {
859
- body?: StartTranslationDetails;
875
+ /** Translation job submission batch request */
876
+ body: StartTranslationDetails;
860
877
  }
861
878
 
862
879
  export declare interface StartTranslationDefaultHeaders {
@@ -884,7 +901,7 @@ export declare interface StartTranslationLogicalResponse extends HttpResponse {
884
901
  export declare type StartTranslationParameters = StartTranslationBodyParam & RequestParameters;
885
902
 
886
903
  /** Alias for StatusOutput */
887
- export declare type StatusOutput = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed" | string;
904
+ export declare type StatusOutput = string;
888
905
 
889
906
  /** Status Summary */
890
907
  export declare interface StatusSummaryOutput {
@@ -905,10 +922,10 @@ export declare interface StatusSummaryOutput {
905
922
  }
906
923
 
907
924
  /** Alias for StorageInputType */
908
- export declare type StorageInputType = "Folder" | "File" | string;
925
+ export declare type StorageInputType = string;
909
926
 
910
927
  /** Alias for StorageSource */
911
- export declare type StorageSource = "AzureBlob" | string;
928
+ export declare type StorageSource = string;
912
929
 
913
930
  /** List of supported file formats */
914
931
  export declare interface SupportedFileFormatsOutput {
@@ -926,19 +943,27 @@ export declare interface TargetInput {
926
943
  language: string;
927
944
  /** List of Glossary */
928
945
  glossaries?: Array<Glossary>;
929
- /** Storage Source */
946
+ /**
947
+ * Storage Source
948
+ *
949
+ * Possible values: "AzureBlob"
950
+ */
930
951
  storageSource?: StorageSource;
931
952
  }
932
953
 
933
954
  /** Alias for TranslationErrorCodeOutput */
934
- export declare type TranslationErrorCodeOutput = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh" | string;
955
+ export declare type TranslationErrorCodeOutput = string;
935
956
 
936
957
  /**
937
958
  * This contains an outer error with error code, message, details, target and an
938
959
  * inner error with more descriptive details.
939
960
  */
940
961
  export declare interface TranslationErrorOutput {
941
- /** Enums containing high level error codes. */
962
+ /**
963
+ * Enums containing high level error codes.
964
+ *
965
+ * Possible values: "InvalidRequest", "InvalidArgument", "InternalServerError", "ServiceUnavailable", "ResourceNotFound", "Unauthorized", "RequestRateTooHigh"
966
+ */
942
967
  code: TranslationErrorCodeOutput;
943
968
  /** Gets high level error message. */
944
969
  message: string;
@@ -975,7 +1000,11 @@ export declare interface TranslationStatusOutput {
975
1000
  createdDateTimeUtc: string;
976
1001
  /** Date time in which the operation's status has been updated */
977
1002
  lastActionDateTimeUtc: string;
978
- /** List of possible statuses for job or document */
1003
+ /**
1004
+ * List of possible statuses for job or document
1005
+ *
1006
+ * Possible values: "NotStarted", "Running", "Succeeded", "Failed", "Cancelled", "Cancelling", "ValidationFailed"
1007
+ */
979
1008
  status: StatusOutput;
980
1009
  /**
981
1010
  * This contains an outer error with error code, message, details, target and an