@azure-rest/ai-translation-document 1.0.0-alpha.20250227.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.
Files changed (190) hide show
  1. package/README.md +227 -167
  2. package/dist/browser/clientDefinitions.d.ts +191 -0
  3. package/dist/browser/clientDefinitions.d.ts.map +1 -0
  4. package/dist/browser/documentTranslationClient.d.ts +16 -0
  5. package/dist/browser/documentTranslationClient.d.ts.map +1 -0
  6. package/{dist-esm/src → dist/browser}/documentTranslationClient.js +1 -1
  7. package/dist/browser/documentTranslationClient.js.map +1 -0
  8. package/dist/browser/index.d.ts +12 -0
  9. package/dist/browser/index.d.ts.map +1 -0
  10. package/dist/browser/index.js +14 -0
  11. package/dist/browser/index.js.map +1 -0
  12. package/dist/browser/isUnexpected.d.ts +10 -0
  13. package/dist/browser/isUnexpected.d.ts.map +1 -0
  14. package/dist/browser/logger.d.ts +2 -0
  15. package/dist/browser/logger.d.ts.map +1 -0
  16. package/dist/browser/models.d.ts +112 -0
  17. package/dist/browser/models.d.ts.map +1 -0
  18. package/dist/browser/outputModels.d.ts +166 -0
  19. package/dist/browser/outputModels.d.ts.map +1 -0
  20. package/dist/browser/package.json +3 -0
  21. package/dist/browser/paginateHelper.d.ts +43 -0
  22. package/dist/browser/paginateHelper.d.ts.map +1 -0
  23. package/dist/browser/parameters.d.ts +184 -0
  24. package/dist/browser/parameters.d.ts.map +1 -0
  25. package/dist/browser/pollingHelper.d.ts +77 -0
  26. package/dist/browser/pollingHelper.d.ts.map +1 -0
  27. package/dist/browser/responses.d.ts +132 -0
  28. package/dist/browser/responses.d.ts.map +1 -0
  29. package/dist/commonjs/clientDefinitions.d.ts +191 -0
  30. package/dist/commonjs/clientDefinitions.d.ts.map +1 -0
  31. package/dist/commonjs/clientDefinitions.js +3 -0
  32. package/dist/commonjs/clientDefinitions.js.map +1 -0
  33. package/dist/commonjs/documentTranslationClient.d.ts +16 -0
  34. package/dist/commonjs/documentTranslationClient.d.ts.map +1 -0
  35. package/dist/commonjs/documentTranslationClient.js +45 -0
  36. package/dist/commonjs/documentTranslationClient.js.map +1 -0
  37. package/dist/commonjs/index.d.ts +12 -0
  38. package/dist/commonjs/index.d.ts.map +1 -0
  39. package/dist/commonjs/index.js +17 -0
  40. package/dist/commonjs/index.js.map +1 -0
  41. package/dist/commonjs/isUnexpected.d.ts +10 -0
  42. package/dist/commonjs/isUnexpected.d.ts.map +1 -0
  43. package/dist/commonjs/isUnexpected.js +78 -0
  44. package/dist/commonjs/isUnexpected.js.map +1 -0
  45. package/dist/commonjs/logger.d.ts +2 -0
  46. package/dist/commonjs/logger.d.ts.map +1 -0
  47. package/dist/commonjs/logger.js +8 -0
  48. package/dist/commonjs/logger.js.map +1 -0
  49. package/dist/commonjs/models.d.ts +112 -0
  50. package/dist/commonjs/models.d.ts.map +1 -0
  51. package/dist/commonjs/models.js +5 -0
  52. package/dist/commonjs/models.js.map +1 -0
  53. package/dist/commonjs/outputModels.d.ts +166 -0
  54. package/dist/commonjs/outputModels.d.ts.map +1 -0
  55. package/dist/commonjs/outputModels.js +5 -0
  56. package/dist/commonjs/outputModels.js.map +1 -0
  57. package/dist/commonjs/package.json +3 -0
  58. package/dist/commonjs/paginateHelper.d.ts +43 -0
  59. package/dist/commonjs/paginateHelper.d.ts.map +1 -0
  60. package/dist/commonjs/paginateHelper.js +71 -0
  61. package/dist/commonjs/paginateHelper.js.map +1 -0
  62. package/dist/commonjs/parameters.d.ts +184 -0
  63. package/dist/commonjs/parameters.d.ts.map +1 -0
  64. package/dist/commonjs/parameters.js +3 -0
  65. package/dist/commonjs/parameters.js.map +1 -0
  66. package/dist/commonjs/pollingHelper.d.ts +77 -0
  67. package/dist/commonjs/pollingHelper.d.ts.map +1 -0
  68. package/dist/commonjs/pollingHelper.js +98 -0
  69. package/dist/commonjs/pollingHelper.js.map +1 -0
  70. package/dist/commonjs/responses.d.ts +132 -0
  71. package/dist/commonjs/responses.d.ts.map +1 -0
  72. package/dist/commonjs/responses.js +3 -0
  73. package/dist/commonjs/responses.js.map +1 -0
  74. package/dist/commonjs/tsdoc-metadata.json +11 -0
  75. package/dist/esm/clientDefinitions.d.ts +191 -0
  76. package/dist/esm/clientDefinitions.d.ts.map +1 -0
  77. package/dist/esm/clientDefinitions.js +2 -0
  78. package/dist/esm/clientDefinitions.js.map +1 -0
  79. package/dist/esm/documentTranslationClient.d.ts +16 -0
  80. package/dist/esm/documentTranslationClient.d.ts.map +1 -0
  81. package/dist/esm/documentTranslationClient.js +42 -0
  82. package/dist/esm/documentTranslationClient.js.map +1 -0
  83. package/dist/esm/index.d.ts +12 -0
  84. package/dist/esm/index.d.ts.map +1 -0
  85. package/dist/esm/index.js +14 -0
  86. package/dist/esm/index.js.map +1 -0
  87. package/dist/esm/isUnexpected.d.ts +10 -0
  88. package/dist/esm/isUnexpected.d.ts.map +1 -0
  89. package/dist/esm/isUnexpected.js +75 -0
  90. package/dist/esm/isUnexpected.js.map +1 -0
  91. package/dist/esm/logger.d.ts +2 -0
  92. package/dist/esm/logger.d.ts.map +1 -0
  93. package/dist/esm/logger.js +5 -0
  94. package/dist/esm/logger.js.map +1 -0
  95. package/dist/esm/models.d.ts +112 -0
  96. package/dist/esm/models.d.ts.map +1 -0
  97. package/dist/esm/models.js +4 -0
  98. package/dist/esm/models.js.map +1 -0
  99. package/dist/esm/outputModels.d.ts +166 -0
  100. package/dist/esm/outputModels.d.ts.map +1 -0
  101. package/dist/esm/outputModels.js +4 -0
  102. package/dist/esm/outputModels.js.map +1 -0
  103. package/dist/esm/package.json +3 -0
  104. package/dist/esm/paginateHelper.d.ts +43 -0
  105. package/dist/esm/paginateHelper.d.ts.map +1 -0
  106. package/dist/esm/paginateHelper.js +68 -0
  107. package/dist/esm/paginateHelper.js.map +1 -0
  108. package/dist/esm/parameters.d.ts +184 -0
  109. package/dist/esm/parameters.d.ts.map +1 -0
  110. package/dist/esm/parameters.js +2 -0
  111. package/dist/esm/parameters.js.map +1 -0
  112. package/dist/esm/pollingHelper.d.ts +77 -0
  113. package/dist/esm/pollingHelper.d.ts.map +1 -0
  114. package/dist/esm/pollingHelper.js +95 -0
  115. package/dist/esm/pollingHelper.js.map +1 -0
  116. package/dist/esm/responses.d.ts +132 -0
  117. package/dist/esm/responses.d.ts.map +1 -0
  118. package/dist/esm/responses.js +2 -0
  119. package/dist/esm/responses.js.map +1 -0
  120. package/dist/react-native/clientDefinitions.d.ts +191 -0
  121. package/dist/react-native/clientDefinitions.d.ts.map +1 -0
  122. package/dist/react-native/clientDefinitions.js +2 -0
  123. package/dist/react-native/clientDefinitions.js.map +1 -0
  124. package/dist/react-native/documentTranslationClient.d.ts +16 -0
  125. package/dist/react-native/documentTranslationClient.d.ts.map +1 -0
  126. package/dist/react-native/documentTranslationClient.js +42 -0
  127. package/dist/react-native/documentTranslationClient.js.map +1 -0
  128. package/dist/react-native/index.d.ts +12 -0
  129. package/dist/react-native/index.d.ts.map +1 -0
  130. package/dist/react-native/index.js +14 -0
  131. package/dist/react-native/index.js.map +1 -0
  132. package/dist/react-native/isUnexpected.d.ts +10 -0
  133. package/dist/react-native/isUnexpected.d.ts.map +1 -0
  134. package/dist/react-native/isUnexpected.js +75 -0
  135. package/dist/react-native/isUnexpected.js.map +1 -0
  136. package/dist/react-native/logger.d.ts +2 -0
  137. package/dist/react-native/logger.d.ts.map +1 -0
  138. package/dist/react-native/logger.js +5 -0
  139. package/dist/react-native/logger.js.map +1 -0
  140. package/dist/react-native/models.d.ts +112 -0
  141. package/dist/react-native/models.d.ts.map +1 -0
  142. package/dist/react-native/models.js +4 -0
  143. package/dist/react-native/models.js.map +1 -0
  144. package/dist/react-native/outputModels.d.ts +166 -0
  145. package/dist/react-native/outputModels.d.ts.map +1 -0
  146. package/dist/react-native/outputModels.js +4 -0
  147. package/dist/react-native/outputModels.js.map +1 -0
  148. package/dist/react-native/package.json +3 -0
  149. package/dist/react-native/paginateHelper.d.ts +43 -0
  150. package/dist/react-native/paginateHelper.d.ts.map +1 -0
  151. package/dist/react-native/paginateHelper.js +68 -0
  152. package/dist/react-native/paginateHelper.js.map +1 -0
  153. package/dist/react-native/parameters.d.ts +184 -0
  154. package/dist/react-native/parameters.d.ts.map +1 -0
  155. package/dist/react-native/parameters.js +2 -0
  156. package/dist/react-native/parameters.js.map +1 -0
  157. package/dist/react-native/pollingHelper.d.ts +77 -0
  158. package/dist/react-native/pollingHelper.d.ts.map +1 -0
  159. package/dist/react-native/pollingHelper.js +95 -0
  160. package/dist/react-native/pollingHelper.js.map +1 -0
  161. package/dist/react-native/responses.d.ts +132 -0
  162. package/dist/react-native/responses.d.ts.map +1 -0
  163. package/dist/react-native/responses.js +2 -0
  164. package/dist/react-native/responses.js.map +1 -0
  165. package/package.json +68 -43
  166. package/CHANGELOG.md +0 -34
  167. package/dist/index.js +0 -293
  168. package/dist/index.js.map +0 -1
  169. package/dist-esm/src/documentTranslationClient.js.map +0 -1
  170. package/dist-esm/src/index.js +0 -14
  171. package/dist-esm/src/index.js.map +0 -1
  172. package/types/ai-translation-document.d.ts +0 -1018
  173. /package/{dist-esm/src → dist/browser}/clientDefinitions.js +0 -0
  174. /package/{dist-esm/src → dist/browser}/clientDefinitions.js.map +0 -0
  175. /package/{dist-esm/src → dist/browser}/isUnexpected.js +0 -0
  176. /package/{dist-esm/src → dist/browser}/isUnexpected.js.map +0 -0
  177. /package/{dist-esm/src → dist/browser}/logger.js +0 -0
  178. /package/{dist-esm/src → dist/browser}/logger.js.map +0 -0
  179. /package/{dist-esm/src → dist/browser}/models.js +0 -0
  180. /package/{dist-esm/src → dist/browser}/models.js.map +0 -0
  181. /package/{dist-esm/src → dist/browser}/outputModels.js +0 -0
  182. /package/{dist-esm/src → dist/browser}/outputModels.js.map +0 -0
  183. /package/{dist-esm/src → dist/browser}/paginateHelper.js +0 -0
  184. /package/{dist-esm/src → dist/browser}/paginateHelper.js.map +0 -0
  185. /package/{dist-esm/src → dist/browser}/parameters.js +0 -0
  186. /package/{dist-esm/src → dist/browser}/parameters.js.map +0 -0
  187. /package/{dist-esm/src → dist/browser}/pollingHelper.js +0 -0
  188. /package/{dist-esm/src → dist/browser}/pollingHelper.js.map +0 -0
  189. /package/{dist-esm/src → dist/browser}/responses.js +0 -0
  190. /package/{dist-esm/src → dist/browser}/responses.js.map +0 -0
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "A generated SDK for DocumentTranslationClient.",
6
- "version": "1.0.0-alpha.20250227.1",
6
+ "version": "1.0.0-alpha.20250228.1",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",
@@ -15,9 +15,9 @@
15
15
  "translation"
16
16
  ],
17
17
  "license": "MIT",
18
- "main": "dist/index.js",
19
- "module": "./dist-esm/src/index.js",
20
- "types": "./types/ai-translation-document.d.ts",
18
+ "main": "./dist/commonjs/index.js",
19
+ "module": "./dist/esm/index.js",
20
+ "types": "./dist/commonjs/index.d.ts",
21
21
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-document-rest/README.md",
22
22
  "repository": "github:Azure/azure-sdk-for-js",
23
23
  "bugs": {
@@ -25,10 +25,7 @@
25
25
  },
26
26
  "files": [
27
27
  "dist/",
28
- "dist-esm/src/",
29
- "types/ai-translation-document.d.ts",
30
28
  "README.md",
31
- "CHANGELOG.md",
32
29
  "LICENSE"
33
30
  ],
34
31
  "engines": {
@@ -48,50 +45,38 @@
48
45
  "dependencies": {
49
46
  "@azure-rest/core-client": "^2.0.0",
50
47
  "@azure/abort-controller": "^2.1.2",
51
- "@azure/core-auth": "^1.6.0",
48
+ "@azure/core-auth": "^1.9.0",
52
49
  "@azure/core-lro": "^3.0.0",
53
- "@azure/core-paging": "^1.5.0",
54
- "@azure/core-rest-pipeline": "^1.16.3",
55
- "@azure/logger": "^1.0.0",
56
- "tslib": "^2.6.2"
50
+ "@azure/core-paging": "^1.6.2",
51
+ "@azure/core-rest-pipeline": "^1.19.0",
52
+ "@azure/logger": "^1.1.4",
53
+ "tslib": "^2.8.1"
57
54
  },
58
55
  "devDependencies": {
59
- "@azure-tools/test-credential": "^1.0.0",
60
- "@azure-tools/test-recorder": "^3.5.2",
56
+ "@azure-tools/test-credential": "^2.0.0",
57
+ "@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
58
+ "@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
61
59
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
62
60
  "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
63
- "@azure/identity": "^4.0.1",
64
- "@azure/storage-blob": "^12.23.0",
65
- "@types/chai": "^4.2.8",
66
- "@types/mocha": "^10.0.0",
61
+ "@azure/identity": "^4.7.0",
62
+ "@azure/storage-blob": ">=12.26.0-alpha <12.26.0-alphb",
67
63
  "@types/node": "^18.0.0",
64
+ "@vitest/browser": "^3.0.6",
65
+ "@vitest/coverage-istanbul": "^3.0.6",
68
66
  "autorest": "latest",
69
- "chai": "^4.2.0",
70
67
  "dotenv": "^16.0.0",
71
68
  "eslint": "^9.9.0",
72
- "karma": "^6.2.0",
73
- "karma-chrome-launcher": "^3.0.0",
74
- "karma-coverage": "^2.0.0",
75
- "karma-env-preprocessor": "^0.1.1",
76
- "karma-firefox-launcher": "^2.1.3",
77
- "karma-junit-reporter": "^2.0.1",
78
- "karma-mocha": "^2.0.1",
79
- "karma-mocha-reporter": "^2.2.5",
80
- "karma-source-map-support": "~1.4.0",
81
- "karma-sourcemap-loader": "^0.4.0",
82
- "mocha": "^11.0.2",
83
- "nyc": "^17.0.0",
84
- "source-map-support": "^0.5.9",
85
- "ts-node": "^10.0.0",
86
- "typescript": "~5.7.2"
69
+ "playwright": "^1.50.1",
70
+ "typescript": "~5.7.2",
71
+ "vitest": "^3.0.6"
87
72
  },
88
73
  "scripts": {
89
- "build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run extract-api",
90
- "build:browser": "tsc -p . && dev-tool run bundle",
91
- "build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api",
92
- "build:node": "tsc -p . && dev-tool run bundle --browser-test false",
74
+ "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
75
+ "build:browser": "dev-tool run build-package && dev-tool run bundle",
76
+ "build:debug": "dev-tool run build-package && dev-tool run bundle && dev-tool run extract-api",
77
+ "build:node": "dev-tool run build-package && dev-tool run bundle --browser-test false",
93
78
  "build:samples": "echo Obsolete.",
94
- "build:test": "tsc -p . && dev-tool run bundle",
79
+ "build:test": "dev-tool run build-package && dev-tool run bundle",
95
80
  "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
96
81
  "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
97
82
  "execute:samples": "dev-tool samples run samples-dev",
@@ -108,10 +93,50 @@
108
93
  "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
109
94
  "test:node": "npm run clean && npm run build:test && npm run unit-test:node",
110
95
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
111
- "unit-test:browser": "dev-tool run test:browser",
112
- "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
113
- "update-snippets": "echo skipped"
96
+ "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
97
+ "unit-test:node": "dev-tool run test:vitest",
98
+ "update-snippets": "dev-tool run update-snippets"
114
99
  },
115
100
  "sideEffects": false,
116
- "autoPublish": false
101
+ "autoPublish": false,
102
+ "type": "module",
103
+ "tshy": {
104
+ "project": "./tsconfig.src.json",
105
+ "exports": {
106
+ "./package.json": "./package.json",
107
+ ".": "./src/index.ts"
108
+ },
109
+ "dialects": [
110
+ "esm",
111
+ "commonjs"
112
+ ],
113
+ "esmDialects": [
114
+ "browser",
115
+ "react-native"
116
+ ],
117
+ "selfLink": false
118
+ },
119
+ "browser": "./dist/browser/index.js",
120
+ "react-native": "./dist/react-native/index.js",
121
+ "exports": {
122
+ "./package.json": "./package.json",
123
+ ".": {
124
+ "browser": {
125
+ "types": "./dist/browser/index.d.ts",
126
+ "default": "./dist/browser/index.js"
127
+ },
128
+ "react-native": {
129
+ "types": "./dist/react-native/index.d.ts",
130
+ "default": "./dist/react-native/index.js"
131
+ },
132
+ "import": {
133
+ "types": "./dist/esm/index.d.ts",
134
+ "default": "./dist/esm/index.js"
135
+ },
136
+ "require": {
137
+ "types": "./dist/commonjs/index.d.ts",
138
+ "default": "./dist/commonjs/index.js"
139
+ }
140
+ }
141
+ }
117
142
  }
package/CHANGELOG.md DELETED
@@ -1,34 +0,0 @@
1
- # Release History
2
-
3
- ## 1.0.0 (2024-11-15)
4
-
5
- ### Other Changes
6
- - Renamed SingleDocumentTranslationClient's API from `document_translate` to `translate`
7
-
8
- ## 1.0.0-beta.2 (2024-07-01)
9
-
10
- ### Other Changes
11
- - Re-release of 1.0.0-beta.1 as the SDK package was released without types
12
-
13
- ## 1.0.0-beta.1 (2024-06-27)
14
- - Initial release. Please see the README and wiki for information on the new design.
15
-
16
- Version 1.0.0-beta.1 is preview of our efforts in creating a client library that is developer-friendly, idiomatic
17
- to the JS/TS ecosystem, and as consistent across different languages and platforms as possible.
18
-
19
- This package's
20
- [documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/translation/ai-translation-document-rest/README.md)
21
- and
22
- [samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/translation/ai-translation-document-rest/samples)
23
- demonstrate the new API.
24
-
25
- ### Features Added
26
- - Added support for Synchronous document translation - [translate-document API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/translate-document)
27
- - Added support for Batch Translation - [start Translation API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/start-batch-translation)
28
- - Added support for Get Translations Status - [get translations status API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-translations-status)
29
- - Added support for Get Translation Status - [get translation status API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-translation-status)
30
- - Added support for Get Documents Status - [get documents status API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-documents-status)
31
- - Added support for Get Document Status - [get document status API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-document-status)
32
- - Added support for Cancel Translation - [cancel translation API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/cancel-translation)
33
- - Added support for Get Supported Document Formats - [get supported document formats API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-supported-document-formats)
34
- - Added support for Get Supported Glossary Formats - [get supported glossary formats API](https://learn.microsoft.com/azure/ai-services/translator/document-translation/reference/get-supported-glossary-formats)
package/dist/index.js DELETED
@@ -1,293 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib = require('tslib');
6
- var coreClient = require('@azure-rest/core-client');
7
- var logger$1 = require('@azure/logger');
8
- var corePaging = require('@azure/core-paging');
9
- var coreLro = require('@azure/core-lro');
10
-
11
- // Copyright (c) Microsoft Corporation.
12
- // Licensed under the MIT License.
13
- const logger = logger$1.createClientLogger("ai-translation-document");
14
-
15
- /**
16
- * Initialize a new instance of `DocumentTranslationClient`
17
- * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
18
- * @param credentials - uniquely identify client credential
19
- * @param options - the parameter for all optional parameters
20
- */
21
- function createClient(endpointParam, credentials, _a = {}) {
22
- var _b, _c, _d, _e, _f, _g, _h, _j;
23
- var { apiVersion = "2024-05-01" } = _a, options = tslib.__rest(_a, ["apiVersion"]);
24
- const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `${endpointParam}/translator`;
25
- const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
26
- const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
27
- ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
28
- : `${userAgentInfo}`;
29
- options = Object.assign(Object.assign({}, options), { userAgentOptions: {
30
- userAgentPrefix,
31
- }, loggingOptions: {
32
- logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info,
33
- }, credentials: {
34
- scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : ["https://cognitiveservices.azure.com/.default"],
35
- apiKeyHeaderName: (_j = (_h = options.credentials) === null || _h === void 0 ? void 0 : _h.apiKeyHeaderName) !== null && _j !== void 0 ? _j : "Ocp-Apim-Subscription-Key",
36
- } });
37
- const client = coreClient.getClient(endpointUrl, credentials, options);
38
- client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
39
- client.pipeline.addPolicy({
40
- name: "ClientApiVersionPolicy",
41
- sendRequest: (req, next) => {
42
- // Use the apiVersion defined in request url directly
43
- // Append one if there is no apiVersion and we have one at client options
44
- const url = new URL(req.url);
45
- if (!url.searchParams.get("api-version") && apiVersion) {
46
- req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
47
- }
48
- return next(req);
49
- },
50
- });
51
- return client;
52
- }
53
-
54
- const responseMap = {
55
- "POST /document:translate": ["200"],
56
- "GET /document/batches": ["200"],
57
- "POST /document/batches": ["202"],
58
- "GET /document/batches/{id}/documents/{documentId}": ["200"],
59
- "GET /document/batches/{id}": ["200"],
60
- "DELETE /document/batches/{id}": ["200"],
61
- "GET /document/batches/{id}/documents": ["200"],
62
- "GET /document/formats": ["200"],
63
- };
64
- function isUnexpected(response) {
65
- const lroOriginal = response.headers["x-ms-original-url"];
66
- const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
67
- const method = response.request.method;
68
- let pathDetails = responseMap[`${method} ${url.pathname}`];
69
- if (!pathDetails) {
70
- pathDetails = getParametrizedPathSuccess(method, url.pathname);
71
- }
72
- return !pathDetails.includes(response.status);
73
- }
74
- function getParametrizedPathSuccess(method, path) {
75
- var _a, _b, _c, _d;
76
- const pathParts = path.split("/");
77
- // Traverse list to match the longest candidate
78
- // matchedLen: the length of candidate path
79
- // matchedValue: the matched status code array
80
- let matchedLen = -1, matchedValue = [];
81
- // Iterate the responseMap to find a match
82
- for (const [key, value] of Object.entries(responseMap)) {
83
- // Extracting the path from the map key which is in format
84
- // GET /path/foo
85
- if (!key.startsWith(method)) {
86
- continue;
87
- }
88
- const candidatePath = getPathFromMapKey(key);
89
- // Get each part of the url path
90
- const candidateParts = candidatePath.split("/");
91
- // track if we have found a match to return the values found.
92
- let found = true;
93
- for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
94
- if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
95
- const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
96
- // If the current part of the candidate is a "template" part
97
- // Try to use the suffix of pattern to match the path
98
- // {guid} ==> $
99
- // {guid}:export ==> :export$
100
- const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
101
- if (!isMatched) {
102
- found = false;
103
- break;
104
- }
105
- continue;
106
- }
107
- // If the candidate part is not a template and
108
- // the parts don't match mark the candidate as not found
109
- // to move on with the next candidate path.
110
- if (candidateParts[i] !== pathParts[j]) {
111
- found = false;
112
- break;
113
- }
114
- }
115
- // We finished evaluating the current candidate parts
116
- // Update the matched value if and only if we found the longer pattern
117
- if (found && candidatePath.length > matchedLen) {
118
- matchedLen = candidatePath.length;
119
- matchedValue = value;
120
- }
121
- }
122
- return matchedValue;
123
- }
124
- function getPathFromMapKey(mapKey) {
125
- const pathStart = mapKey.indexOf("/");
126
- return mapKey.slice(pathStart);
127
- }
128
-
129
- /**
130
- * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
131
- * @param client - Client to use for sending the next page requests
132
- * @param initialResponse - Initial response containing the nextLink and current page of elements
133
- * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
134
- * @returns - PagedAsyncIterableIterator to iterate the elements
135
- */
136
- function paginate(client, initialResponse, options = {}) {
137
- let firstRun = true;
138
- const itemName = "value";
139
- const nextLinkName = "nextLink";
140
- const { customGetPage } = options;
141
- const pagedResult = {
142
- firstPageLink: "",
143
- getPage: typeof customGetPage === "function"
144
- ? customGetPage
145
- : async (pageLink) => {
146
- const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
147
- firstRun = false;
148
- checkPagingRequest(result);
149
- const nextLink = getNextLink(result.body, nextLinkName);
150
- const values = getElements(result.body, itemName);
151
- return {
152
- page: values,
153
- nextPageLink: nextLink,
154
- };
155
- },
156
- };
157
- return corePaging.getPagedAsyncIterator(pagedResult);
158
- }
159
- /**
160
- * Gets for the value of nextLink in the body
161
- */
162
- function getNextLink(body, nextLinkName) {
163
- const nextLink = body[nextLinkName];
164
- if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
165
- throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
166
- }
167
- return nextLink;
168
- }
169
- /**
170
- * Gets the elements of the current request in the body.
171
- */
172
- function getElements(body, itemName) {
173
- const value = body[itemName];
174
- // value has to be an array according to the x-ms-pageable extension.
175
- // The fact that this must be an array is used above to calculate the
176
- // type of elements in the page in PaginateReturn
177
- if (!Array.isArray(value)) {
178
- throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
179
- }
180
- return value !== null && value !== void 0 ? value : [];
181
- }
182
- /**
183
- * Checks if a request failed
184
- */
185
- function checkPagingRequest(response) {
186
- const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
187
- if (!Http2xxStatusCodes.includes(response.status)) {
188
- throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
189
- }
190
- }
191
-
192
- async function getLongRunningPoller(client, initialResponse, options = {}) {
193
- var _a;
194
- const abortController = new AbortController();
195
- const poller = {
196
- sendInitialRequest: async () => {
197
- // In the case of Rest Clients we are building the LRO poller object from a response that's the reason
198
- // we are not triggering the initial request here, just extracting the information from the
199
- // response we were provided.
200
- return getLroResponse(initialResponse);
201
- },
202
- sendPollRequest: async (path, pollOptions) => {
203
- // This is the callback that is going to be called to poll the service
204
- // to get the latest status. We use the client provided and the polling path
205
- // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
206
- // depending on the lro pattern that the service implements. If non is provided we default to the initial path.
207
- function abortListener() {
208
- abortController.abort();
209
- }
210
- const inputAbortSignal = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal;
211
- const abortSignal = abortController.signal;
212
- if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
213
- abortController.abort();
214
- }
215
- else if (!abortSignal.aborted) {
216
- inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, {
217
- once: true,
218
- });
219
- }
220
- let response;
221
- try {
222
- response = await client
223
- .pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url)
224
- .get({ abortSignal });
225
- }
226
- finally {
227
- inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
228
- }
229
- const lroResponse = getLroResponse(response);
230
- lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
231
- return lroResponse;
232
- },
233
- };
234
- options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
235
- const httpPoller = coreLro.createHttpPoller(poller, options);
236
- const simplePoller = {
237
- isDone() {
238
- return httpPoller.isDone;
239
- },
240
- isStopped() {
241
- return abortController.signal.aborted;
242
- },
243
- getOperationState() {
244
- if (!httpPoller.operationState) {
245
- throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
246
- }
247
- return httpPoller.operationState;
248
- },
249
- getResult() {
250
- return httpPoller.result;
251
- },
252
- toString() {
253
- if (!httpPoller.operationState) {
254
- throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
255
- }
256
- return JSON.stringify({
257
- state: httpPoller.operationState,
258
- });
259
- },
260
- stopPolling() {
261
- abortController.abort();
262
- },
263
- onProgress: httpPoller.onProgress,
264
- poll: httpPoller.poll,
265
- pollUntilDone: httpPoller.pollUntilDone,
266
- serialize: httpPoller.serialize,
267
- submitted: httpPoller.submitted,
268
- };
269
- return simplePoller;
270
- }
271
- /**
272
- * Converts a Rest Client response to a response that the LRO implementation understands
273
- * @param response - a rest client http response
274
- * @returns - An LRO response that the LRO implementation understands
275
- */
276
- function getLroResponse(response) {
277
- if (Number.isNaN(response.status)) {
278
- throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
279
- }
280
- return {
281
- flatResponse: response,
282
- rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
283
- };
284
- }
285
-
286
- // Copyright (c) Microsoft Corporation.
287
- // Licensed under the MIT License.
288
-
289
- exports.default = createClient;
290
- exports.getLongRunningPoller = getLongRunningPoller;
291
- exports.isUnexpected = isUnexpected;
292
- exports.paginate = paginate;
293
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/documentTranslationClient.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-translation-document\");\n","// 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\";\nimport type { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport type { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface DocumentTranslationClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n { apiVersion = \"2024-05-01\", ...options }: DocumentTranslationClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { getPagedAsyncIterator } from \"@azure/core-paging\";\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number,\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n} from \"@azure/core-lro\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport type {\n StartTranslation202Response,\n StartTranslationDefaultResponse,\n StartTranslationLogicalResponse,\n} from \"./responses.js\";\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<TState extends OperationState<TResult>, TResult> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n\n /**\n * Returns true if the poller is stopped.\n * @deprecated Use abortSignal status to track this instead.\n */\n isStopped(): boolean;\n}\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport async function getLongRunningPoller<\n TResult extends StartTranslationLogicalResponse | StartTranslationDefaultResponse,\n>(\n client: Client,\n initialResponse: StartTranslation202Response | StartTranslationDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {},\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n const abortController = new AbortController();\n const poller: RunningOperation<TResult> = {\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path: string, pollOptions?: { abortSignal?: AbortSignalLike }) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = pollOptions?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] = initialResponse.request.url;\n return lroResponse;\n },\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return abortController.signal.aborted;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState,\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted,\n };\n return simplePoller;\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult,\n): OperationResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default DocumentTranslationClient;\n"],"names":["createClientLogger","__rest","getClient","getPagedAsyncIterator","createRestError","createHttpPoller"],"mappings":";;;;;;;;;;AAAA;AACA;AAEO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,yBAAyB,CAAC;;ACWnE;;;;;AAKG;AACW,SAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,EAAA,GAA8E,EAAE,EAAA;;QAAhF,EAAE,UAAU,GAAG,YAAY,EAAA,GAAA,EAAqD,EAAhD,OAAO,GAAAC,YAAA,CAAA,EAAA,EAAvC,cAAyC,CAAF;AAEvC,IAAA,MAAM,WAAW,GAAG,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,QAAQ,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,CAAG,EAAA,aAAa,aAAa;IACxF,MAAM,aAAa,GAAG,CAAA,kDAAA,CAAoD;IAC1E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;UACjD,GAAG,OAAO,CAAC,gBAAgB,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,EAAE;AAC9B,gBAAA,MAAM,IAAI,KAAK,CACb,4IAA4I,CAC7I;;YAEH,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,UAAU,CAAC,cAAc;AACjC,aAAA,CAAC;SACH;QACD,WAAW,GAAA;YACT,eAAe,CAAC,KAAK,EAAE;SACxB;QACD,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC;AACD,IAAA,OAAO,YAAY;AACrB;AAEA;;;;AAIG;AACH,SAAS,cAAc,CACrB,QAAiB,EAAA;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC;;IAG/F,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,kCACN,QAAQ,CAAA,EAAA,EACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EACpB,CAAA;KACF;AACH;;AC5MA;AACA;;;;;;;"}
@@ -1 +0,0 @@
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,UAAU,CAAC;AAUlC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAqB,EACrB,WAA4C,EAC5C,KAA8E,EAAE;;QAAhF,EAAE,UAAU,GAAG,YAAY,OAAqD,EAAhD,OAAO,cAAvC,cAAyC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CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport type { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport type { DocumentTranslationClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface DocumentTranslationClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DocumentTranslationClient`\n * @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential | KeyCredential,\n { apiVersion = \"2024-05-01\", ...options }: DocumentTranslationClientOptions = {},\n): DocumentTranslationClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;\n const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
@@ -1,14 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import DocumentTranslationClient from "./documentTranslationClient";
4
- export * from "./documentTranslationClient";
5
- export * from "./parameters";
6
- export * from "./responses";
7
- export * from "./clientDefinitions";
8
- export * from "./isUnexpected";
9
- export * from "./models";
10
- export * from "./outputModels";
11
- export * from "./paginateHelper";
12
- export * from "./pollingHelper";
13
- export default DocumentTranslationClient;
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,eAAe,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport DocumentTranslationClient from \"./documentTranslationClient\";\n\nexport * from \"./documentTranslationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default DocumentTranslationClient;\n"]}