@azure-rest/ai-document-intelligence 1.0.0-alpha.20240305.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/index.js +20 -26
- package/dist/index.js.map +1 -1
- package/dist-esm/src/documentIntelligence.js +10 -14
- package/dist-esm/src/documentIntelligence.js.map +1 -1
- package/dist-esm/src/isUnexpected.js +5 -4
- package/dist-esm/src/isUnexpected.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/outputModels.js.map +1 -1
- package/dist-esm/src/paginateHelper.js +1 -1
- package/dist-esm/src/paginateHelper.js.map +1 -1
- package/dist-esm/src/parameters.js.map +1 -1
- package/dist-esm/src/pollingHelper.js +4 -7
- package/dist-esm/src/pollingHelper.js.map +1 -1
- package/dist-esm/src/responses.js.map +1 -1
- package/package.json +7 -7
- package/review/ai-document-intelligence.api.md +257 -16
- package/types/ai-document-intelligence.d.ts +268 -47
package/README.md
CHANGED
|
@@ -10,16 +10,18 @@ Key links:
|
|
|
10
10
|
|
|
11
11
|
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest)
|
|
12
12
|
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-document-intelligence)
|
|
13
|
+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-document-intelligence?view=azure-node-preview)
|
|
13
14
|
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/samples)
|
|
14
15
|
- [Changelog](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/CHANGELOG.md)
|
|
15
16
|
- [Migration Guide from Form Recognizer](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/MIGRATION-FR_v4-DI_v1.md)
|
|
16
17
|
|
|
17
|
-
> This version of the client library defaults to the `"
|
|
18
|
+
> This version of the client library defaults to the `"2024-02-29-preview"` version of the service.
|
|
18
19
|
|
|
19
20
|
This table shows the relationship between SDK versions and supported API versions of the service:
|
|
20
21
|
|
|
21
22
|
| SDK version | Supported API version of service |
|
|
22
23
|
| ------------ | -------------------------------- |
|
|
24
|
+
| 1.0.0-beta.2 | 2024-02-29-preview |
|
|
23
25
|
| 1.0.0-beta.1 | 2023-10-31-preview |
|
|
24
26
|
|
|
25
27
|
> Please rely on the older `@azure/ai-form-recognizer` library through the older service API versions for retired models, such as `"prebuilt-businessCard"` and `"prebuilt-document"`. For more information, see [Changelog](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/documentintelligence/ai-document-intelligence-rest/CHANGELOG.md).
|
|
@@ -28,6 +30,7 @@ The below table describes the relationship of each client and its supported API
|
|
|
28
30
|
|
|
29
31
|
| Service API version | Supported clients | Package |
|
|
30
32
|
| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------- |
|
|
33
|
+
| 2024-02-29-preview | DocumentIntelligenceClient | `@azure-rest/ai-document-intelligence` version `1.0.0-beta.2` |
|
|
31
34
|
| 2023-10-31-preview | DocumentIntelligenceClient | `@azure-rest/ai-document-intelligence` version `1.0.0-beta.1` |
|
|
32
35
|
| 2023-07-31 | DocumentAnalysisClient and DocumentModelAdministrationClient | `@azure/ai-form-recognizer` version `^5.0.0` |
|
|
33
36
|
| 2022-08-01 | DocumentAnalysisClient and DocumentModelAdministrationClient | `@azure/ai-form-recognizer` version `^4.0.0` |
|
package/dist/index.js
CHANGED
|
@@ -20,25 +20,21 @@ const logger = logger$1.createClientLogger("ai-document-intelligence");
|
|
|
20
20
|
* @param options - the parameter for all optional parameters
|
|
21
21
|
*/
|
|
22
22
|
function createClient(endpoint, credentials, options = {}) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
24
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/documentintelligence`;
|
|
25
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2024-02-29-preview";
|
|
25
26
|
const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`;
|
|
26
27
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
27
28
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
28
29
|
: `${userAgentInfo}`;
|
|
29
|
-
options = {
|
|
30
|
-
...options,
|
|
31
|
-
userAgentOptions: {
|
|
30
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
32
31
|
userAgentPrefix,
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
|
|
40
|
-
},
|
|
41
|
-
};
|
|
32
|
+
}, loggingOptions: {
|
|
33
|
+
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
|
|
34
|
+
}, credentials: {
|
|
35
|
+
scopes: (_f = (_e = options.credentials) === null || _e === void 0 ? void 0 : _e.scopes) !== null && _f !== void 0 ? _f : ["https://cognitiveservices.azure.com/.default"],
|
|
36
|
+
apiKeyHeaderName: (_h = (_g = options.credentials) === null || _g === void 0 ? void 0 : _g.apiKeyHeaderName) !== null && _h !== void 0 ? _h : "Ocp-Apim-Subscription-Key",
|
|
37
|
+
} });
|
|
42
38
|
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
43
39
|
return client;
|
|
44
40
|
}
|
|
@@ -73,7 +69,7 @@ const responseMap = {
|
|
|
73
69
|
};
|
|
74
70
|
function isUnexpected(response) {
|
|
75
71
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
76
|
-
const url = new URL(lroOriginal
|
|
72
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
77
73
|
const method = response.request.method;
|
|
78
74
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
79
75
|
if (!pathDetails) {
|
|
@@ -82,6 +78,7 @@ function isUnexpected(response) {
|
|
|
82
78
|
return !pathDetails.includes(response.status);
|
|
83
79
|
}
|
|
84
80
|
function getParametrizedPathSuccess(method, path) {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
85
82
|
const pathParts = path.split("/");
|
|
86
83
|
// Traverse list to match the longest candidate
|
|
87
84
|
// matchedLen: the length of candidate path
|
|
@@ -100,13 +97,13 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
100
97
|
// track if we have found a match to return the values found.
|
|
101
98
|
let found = true;
|
|
102
99
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
103
|
-
if (candidateParts[i]
|
|
104
|
-
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]
|
|
100
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
101
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
105
102
|
// If the current part of the candidate is a "template" part
|
|
106
103
|
// Try to use the suffix of pattern to match the path
|
|
107
104
|
// {guid} ==> $
|
|
108
105
|
// {guid}:export ==> :export$
|
|
109
|
-
const isMatched = new RegExp(`${candidateParts[i]
|
|
106
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
110
107
|
if (!isMatched) {
|
|
111
108
|
found = false;
|
|
112
109
|
break;
|
|
@@ -191,7 +188,7 @@ function getElements(body, itemName) {
|
|
|
191
188
|
if (!Array.isArray(value)) {
|
|
192
189
|
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
193
190
|
}
|
|
194
|
-
return value
|
|
191
|
+
return value !== null && value !== void 0 ? value : [];
|
|
195
192
|
}
|
|
196
193
|
/**
|
|
197
194
|
* Checks if a request failed
|
|
@@ -206,6 +203,7 @@ function checkPagingRequest(response) {
|
|
|
206
203
|
// Copyright (c) Microsoft Corporation.
|
|
207
204
|
// Licensed under the MIT license.
|
|
208
205
|
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
206
|
+
var _a;
|
|
209
207
|
const poller = {
|
|
210
208
|
requestMethod: initialResponse.request.method,
|
|
211
209
|
requestPath: initialResponse.request.url,
|
|
@@ -220,13 +218,13 @@ async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
220
218
|
// to get the latest status. We use the client provided and the polling path
|
|
221
219
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
222
220
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
223
|
-
const response = await client.pathUnchecked(path
|
|
221
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
224
222
|
const lroResponse = getLroResponse(response);
|
|
225
223
|
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
226
224
|
return lroResponse;
|
|
227
225
|
},
|
|
228
226
|
};
|
|
229
|
-
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful
|
|
227
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
230
228
|
return coreLro.createHttpPoller(poller, options);
|
|
231
229
|
}
|
|
232
230
|
/**
|
|
@@ -240,11 +238,7 @@ function getLroResponse(response) {
|
|
|
240
238
|
}
|
|
241
239
|
return {
|
|
242
240
|
flatResponse: response,
|
|
243
|
-
rawResponse: {
|
|
244
|
-
...response,
|
|
245
|
-
statusCode: Number.parseInt(response.status),
|
|
246
|
-
body: response.body,
|
|
247
|
-
},
|
|
241
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
248
242
|
};
|
|
249
243
|
}
|
|
250
244
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/logger.ts","../src/documentIntelligence.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-document-intelligence\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentIntelligenceClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `DocumentIntelligenceClient`\n * @param endpoint - The Document Intelligence service endpoint.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credentials: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): DocumentIntelligenceClient {\n const baseUrl = options.baseUrl ?? `${endpoint}/documentintelligence`;\n options.apiVersion = options.apiVersion ?? \"2023-10-31-preview\";\n const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as DocumentIntelligenceClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ListOperations200Response,\n ListOperationsDefaultResponse,\n GetDocumentModelBuildOperation200Response,\n GetDocumentModelBuildOperationDefaultResponse,\n GetResourceInfo200Response,\n GetResourceInfoDefaultResponse,\n GetAnalyzeResult200Response,\n GetAnalyzeResultDefaultResponse,\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocumentFromStreamLogicalResponse,\n AnalyzeDocumentFromStreamDefaultResponse,\n GetModel200Response,\n GetModelDefaultResponse,\n DeleteModel204Response,\n DeleteModelDefaultResponse,\n BuildModel202Response,\n BuildModelLogicalResponse,\n BuildModelDefaultResponse,\n ComposeModel202Response,\n ComposeModelLogicalResponse,\n ComposeModelDefaultResponse,\n AuthorizeModelCopy200Response,\n AuthorizeModelCopyDefaultResponse,\n CopyModelTo202Response,\n CopyModelToLogicalResponse,\n CopyModelToDefaultResponse,\n ListModels200Response,\n ListModelsDefaultResponse,\n BuildClassifier202Response,\n BuildClassifierLogicalResponse,\n BuildClassifierDefaultResponse,\n ListClassifiers200Response,\n ListClassifiersDefaultResponse,\n GetClassifier200Response,\n GetClassifierDefaultResponse,\n DeleteClassifier204Response,\n DeleteClassifierDefaultResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocumentFromStreamLogicalResponse,\n ClassifyDocumentFromStreamDefaultResponse,\n GetClassifyResult200Response,\n GetClassifyResultDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /operations\": [\"200\"],\n \"GET /operations/{operationId}\": [\"200\"],\n \"GET /info\": [\"200\"],\n \"GET /documentModels/{modelId}/analyzeResults/{resultId}\": [\"200\"],\n \"POST /documentModels/{modelId}:analyze\": [\"202\"],\n \"GET /documentModels/{modelId}:analyze\": [\"200\", \"202\"],\n \"GET /documentModels/{modelId}\": [\"200\"],\n \"DELETE /documentModels/{modelId}\": [\"204\"],\n \"POST /documentModels:build\": [\"202\"],\n \"GET /documentModels:build\": [\"200\", \"202\"],\n \"POST /documentModels:compose\": [\"202\"],\n \"GET /documentModels:compose\": [\"200\", \"202\"],\n \"POST /documentModels:authorizeCopy\": [\"200\"],\n \"POST /documentModels/{modelId}:copyTo\": [\"202\"],\n \"GET /documentModels/{modelId}:copyTo\": [\"200\", \"202\"],\n \"GET /documentModels\": [\"200\"],\n \"POST /documentClassifiers:build\": [\"202\"],\n \"GET /documentClassifiers:build\": [\"200\", \"202\"],\n \"GET /documentClassifiers\": [\"200\"],\n \"GET /documentClassifiers/{classifierId}\": [\"200\"],\n \"DELETE /documentClassifiers/{classifierId}\": [\"204\"],\n \"POST /documentClassifiers/{classifierId}:analyze\": [\"202\"],\n \"GET /documentClassifiers/{classifierId}:analyze\": [\"200\", \"202\"],\n \"GET /documentClassifiers/{classifierId}/analyzeResults/{resultId}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListOperations200Response | ListOperationsDefaultResponse,\n): response is ListOperationsDefaultResponse;\nexport function isUnexpected(\n response:\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse,\n): response is GetDocumentModelBuildOperationDefaultResponse;\nexport function isUnexpected(\n response: GetResourceInfo200Response | GetResourceInfoDefaultResponse,\n): response is GetResourceInfoDefaultResponse;\nexport function isUnexpected(\n response: GetAnalyzeResult200Response | GetAnalyzeResultDefaultResponse,\n): response is GetAnalyzeResultDefaultResponse;\nexport function isUnexpected(\n response:\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n): response is AnalyzeDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetModel200Response | GetModelDefaultResponse,\n): response is GetModelDefaultResponse;\nexport function isUnexpected(\n response: DeleteModel204Response | DeleteModelDefaultResponse,\n): response is DeleteModelDefaultResponse;\nexport function isUnexpected(\n response: BuildModel202Response | BuildModelLogicalResponse | BuildModelDefaultResponse,\n): response is BuildModelDefaultResponse;\nexport function isUnexpected(\n response: ComposeModel202Response | ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n): response is ComposeModelDefaultResponse;\nexport function isUnexpected(\n response: AuthorizeModelCopy200Response | AuthorizeModelCopyDefaultResponse,\n): response is AuthorizeModelCopyDefaultResponse;\nexport function isUnexpected(\n response: CopyModelTo202Response | CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n): response is CopyModelToDefaultResponse;\nexport function isUnexpected(\n response: ListModels200Response | ListModelsDefaultResponse,\n): response is ListModelsDefaultResponse;\nexport function isUnexpected(\n response:\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse,\n): response is BuildClassifierDefaultResponse;\nexport function isUnexpected(\n response: ListClassifiers200Response | ListClassifiersDefaultResponse,\n): response is ListClassifiersDefaultResponse;\nexport function isUnexpected(\n response: GetClassifier200Response | GetClassifierDefaultResponse,\n): response is GetClassifierDefaultResponse;\nexport function isUnexpected(\n response: DeleteClassifier204Response | DeleteClassifierDefaultResponse,\n): response is DeleteClassifierDefaultResponse;\nexport function isUnexpected(\n response:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n): response is ClassifyDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetClassifyResult200Response | GetClassifyResultDefaultResponse,\n): response is GetClassifyResultDefaultResponse;\nexport function isUnexpected(\n response:\n | ListOperations200Response\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfo200Response\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResult200Response\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModel200Response\n | GetModelDefaultResponse\n | DeleteModel204Response\n | DeleteModelDefaultResponse\n | BuildModel202Response\n | BuildModelLogicalResponse\n | BuildModelDefaultResponse\n | ComposeModel202Response\n | ComposeModelLogicalResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopy200Response\n | AuthorizeModelCopyDefaultResponse\n | CopyModelTo202Response\n | CopyModelToLogicalResponse\n | CopyModelToDefaultResponse\n | ListModels200Response\n | ListModelsDefaultResponse\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse\n | ListClassifiers200Response\n | ListClassifiersDefaultResponse\n | GetClassifier200Response\n | GetClassifierDefaultResponse\n | DeleteClassifier204Response\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResult200Response\n | GetClassifyResultDefaultResponse,\n): response is\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModelDefaultResponse\n | DeleteModelDefaultResponse\n | BuildModelDefaultResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopyDefaultResponse\n | CopyModelToDefaultResponse\n | ListModelsDefaultResponse\n | BuildClassifierDefaultResponse\n | ListClassifiersDefaultResponse\n | GetClassifierDefaultResponse\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResultDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number,\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocumentFromStreamDefaultResponse,\n AnalyzeDocumentFromStreamLogicalResponse,\n BuildModel202Response,\n BuildModelDefaultResponse,\n BuildModelLogicalResponse,\n ComposeModel202Response,\n ComposeModelDefaultResponse,\n ComposeModelLogicalResponse,\n CopyModelTo202Response,\n CopyModelToDefaultResponse,\n CopyModelToLogicalResponse,\n BuildClassifier202Response,\n BuildClassifierDefaultResponse,\n BuildClassifierLogicalResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocumentFromStreamDefaultResponse,\n ClassifyDocumentFromStreamLogicalResponse,\n} from \"./responses\";\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 BuildModelLogicalResponse | BuildModelDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildModel202Response | BuildModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n>(\n client: Client,\n initialResponse: ComposeModel202Response | ComposeModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n>(\n client: Client,\n initialResponse: CopyModelTo202Response | CopyModelToDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends BuildClassifierLogicalResponse | BuildClassifierDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildClassifier202Response | BuildClassifierDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse: AnalyzeDocumentFromStream202Response | AnalyzeDocumentFromStreamDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamDefaultResponse,\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 poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\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) => {\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 const response = await client.pathUnchecked(path ?? initialResponse.request.url).get();\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 return createHttpPoller(poller, options);\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>(response: TResult): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentIntelligence from \"./documentIntelligence\";\n\nexport * from \"./documentIntelligence\";\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 DocumentIntelligence;\n"],"names":["createClientLogger","getClient","getPagedAsyncIterator","createRestError","createHttpPoller"],"mappings":";;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,0BAA0B,CAAC;;ACJpE;AACA;AAOA;;;;;AAKG;AACW,SAAU,YAAY,CAClC,QAAgB,EAChB,WAA4C,EAC5C,OAAA,GAAyB,EAAE,EAAA;IAE3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAA,EAAG,QAAQ,CAAA,qBAAA,CAAuB,CAAC;IACtE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,oBAAoB,CAAC;IAChE,MAAM,aAAa,GAAG,CAAA,mDAAA,CAAqD,CAAC;IAC5E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE,CAAC;AACzB,IAAA,OAAO,GAAG;AACR,QAAA,GAAG,OAAO;AACV,QAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA;AACD,QAAA,cAAc,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI;AACtD,SAAA;AACD,QAAA,WAAW,EAAE;YACX,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,8CAA8C,CAAC;AACvF,YAAA,gBAAgB,EAAE,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,2BAA2B;AACvF,SAAA;KACF,CAAC;IAEF,MAAM,MAAM,GAAGC,oBAAS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AAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AACvF,YAAA,MAAM,WAAW,GAAG,cAAc,CAAC,QAAmB,CAAC,CAAC;AACxD,YAAA,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;AACnF,YAAA,OAAO,WAAW,CAAC;SACpB;KACF,CAAC;IAEF,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,IAAI,IAAI,CAAC;AACtE,IAAA,OAAOC,wBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;;AAIG;AACH,SAAS,cAAc,CAA+B,QAAiB,EAAA;IACrE,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;KAC/F;IAED,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,EAAE;AACX,YAAA,GAAG,QAAQ;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI;AACpB,SAAA;KACF,CAAC;AACJ;;ACvIA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/logger.ts","../src/documentIntelligence.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"ai-document-intelligence\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentIntelligenceClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `DocumentIntelligenceClient`\n * @param endpoint - The Document Intelligence service endpoint.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credentials: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): DocumentIntelligenceClient {\n const baseUrl = options.baseUrl ?? `${endpoint}/documentintelligence`;\n options.apiVersion = options.apiVersion ?? \"2024-02-29-preview\";\n const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as DocumentIntelligenceClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ListOperations200Response,\n ListOperationsDefaultResponse,\n GetDocumentModelBuildOperation200Response,\n GetDocumentModelComposeOperation200Response,\n GetDocumentModelCopyToOperation200Response,\n GetDocumentClassifierBuildOperation200Response,\n GetOperation200Response,\n GetDocumentModelBuildOperationDefaultResponse,\n GetResourceInfo200Response,\n GetResourceInfoDefaultResponse,\n GetAnalyzeResult200Response,\n GetAnalyzeResultDefaultResponse,\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocument202Response,\n AnalyzeDocumentFromStreamLogicalResponse,\n AnalyzeDocumentLogicalResponse,\n AnalyzeDocumentFromStreamDefaultResponse,\n GetModel200Response,\n GetModelDefaultResponse,\n DeleteModel204Response,\n DeleteModelDefaultResponse,\n BuildModel202Response,\n BuildModelLogicalResponse,\n BuildModelDefaultResponse,\n ComposeModel202Response,\n ComposeModelLogicalResponse,\n ComposeModelDefaultResponse,\n AuthorizeModelCopy200Response,\n AuthorizeModelCopyDefaultResponse,\n CopyModelTo202Response,\n CopyModelToLogicalResponse,\n CopyModelToDefaultResponse,\n ListModels200Response,\n ListModelsDefaultResponse,\n BuildClassifier202Response,\n BuildClassifierLogicalResponse,\n BuildClassifierDefaultResponse,\n ListClassifiers200Response,\n ListClassifiersDefaultResponse,\n GetClassifier200Response,\n GetClassifierDefaultResponse,\n DeleteClassifier204Response,\n DeleteClassifierDefaultResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocument202Response,\n ClassifyDocumentFromStreamLogicalResponse,\n ClassifyDocumentLogicalResponse,\n ClassifyDocumentFromStreamDefaultResponse,\n GetClassifyResult200Response,\n GetClassifyResultDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /operations\": [\"200\"],\n \"GET /operations/{operationId}\": [\"200\"],\n \"GET /info\": [\"200\"],\n \"GET /documentModels/{modelId}/analyzeResults/{resultId}\": [\"200\"],\n \"POST /documentModels/{modelId}:analyze\": [\"202\"],\n \"GET /documentModels/{modelId}:analyze\": [\"200\", \"202\"],\n \"GET /documentModels/{modelId}\": [\"200\"],\n \"DELETE /documentModels/{modelId}\": [\"204\"],\n \"POST /documentModels:build\": [\"202\"],\n \"GET /documentModels:build\": [\"200\", \"202\"],\n \"POST /documentModels:compose\": [\"202\"],\n \"GET /documentModels:compose\": [\"200\", \"202\"],\n \"POST /documentModels:authorizeCopy\": [\"200\"],\n \"POST /documentModels/{modelId}:copyTo\": [\"202\"],\n \"GET /documentModels/{modelId}:copyTo\": [\"200\", \"202\"],\n \"GET /documentModels\": [\"200\"],\n \"POST /documentClassifiers:build\": [\"202\"],\n \"GET /documentClassifiers:build\": [\"200\", \"202\"],\n \"GET /documentClassifiers\": [\"200\"],\n \"GET /documentClassifiers/{classifierId}\": [\"200\"],\n \"DELETE /documentClassifiers/{classifierId}\": [\"204\"],\n \"POST /documentClassifiers/{classifierId}:analyze\": [\"202\"],\n \"GET /documentClassifiers/{classifierId}:analyze\": [\"200\", \"202\"],\n \"GET /documentClassifiers/{classifierId}/analyzeResults/{resultId}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListOperations200Response | ListOperationsDefaultResponse,\n): response is ListOperationsDefaultResponse;\nexport function isUnexpected(\n response:\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelComposeOperation200Response\n | GetDocumentModelCopyToOperation200Response\n | GetDocumentClassifierBuildOperation200Response\n | GetOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse,\n): response is GetDocumentModelBuildOperationDefaultResponse;\nexport function isUnexpected(\n response: GetResourceInfo200Response | GetResourceInfoDefaultResponse,\n): response is GetResourceInfoDefaultResponse;\nexport function isUnexpected(\n response: GetAnalyzeResult200Response | GetAnalyzeResultDefaultResponse,\n): response is GetAnalyzeResultDefaultResponse;\nexport function isUnexpected(\n response:\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocument202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n): response is AnalyzeDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetModel200Response | GetModelDefaultResponse,\n): response is GetModelDefaultResponse;\nexport function isUnexpected(\n response: DeleteModel204Response | DeleteModelDefaultResponse,\n): response is DeleteModelDefaultResponse;\nexport function isUnexpected(\n response: BuildModel202Response | BuildModelLogicalResponse | BuildModelDefaultResponse,\n): response is BuildModelDefaultResponse;\nexport function isUnexpected(\n response: ComposeModel202Response | ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n): response is ComposeModelDefaultResponse;\nexport function isUnexpected(\n response: AuthorizeModelCopy200Response | AuthorizeModelCopyDefaultResponse,\n): response is AuthorizeModelCopyDefaultResponse;\nexport function isUnexpected(\n response: CopyModelTo202Response | CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n): response is CopyModelToDefaultResponse;\nexport function isUnexpected(\n response: ListModels200Response | ListModelsDefaultResponse,\n): response is ListModelsDefaultResponse;\nexport function isUnexpected(\n response:\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse,\n): response is BuildClassifierDefaultResponse;\nexport function isUnexpected(\n response: ListClassifiers200Response | ListClassifiersDefaultResponse,\n): response is ListClassifiersDefaultResponse;\nexport function isUnexpected(\n response: GetClassifier200Response | GetClassifierDefaultResponse,\n): response is GetClassifierDefaultResponse;\nexport function isUnexpected(\n response: DeleteClassifier204Response | DeleteClassifierDefaultResponse,\n): response is DeleteClassifierDefaultResponse;\nexport function isUnexpected(\n response:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocument202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n): response is ClassifyDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetClassifyResult200Response | GetClassifyResultDefaultResponse,\n): response is GetClassifyResultDefaultResponse;\nexport function isUnexpected(\n response:\n | ListOperations200Response\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelComposeOperation200Response\n | GetDocumentModelCopyToOperation200Response\n | GetDocumentClassifierBuildOperation200Response\n | GetOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfo200Response\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResult200Response\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocument202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModel200Response\n | GetModelDefaultResponse\n | DeleteModel204Response\n | DeleteModelDefaultResponse\n | BuildModel202Response\n | BuildModelLogicalResponse\n | BuildModelDefaultResponse\n | ComposeModel202Response\n | ComposeModelLogicalResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopy200Response\n | AuthorizeModelCopyDefaultResponse\n | CopyModelTo202Response\n | CopyModelToLogicalResponse\n | CopyModelToDefaultResponse\n | ListModels200Response\n | ListModelsDefaultResponse\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse\n | ListClassifiers200Response\n | ListClassifiersDefaultResponse\n | GetClassifier200Response\n | GetClassifierDefaultResponse\n | DeleteClassifier204Response\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStream202Response\n | ClassifyDocument202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResult200Response\n | GetClassifyResultDefaultResponse,\n): response is\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModelDefaultResponse\n | DeleteModelDefaultResponse\n | BuildModelDefaultResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopyDefaultResponse\n | CopyModelToDefaultResponse\n | ListModelsDefaultResponse\n | BuildClassifierDefaultResponse\n | ListClassifiersDefaultResponse\n | GetClassifierDefaultResponse\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResultDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number,\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller,\n} from \"@azure/core-lro\";\nimport {\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocumentFromStreamDefaultResponse,\n AnalyzeDocumentFromStreamLogicalResponse,\n BuildModel202Response,\n BuildModelDefaultResponse,\n BuildModelLogicalResponse,\n ComposeModel202Response,\n ComposeModelDefaultResponse,\n ComposeModelLogicalResponse,\n CopyModelTo202Response,\n CopyModelToDefaultResponse,\n CopyModelToLogicalResponse,\n BuildClassifier202Response,\n BuildClassifierDefaultResponse,\n BuildClassifierLogicalResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocumentFromStreamDefaultResponse,\n ClassifyDocumentFromStreamLogicalResponse,\n} from \"./responses\";\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 BuildModelLogicalResponse | BuildModelDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildModel202Response | BuildModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n>(\n client: Client,\n initialResponse: ComposeModel202Response | ComposeModelDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n>(\n client: Client,\n initialResponse: CopyModelTo202Response | CopyModelToDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends BuildClassifierLogicalResponse | BuildClassifierDefaultResponse,\n>(\n client: Client,\n initialResponse: BuildClassifier202Response | BuildClassifierDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse: AnalyzeDocumentFromStream202Response | AnalyzeDocumentFromStreamDefaultResponse,\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>,\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\nexport async function getLongRunningPoller<\n TResult extends\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n>(\n client: Client,\n initialResponse:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamDefaultResponse,\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 poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\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) => {\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 const response = await client.pathUnchecked(path ?? initialResponse.request.url).get();\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 return createHttpPoller(poller, options);\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>(response: TResult): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport DocumentIntelligence from \"./documentIntelligence\";\n\nexport * from \"./documentIntelligence\";\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 DocumentIntelligence;\n"],"names":["createClientLogger","getClient","getPagedAsyncIterator","createRestError","createHttpPoller"],"mappings":";;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,0BAA0B,CAAC;;ACJpE;AACA;AAOA;;;;;AAKG;AACW,SAAU,YAAY,CAClC,QAAgB,EAChB,WAA4C,EAC5C,OAAA,GAAyB,EAAE,EAAA;;IAE3B,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,QAAQ,CAAA,qBAAA,CAAuB,CAAC;IACtE,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,oBAAoB,CAAC;IAChE,MAAM,aAAa,GAAG,CAAA,mDAAA,CAAqD,CAAC;IAC5E,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE,CAAC;AACzB,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA,EACD,cAAc,EAAE;YACd,MAAM,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,cAAc,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA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,CAAC,QAAmB,CAAC,CAAC;AACxD,YAAA,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;AACnF,YAAA,OAAO,WAAW,CAAC;SACpB;KACF,CAAC;IAEF,OAAO,CAAC,qBAAqB,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,qBAAqB,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,IAAI,CAAC;AACtE,IAAA,OAAOC,wBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;;AAIG;AACH,SAAS,cAAc,CAA+B,QAAiB,EAAA;IACrE,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;KAC/F;IAED,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,kCACN,QAAQ,CAAA,EAAA,EACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EACpB,CAAA;KACF,CAAC;AACJ;;ACvIA;AACA;;;;;;;"}
|
|
@@ -9,25 +9,21 @@ import { logger } from "./logger";
|
|
|
9
9
|
* @param options - the parameter for all optional parameters
|
|
10
10
|
*/
|
|
11
11
|
export default function createClient(endpoint, credentials, options = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/documentintelligence`;
|
|
14
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2024-02-29-preview";
|
|
14
15
|
const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`;
|
|
15
16
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
16
17
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
17
18
|
: `${userAgentInfo}`;
|
|
18
|
-
options = {
|
|
19
|
-
...options,
|
|
20
|
-
userAgentOptions: {
|
|
19
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
21
20
|
userAgentPrefix,
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
21
|
+
}, loggingOptions: {
|
|
22
|
+
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
|
|
23
|
+
}, credentials: {
|
|
24
|
+
scopes: (_f = (_e = options.credentials) === null || _e === void 0 ? void 0 : _e.scopes) !== null && _f !== void 0 ? _f : ["https://cognitiveservices.azure.com/.default"],
|
|
25
|
+
apiKeyHeaderName: (_h = (_g = options.credentials) === null || _g === void 0 ? void 0 : _g.apiKeyHeaderName) !== null && _h !== void 0 ? _h : "Ocp-Apim-Subscription-Key",
|
|
26
|
+
} });
|
|
31
27
|
const client = getClient(baseUrl, credentials, options);
|
|
32
28
|
return client;
|
|
33
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentIntelligence.js","sourceRoot":"","sources":["../../src/documentIntelligence.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAA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B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { TokenCredential, KeyCredential } from \"@azure/core-auth\";\nimport { DocumentIntelligenceClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of `DocumentIntelligenceClient`\n * @param endpoint - The Document Intelligence service endpoint.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credentials: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): DocumentIntelligenceClient {\n const baseUrl = options.baseUrl ?? `${endpoint}/documentintelligence`;\n options.apiVersion = options.apiVersion ?? \"2024-02-29-preview\";\n const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as DocumentIntelligenceClient;\n\n return client;\n}\n"]}
|
|
@@ -28,7 +28,7 @@ const responseMap = {
|
|
|
28
28
|
};
|
|
29
29
|
export function isUnexpected(response) {
|
|
30
30
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
31
|
-
const url = new URL(lroOriginal
|
|
31
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
32
32
|
const method = response.request.method;
|
|
33
33
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
34
34
|
if (!pathDetails) {
|
|
@@ -37,6 +37,7 @@ export function isUnexpected(response) {
|
|
|
37
37
|
return !pathDetails.includes(response.status);
|
|
38
38
|
}
|
|
39
39
|
function getParametrizedPathSuccess(method, path) {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
40
41
|
const pathParts = path.split("/");
|
|
41
42
|
// Traverse list to match the longest candidate
|
|
42
43
|
// matchedLen: the length of candidate path
|
|
@@ -55,13 +56,13 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
55
56
|
// track if we have found a match to return the values found.
|
|
56
57
|
let found = true;
|
|
57
58
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
58
|
-
if (candidateParts[i]
|
|
59
|
-
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]
|
|
59
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
60
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
60
61
|
// If the current part of the candidate is a "template" part
|
|
61
62
|
// Try to use the suffix of pattern to match the path
|
|
62
63
|
// {guid} ==> $
|
|
63
64
|
// {guid}:export ==> :export$
|
|
64
|
-
const isMatched = new RegExp(`${candidateParts[i]
|
|
65
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
65
66
|
if (!isMatched) {
|
|
66
67
|
found = false;
|
|
67
68
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA+ClC,MAAM,WAAW,GAA6B;IAC5C,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,+BAA+B,EAAE,CAAC,KA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n ListOperations200Response,\n ListOperationsDefaultResponse,\n GetDocumentModelBuildOperation200Response,\n GetDocumentModelBuildOperationDefaultResponse,\n GetResourceInfo200Response,\n GetResourceInfoDefaultResponse,\n GetAnalyzeResult200Response,\n GetAnalyzeResultDefaultResponse,\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocumentFromStreamLogicalResponse,\n AnalyzeDocumentFromStreamDefaultResponse,\n GetModel200Response,\n GetModelDefaultResponse,\n DeleteModel204Response,\n DeleteModelDefaultResponse,\n BuildModel202Response,\n BuildModelLogicalResponse,\n BuildModelDefaultResponse,\n ComposeModel202Response,\n ComposeModelLogicalResponse,\n ComposeModelDefaultResponse,\n AuthorizeModelCopy200Response,\n AuthorizeModelCopyDefaultResponse,\n CopyModelTo202Response,\n CopyModelToLogicalResponse,\n CopyModelToDefaultResponse,\n ListModels200Response,\n ListModelsDefaultResponse,\n BuildClassifier202Response,\n BuildClassifierLogicalResponse,\n BuildClassifierDefaultResponse,\n ListClassifiers200Response,\n ListClassifiersDefaultResponse,\n GetClassifier200Response,\n GetClassifierDefaultResponse,\n DeleteClassifier204Response,\n DeleteClassifierDefaultResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocumentFromStreamLogicalResponse,\n ClassifyDocumentFromStreamDefaultResponse,\n GetClassifyResult200Response,\n GetClassifyResultDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /operations\": [\"200\"],\n \"GET /operations/{operationId}\": [\"200\"],\n \"GET /info\": [\"200\"],\n \"GET /documentModels/{modelId}/analyzeResults/{resultId}\": [\"200\"],\n \"POST /documentModels/{modelId}:analyze\": [\"202\"],\n \"GET /documentModels/{modelId}:analyze\": [\"200\", \"202\"],\n \"GET /documentModels/{modelId}\": [\"200\"],\n \"DELETE /documentModels/{modelId}\": [\"204\"],\n \"POST /documentModels:build\": [\"202\"],\n \"GET /documentModels:build\": [\"200\", \"202\"],\n \"POST /documentModels:compose\": [\"202\"],\n \"GET /documentModels:compose\": [\"200\", \"202\"],\n \"POST /documentModels:authorizeCopy\": [\"200\"],\n \"POST /documentModels/{modelId}:copyTo\": [\"202\"],\n \"GET /documentModels/{modelId}:copyTo\": [\"200\", \"202\"],\n \"GET /documentModels\": [\"200\"],\n \"POST /documentClassifiers:build\": [\"202\"],\n \"GET /documentClassifiers:build\": [\"200\", \"202\"],\n \"GET /documentClassifiers\": [\"200\"],\n \"GET /documentClassifiers/{classifierId}\": [\"200\"],\n \"DELETE /documentClassifiers/{classifierId}\": [\"204\"],\n \"POST /documentClassifiers/{classifierId}:analyze\": [\"202\"],\n \"GET /documentClassifiers/{classifierId}:analyze\": [\"200\", \"202\"],\n \"GET /documentClassifiers/{classifierId}/analyzeResults/{resultId}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListOperations200Response | ListOperationsDefaultResponse,\n): response is ListOperationsDefaultResponse;\nexport function isUnexpected(\n response:\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse,\n): response is GetDocumentModelBuildOperationDefaultResponse;\nexport function isUnexpected(\n response: GetResourceInfo200Response | GetResourceInfoDefaultResponse,\n): response is GetResourceInfoDefaultResponse;\nexport function isUnexpected(\n response: GetAnalyzeResult200Response | GetAnalyzeResultDefaultResponse,\n): response is GetAnalyzeResultDefaultResponse;\nexport function isUnexpected(\n response:\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n): response is AnalyzeDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetModel200Response | GetModelDefaultResponse,\n): response is GetModelDefaultResponse;\nexport function isUnexpected(\n response: DeleteModel204Response | DeleteModelDefaultResponse,\n): response is DeleteModelDefaultResponse;\nexport function isUnexpected(\n response: BuildModel202Response | BuildModelLogicalResponse | BuildModelDefaultResponse,\n): response is BuildModelDefaultResponse;\nexport function isUnexpected(\n response: ComposeModel202Response | ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n): response is ComposeModelDefaultResponse;\nexport function isUnexpected(\n response: AuthorizeModelCopy200Response | AuthorizeModelCopyDefaultResponse,\n): response is AuthorizeModelCopyDefaultResponse;\nexport function isUnexpected(\n response: CopyModelTo202Response | CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n): response is CopyModelToDefaultResponse;\nexport function isUnexpected(\n response: ListModels200Response | ListModelsDefaultResponse,\n): response is ListModelsDefaultResponse;\nexport function isUnexpected(\n response:\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse,\n): response is BuildClassifierDefaultResponse;\nexport function isUnexpected(\n response: ListClassifiers200Response | ListClassifiersDefaultResponse,\n): response is ListClassifiersDefaultResponse;\nexport function isUnexpected(\n response: GetClassifier200Response | GetClassifierDefaultResponse,\n): response is GetClassifierDefaultResponse;\nexport function isUnexpected(\n response: DeleteClassifier204Response | DeleteClassifierDefaultResponse,\n): response is DeleteClassifierDefaultResponse;\nexport function isUnexpected(\n response:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n): response is ClassifyDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetClassifyResult200Response | GetClassifyResultDefaultResponse,\n): response is GetClassifyResultDefaultResponse;\nexport function isUnexpected(\n response:\n | ListOperations200Response\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfo200Response\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResult200Response\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModel200Response\n | GetModelDefaultResponse\n | DeleteModel204Response\n | DeleteModelDefaultResponse\n | BuildModel202Response\n | BuildModelLogicalResponse\n | BuildModelDefaultResponse\n | ComposeModel202Response\n | ComposeModelLogicalResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopy200Response\n | AuthorizeModelCopyDefaultResponse\n | CopyModelTo202Response\n | CopyModelToLogicalResponse\n | CopyModelToDefaultResponse\n | ListModels200Response\n | ListModelsDefaultResponse\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse\n | ListClassifiers200Response\n | ListClassifiersDefaultResponse\n | GetClassifier200Response\n | GetClassifierDefaultResponse\n | DeleteClassifier204Response\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStream202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResult200Response\n | GetClassifyResultDefaultResponse,\n): response is\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModelDefaultResponse\n | DeleteModelDefaultResponse\n | BuildModelDefaultResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopyDefaultResponse\n | CopyModelToDefaultResponse\n | ListModelsDefaultResponse\n | BuildClassifierDefaultResponse\n | ListClassifiersDefaultResponse\n | GetClassifierDefaultResponse\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResultDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAuDlC,MAAM,WAAW,GAA6B;IAC5C,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,+BAA+B,EAAE,CAAC,KAAK,CAAC;IACxC,WAAW,EAAE,CAAC,KAAK,CAAC;IACpB,yDAAyD,EAAE,CAAC,KAAK,CAAC;IAClE,wCAAwC,EAAE,CAAC,KAAK,CAAC;IACjD,uCAAuC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACvD,+BAA+B,EAAE,CAAC,KAAK,CAA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G,CAAC,EAC/C,GAAG,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC;gBAClC,4DAA4D;gBAC5D,qDAAqD;gBACrD,eAAe;gBACf,6BAA6B;gBAC7B,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAC1E,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CACnB,CAAC;gBAEF,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;gBACR,CAAC;gBACD,SAAS;YACX,CAAC;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;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 {\n ListOperations200Response,\n ListOperationsDefaultResponse,\n GetDocumentModelBuildOperation200Response,\n GetDocumentModelComposeOperation200Response,\n GetDocumentModelCopyToOperation200Response,\n GetDocumentClassifierBuildOperation200Response,\n GetOperation200Response,\n GetDocumentModelBuildOperationDefaultResponse,\n GetResourceInfo200Response,\n GetResourceInfoDefaultResponse,\n GetAnalyzeResult200Response,\n GetAnalyzeResultDefaultResponse,\n AnalyzeDocumentFromStream202Response,\n AnalyzeDocument202Response,\n AnalyzeDocumentFromStreamLogicalResponse,\n AnalyzeDocumentLogicalResponse,\n AnalyzeDocumentFromStreamDefaultResponse,\n GetModel200Response,\n GetModelDefaultResponse,\n DeleteModel204Response,\n DeleteModelDefaultResponse,\n BuildModel202Response,\n BuildModelLogicalResponse,\n BuildModelDefaultResponse,\n ComposeModel202Response,\n ComposeModelLogicalResponse,\n ComposeModelDefaultResponse,\n AuthorizeModelCopy200Response,\n AuthorizeModelCopyDefaultResponse,\n CopyModelTo202Response,\n CopyModelToLogicalResponse,\n CopyModelToDefaultResponse,\n ListModels200Response,\n ListModelsDefaultResponse,\n BuildClassifier202Response,\n BuildClassifierLogicalResponse,\n BuildClassifierDefaultResponse,\n ListClassifiers200Response,\n ListClassifiersDefaultResponse,\n GetClassifier200Response,\n GetClassifierDefaultResponse,\n DeleteClassifier204Response,\n DeleteClassifierDefaultResponse,\n ClassifyDocumentFromStream202Response,\n ClassifyDocument202Response,\n ClassifyDocumentFromStreamLogicalResponse,\n ClassifyDocumentLogicalResponse,\n ClassifyDocumentFromStreamDefaultResponse,\n GetClassifyResult200Response,\n GetClassifyResultDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /operations\": [\"200\"],\n \"GET /operations/{operationId}\": [\"200\"],\n \"GET /info\": [\"200\"],\n \"GET /documentModels/{modelId}/analyzeResults/{resultId}\": [\"200\"],\n \"POST /documentModels/{modelId}:analyze\": [\"202\"],\n \"GET /documentModels/{modelId}:analyze\": [\"200\", \"202\"],\n \"GET /documentModels/{modelId}\": [\"200\"],\n \"DELETE /documentModels/{modelId}\": [\"204\"],\n \"POST /documentModels:build\": [\"202\"],\n \"GET /documentModels:build\": [\"200\", \"202\"],\n \"POST /documentModels:compose\": [\"202\"],\n \"GET /documentModels:compose\": [\"200\", \"202\"],\n \"POST /documentModels:authorizeCopy\": [\"200\"],\n \"POST /documentModels/{modelId}:copyTo\": [\"202\"],\n \"GET /documentModels/{modelId}:copyTo\": [\"200\", \"202\"],\n \"GET /documentModels\": [\"200\"],\n \"POST /documentClassifiers:build\": [\"202\"],\n \"GET /documentClassifiers:build\": [\"200\", \"202\"],\n \"GET /documentClassifiers\": [\"200\"],\n \"GET /documentClassifiers/{classifierId}\": [\"200\"],\n \"DELETE /documentClassifiers/{classifierId}\": [\"204\"],\n \"POST /documentClassifiers/{classifierId}:analyze\": [\"202\"],\n \"GET /documentClassifiers/{classifierId}:analyze\": [\"200\", \"202\"],\n \"GET /documentClassifiers/{classifierId}/analyzeResults/{resultId}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListOperations200Response | ListOperationsDefaultResponse,\n): response is ListOperationsDefaultResponse;\nexport function isUnexpected(\n response:\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelComposeOperation200Response\n | GetDocumentModelCopyToOperation200Response\n | GetDocumentClassifierBuildOperation200Response\n | GetOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse,\n): response is GetDocumentModelBuildOperationDefaultResponse;\nexport function isUnexpected(\n response: GetResourceInfo200Response | GetResourceInfoDefaultResponse,\n): response is GetResourceInfoDefaultResponse;\nexport function isUnexpected(\n response: GetAnalyzeResult200Response | GetAnalyzeResultDefaultResponse,\n): response is GetAnalyzeResultDefaultResponse;\nexport function isUnexpected(\n response:\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocument202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse,\n): response is AnalyzeDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetModel200Response | GetModelDefaultResponse,\n): response is GetModelDefaultResponse;\nexport function isUnexpected(\n response: DeleteModel204Response | DeleteModelDefaultResponse,\n): response is DeleteModelDefaultResponse;\nexport function isUnexpected(\n response: BuildModel202Response | BuildModelLogicalResponse | BuildModelDefaultResponse,\n): response is BuildModelDefaultResponse;\nexport function isUnexpected(\n response: ComposeModel202Response | ComposeModelLogicalResponse | ComposeModelDefaultResponse,\n): response is ComposeModelDefaultResponse;\nexport function isUnexpected(\n response: AuthorizeModelCopy200Response | AuthorizeModelCopyDefaultResponse,\n): response is AuthorizeModelCopyDefaultResponse;\nexport function isUnexpected(\n response: CopyModelTo202Response | CopyModelToLogicalResponse | CopyModelToDefaultResponse,\n): response is CopyModelToDefaultResponse;\nexport function isUnexpected(\n response: ListModels200Response | ListModelsDefaultResponse,\n): response is ListModelsDefaultResponse;\nexport function isUnexpected(\n response:\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse,\n): response is BuildClassifierDefaultResponse;\nexport function isUnexpected(\n response: ListClassifiers200Response | ListClassifiersDefaultResponse,\n): response is ListClassifiersDefaultResponse;\nexport function isUnexpected(\n response: GetClassifier200Response | GetClassifierDefaultResponse,\n): response is GetClassifierDefaultResponse;\nexport function isUnexpected(\n response: DeleteClassifier204Response | DeleteClassifierDefaultResponse,\n): response is DeleteClassifierDefaultResponse;\nexport function isUnexpected(\n response:\n | ClassifyDocumentFromStream202Response\n | ClassifyDocument202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse,\n): response is ClassifyDocumentFromStreamDefaultResponse;\nexport function isUnexpected(\n response: GetClassifyResult200Response | GetClassifyResultDefaultResponse,\n): response is GetClassifyResultDefaultResponse;\nexport function isUnexpected(\n response:\n | ListOperations200Response\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperation200Response\n | GetDocumentModelComposeOperation200Response\n | GetDocumentModelCopyToOperation200Response\n | GetDocumentClassifierBuildOperation200Response\n | GetOperation200Response\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfo200Response\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResult200Response\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStream202Response\n | AnalyzeDocument202Response\n | AnalyzeDocumentFromStreamLogicalResponse\n | AnalyzeDocumentLogicalResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModel200Response\n | GetModelDefaultResponse\n | DeleteModel204Response\n | DeleteModelDefaultResponse\n | BuildModel202Response\n | BuildModelLogicalResponse\n | BuildModelDefaultResponse\n | ComposeModel202Response\n | ComposeModelLogicalResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopy200Response\n | AuthorizeModelCopyDefaultResponse\n | CopyModelTo202Response\n | CopyModelToLogicalResponse\n | CopyModelToDefaultResponse\n | ListModels200Response\n | ListModelsDefaultResponse\n | BuildClassifier202Response\n | BuildClassifierLogicalResponse\n | BuildClassifierDefaultResponse\n | ListClassifiers200Response\n | ListClassifiersDefaultResponse\n | GetClassifier200Response\n | GetClassifierDefaultResponse\n | DeleteClassifier204Response\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStream202Response\n | ClassifyDocument202Response\n | ClassifyDocumentFromStreamLogicalResponse\n | ClassifyDocumentLogicalResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResult200Response\n | GetClassifyResultDefaultResponse,\n): response is\n | ListOperationsDefaultResponse\n | GetDocumentModelBuildOperationDefaultResponse\n | GetResourceInfoDefaultResponse\n | GetAnalyzeResultDefaultResponse\n | AnalyzeDocumentFromStreamDefaultResponse\n | GetModelDefaultResponse\n | DeleteModelDefaultResponse\n | BuildModelDefaultResponse\n | ComposeModelDefaultResponse\n | AuthorizeModelCopyDefaultResponse\n | CopyModelToDefaultResponse\n | ListModelsDefaultResponse\n | BuildClassifierDefaultResponse\n | ListClassifiersDefaultResponse\n | GetClassifierDefaultResponse\n | DeleteClassifierDefaultResponse\n | ClassifyDocumentFromStreamDefaultResponse\n | GetClassifyResultDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** Azure Blob Storage content. */\nexport interface AzureBlobContentSource {\n /** Azure Blob Storage container URL. */\n containerUrl: string;\n /** Blob name prefix. */\n prefix?: string;\n}\n\n/** File list in Azure Blob Storage. */\nexport interface AzureBlobFileListContentSource {\n /** Azure Blob Storage container URL. */\n containerUrl: string;\n /** Path to a JSONL file within the container specifying a subset of documents. */\n fileList: string;\n}\n\n/** Classifier document type info. */\nexport interface ClassifierDocumentTypeDetails {\n /**\n * Type of training data source.\n *\n * Possible values: url, base64, azureBlob, azureBlobFileList\n */\n sourceKind?: string;\n /**\n * Azure Blob Storage location containing the training data for a classifier\n * document type. Either azureBlobSource or azureBlobFileListSource must be\n * specified.\n */\n azureBlobSource?: AzureBlobContentSource;\n /**\n * Azure Blob Storage file list specifying the training data for a classifier\n * document type. Either azureBlobSource or azureBlobFileListSource must be\n * specified.\n */\n azureBlobFileListSource?: AzureBlobFileListContentSource;\n}\n\n/** Document analysis parameters. */\nexport interface AnalyzeDocumentRequest {\n /** Document URL to analyze. Either urlSource or base64Source must be specified. */\n urlSource?: string;\n /**\n * Base64 encoding of the document to analyze. Either urlSource or base64Source\n * must be specified.\n */\n base64Source?: string;\n}\n\n/** Request body to build a new custom document model. */\nexport interface BuildDocumentModelRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /**\n * Custom document model build mode.\n *\n * Possible values: template, neural\n */\n buildMode: string;\n /**\n * Azure Blob Storage location containing the training data. Either\n * azureBlobSource or azureBlobFileListSource must be specified.\n */\n azureBlobSource?: AzureBlobContentSource;\n /**\n * Azure Blob Storage file list specifying the training data. Either\n * azureBlobSource or azureBlobFileListSource must be specified.\n */\n azureBlobFileListSource?: AzureBlobFileListContentSource;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/** Request body to create a composed document model from component document models. */\nexport interface ComposeDocumentModelRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /** List of component document models to compose. */\n componentModels: Array<ComponentDocumentModelDetails>;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/** A component of a composed document model. */\nexport interface ComponentDocumentModelDetails {\n /** Unique document model name. */\n modelId: string;\n}\n\n/** Request body to authorize document model copy. */\nexport interface AuthorizeCopyRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/**\n * Authorization to copy a document model to the specified target resource and\n * modelId.\n */\nexport interface CopyAuthorization {\n /** ID of the target Azure resource where the document model should be copied to. */\n targetResourceId: string;\n /**\n * Location of the target Azure resource where the document model should be copied\n * to.\n */\n targetResourceRegion: string;\n /** Identifier of the target document model. */\n targetModelId: string;\n /** URL of the copied document model in the target account. */\n targetModelLocation: string;\n /** Token used to authorize the request. */\n accessToken: string;\n /** Date/time when the access token expires. */\n expirationDateTime: Date | string;\n}\n\n/** Request body to build a new custom document classifier. */\nexport interface BuildDocumentClassifierRequest {\n /** Unique document classifier name. */\n classifierId: string;\n /** Document classifier description. */\n description?: string;\n /** List of document types to classify against. */\n docTypes: Record<string, ClassifierDocumentTypeDetails>;\n}\n\n/** Document classification parameters. */\nexport interface ClassifyDocumentRequest {\n /** Document URL to classify. Either urlSource or base64Source must be specified. */\n urlSource?: string;\n /**\n * Base64 encoding of the document to classify. Either urlSource or base64Source\n * must be specified.\n */\n base64Source?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** Azure Blob Storage content. */\nexport interface AzureBlobContentSource {\n /** Azure Blob Storage container URL. */\n containerUrl: string;\n /** Blob name prefix. */\n prefix?: string;\n}\n\n/** File list in Azure Blob Storage. */\nexport interface AzureBlobFileListContentSource {\n /** Azure Blob Storage container URL. */\n containerUrl: string;\n /** Path to a JSONL file within the container specifying a subset of documents. */\n fileList: string;\n}\n\n/** Classifier document type info. */\nexport interface ClassifierDocumentTypeDetails {\n /**\n * Type of training data source.\n *\n * Possible values: \"url\", \"base64\", \"azureBlob\", \"azureBlobFileList\"\n */\n sourceKind?: string;\n /**\n * Azure Blob Storage location containing the training data for a classifier\n * document type. Either azureBlobSource or azureBlobFileListSource must be\n * specified.\n */\n azureBlobSource?: AzureBlobContentSource;\n /**\n * Azure Blob Storage file list specifying the training data for a classifier\n * document type. Either azureBlobSource or azureBlobFileListSource must be\n * specified.\n */\n azureBlobFileListSource?: AzureBlobFileListContentSource;\n}\n\n/** Document analysis parameters. */\nexport interface AnalyzeDocumentRequest {\n /** Document URL to analyze. Either urlSource or base64Source must be specified. */\n urlSource?: string;\n /**\n * Base64 encoding of the document to analyze. Either urlSource or base64Source\n * must be specified.\n */\n base64Source?: string;\n}\n\n/** Request body to build a new custom document model. */\nexport interface BuildDocumentModelRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /**\n * Custom document model build mode.\n *\n * Possible values: \"template\", \"neural\"\n */\n buildMode: string;\n /**\n * Azure Blob Storage location containing the training data. Either\n * azureBlobSource or azureBlobFileListSource must be specified.\n */\n azureBlobSource?: AzureBlobContentSource;\n /**\n * Azure Blob Storage file list specifying the training data. Either\n * azureBlobSource or azureBlobFileListSource must be specified.\n */\n azureBlobFileListSource?: AzureBlobFileListContentSource;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/** Request body to create a composed document model from component document models. */\nexport interface ComposeDocumentModelRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /** List of component document models to compose. */\n componentModels: Array<ComponentDocumentModelDetails>;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/** A component of a composed document model. */\nexport interface ComponentDocumentModelDetails {\n /** Unique document model name. */\n modelId: string;\n}\n\n/** Request body to authorize document model copy. */\nexport interface AuthorizeCopyRequest {\n /** Unique document model name. */\n modelId: string;\n /** Document model description. */\n description?: string;\n /** List of key-value tag attributes associated with the document model. */\n tags?: Record<string, string>;\n}\n\n/**\n * Authorization to copy a document model to the specified target resource and\n * modelId.\n */\nexport interface CopyAuthorization {\n /** ID of the target Azure resource where the document model should be copied to. */\n targetResourceId: string;\n /**\n * Location of the target Azure resource where the document model should be copied\n * to.\n */\n targetResourceRegion: string;\n /** Identifier of the target document model. */\n targetModelId: string;\n /** URL of the copied document model in the target account. */\n targetModelLocation: string;\n /** Token used to authorize the request. */\n accessToken: string;\n /** Date/time when the access token expires. */\n expirationDateTime: Date | string;\n}\n\n/** Request body to build a new custom document classifier. */\nexport interface BuildDocumentClassifierRequest {\n /** Unique document classifier name. */\n classifierId: string;\n /** Document classifier description. */\n description?: string;\n /** Base classifierId on top of which to train the classifier. */\n baseClassifierId?: string;\n /** List of document types to classify against. */\n docTypes: Record<string, ClassifierDocumentTypeDetails>;\n}\n\n/** Document classification parameters. */\nexport interface ClassifyDocumentRequest {\n /** Document URL to classify. Either urlSource or base64Source must be specified. */\n urlSource?: string;\n /**\n * Base64 encoding of the document to classify. Either urlSource or base64Source\n * must be specified.\n */\n base64Source?: string;\n}\n"]}
|