@azure-rest/ai-translation-document 1.0.0-alpha.20250226.1 → 1.0.0-alpha.20250228.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -167
- package/dist/browser/clientDefinitions.d.ts +191 -0
- package/dist/browser/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/documentTranslationClient.d.ts +16 -0
- package/dist/browser/documentTranslationClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/documentTranslationClient.js +1 -1
- package/dist/browser/documentTranslationClient.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/isUnexpected.d.ts +10 -0
- package/dist/browser/isUnexpected.d.ts.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/models.d.ts +112 -0
- package/dist/browser/models.d.ts.map +1 -0
- package/dist/browser/outputModels.d.ts +166 -0
- package/dist/browser/outputModels.d.ts.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/paginateHelper.d.ts +43 -0
- package/dist/browser/paginateHelper.d.ts.map +1 -0
- package/dist/browser/parameters.d.ts +184 -0
- package/dist/browser/parameters.d.ts.map +1 -0
- package/dist/browser/pollingHelper.d.ts +77 -0
- package/dist/browser/pollingHelper.d.ts.map +1 -0
- package/dist/browser/responses.d.ts +132 -0
- package/dist/browser/responses.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.d.ts +191 -0
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.js +3 -0
- package/dist/commonjs/clientDefinitions.js.map +1 -0
- package/dist/commonjs/documentTranslationClient.d.ts +16 -0
- package/dist/commonjs/documentTranslationClient.d.ts.map +1 -0
- package/dist/commonjs/documentTranslationClient.js +45 -0
- package/dist/commonjs/documentTranslationClient.js.map +1 -0
- package/dist/commonjs/index.d.ts +12 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +17 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/isUnexpected.d.ts +10 -0
- package/dist/commonjs/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/isUnexpected.js +78 -0
- package/dist/commonjs/isUnexpected.js.map +1 -0
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models.d.ts +112 -0
- package/dist/commonjs/models.d.ts.map +1 -0
- package/dist/commonjs/models.js +5 -0
- package/dist/commonjs/models.js.map +1 -0
- package/dist/commonjs/outputModels.d.ts +166 -0
- package/dist/commonjs/outputModels.d.ts.map +1 -0
- package/dist/commonjs/outputModels.js +5 -0
- package/dist/commonjs/outputModels.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/paginateHelper.d.ts +43 -0
- package/dist/commonjs/paginateHelper.d.ts.map +1 -0
- package/dist/commonjs/paginateHelper.js +71 -0
- package/dist/commonjs/paginateHelper.js.map +1 -0
- package/dist/commonjs/parameters.d.ts +184 -0
- package/dist/commonjs/parameters.d.ts.map +1 -0
- package/dist/commonjs/parameters.js +3 -0
- package/dist/commonjs/parameters.js.map +1 -0
- package/dist/commonjs/pollingHelper.d.ts +77 -0
- package/dist/commonjs/pollingHelper.d.ts.map +1 -0
- package/dist/commonjs/pollingHelper.js +98 -0
- package/dist/commonjs/pollingHelper.js.map +1 -0
- package/dist/commonjs/responses.d.ts +132 -0
- package/dist/commonjs/responses.d.ts.map +1 -0
- package/dist/commonjs/responses.js +3 -0
- package/dist/commonjs/responses.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/clientDefinitions.d.ts +191 -0
- package/dist/esm/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/clientDefinitions.js +2 -0
- package/dist/esm/clientDefinitions.js.map +1 -0
- package/dist/esm/documentTranslationClient.d.ts +16 -0
- package/dist/esm/documentTranslationClient.d.ts.map +1 -0
- package/dist/esm/documentTranslationClient.js +42 -0
- package/dist/esm/documentTranslationClient.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/isUnexpected.d.ts +10 -0
- package/dist/esm/isUnexpected.d.ts.map +1 -0
- package/dist/esm/isUnexpected.js +75 -0
- package/dist/esm/isUnexpected.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models.d.ts +112 -0
- package/dist/esm/models.d.ts.map +1 -0
- package/dist/esm/models.js +4 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/outputModels.d.ts +166 -0
- package/dist/esm/outputModels.d.ts.map +1 -0
- package/dist/esm/outputModels.js +4 -0
- package/dist/esm/outputModels.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/paginateHelper.d.ts +43 -0
- package/dist/esm/paginateHelper.d.ts.map +1 -0
- package/dist/esm/paginateHelper.js +68 -0
- package/dist/esm/paginateHelper.js.map +1 -0
- package/dist/esm/parameters.d.ts +184 -0
- package/dist/esm/parameters.d.ts.map +1 -0
- package/dist/esm/parameters.js +2 -0
- package/dist/esm/parameters.js.map +1 -0
- package/dist/esm/pollingHelper.d.ts +77 -0
- package/dist/esm/pollingHelper.d.ts.map +1 -0
- package/dist/esm/pollingHelper.js +95 -0
- package/dist/esm/pollingHelper.js.map +1 -0
- package/dist/esm/responses.d.ts +132 -0
- package/dist/esm/responses.d.ts.map +1 -0
- package/dist/esm/responses.js +2 -0
- package/dist/esm/responses.js.map +1 -0
- package/dist/react-native/clientDefinitions.d.ts +191 -0
- package/dist/react-native/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/clientDefinitions.js +2 -0
- package/dist/react-native/clientDefinitions.js.map +1 -0
- package/dist/react-native/documentTranslationClient.d.ts +16 -0
- package/dist/react-native/documentTranslationClient.d.ts.map +1 -0
- package/dist/react-native/documentTranslationClient.js +42 -0
- package/dist/react-native/documentTranslationClient.js.map +1 -0
- package/dist/react-native/index.d.ts +12 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +14 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/isUnexpected.d.ts +10 -0
- package/dist/react-native/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/isUnexpected.js +75 -0
- package/dist/react-native/isUnexpected.js.map +1 -0
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models.d.ts +112 -0
- package/dist/react-native/models.d.ts.map +1 -0
- package/dist/react-native/models.js +4 -0
- package/dist/react-native/models.js.map +1 -0
- package/dist/react-native/outputModels.d.ts +166 -0
- package/dist/react-native/outputModels.d.ts.map +1 -0
- package/dist/react-native/outputModels.js +4 -0
- package/dist/react-native/outputModels.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/paginateHelper.d.ts +43 -0
- package/dist/react-native/paginateHelper.d.ts.map +1 -0
- package/dist/react-native/paginateHelper.js +68 -0
- package/dist/react-native/paginateHelper.js.map +1 -0
- package/dist/react-native/parameters.d.ts +184 -0
- package/dist/react-native/parameters.d.ts.map +1 -0
- package/dist/react-native/parameters.js +2 -0
- package/dist/react-native/parameters.js.map +1 -0
- package/dist/react-native/pollingHelper.d.ts +77 -0
- package/dist/react-native/pollingHelper.d.ts.map +1 -0
- package/dist/react-native/pollingHelper.js +95 -0
- package/dist/react-native/pollingHelper.js.map +1 -0
- package/dist/react-native/responses.d.ts +132 -0
- package/dist/react-native/responses.d.ts.map +1 -0
- package/dist/react-native/responses.js +2 -0
- package/dist/react-native/responses.js.map +1 -0
- package/package.json +68 -43
- package/CHANGELOG.md +0 -34
- package/dist/index.js +0 -293
- package/dist/index.js.map +0 -1
- package/dist-esm/src/documentTranslationClient.js.map +0 -1
- package/dist-esm/src/index.js +0 -14
- package/dist-esm/src/index.js.map +0 -1
- package/types/ai-translation-document.d.ts +0 -1018
- /package/{dist-esm/src → dist/browser}/clientDefinitions.js +0 -0
- /package/{dist-esm/src → dist/browser}/clientDefinitions.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/isUnexpected.js +0 -0
- /package/{dist-esm/src → dist/browser}/isUnexpected.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/logger.js +0 -0
- /package/{dist-esm/src → dist/browser}/logger.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/models.js +0 -0
- /package/{dist-esm/src → dist/browser}/models.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/outputModels.js +0 -0
- /package/{dist-esm/src → dist/browser}/outputModels.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/paginateHelper.js +0 -0
- /package/{dist-esm/src → dist/browser}/paginateHelper.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/parameters.js +0 -0
- /package/{dist-esm/src → dist/browser}/parameters.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/pollingHelper.js +0 -0
- /package/{dist-esm/src → dist/browser}/pollingHelper.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/responses.js +0 -0
- /package/{dist-esm/src → dist/browser}/responses.js.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/responses.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { RawHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport type { HttpResponse, ErrorResponse } from \"@azure-rest/core-client\";\nimport type {\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"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.50.1"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { DocumentTranslateParameters, StartTranslationParameters, GetTranslationsStatusParameters, GetDocumentStatusParameters, GetTranslationStatusParameters, CancelTranslationParameters, GetDocumentsStatusParameters, GetSupportedFormatsParameters } from "./parameters.js";
|
|
2
|
+
import type { DocumentTranslate200Response, DocumentTranslateDefaultResponse, StartTranslation202Response, StartTranslationDefaultResponse, GetTranslationsStatus200Response, GetTranslationsStatusDefaultResponse, GetDocumentStatus200Response, GetDocumentStatusDefaultResponse, GetTranslationStatus200Response, GetTranslationStatusDefaultResponse, CancelTranslation200Response, CancelTranslationDefaultResponse, GetDocumentsStatus200Response, GetDocumentsStatusDefaultResponse, GetSupportedFormats200Response, GetSupportedFormatsDefaultResponse } from "./responses.js";
|
|
3
|
+
import type { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
4
|
+
export interface DocumentTranslate {
|
|
5
|
+
/** Use this API to submit a single translation request to the Document Translation Service. */
|
|
6
|
+
post(options: DocumentTranslateParameters): StreamableMethod<DocumentTranslate200Response | DocumentTranslateDefaultResponse>;
|
|
7
|
+
}
|
|
8
|
+
export interface StartTranslation {
|
|
9
|
+
/**
|
|
10
|
+
* Use this API to submit a bulk (batch) translation request to the Document
|
|
11
|
+
* Translation service.
|
|
12
|
+
* Each request can contain multiple documents and must
|
|
13
|
+
* contain a source and destination container for each document.
|
|
14
|
+
*
|
|
15
|
+
* The
|
|
16
|
+
* prefix and suffix filter (if supplied) are used to filter folders. The prefix
|
|
17
|
+
* is applied to the subpath after the container name.
|
|
18
|
+
*
|
|
19
|
+
* Glossaries /
|
|
20
|
+
* Translation memory can be included in the request and are applied by the
|
|
21
|
+
* service when the document is translated.
|
|
22
|
+
*
|
|
23
|
+
* If the glossary is
|
|
24
|
+
* invalid or unreachable during translation, an error is indicated in the
|
|
25
|
+
* document status.
|
|
26
|
+
* If a file with the same name already exists at the
|
|
27
|
+
* destination, it will be overwritten. The targetUrl for each target language
|
|
28
|
+
* must be unique.
|
|
29
|
+
*/
|
|
30
|
+
post(options: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a list of batch requests submitted and the status for each
|
|
33
|
+
* request.
|
|
34
|
+
* This list only contains batch requests submitted by the user (based on
|
|
35
|
+
* the resource).
|
|
36
|
+
*
|
|
37
|
+
* If the number of requests exceeds our paging limit,
|
|
38
|
+
* server-side paging is used. Paginated responses indicate a partial result and
|
|
39
|
+
* include a continuation token in the response.
|
|
40
|
+
* The absence of a continuation
|
|
41
|
+
* token means that no additional pages are available.
|
|
42
|
+
*
|
|
43
|
+
* top, skip
|
|
44
|
+
* and maxpagesize query parameters can be used to specify a number of results to
|
|
45
|
+
* return and an offset for the collection.
|
|
46
|
+
*
|
|
47
|
+
* top indicates the total
|
|
48
|
+
* number of records the user wants to be returned across all pages.
|
|
49
|
+
* skip
|
|
50
|
+
* indicates the number of records to skip from the list of batches based on the
|
|
51
|
+
* sorting method specified. By default, we sort by descending start
|
|
52
|
+
* time.
|
|
53
|
+
* maxpagesize is the maximum items returned in a page. If more items are
|
|
54
|
+
* requested via top (or top is not specified and there are more items to be
|
|
55
|
+
* returned), @nextLink will contain the link to the next page.
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* orderby query parameter can be used to sort the returned list (ex
|
|
59
|
+
* "orderby=createdDateTimeUtc asc" or "orderby=createdDateTimeUtc
|
|
60
|
+
* desc").
|
|
61
|
+
* The default sorting is descending by createdDateTimeUtc.
|
|
62
|
+
* Some query
|
|
63
|
+
* parameters can be used to filter the returned list (ex:
|
|
64
|
+
* "status=Succeeded,Cancelled") will only return succeeded and cancelled
|
|
65
|
+
* operations.
|
|
66
|
+
* createdDateTimeUtcStart and createdDateTimeUtcEnd can be used
|
|
67
|
+
* combined or separately to specify a range of datetime to filter the returned
|
|
68
|
+
* list by.
|
|
69
|
+
* The supported filtering query parameters are (status, ids,
|
|
70
|
+
* createdDateTimeUtcStart, createdDateTimeUtcEnd).
|
|
71
|
+
*
|
|
72
|
+
* The server honors
|
|
73
|
+
* the values specified by the client. However, clients must be prepared to handle
|
|
74
|
+
* responses that contain a different page size or contain a continuation token.
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* When both top and skip are included, the server should first apply
|
|
78
|
+
* skip and then top on the collection.
|
|
79
|
+
* Note: If the server can't honor top
|
|
80
|
+
* and/or skip, the server must return an error to the client informing about it
|
|
81
|
+
* instead of just ignoring the query options.
|
|
82
|
+
* This reduces the risk of the client
|
|
83
|
+
* making assumptions about the data returned.
|
|
84
|
+
*/
|
|
85
|
+
get(options?: GetTranslationsStatusParameters): StreamableMethod<GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse>;
|
|
86
|
+
}
|
|
87
|
+
export interface GetDocumentStatus {
|
|
88
|
+
/**
|
|
89
|
+
* Returns the translation status for a specific document based on the request Id
|
|
90
|
+
* and document Id.
|
|
91
|
+
*/
|
|
92
|
+
get(options?: GetDocumentStatusParameters): StreamableMethod<GetDocumentStatus200Response | GetDocumentStatusDefaultResponse>;
|
|
93
|
+
}
|
|
94
|
+
export interface GetTranslationStatus {
|
|
95
|
+
/**
|
|
96
|
+
* Returns the status for a document translation request.
|
|
97
|
+
* The status includes the
|
|
98
|
+
* overall request status, as well as the status for documents that are being
|
|
99
|
+
* translated as part of that request.
|
|
100
|
+
*/
|
|
101
|
+
get(options?: GetTranslationStatusParameters): StreamableMethod<GetTranslationStatus200Response | GetTranslationStatusDefaultResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Cancel a currently processing or queued translation.
|
|
104
|
+
* A translation will not be
|
|
105
|
+
* cancelled if it is already completed or failed or cancelling. A bad request
|
|
106
|
+
* will be returned.
|
|
107
|
+
* All documents that have completed translation will not be
|
|
108
|
+
* cancelled and will be charged.
|
|
109
|
+
* All pending documents will be cancelled if
|
|
110
|
+
* possible.
|
|
111
|
+
*/
|
|
112
|
+
delete(options?: CancelTranslationParameters): StreamableMethod<CancelTranslation200Response | CancelTranslationDefaultResponse>;
|
|
113
|
+
}
|
|
114
|
+
export interface GetDocumentsStatus {
|
|
115
|
+
/**
|
|
116
|
+
* Returns the status for all documents in a batch document translation request.
|
|
117
|
+
*
|
|
118
|
+
*
|
|
119
|
+
* If the number of documents in the response exceeds our paging limit,
|
|
120
|
+
* server-side paging is used.
|
|
121
|
+
* Paginated responses indicate a partial result and
|
|
122
|
+
* include a continuation token in the response. The absence of a continuation
|
|
123
|
+
* token means that no additional pages are available.
|
|
124
|
+
*
|
|
125
|
+
* top, skip
|
|
126
|
+
* and maxpagesize query parameters can be used to specify a number of results to
|
|
127
|
+
* return and an offset for the collection.
|
|
128
|
+
*
|
|
129
|
+
* top indicates the total
|
|
130
|
+
* number of records the user wants to be returned across all pages.
|
|
131
|
+
* skip
|
|
132
|
+
* indicates the number of records to skip from the list of document status held
|
|
133
|
+
* by the server based on the sorting method specified. By default, we sort by
|
|
134
|
+
* descending start time.
|
|
135
|
+
* maxpagesize is the maximum items returned in a page.
|
|
136
|
+
* If more items are requested via top (or top is not specified and there are
|
|
137
|
+
* more items to be returned), @nextLink will contain the link to the next page.
|
|
138
|
+
*
|
|
139
|
+
*
|
|
140
|
+
* orderby query parameter can be used to sort the returned list (ex
|
|
141
|
+
* "orderby=createdDateTimeUtc asc" or "orderby=createdDateTimeUtc
|
|
142
|
+
* desc").
|
|
143
|
+
* The default sorting is descending by createdDateTimeUtc.
|
|
144
|
+
* Some query
|
|
145
|
+
* parameters can be used to filter the returned list (ex:
|
|
146
|
+
* "status=Succeeded,Cancelled") will only return succeeded and cancelled
|
|
147
|
+
* documents.
|
|
148
|
+
* createdDateTimeUtcStart and createdDateTimeUtcEnd can be used
|
|
149
|
+
* combined or separately to specify a range of datetime to filter the returned
|
|
150
|
+
* list by.
|
|
151
|
+
* The supported filtering query parameters are (status, ids,
|
|
152
|
+
* createdDateTimeUtcStart, createdDateTimeUtcEnd).
|
|
153
|
+
*
|
|
154
|
+
* When both top
|
|
155
|
+
* and skip are included, the server should first apply skip and then top on
|
|
156
|
+
* the collection.
|
|
157
|
+
* Note: If the server can't honor top and/or skip, the server
|
|
158
|
+
* must return an error to the client informing about it instead of just ignoring
|
|
159
|
+
* the query options.
|
|
160
|
+
* This reduces the risk of the client making assumptions about
|
|
161
|
+
* the data returned.
|
|
162
|
+
*/
|
|
163
|
+
get(options?: GetDocumentsStatusParameters): StreamableMethod<GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse>;
|
|
164
|
+
}
|
|
165
|
+
export interface GetSupportedFormats {
|
|
166
|
+
/**
|
|
167
|
+
* The list of supported formats supported by the Document Translation
|
|
168
|
+
* service.
|
|
169
|
+
* The list includes the common file extension, as well as the
|
|
170
|
+
* content-type if using the upload API.
|
|
171
|
+
*/
|
|
172
|
+
get(options?: GetSupportedFormatsParameters): StreamableMethod<GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse>;
|
|
173
|
+
}
|
|
174
|
+
export interface Routes {
|
|
175
|
+
/** Resource for '/document:translate' has methods for the following verbs: post */
|
|
176
|
+
(path: "/document:translate"): DocumentTranslate;
|
|
177
|
+
/** Resource for '/document/batches' has methods for the following verbs: post, get */
|
|
178
|
+
(path: "/document/batches"): StartTranslation;
|
|
179
|
+
/** Resource for '/document/batches/\{id\}/documents/\{documentId\}' has methods for the following verbs: get */
|
|
180
|
+
(path: "/document/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus;
|
|
181
|
+
/** Resource for '/document/batches/\{id\}' has methods for the following verbs: get, delete */
|
|
182
|
+
(path: "/document/batches/{id}", id: string): GetTranslationStatus;
|
|
183
|
+
/** Resource for '/document/batches/\{id\}/documents' has methods for the following verbs: get */
|
|
184
|
+
(path: "/document/batches/{id}/documents", id: string): GetDocumentsStatus;
|
|
185
|
+
/** Resource for '/document/formats' has methods for the following verbs: get */
|
|
186
|
+
(path: "/document/formats"): GetSupportedFormats;
|
|
187
|
+
}
|
|
188
|
+
export type DocumentTranslationClient = Client & {
|
|
189
|
+
path: Routes;
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=clientDefinitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientDefinitions.d.ts","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,+BAA+B,EAC/B,gCAAgC,EAChC,oCAAoC,EACpC,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,mCAAmC,EACnC,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,+FAA+F;IAC/F,IAAI,CACF,OAAO,EAAE,2BAA2B,GACnC,gBAAgB,CAAC,4BAA4B,GAAG,gCAAgC,CAAC,CAAC;CACtF;AAED,MAAM,WAAW,gB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,gHAAgH;IAChH,CACE,IAAI,EAAE,+CAA+C,EACrD,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,GACjB,iBAAiB,CAAC;IACrB,+FAA+F;IAC/F,CAAC,IAAI,EAAE,wBAAwB,EAAE,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAAC;IACnE,iGAAiG;IACjG,CAAC,IAAI,EAAE,kCAAkC,EAAE,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC3E,gFAAgF;IAChF,CAAC,IAAI,EAAE,mBAAmB,GAAG,mBAAmB,CAAC;CAClD;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type {\n DocumentTranslateParameters,\n StartTranslationParameters,\n GetTranslationsStatusParameters,\n GetDocumentStatusParameters,\n GetTranslationStatusParameters,\n CancelTranslationParameters,\n GetDocumentsStatusParameters,\n GetSupportedFormatsParameters,\n} from \"./parameters.js\";\nimport type {\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 type { 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"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClientOptions } from "@azure-rest/core-client";
|
|
2
|
+
import type { TokenCredential, KeyCredential } from "@azure/core-auth";
|
|
3
|
+
import type { DocumentTranslationClient } from "./clientDefinitions.js";
|
|
4
|
+
/** The optional parameters for the client */
|
|
5
|
+
export interface DocumentTranslationClientOptions extends ClientOptions {
|
|
6
|
+
/** The api version option of the client */
|
|
7
|
+
apiVersion?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Initialize a new instance of `DocumentTranslationClient`
|
|
11
|
+
* @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
|
|
12
|
+
* @param credentials - uniquely identify client credential
|
|
13
|
+
* @param options - the parameter for all optional parameters
|
|
14
|
+
*/
|
|
15
|
+
export default function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, { apiVersion, ...options }?: DocumentTranslationClientOptions): DocumentTranslationClient;
|
|
16
|
+
//# sourceMappingURL=documentTranslationClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentTranslationClient.d.ts","sourceRoot":"","sources":["../../src/documentTranslationClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,6CAA6C;AAC7C,MAAM,WAAW,gCAAiC,SAAQ,aAAa;IACrE,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,eAAe,GAAG,aAAa,EAC5C,EAAE,UAAyB,EAAE,GAAG,OAAO,EAAE,GAAE,gCAAqC,GAC/E,yBAAyB,CAwC3B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { getClient } from "@azure-rest/core-client";
|
|
3
|
+
import { logger } from "./logger.js";
|
|
4
|
+
/**
|
|
5
|
+
* Initialize a new instance of `DocumentTranslationClient`
|
|
6
|
+
* @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
|
|
7
|
+
* @param credentials - uniquely identify client credential
|
|
8
|
+
* @param options - the parameter for all optional parameters
|
|
9
|
+
*/
|
|
10
|
+
export default function createClient(endpointParam, credentials, _a = {}) {
|
|
11
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
12
|
+
var { apiVersion = "2024-05-01" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
13
|
+
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `${endpointParam}/translator`;
|
|
14
|
+
const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
|
|
15
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
16
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
17
|
+
: `${userAgentInfo}`;
|
|
18
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
19
|
+
userAgentPrefix,
|
|
20
|
+
}, loggingOptions: {
|
|
21
|
+
logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info,
|
|
22
|
+
}, credentials: {
|
|
23
|
+
scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : ["https://cognitiveservices.azure.com/.default"],
|
|
24
|
+
apiKeyHeaderName: (_j = (_h = options.credentials) === null || _h === void 0 ? void 0 : _h.apiKeyHeaderName) !== null && _j !== void 0 ? _j : "Ocp-Apim-Subscription-Key",
|
|
25
|
+
} });
|
|
26
|
+
const client = getClient(endpointUrl, credentials, options);
|
|
27
|
+
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
28
|
+
client.pipeline.addPolicy({
|
|
29
|
+
name: "ClientApiVersionPolicy",
|
|
30
|
+
sendRequest: (req, next) => {
|
|
31
|
+
// Use the apiVersion defined in request url directly
|
|
32
|
+
// Append one if there is no apiVersion and we have one at client options
|
|
33
|
+
const url = new URL(req.url);
|
|
34
|
+
if (!url.searchParams.get("api-version") && apiVersion) {
|
|
35
|
+
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
|
|
36
|
+
}
|
|
37
|
+
return next(req);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return client;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=documentTranslationClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentTranslationClient.js","sourceRoot":"","sources":["../../src/documentTranslationClient.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;;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,C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C,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport type { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport type { DocumentTranslationClient } from \"./clientDefinitions.js\";\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DocumentTranslationClient from "./documentTranslationClient.js";
|
|
2
|
+
export * from "./documentTranslationClient.js";
|
|
3
|
+
export * from "./parameters.js";
|
|
4
|
+
export * from "./responses.js";
|
|
5
|
+
export * from "./clientDefinitions.js";
|
|
6
|
+
export * from "./isUnexpected.js";
|
|
7
|
+
export * from "./models.js";
|
|
8
|
+
export * from "./outputModels.js";
|
|
9
|
+
export * from "./paginateHelper.js";
|
|
10
|
+
export * from "./pollingHelper.js";
|
|
11
|
+
export default DocumentTranslationClient;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AAEvE,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AAEnC,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import DocumentTranslationClient from "./documentTranslationClient.js";
|
|
4
|
+
export * from "./documentTranslationClient.js";
|
|
5
|
+
export * from "./parameters.js";
|
|
6
|
+
export * from "./responses.js";
|
|
7
|
+
export * from "./clientDefinitions.js";
|
|
8
|
+
export * from "./isUnexpected.js";
|
|
9
|
+
export * from "./models.js";
|
|
10
|
+
export * from "./outputModels.js";
|
|
11
|
+
export * from "./paginateHelper.js";
|
|
12
|
+
export * from "./pollingHelper.js";
|
|
13
|
+
export default DocumentTranslationClient;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AAEvE,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AAEnC,eAAe,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport DocumentTranslationClient from \"./documentTranslationClient.js\";\n\nexport * from \"./documentTranslationClient.js\";\nexport * from \"./parameters.js\";\nexport * from \"./responses.js\";\nexport * from \"./clientDefinitions.js\";\nexport * from \"./isUnexpected.js\";\nexport * from \"./models.js\";\nexport * from \"./outputModels.js\";\nexport * from \"./paginateHelper.js\";\nexport * from \"./pollingHelper.js\";\n\nexport default DocumentTranslationClient;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DocumentTranslate200Response, DocumentTranslateDefaultResponse, StartTranslation202Response, StartTranslationLogicalResponse, StartTranslationDefaultResponse, GetTranslationsStatus200Response, GetTranslationsStatusDefaultResponse, GetDocumentStatus200Response, GetDocumentStatusDefaultResponse, GetTranslationStatus200Response, GetTranslationStatusDefaultResponse, CancelTranslation200Response, CancelTranslationDefaultResponse, GetDocumentsStatus200Response, GetDocumentsStatusDefaultResponse, GetSupportedFormats200Response, GetSupportedFormatsDefaultResponse } from "./responses.js";
|
|
2
|
+
export declare function isUnexpected(response: DocumentTranslate200Response | DocumentTranslateDefaultResponse): response is DocumentTranslateDefaultResponse;
|
|
3
|
+
export declare function isUnexpected(response: StartTranslation202Response | StartTranslationLogicalResponse | StartTranslationDefaultResponse): response is StartTranslationDefaultResponse;
|
|
4
|
+
export declare function isUnexpected(response: GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse): response is GetTranslationsStatusDefaultResponse;
|
|
5
|
+
export declare function isUnexpected(response: GetDocumentStatus200Response | GetDocumentStatusDefaultResponse): response is GetDocumentStatusDefaultResponse;
|
|
6
|
+
export declare function isUnexpected(response: GetTranslationStatus200Response | GetTranslationStatusDefaultResponse): response is GetTranslationStatusDefaultResponse;
|
|
7
|
+
export declare function isUnexpected(response: CancelTranslation200Response | CancelTranslationDefaultResponse): response is CancelTranslationDefaultResponse;
|
|
8
|
+
export declare function isUnexpected(response: GetDocumentsStatus200Response | GetDocumentsStatusDefaultResponse): response is GetDocumentsStatusDefaultResponse;
|
|
9
|
+
export declare function isUnexpected(response: GetSupportedFormats200Response | GetSupportedFormatsDefaultResponse): response is GetSupportedFormatsDefaultResponse;
|
|
10
|
+
//# sourceMappingURL=isUnexpected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUnexpected.d.ts","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,oCAAoC,EACpC,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,mCAAmC,EACnC,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,gBAAgB,CAAC;AAaxB,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,4BAA4B,GAAG,gCAAgC,GACxE,QAAQ,IAAI,gCAAgC,CAAC;AAChD,wBAAgB,YAAY,CAC1B,QAAQ,EACJ,2BAA2B,GAC3B,+BAA+B,GAC/B,+BAA+B,GAClC,QAAQ,IAAI,+BAA+B,CAAC;AAC/C,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gCAAgC,GAAG,oCAAoC,GAChF,QAAQ,IAAI,oCAAoC,CAAC;AACpD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,4BAA4B,GAAG,gCAAgC,GACxE,QAAQ,IAAI,gCAAgC,CAAC;AAChD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,+BAA+B,GAAG,mCAAmC,GAC9E,QAAQ,IAAI,mCAAmC,CAAC;AACnD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,4BAA4B,GAAG,gCAAgC,GACxE,QAAQ,IAAI,gCAAgC,CAAC;AAChD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,6BAA6B,GAAG,iCAAiC,GAC1E,QAAQ,IAAI,iCAAiC,CAAC;AACjD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,8BAA8B,GAAG,kCAAkC,GAC5E,QAAQ,IAAI,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const responseMap = {
|
|
2
|
+
"POST /document:translate": ["200"],
|
|
3
|
+
"GET /document/batches": ["200"],
|
|
4
|
+
"POST /document/batches": ["202"],
|
|
5
|
+
"GET /document/batches/{id}/documents/{documentId}": ["200"],
|
|
6
|
+
"GET /document/batches/{id}": ["200"],
|
|
7
|
+
"DELETE /document/batches/{id}": ["200"],
|
|
8
|
+
"GET /document/batches/{id}/documents": ["200"],
|
|
9
|
+
"GET /document/formats": ["200"],
|
|
10
|
+
};
|
|
11
|
+
export function isUnexpected(response) {
|
|
12
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
13
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
14
|
+
const method = response.request.method;
|
|
15
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
16
|
+
if (!pathDetails) {
|
|
17
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
18
|
+
}
|
|
19
|
+
return !pathDetails.includes(response.status);
|
|
20
|
+
}
|
|
21
|
+
function getParametrizedPathSuccess(method, path) {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
const pathParts = path.split("/");
|
|
24
|
+
// Traverse list to match the longest candidate
|
|
25
|
+
// matchedLen: the length of candidate path
|
|
26
|
+
// matchedValue: the matched status code array
|
|
27
|
+
let matchedLen = -1, matchedValue = [];
|
|
28
|
+
// Iterate the responseMap to find a match
|
|
29
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
30
|
+
// Extracting the path from the map key which is in format
|
|
31
|
+
// GET /path/foo
|
|
32
|
+
if (!key.startsWith(method)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const candidatePath = getPathFromMapKey(key);
|
|
36
|
+
// Get each part of the url path
|
|
37
|
+
const candidateParts = candidatePath.split("/");
|
|
38
|
+
// track if we have found a match to return the values found.
|
|
39
|
+
let found = true;
|
|
40
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
41
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
42
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
43
|
+
// If the current part of the candidate is a "template" part
|
|
44
|
+
// Try to use the suffix of pattern to match the path
|
|
45
|
+
// {guid} ==> $
|
|
46
|
+
// {guid}:export ==> :export$
|
|
47
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
48
|
+
if (!isMatched) {
|
|
49
|
+
found = false;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// If the candidate part is not a template and
|
|
55
|
+
// the parts don't match mark the candidate as not found
|
|
56
|
+
// to move on with the next candidate path.
|
|
57
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
58
|
+
found = false;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// We finished evaluating the current candidate parts
|
|
63
|
+
// Update the matched value if and only if we found the longer pattern
|
|
64
|
+
if (found && candidatePath.length > matchedLen) {
|
|
65
|
+
matchedLen = candidatePath.length;
|
|
66
|
+
matchedValue = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return matchedValue;
|
|
70
|
+
}
|
|
71
|
+
function getPathFromMapKey(mapKey) {
|
|
72
|
+
const pathStart = mapKey.indexOf("/");
|
|
73
|
+
return mapKey.slice(pathStart);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=isUnexpected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAsBA,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,M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Y,GAAG,KAAK,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.\nimport type {\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,qCAAgD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,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.\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export interface DocumentTranslateContentDocumentPartDescriptor {
|
|
2
|
+
name: "document";
|
|
3
|
+
body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;
|
|
4
|
+
filename?: string;
|
|
5
|
+
contentType?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DocumentTranslateContentGlossaryPartDescriptor {
|
|
8
|
+
name: "glossary";
|
|
9
|
+
body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;
|
|
10
|
+
filename?: string;
|
|
11
|
+
contentType?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Translation job submission batch request */
|
|
14
|
+
export interface StartTranslationDetails {
|
|
15
|
+
/** The input list of documents or folders containing documents */
|
|
16
|
+
inputs: Array<BatchRequest>;
|
|
17
|
+
}
|
|
18
|
+
/** Definition for the input batch translation request */
|
|
19
|
+
export interface BatchRequest {
|
|
20
|
+
/** Source of the input documents */
|
|
21
|
+
source: SourceInput;
|
|
22
|
+
/** Location of the destination for the output */
|
|
23
|
+
targets: Array<TargetInput>;
|
|
24
|
+
/**
|
|
25
|
+
* Storage type of the input documents source string
|
|
26
|
+
*
|
|
27
|
+
* Possible values: "Folder", "File"
|
|
28
|
+
*/
|
|
29
|
+
storageType?: StorageInputType;
|
|
30
|
+
}
|
|
31
|
+
/** Source of the input documents */
|
|
32
|
+
export interface SourceInput {
|
|
33
|
+
/** Location of the folder / container or single file with your documents */
|
|
34
|
+
sourceUrl: string;
|
|
35
|
+
/** Document filter */
|
|
36
|
+
filter?: DocumentFilter;
|
|
37
|
+
/**
|
|
38
|
+
* Language code
|
|
39
|
+
* If none is specified, we will perform auto detect on the document
|
|
40
|
+
*/
|
|
41
|
+
language?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Storage Source
|
|
44
|
+
*
|
|
45
|
+
* Possible values: "AzureBlob"
|
|
46
|
+
*/
|
|
47
|
+
storageSource?: StorageSource;
|
|
48
|
+
}
|
|
49
|
+
/** Document filter */
|
|
50
|
+
export interface DocumentFilter {
|
|
51
|
+
/**
|
|
52
|
+
* A case-sensitive prefix string to filter documents in the source path for
|
|
53
|
+
* translation.
|
|
54
|
+
* For example, when using a Azure storage blob Uri, use the prefix
|
|
55
|
+
* to restrict sub folders for translation.
|
|
56
|
+
*/
|
|
57
|
+
prefix?: string;
|
|
58
|
+
/**
|
|
59
|
+
* A case-sensitive suffix string to filter documents in the source path for
|
|
60
|
+
* translation.
|
|
61
|
+
* This is most often use for file extensions
|
|
62
|
+
*/
|
|
63
|
+
suffix?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Destination for the finished translated documents */
|
|
66
|
+
export interface TargetInput {
|
|
67
|
+
/** Location of the folder / container with your documents */
|
|
68
|
+
targetUrl: string;
|
|
69
|
+
/** Category / custom system for translation request */
|
|
70
|
+
category?: string;
|
|
71
|
+
/** Target Language */
|
|
72
|
+
language: string;
|
|
73
|
+
/** List of Glossary */
|
|
74
|
+
glossaries?: Array<Glossary>;
|
|
75
|
+
/**
|
|
76
|
+
* Storage Source
|
|
77
|
+
*
|
|
78
|
+
* Possible values: "AzureBlob"
|
|
79
|
+
*/
|
|
80
|
+
storageSource?: StorageSource;
|
|
81
|
+
}
|
|
82
|
+
/** Glossary / translation memory for the request */
|
|
83
|
+
export interface Glossary {
|
|
84
|
+
/**
|
|
85
|
+
* Location of the glossary.
|
|
86
|
+
* We will use the file extension to extract the
|
|
87
|
+
* formatting if the format parameter is not supplied.
|
|
88
|
+
*
|
|
89
|
+
* If the translation
|
|
90
|
+
* language pair is not present in the glossary, it will not be applied
|
|
91
|
+
*/
|
|
92
|
+
glossaryUrl: string;
|
|
93
|
+
/** Format */
|
|
94
|
+
format: string;
|
|
95
|
+
/** Optional Version. If not specified, default is used. */
|
|
96
|
+
version?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Storage Source
|
|
99
|
+
*
|
|
100
|
+
* Possible values: "AzureBlob"
|
|
101
|
+
*/
|
|
102
|
+
storageSource?: StorageSource;
|
|
103
|
+
}
|
|
104
|
+
/** Document Translate Request Content */
|
|
105
|
+
export type DocumentTranslateContent = FormData | Array<DocumentTranslateContentDocumentPartDescriptor | DocumentTranslateContentGlossaryPartDescriptor>;
|
|
106
|
+
/** Alias for StorageSource */
|
|
107
|
+
export type StorageSource = string;
|
|
108
|
+
/** Alias for StorageInputType */
|
|
109
|
+
export type StorageInputType = string;
|
|
110
|
+
/** Alias for FileFormatType */
|
|
111
|
+
export type FileFormatType = string;
|
|
112
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,8CAA8C;IAC7D,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,8CAA8C;IAC7D,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACtC,kEAAkE;IAClE,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC7B;AAED,yDAAyD;AACzD,MAAM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