@azure-rest/ai-translation-text 1.0.3-alpha.20251210.1 → 2.0.0-alpha.20251218.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 +9 -2
- package/README.md +26 -173
- package/dist/browser/clientDefinitions.d.ts +2 -20
- package/dist/browser/clientDefinitions.d.ts.map +1 -1
- package/dist/browser/clientDefinitions.js.map +1 -1
- package/dist/browser/customClient.js +2 -2
- package/dist/browser/customClient.js.map +1 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +0 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/isUnexpected.d.ts +1 -4
- package/dist/browser/isUnexpected.d.ts.map +1 -1
- package/dist/browser/isUnexpected.js +0 -3
- package/dist/browser/isUnexpected.js.map +1 -1
- package/dist/browser/models.d.ts +96 -7
- package/dist/browser/models.d.ts.map +1 -1
- package/dist/browser/models.js.map +1 -1
- package/dist/browser/outputModels.d.ts +31 -209
- package/dist/browser/outputModels.d.ts.map +1 -1
- package/dist/browser/outputModels.js.map +1 -1
- package/dist/browser/parameters.d.ts +4 -160
- package/dist/browser/parameters.d.ts.map +1 -1
- package/dist/browser/parameters.js.map +1 -1
- package/dist/browser/responses.d.ts +5 -62
- package/dist/browser/responses.d.ts.map +1 -1
- package/dist/browser/responses.js.map +1 -1
- package/dist/browser/textTranslationClient.d.ts.map +1 -1
- package/dist/browser/textTranslationClient.js +3 -3
- package/dist/browser/textTranslationClient.js.map +1 -1
- package/dist/commonjs/clientDefinitions.d.ts +2 -20
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -1
- package/dist/commonjs/clientDefinitions.js.map +1 -1
- package/dist/commonjs/customClient.js +2 -2
- package/dist/commonjs/customClient.js.map +1 -1
- package/dist/commonjs/index.d.ts +0 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +0 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/isUnexpected.d.ts +1 -4
- package/dist/commonjs/isUnexpected.d.ts.map +1 -1
- package/dist/commonjs/isUnexpected.js +0 -3
- package/dist/commonjs/isUnexpected.js.map +1 -1
- package/dist/commonjs/models.d.ts +96 -7
- package/dist/commonjs/models.d.ts.map +1 -1
- package/dist/commonjs/models.js.map +1 -1
- package/dist/commonjs/outputModels.d.ts +31 -209
- package/dist/commonjs/outputModels.d.ts.map +1 -1
- package/dist/commonjs/outputModels.js.map +1 -1
- package/dist/commonjs/parameters.d.ts +4 -160
- package/dist/commonjs/parameters.d.ts.map +1 -1
- package/dist/commonjs/parameters.js.map +1 -1
- package/dist/commonjs/responses.d.ts +5 -62
- package/dist/commonjs/responses.d.ts.map +1 -1
- package/dist/commonjs/responses.js.map +1 -1
- package/dist/commonjs/textTranslationClient.d.ts.map +1 -1
- package/dist/commonjs/textTranslationClient.js +3 -3
- package/dist/commonjs/textTranslationClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/clientDefinitions.d.ts +2 -20
- package/dist/esm/clientDefinitions.d.ts.map +1 -1
- package/dist/esm/clientDefinitions.js.map +1 -1
- package/dist/esm/customClient.js +2 -2
- package/dist/esm/customClient.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/isUnexpected.d.ts +1 -4
- package/dist/esm/isUnexpected.d.ts.map +1 -1
- package/dist/esm/isUnexpected.js +0 -3
- package/dist/esm/isUnexpected.js.map +1 -1
- package/dist/esm/models.d.ts +96 -7
- package/dist/esm/models.d.ts.map +1 -1
- package/dist/esm/models.js.map +1 -1
- package/dist/esm/outputModels.d.ts +31 -209
- package/dist/esm/outputModels.d.ts.map +1 -1
- package/dist/esm/outputModels.js.map +1 -1
- package/dist/esm/parameters.d.ts +4 -160
- package/dist/esm/parameters.d.ts.map +1 -1
- package/dist/esm/parameters.js.map +1 -1
- package/dist/esm/responses.d.ts +5 -62
- package/dist/esm/responses.d.ts.map +1 -1
- package/dist/esm/responses.js.map +1 -1
- package/dist/esm/textTranslationClient.d.ts.map +1 -1
- package/dist/esm/textTranslationClient.js +3 -3
- package/dist/esm/textTranslationClient.js.map +1 -1
- package/dist/react-native/clientDefinitions.d.ts +2 -20
- package/dist/react-native/clientDefinitions.d.ts.map +1 -1
- package/dist/react-native/clientDefinitions.js.map +1 -1
- package/dist/react-native/customClient.js +2 -2
- package/dist/react-native/customClient.js.map +1 -1
- package/dist/react-native/index.d.ts +0 -1
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +0 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/isUnexpected.d.ts +1 -4
- package/dist/react-native/isUnexpected.d.ts.map +1 -1
- package/dist/react-native/isUnexpected.js +0 -3
- package/dist/react-native/isUnexpected.js.map +1 -1
- package/dist/react-native/models.d.ts +96 -7
- package/dist/react-native/models.d.ts.map +1 -1
- package/dist/react-native/models.js.map +1 -1
- package/dist/react-native/outputModels.d.ts +31 -209
- package/dist/react-native/outputModels.d.ts.map +1 -1
- package/dist/react-native/outputModels.js.map +1 -1
- package/dist/react-native/parameters.d.ts +4 -160
- package/dist/react-native/parameters.d.ts.map +1 -1
- package/dist/react-native/parameters.js.map +1 -1
- package/dist/react-native/responses.d.ts +5 -62
- package/dist/react-native/responses.d.ts.map +1 -1
- package/dist/react-native/responses.js.map +1 -1
- package/dist/react-native/textTranslationClient.d.ts.map +1 -1
- package/dist/react-native/textTranslationClient.js +3 -3
- package/dist/react-native/textTranslationClient.js.map +1 -1
- package/package.json +2 -2
- package/review/ai-translation-text-node.api.md +66 -334
- package/dist/browser/serializeHelper.d.ts +0 -2
- package/dist/browser/serializeHelper.d.ts.map +0 -1
- package/dist/browser/serializeHelper.js +0 -13
- package/dist/browser/serializeHelper.js.map +0 -1
- package/dist/commonjs/serializeHelper.d.ts +0 -2
- package/dist/commonjs/serializeHelper.d.ts.map +0 -1
- package/dist/commonjs/serializeHelper.js +0 -16
- package/dist/commonjs/serializeHelper.js.map +0 -1
- package/dist/esm/serializeHelper.d.ts +0 -2
- package/dist/esm/serializeHelper.d.ts.map +0 -1
- package/dist/esm/serializeHelper.js +0 -13
- package/dist/esm/serializeHelper.js.map +0 -1
- package/dist/react-native/serializeHelper.d.ts +0 -2
- package/dist/react-native/serializeHelper.d.ts.map +0 -1
- package/dist/react-native/serializeHelper.js +0 -13
- package/dist/react-native/serializeHelper.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0-beta.1 (Unreleased)
|
|
4
4
|
|
|
5
5
|
### Features Added
|
|
6
6
|
|
|
7
|
+
- Added support for the latest Azure AI Translator API, including translations using LLM models, adaptive custom translation, tone variant translations, and gender-specific translations.
|
|
8
|
+
- Added `TranslationTarget` for configuring translation options.
|
|
9
|
+
|
|
7
10
|
### Breaking Changes
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
- Upgraded to API version `2025-10-01-preview`
|
|
13
|
+
- Get languages returns `models` listing the LLM models available for translations.
|
|
14
|
+
- Dictionary, sentence boundaries and text alignments features have been deprecated.
|
|
10
15
|
|
|
11
16
|
### Other Changes
|
|
12
17
|
|
|
18
|
+
- Updated dependencies to latest versions
|
|
19
|
+
|
|
13
20
|
## 1.0.2 (2025-08-22)
|
|
14
21
|
|
|
15
22
|
### Other Changes
|
package/README.md
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
# Azure TextTranslation REST client library for JavaScript
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
machine translation technology to enable quick and accurate source-to-target text translation
|
|
5
|
-
in real time across all supported languages.
|
|
3
|
+
Azure text translation is a cloud-based REST API provided by the Azure Translator service. It utilizes neural machine translation technology to deliver precise, contextually relevant, and semantically accurate real-time text translations across all supported languages.
|
|
6
4
|
|
|
7
|
-
The
|
|
5
|
+
The client library offers several key functionalities:
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- Retrieve the list of languages supported for translation and transliteration operations, as well as LLM models available for translations.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- Perform deterministic text translation from a specified source language to a target language, with configurable parameters to ensure precision and maintain contextual integrity.
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
- Execute transliteration by converting text from the original script to an alternative script representation.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Dictionary lookup. Returns equivalent words for the source term in the target language.
|
|
18
|
-
|
|
19
|
-
Dictionary example Returns grammatical structure and context examples for the source term and target term pair.
|
|
13
|
+
- Use LLM models to produce translation output variants that are tone-specific and gender-aware.
|
|
20
14
|
|
|
21
15
|
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
|
|
22
16
|
|
|
23
17
|
Key links:
|
|
24
18
|
|
|
25
19
|
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-translation-text)
|
|
26
|
-
- [API reference documentation](https://learn.microsoft.com/azure/
|
|
20
|
+
- [API reference documentation](https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/rest-api-guide)
|
|
27
21
|
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-text-rest/samples)
|
|
28
22
|
|
|
29
23
|
## Getting started
|
|
@@ -135,12 +129,10 @@ if (languages.transliteration) {
|
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
|
|
138
|
-
if (languages.
|
|
139
|
-
console.log("
|
|
140
|
-
for (const
|
|
141
|
-
console.log(
|
|
142
|
-
`${key} -- name: ${dictionaryLanguage.name} (${dictionaryLanguage.nativeName}), supported target languages count: ${dictionaryLanguage.translations.length}`,
|
|
143
|
-
);
|
|
132
|
+
if (languages.models) {
|
|
133
|
+
console.log("Available LLM Models:");
|
|
134
|
+
for (const model in languages.models) {
|
|
135
|
+
console.log(model);
|
|
144
136
|
}
|
|
145
137
|
}
|
|
146
138
|
```
|
|
@@ -166,24 +158,23 @@ const credential: TranslatorCredential = {
|
|
|
166
158
|
};
|
|
167
159
|
const translationClient = TextTranslationClient(endpoint, credential);
|
|
168
160
|
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
const input = {
|
|
162
|
+
text: "This is a test.",
|
|
163
|
+
targets: [{ language: "cs" }],
|
|
164
|
+
language: "en",
|
|
173
165
|
};
|
|
174
166
|
const translateResponse = await translationClient.path("/translate").post({
|
|
175
|
-
body:
|
|
176
|
-
queryParameters: parameters,
|
|
167
|
+
body: { inputs: [input] },
|
|
177
168
|
});
|
|
178
169
|
|
|
179
170
|
if (isUnexpected(translateResponse)) {
|
|
180
171
|
throw translateResponse.body.error;
|
|
181
172
|
}
|
|
182
173
|
|
|
183
|
-
const translations = translateResponse.body;
|
|
174
|
+
const translations = translateResponse.body.value;
|
|
184
175
|
for (const translation of translations) {
|
|
185
176
|
console.log(
|
|
186
|
-
`Text was translated to: '${translation?.translations[0]?.
|
|
177
|
+
`Text was translated to: '${translation?.translations[0]?.language}' and the result is: '${translation?.translations[0]?.text}'.`,
|
|
187
178
|
);
|
|
188
179
|
}
|
|
189
180
|
```
|
|
@@ -216,7 +207,7 @@ const parameters = {
|
|
|
216
207
|
toScript: "Latn",
|
|
217
208
|
};
|
|
218
209
|
const transliterateResponse = await translationClient.path("/transliterate").post({
|
|
219
|
-
body: inputText,
|
|
210
|
+
body: { inputs: inputText },
|
|
220
211
|
queryParameters: parameters,
|
|
221
212
|
});
|
|
222
213
|
|
|
@@ -224,8 +215,8 @@ if (isUnexpected(transliterateResponse)) {
|
|
|
224
215
|
throw transliterateResponse.body.error;
|
|
225
216
|
}
|
|
226
217
|
|
|
227
|
-
const
|
|
228
|
-
for (const transliteration of
|
|
218
|
+
const transliterations = transliterateResponse.body.value;
|
|
219
|
+
for (const transliteration of transliterations) {
|
|
229
220
|
console.log(
|
|
230
221
|
`Input text was transliterated to '${transliteration?.script}' script. Transliterated text: '${transliteration?.text}'.`,
|
|
231
222
|
);
|
|
@@ -234,139 +225,7 @@ for (const transliteration of translations) {
|
|
|
234
225
|
|
|
235
226
|
Please refer to the service documentation for a conceptual discussion of [transliterate][transliterate_doc].
|
|
236
227
|
|
|
237
|
-
### Break Sentence
|
|
238
|
-
|
|
239
|
-
Identifies the positioning of sentence boundaries in a piece of text.
|
|
240
|
-
|
|
241
|
-
```ts snippet:ReadmeSampleBreakSentence
|
|
242
|
-
import TextTranslationClient, {
|
|
243
|
-
TranslatorCredential,
|
|
244
|
-
isUnexpected,
|
|
245
|
-
} from "@azure-rest/ai-translation-text";
|
|
246
|
-
|
|
247
|
-
const endpoint = "https://api.cognitive.microsofttranslator.com";
|
|
248
|
-
const key = "YOUR_SUBSCRIPTION_KEY";
|
|
249
|
-
const region = "westus";
|
|
250
|
-
const credential: TranslatorCredential = {
|
|
251
|
-
key,
|
|
252
|
-
region,
|
|
253
|
-
};
|
|
254
|
-
const translationClient = TextTranslationClient(endpoint, credential);
|
|
255
|
-
|
|
256
|
-
const inputText = [{ text: "zhè shì gè cè shì。" }];
|
|
257
|
-
const parameters = {
|
|
258
|
-
language: "zh-Hans",
|
|
259
|
-
script: "Latn",
|
|
260
|
-
};
|
|
261
|
-
const breakSentenceResponse = await translationClient.path("/breaksentence").post({
|
|
262
|
-
body: inputText,
|
|
263
|
-
queryParameters: parameters,
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
if (isUnexpected(breakSentenceResponse)) {
|
|
267
|
-
throw breakSentenceResponse.body.error;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const breakSentences = breakSentenceResponse.body;
|
|
271
|
-
for (const breakSentence of breakSentences) {
|
|
272
|
-
console.log(`The detected sentece boundaries: '${breakSentence?.sentLen.join(", ")}'.`);
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
Please refer to the service documentation for a conceptual discussion of [break sentence][breaksentence_doc].
|
|
277
|
-
|
|
278
|
-
### Dictionary Lookup
|
|
279
|
-
|
|
280
|
-
Returns equivalent words for the source term in the target language.
|
|
281
|
-
|
|
282
|
-
```ts snippet:ReadmeSampleDictionaryLookup
|
|
283
|
-
import TextTranslationClient, {
|
|
284
|
-
TranslatorCredential,
|
|
285
|
-
isUnexpected,
|
|
286
|
-
} from "@azure-rest/ai-translation-text";
|
|
287
228
|
|
|
288
|
-
const endpoint = "https://api.cognitive.microsofttranslator.com";
|
|
289
|
-
const key = "YOUR_SUBSCRIPTION_KEY";
|
|
290
|
-
const region = "westus";
|
|
291
|
-
const credential: TranslatorCredential = {
|
|
292
|
-
key,
|
|
293
|
-
region,
|
|
294
|
-
};
|
|
295
|
-
const translationClient = TextTranslationClient(endpoint, credential);
|
|
296
|
-
|
|
297
|
-
const inputText = [{ text: "fly" }];
|
|
298
|
-
const parameters = {
|
|
299
|
-
to: "es",
|
|
300
|
-
from: "en",
|
|
301
|
-
};
|
|
302
|
-
const dictionaryResponse = await translationClient.path("/dictionary/lookup").post({
|
|
303
|
-
body: inputText,
|
|
304
|
-
queryParameters: parameters,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
if (isUnexpected(dictionaryResponse)) {
|
|
308
|
-
throw dictionaryResponse.body.error;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const dictionaryEntries = dictionaryResponse.body;
|
|
312
|
-
for (const dictionaryEntry of dictionaryEntries) {
|
|
313
|
-
console.log(
|
|
314
|
-
`For the given input ${dictionaryEntry?.translations?.length} entries were found in the dictionary.`,
|
|
315
|
-
);
|
|
316
|
-
console.log(
|
|
317
|
-
`First entry: '${dictionaryEntry?.translations[0]?.displayTarget}', confidence: ${dictionaryEntry?.translations[0]?.confidence}.`,
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
Please refer to the service documentation for a conceptual discussion of [dictionary lookup][dictionarylookup_doc].
|
|
323
|
-
|
|
324
|
-
### Dictionary Examples
|
|
325
|
-
|
|
326
|
-
Returns grammatical structure and context examples for the source term and target term pair.
|
|
327
|
-
|
|
328
|
-
```ts snippet:ReadmeSampleDictionaryExamples
|
|
329
|
-
import TextTranslationClient, {
|
|
330
|
-
TranslatorCredential,
|
|
331
|
-
isUnexpected,
|
|
332
|
-
} from "@azure-rest/ai-translation-text";
|
|
333
|
-
|
|
334
|
-
const endpoint = "https://api.cognitive.microsofttranslator.com";
|
|
335
|
-
const key = "YOUR_SUBSCRIPTION_KEY";
|
|
336
|
-
const region = "westus";
|
|
337
|
-
const credential: TranslatorCredential = {
|
|
338
|
-
key,
|
|
339
|
-
region,
|
|
340
|
-
};
|
|
341
|
-
const translationClient = TextTranslationClient(endpoint, credential);
|
|
342
|
-
|
|
343
|
-
const inputText = [{ text: "fly", translation: "volar" }];
|
|
344
|
-
const parameters = {
|
|
345
|
-
to: "es",
|
|
346
|
-
from: "en",
|
|
347
|
-
};
|
|
348
|
-
const dictionaryResponse = await translationClient.path("/dictionary/examples").post({
|
|
349
|
-
body: inputText,
|
|
350
|
-
queryParameters: parameters,
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
if (isUnexpected(dictionaryResponse)) {
|
|
354
|
-
throw dictionaryResponse.body.error;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
const dictionaryExamples = dictionaryResponse.body;
|
|
358
|
-
for (const dictionaryExample of dictionaryExamples) {
|
|
359
|
-
console.log(
|
|
360
|
-
`For the given input ${dictionaryExample?.examples?.length} examples were found in the dictionary.`,
|
|
361
|
-
);
|
|
362
|
-
const firstExample = dictionaryExample?.examples[0];
|
|
363
|
-
console.log(
|
|
364
|
-
`Example: '${firstExample.targetPrefix + firstExample.targetTerm + firstExample.targetSuffix}'.`,
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
Please refer to the service documentation for a conceptual discussion of [dictionary examples][dictionaryexamples_doc].
|
|
370
229
|
|
|
371
230
|
## Troubleshooting
|
|
372
231
|
|
|
@@ -374,8 +233,6 @@ When you interact with the Translator Service using the TextTranslator client li
|
|
|
374
233
|
|
|
375
234
|
For example, if you submit a translation request without a target translate language, a `400` error is returned, indicating "Bad Request".
|
|
376
235
|
|
|
377
|
-
You can find the different error codes returned by the service in the [Service Documentation][service_errors].
|
|
378
|
-
|
|
379
236
|
### Logging
|
|
380
237
|
|
|
381
238
|
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
@@ -390,13 +247,9 @@ For more detailed instructions on how to enable logs, you can look at the [@azur
|
|
|
390
247
|
|
|
391
248
|
[azure_cli]: https://learn.microsoft.com/cli/azure
|
|
392
249
|
[azure_portal]: https://portal.azure.com
|
|
393
|
-
[translator_resource_create]: https://learn.microsoft.com/azure/
|
|
394
|
-
[translator_auth]: https://learn.microsoft.com/azure/
|
|
395
|
-
[service_errors]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-reference#errors
|
|
250
|
+
[translator_resource_create]: https://learn.microsoft.com/azure/ai-services/translator/how-to/create-translator-resource?tabs=foundry
|
|
251
|
+
[translator_auth]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/reference/authentication
|
|
396
252
|
[translator_client_class]: https://learn.microsoft.com/javascript/api/@azure-rest/ai-translation-text/texttranslationclient
|
|
397
|
-
[languages_doc]: https://learn.microsoft.com/azure/
|
|
398
|
-
[translate_doc]: https://learn.microsoft.com/azure/
|
|
399
|
-
[transliterate_doc]: https://learn.microsoft.com/azure/
|
|
400
|
-
[breaksentence_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-break-sentence
|
|
401
|
-
[dictionarylookup_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup
|
|
402
|
-
[dictionaryexamples_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-examples
|
|
253
|
+
[languages_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/get-languages
|
|
254
|
+
[translate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/translate-api
|
|
255
|
+
[transliterate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/transliterate-api
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GetSupportedLanguagesParameters, TranslateParameters, TransliterateParameters
|
|
2
|
-
import type { GetSupportedLanguages200Response, GetSupportedLanguagesDefaultResponse, Translate200Response, TranslateDefaultResponse, Transliterate200Response, TransliterateDefaultResponse
|
|
1
|
+
import type { GetSupportedLanguagesParameters, TranslateParameters, TransliterateParameters } from "./parameters.js";
|
|
2
|
+
import type { GetSupportedLanguages200Response, GetSupportedLanguagesDefaultResponse, Translate200Response, TranslateDefaultResponse, Transliterate200Response, TransliterateDefaultResponse } from "./responses.js";
|
|
3
3
|
import type { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
4
4
|
export interface GetSupportedLanguages {
|
|
5
5
|
/** Gets the set of languages currently supported by other operations of the Translator. */
|
|
@@ -13,18 +13,6 @@ export interface Transliterate {
|
|
|
13
13
|
/** Transliterate Text */
|
|
14
14
|
post(options: TransliterateParameters): StreamableMethod<Transliterate200Response | TransliterateDefaultResponse>;
|
|
15
15
|
}
|
|
16
|
-
export interface FindSentenceBoundaries {
|
|
17
|
-
/** Find Sentence Boundaries */
|
|
18
|
-
post(options: FindSentenceBoundariesParameters): StreamableMethod<FindSentenceBoundaries200Response | FindSentenceBoundariesDefaultResponse>;
|
|
19
|
-
}
|
|
20
|
-
export interface LookupDictionaryEntries {
|
|
21
|
-
/** Lookup Dictionary Entries */
|
|
22
|
-
post(options: LookupDictionaryEntriesParameters): StreamableMethod<LookupDictionaryEntries200Response | LookupDictionaryEntriesDefaultResponse>;
|
|
23
|
-
}
|
|
24
|
-
export interface LookupDictionaryExamples {
|
|
25
|
-
/** Lookup Dictionary Examples */
|
|
26
|
-
post(options: LookupDictionaryExamplesParameters): StreamableMethod<LookupDictionaryExamples200Response | LookupDictionaryExamplesDefaultResponse>;
|
|
27
|
-
}
|
|
28
16
|
export interface Routes {
|
|
29
17
|
/** Resource for '/languages' has methods for the following verbs: get */
|
|
30
18
|
(path: "/languages"): GetSupportedLanguages;
|
|
@@ -32,12 +20,6 @@ export interface Routes {
|
|
|
32
20
|
(path: "/translate"): Translate;
|
|
33
21
|
/** Resource for '/transliterate' has methods for the following verbs: post */
|
|
34
22
|
(path: "/transliterate"): Transliterate;
|
|
35
|
-
/** Resource for '/breaksentence' has methods for the following verbs: post */
|
|
36
|
-
(path: "/breaksentence"): FindSentenceBoundaries;
|
|
37
|
-
/** Resource for '/dictionary/lookup' has methods for the following verbs: post */
|
|
38
|
-
(path: "/dictionary/lookup"): LookupDictionaryEntries;
|
|
39
|
-
/** Resource for '/dictionary/examples' has methods for the following verbs: post */
|
|
40
|
-
(path: "/dictionary/examples"): LookupDictionaryExamples;
|
|
41
23
|
}
|
|
42
24
|
export type TextTranslationClient = Client & {
|
|
43
25
|
path: Routes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientDefinitions.d.ts","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"clientDefinitions.d.ts","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,gCAAgC,EAChC,oCAAoC,EACpC,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,WAAW,qBAAqB;IACpC,2FAA2F;IAC3F,GAAG,CACD,OAAO,CAAC,EAAE,+BAA+B,GACxC,gBAAgB,CAAC,gCAAgC,GAAG,oCAAoC,CAAC,CAAC;CAC9F;AAED,MAAM,WAAW,SAAS;IACxB,qBAAqB;IACrB,IAAI,CACF,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,aAAa;IAC5B,yBAAyB;IACzB,IAAI,CACF,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAAC,wBAAwB,GAAG,4BAA4B,CAAC,CAAC;CAC9E;AAED,MAAM,WAAW,MAAM;IACrB,yEAAyE;IACzE,CAAC,IAAI,EAAE,YAAY,GAAG,qBAAqB,CAAC;IAC5C,0EAA0E;IAC1E,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,8EAA8E;IAC9E,CAAC,IAAI,EAAE,gBAAgB,GAAG,aAAa,CAAC;CACzC;AAED,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -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 type {\n GetSupportedLanguagesParameters,\n TranslateParameters,\n TransliterateParameters,\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\nimport type {\n GetSupportedLanguagesParameters,\n TranslateParameters,\n TransliterateParameters,\n} from \"./parameters.js\";\nimport type {\n GetSupportedLanguages200Response,\n GetSupportedLanguagesDefaultResponse,\n Translate200Response,\n TranslateDefaultResponse,\n Transliterate200Response,\n TransliterateDefaultResponse,\n} from \"./responses.js\";\nimport type { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface GetSupportedLanguages {\n /** Gets the set of languages currently supported by other operations of the Translator. */\n get(\n options?: GetSupportedLanguagesParameters,\n ): StreamableMethod<GetSupportedLanguages200Response | GetSupportedLanguagesDefaultResponse>;\n}\n\nexport interface Translate {\n /** Translate Text */\n post(\n options: TranslateParameters,\n ): StreamableMethod<Translate200Response | TranslateDefaultResponse>;\n}\n\nexport interface Transliterate {\n /** Transliterate Text */\n post(\n options: TransliterateParameters,\n ): StreamableMethod<Transliterate200Response | TransliterateDefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/languages' has methods for the following verbs: get */\n (path: \"/languages\"): GetSupportedLanguages;\n /** Resource for '/translate' has methods for the following verbs: post */\n (path: \"/translate\"): Translate;\n /** Resource for '/transliterate' has methods for the following verbs: post */\n (path: \"/transliterate\"): Transliterate;\n}\n\nexport type TextTranslationClient = Client & {\n path: Routes;\n};\n"]}
|
|
@@ -46,7 +46,7 @@ export default function createClient(arg1, arg2, arg3) {
|
|
|
46
46
|
if (!options) {
|
|
47
47
|
options = {};
|
|
48
48
|
}
|
|
49
|
-
options.apiVersion = options.apiVersion ?? "
|
|
49
|
+
options.apiVersion = options.apiVersion ?? "2025-10-01-preview";
|
|
50
50
|
if (!endpoint) {
|
|
51
51
|
serviceEndpoint = DEFAULT_ENPOINT;
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ export default function createClient(arg1, arg2, arg3) {
|
|
|
57
57
|
serviceEndpoint = endpoint;
|
|
58
58
|
}
|
|
59
59
|
const baseUrl = options.baseUrl ?? `${serviceEndpoint}`;
|
|
60
|
-
const userAgentInfo = `azsdk-js-ai-translation-text-rest/
|
|
60
|
+
const userAgentInfo = `azsdk-js-ai-translation-text-rest/2.0.0-beta.1`;
|
|
61
61
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
62
62
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
63
63
|
: `${userAgentInfo}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customClient.js","sourceRoot":"","sources":["../../src/customClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAC;AAM9D,OAAO,EACL,aAAa,EACb,8BAA8B,EAC9B,sCAAsC,EACtC,6CAA6C,GAC9C,MAAM,+BAA+B,CAAC;AAGvC,MAAM,eAAe,GAAG,+CAA+C,CAAC;AACxE,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,EAAE,GAAG,KAAK,SAAS,CAAC;AAC1D,CAAC;AAED,SAAS,yBAAyB,CAAC,UAAe;IAChD,OAAQ,UAAmC,EAAE,GAAG,KAAK,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAe;IACxC,OAAQ,UAA8B,EAAE,QAAQ,KAAK,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,2BAA2B,CAAC,UAAe;IAClD,OAAO,CACJ,UAAwC,EAAE,eAAe,KAAK,SAAS;QACvE,UAAwC,EAAE,eAAe,KAAK,SAAS,CACzE,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,UAAe;IACpC,OAAO,CACL,eAAe,CAAC,UAAU,CAAC;QAC3B,yBAAyB,CAAC,UAAU,CAAC;QACrC,iBAAiB,CAAC,UAAU,CAAC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;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACvD,CAAC;SAAM,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,gBAAgB,CAAC,+BAA+B,CAAC;YAC/C,UAAU,EAAE,UAA6B;YACzC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,aAAa;SACtD,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,IAAI,2BAA2B,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,gBAAgB,CAAC,+BAA+B,CAAC;YAC/C,UAAU,EAAG,UAAwC,CAAC,eAAe;YACrE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,aAAa;SACtD,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,6CAA6C,CAAC,UAAuC,CAAC,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport * as coreRestPipeline from \"@azure/core-rest-pipeline\";\nimport type { TextTranslationClient } from \"./clientDefinitions.js\";\nimport type {\n TranslatorCredential,\n TranslatorTokenCredential,\n} from \"./authenticationCustomized.js\";\nimport {\n DEFAULT_SCOPE,\n TranslatorAuthenticationPolicy,\n TranslatorAzureKeyAuthenticationPolicy,\n TranslatorTokenCredentialAuthenticationPolicy,\n} from \"./authenticationCustomized.js\";\nimport type { AzureKeyCredential, KeyCredential, TokenCredential } from \"@azure/core-auth\";\n\nconst DEFAULT_ENPOINT = \"https://api.cognitive.microsofttranslator.com\";\nconst PLATFORM_HOST = \"cognitiveservices\";\nconst PLATFORM_PATH = \"/translator/text/v3.0\";\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential)?.key !== undefined;\n}\n\nfunction isTranslatorKeyCredential(credential: any): credential is TranslatorCredential {\n return (credential as TranslatorCredential)?.key !== undefined;\n}\n\nfunction isTokenCredential(credential: any): credential is TokenCredential {\n return (credential as TokenCredential)?.getToken !== undefined;\n}\n\nfunction isTranslatorTokenCredential(credential: any): credential is TranslatorTokenCredential {\n return (\n (credential as TranslatorTokenCredential)?.tokenCredential !== undefined &&\n (credential as TranslatorTokenCredential)?.azureResourceId !== undefined\n );\n}\n\nfunction isCredentials(credential: any): boolean {\n return (\n isKeyCredential(credential) ||\n isTranslatorKeyCredential(credential) ||\n isTokenCredential(credential) ||\n isTranslatorTokenCredential(credential)\n );\n}\n\n/**\n * Initialize a new instance of `TextTranslationClient`\n * @param credential - type: TranslatorCredential | TranslatorTokenCredential | KeyCredential |TokenCredential, credentials\n * used to authenticate the service with.\n * @param options - type: ClientOptions, the parameter for all optional parameters\n */\nexport default function createClient(\n credential: TranslatorCredential | TranslatorTokenCredential | KeyCredential | TokenCredential,\n options?: ClientOptions,\n): TextTranslationClient;\n\n/**\n * Initialize a new instance of `TextTranslationClient`\n * @param endpoint - type: string, Supported Text Translation endpoints (protocol and hostname, for example:\n * https://api.cognitive.microsofttranslator.com).\n * @param options - type: ClientOptions, the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n options?: ClientOptions,\n): TextTranslationClient;\n\n/**\n * Initialize a new instance of `TextTranslationClient`\n * @param endpoint - type: string, Supported Text Translation endpoints (protocol and hostname, for example:\n * https://api.cognitive.microsofttranslator.com).\n * @param credential - type: TranslatorCredential | TranslatorTokenCredential | KeyCredential |TokenCredential, credentials\n * used to authenticate the service with.\n * @param options - type: ClientOptions, the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credential: TranslatorCredential | TranslatorTokenCredential | KeyCredential | TokenCredential,\n options?: ClientOptions,\n): TextTranslationClient;\n\n// Implementation\nexport default function createClient(\n arg1?:\n | string\n | (TranslatorCredential | TranslatorTokenCredential | KeyCredential | TokenCredential),\n arg2?:\n | (TranslatorCredential | TranslatorTokenCredential | KeyCredential | TokenCredential)\n | ClientOptions,\n arg3?: ClientOptions,\n): TextTranslationClient {\n let serviceEndpoint: string;\n\n let endpoint: string | undefined;\n let options: ClientOptions | undefined;\n let credential:\n | TranslatorCredential\n | TranslatorTokenCredential\n | KeyCredential\n | TokenCredential\n | undefined;\n\n if (typeof arg1 === \"string\") {\n endpoint = arg1;\n }\n\n if (typeof arg1 !== \"string\" && isCredentials(arg1)) {\n credential = arg1;\n options = arg2 as ClientOptions;\n } else if (isCredentials(arg2)) {\n credential = arg2 as\n | TranslatorCredential\n | TranslatorTokenCredential\n | KeyCredential\n | TokenCredential;\n options = arg3;\n }\n\n if (!options) {\n options = {};\n }\n\n options.apiVersion = options.apiVersion ?? \"2025-10-01-preview\";\n\n if (!endpoint) {\n serviceEndpoint = DEFAULT_ENPOINT;\n } else if (endpoint.toLowerCase().indexOf(PLATFORM_HOST) !== -1) {\n serviceEndpoint = `${endpoint}${PLATFORM_PATH}`;\n } else {\n serviceEndpoint = endpoint;\n }\n\n const baseUrl = options.baseUrl ?? `${serviceEndpoint}`;\n\n const userAgentInfo = `azsdk-js-ai-translation-text-rest/2.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 };\n\n const client = getClient(baseUrl, options) as TextTranslationClient;\n\n if (isTranslatorKeyCredential(credential)) {\n const mtAuthneticationPolicy = new TranslatorAuthenticationPolicy(\n credential as TranslatorCredential,\n );\n client.pipeline.addPolicy(mtAuthneticationPolicy);\n } else if (isKeyCredential(credential)) {\n const mtKeyAuthenticationPolicy = new TranslatorAzureKeyAuthenticationPolicy(\n credential as AzureKeyCredential,\n );\n client.pipeline.addPolicy(mtKeyAuthenticationPolicy);\n } else if (isTokenCredential(credential)) {\n client.pipeline.addPolicy(\n coreRestPipeline.bearerTokenAuthenticationPolicy({\n credential: credential as TokenCredential,\n scopes: options?.credentials?.scopes ?? DEFAULT_SCOPE,\n }),\n );\n } else if (isTranslatorTokenCredential(credential)) {\n client.pipeline.addPolicy(\n coreRestPipeline.bearerTokenAuthenticationPolicy({\n credential: (credential as TranslatorTokenCredential).tokenCredential,\n scopes: options?.credentials?.scopes ?? DEFAULT_SCOPE,\n }),\n );\n client.pipeline.addPolicy(\n new TranslatorTokenCredentialAuthenticationPolicy(credential as TranslatorTokenCredential),\n );\n }\n\n return client;\n}\n"]}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./clientDefinitions.js";
|
|
|
6
6
|
export * from "./isUnexpected.js";
|
|
7
7
|
export * from "./models.js";
|
|
8
8
|
export * from "./outputModels.js";
|
|
9
|
-
export * from "./serializeHelper.js";
|
|
10
9
|
export { TranslatorCredential, TranslatorTokenCredential } from "./authenticationCustomized.js";
|
|
11
10
|
export default TextTranslationClient;
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AAEtD,cAAc,mBAAmB,CAAC;AAClC,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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AAEtD,cAAc,mBAAmB,CAAC;AAClC,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,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAGhG,eAAe,qBAAqB,CAAC"}
|
package/dist/browser/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./clientDefinitions.js";
|
|
|
8
8
|
export * from "./isUnexpected.js";
|
|
9
9
|
export * from "./models.js";
|
|
10
10
|
export * from "./outputModels.js";
|
|
11
|
-
export * from "./serializeHelper.js";
|
|
12
11
|
// eslint-disable-next-line @azure/azure-sdk/ts-modules-only-named
|
|
13
12
|
export default TextTranslationClient;
|
|
14
13
|
//# 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,qBAAqB,MAAM,mBAAmB,CAAC;AAEtD,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AAEtD,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAGlC,kEAAkE;AAClE,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport TextTranslationClient from \"./customClient.js\";\n\nexport * from \"./customClient.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 { TranslatorCredential, TranslatorTokenCredential } from \"./authenticationCustomized.js\";\n\n// eslint-disable-next-line @azure/azure-sdk/ts-modules-only-named\nexport default TextTranslationClient;\n"]}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { GetSupportedLanguages200Response, GetSupportedLanguagesDefaultResponse, Translate200Response, TranslateDefaultResponse, Transliterate200Response, TransliterateDefaultResponse
|
|
1
|
+
import type { GetSupportedLanguages200Response, GetSupportedLanguagesDefaultResponse, Translate200Response, TranslateDefaultResponse, Transliterate200Response, TransliterateDefaultResponse } from "./responses.js";
|
|
2
2
|
export declare function isUnexpected(response: GetSupportedLanguages200Response | GetSupportedLanguagesDefaultResponse): response is GetSupportedLanguagesDefaultResponse;
|
|
3
3
|
export declare function isUnexpected(response: Translate200Response | TranslateDefaultResponse): response is TranslateDefaultResponse;
|
|
4
4
|
export declare function isUnexpected(response: Transliterate200Response | TransliterateDefaultResponse): response is TransliterateDefaultResponse;
|
|
5
|
-
export declare function isUnexpected(response: FindSentenceBoundaries200Response | FindSentenceBoundariesDefaultResponse): response is FindSentenceBoundariesDefaultResponse;
|
|
6
|
-
export declare function isUnexpected(response: LookupDictionaryEntries200Response | LookupDictionaryEntriesDefaultResponse): response is LookupDictionaryEntriesDefaultResponse;
|
|
7
|
-
export declare function isUnexpected(response: LookupDictionaryExamples200Response | LookupDictionaryExamplesDefaultResponse): response is LookupDictionaryExamplesDefaultResponse;
|
|
8
5
|
//# sourceMappingURL=isUnexpected.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.d.ts","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,oCAAoC,EACpC,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"isUnexpected.d.ts","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,oCAAoC,EACpC,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AAQxB,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gCAAgC,GAAG,oCAAoC,GAChF,QAAQ,IAAI,oCAAoC,CAAC;AACpD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,oBAAoB,GAAG,wBAAwB,GACxD,QAAQ,IAAI,wBAAwB,CAAC;AACxC,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,wBAAwB,GAAG,4BAA4B,GAChE,QAAQ,IAAI,4BAA4B,CAAC"}
|
|
@@ -4,9 +4,6 @@ const responseMap = {
|
|
|
4
4
|
"GET /languages": ["200"],
|
|
5
5
|
"POST /translate": ["200"],
|
|
6
6
|
"POST /transliterate": ["200"],
|
|
7
|
-
"POST /breaksentence": ["200"],
|
|
8
|
-
"POST /dictionary/lookup": ["200"],
|
|
9
|
-
"POST /dictionary/examples": ["200"],
|
|
10
7
|
};
|
|
11
8
|
export function isUnexpected(response) {
|
|
12
9
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts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C;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,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.\n\nimport type {\n GetSupportedLanguages200Response,\n GetSupportedLanguagesDefaultResponse,\n Translate200Response,\n TranslateDefaultResponse,\n Transliterate200Response,\n TransliterateDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /languages\": [\"200\"],\n \"POST /translate\": [\"200\"],\n \"POST /transliterate\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: GetSupportedLanguages200Response | GetSupportedLanguagesDefaultResponse,\n): response is GetSupportedLanguagesDefaultResponse;\nexport function isUnexpected(\n response: Translate200Response | TranslateDefaultResponse,\n): response is TranslateDefaultResponse;\nexport function isUnexpected(\n response: Transliterate200Response | TransliterateDefaultResponse,\n): response is TransliterateDefaultResponse;\nexport function isUnexpected(\n response:\n | GetSupportedLanguages200Response\n | GetSupportedLanguagesDefaultResponse\n | Translate200Response\n | TranslateDefaultResponse\n | Transliterate200Response\n | TransliterateDefaultResponse,\n): response is\n | GetSupportedLanguagesDefaultResponse\n | TranslateDefaultResponse\n | TransliterateDefaultResponse {\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"]}
|