@azure/ai-content-understanding 1.0.0
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/LICENSE +21 -0
- package/README.md +591 -0
- package/dist/browser/api/contentUnderstandingContext.d.ts +15 -0
- package/dist/browser/api/contentUnderstandingContext.js +27 -0
- package/dist/browser/api/contentUnderstandingContext.js.map +1 -0
- package/dist/browser/api/index.d.ts +4 -0
- package/dist/browser/api/index.js +5 -0
- package/dist/browser/api/index.js.map +1 -0
- package/dist/browser/api/operations.d.ts +67 -0
- package/dist/browser/api/operations.js +488 -0
- package/dist/browser/api/operations.js.map +1 -0
- package/dist/browser/api/options.d.ts +94 -0
- package/dist/browser/api/options.js +4 -0
- package/dist/browser/api/options.js.map +1 -0
- package/dist/browser/contentUnderstandingClient.d.ts +65 -0
- package/dist/browser/contentUnderstandingClient.js +161 -0
- package/dist/browser/contentUnderstandingClient.js.map +1 -0
- package/dist/browser/index.d.ts +6 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.js +5 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/models/index.d.ts +2 -0
- package/dist/browser/models/index.js +4 -0
- package/dist/browser/models/index.js.map +1 -0
- package/dist/browser/models/models.d.ts +846 -0
- package/dist/browser/models/models.js +1005 -0
- package/dist/browser/models/models.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/static-helpers/pagingHelpers.d.ts +74 -0
- package/dist/browser/static-helpers/pagingHelpers.js +143 -0
- package/dist/browser/static-helpers/pagingHelpers.js.map +1 -0
- package/dist/browser/static-helpers/pollingHelpers.d.ts +34 -0
- package/dist/browser/static-helpers/pollingHelpers.js +95 -0
- package/dist/browser/static-helpers/pollingHelpers.js.map +1 -0
- package/dist/browser/static-helpers/serialization/get-binary-response-browser.mjs.map +1 -0
- package/dist/browser/static-helpers/serialization/get-binary-response.d.ts +10 -0
- package/dist/browser/static-helpers/serialization/get-binary-response.js +19 -0
- package/dist/browser/static-helpers/serialization/serialize-record.d.ts +2 -0
- package/dist/browser/static-helpers/serialization/serialize-record.js +22 -0
- package/dist/browser/static-helpers/serialization/serialize-record.js.map +1 -0
- package/dist/browser/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/browser/static-helpers/urlTemplate.js +200 -0
- package/dist/browser/static-helpers/urlTemplate.js.map +1 -0
- package/dist/commonjs/api/contentUnderstandingContext.d.ts +15 -0
- package/dist/commonjs/api/contentUnderstandingContext.js +30 -0
- package/dist/commonjs/api/contentUnderstandingContext.js.map +1 -0
- package/dist/commonjs/api/index.d.ts +4 -0
- package/dist/commonjs/api/index.js +24 -0
- package/dist/commonjs/api/index.js.map +1 -0
- package/dist/commonjs/api/operations.d.ts +67 -0
- package/dist/commonjs/api/operations.js +535 -0
- package/dist/commonjs/api/operations.js.map +1 -0
- package/dist/commonjs/api/options.d.ts +94 -0
- package/dist/commonjs/api/options.js +5 -0
- package/dist/commonjs/api/options.js.map +1 -0
- package/dist/commonjs/contentUnderstandingClient.d.ts +65 -0
- package/dist/commonjs/contentUnderstandingClient.js +160 -0
- package/dist/commonjs/contentUnderstandingClient.js.map +1 -0
- package/dist/commonjs/index.d.ts +6 -0
- package/dist/commonjs/index.js +19 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models/index.d.ts +2 -0
- package/dist/commonjs/models/index.js +8 -0
- package/dist/commonjs/models/index.js.map +1 -0
- package/dist/commonjs/models/models.d.ts +846 -0
- package/dist/commonjs/models/models.js +1103 -0
- package/dist/commonjs/models/models.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/static-helpers/pagingHelpers.d.ts +74 -0
- package/dist/commonjs/static-helpers/pagingHelpers.js +146 -0
- package/dist/commonjs/static-helpers/pagingHelpers.js.map +1 -0
- package/dist/commonjs/static-helpers/pollingHelpers.d.ts +34 -0
- package/dist/commonjs/static-helpers/pollingHelpers.js +98 -0
- package/dist/commonjs/static-helpers/pollingHelpers.js.map +1 -0
- package/dist/commonjs/static-helpers/serialization/get-binary-response.d.ts +10 -0
- package/dist/commonjs/static-helpers/serialization/get-binary-response.js +26 -0
- package/dist/commonjs/static-helpers/serialization/get-binary-response.js.map +1 -0
- package/dist/commonjs/static-helpers/serialization/serialize-record.d.ts +2 -0
- package/dist/commonjs/static-helpers/serialization/serialize-record.js +25 -0
- package/dist/commonjs/static-helpers/serialization/serialize-record.js.map +1 -0
- package/dist/commonjs/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/commonjs/static-helpers/urlTemplate.js +203 -0
- package/dist/commonjs/static-helpers/urlTemplate.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/api/contentUnderstandingContext.d.ts +15 -0
- package/dist/esm/api/contentUnderstandingContext.js +27 -0
- package/dist/esm/api/contentUnderstandingContext.js.map +1 -0
- package/dist/esm/api/index.d.ts +4 -0
- package/dist/esm/api/index.js +5 -0
- package/dist/esm/api/index.js.map +1 -0
- package/dist/esm/api/operations.d.ts +67 -0
- package/dist/esm/api/operations.js +488 -0
- package/dist/esm/api/operations.js.map +1 -0
- package/dist/esm/api/options.d.ts +94 -0
- package/dist/esm/api/options.js +4 -0
- package/dist/esm/api/options.js.map +1 -0
- package/dist/esm/contentUnderstandingClient.d.ts +65 -0
- package/dist/esm/contentUnderstandingClient.js +161 -0
- package/dist/esm/contentUnderstandingClient.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models/index.d.ts +2 -0
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/models/index.js.map +1 -0
- package/dist/esm/models/models.d.ts +846 -0
- package/dist/esm/models/models.js +1005 -0
- package/dist/esm/models/models.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/static-helpers/pagingHelpers.d.ts +74 -0
- package/dist/esm/static-helpers/pagingHelpers.js +143 -0
- package/dist/esm/static-helpers/pagingHelpers.js.map +1 -0
- package/dist/esm/static-helpers/pollingHelpers.d.ts +34 -0
- package/dist/esm/static-helpers/pollingHelpers.js +95 -0
- package/dist/esm/static-helpers/pollingHelpers.js.map +1 -0
- package/dist/esm/static-helpers/serialization/get-binary-response.d.ts +10 -0
- package/dist/esm/static-helpers/serialization/get-binary-response.js +23 -0
- package/dist/esm/static-helpers/serialization/get-binary-response.js.map +1 -0
- package/dist/esm/static-helpers/serialization/serialize-record.d.ts +2 -0
- package/dist/esm/static-helpers/serialization/serialize-record.js +22 -0
- package/dist/esm/static-helpers/serialization/serialize-record.js.map +1 -0
- package/dist/esm/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/esm/static-helpers/urlTemplate.js +200 -0
- package/dist/esm/static-helpers/urlTemplate.js.map +1 -0
- package/dist/react-native/api/contentUnderstandingContext.d.ts +15 -0
- package/dist/react-native/api/contentUnderstandingContext.js +27 -0
- package/dist/react-native/api/contentUnderstandingContext.js.map +1 -0
- package/dist/react-native/api/index.d.ts +4 -0
- package/dist/react-native/api/index.js +5 -0
- package/dist/react-native/api/index.js.map +1 -0
- package/dist/react-native/api/operations.d.ts +67 -0
- package/dist/react-native/api/operations.js +488 -0
- package/dist/react-native/api/operations.js.map +1 -0
- package/dist/react-native/api/options.d.ts +94 -0
- package/dist/react-native/api/options.js +4 -0
- package/dist/react-native/api/options.js.map +1 -0
- package/dist/react-native/contentUnderstandingClient.d.ts +65 -0
- package/dist/react-native/contentUnderstandingClient.js +161 -0
- package/dist/react-native/contentUnderstandingClient.js.map +1 -0
- package/dist/react-native/index.d.ts +6 -0
- package/dist/react-native/index.js +14 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models/index.d.ts +2 -0
- package/dist/react-native/models/index.js +4 -0
- package/dist/react-native/models/index.js.map +1 -0
- package/dist/react-native/models/models.d.ts +846 -0
- package/dist/react-native/models/models.js +1005 -0
- package/dist/react-native/models/models.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/static-helpers/pagingHelpers.d.ts +74 -0
- package/dist/react-native/static-helpers/pagingHelpers.js +143 -0
- package/dist/react-native/static-helpers/pagingHelpers.js.map +1 -0
- package/dist/react-native/static-helpers/pollingHelpers.d.ts +34 -0
- package/dist/react-native/static-helpers/pollingHelpers.js +95 -0
- package/dist/react-native/static-helpers/pollingHelpers.js.map +1 -0
- package/dist/react-native/static-helpers/serialization/get-binary-response.d.ts +10 -0
- package/dist/react-native/static-helpers/serialization/get-binary-response.js +23 -0
- package/dist/react-native/static-helpers/serialization/get-binary-response.js.map +1 -0
- package/dist/react-native/static-helpers/serialization/serialize-record.d.ts +2 -0
- package/dist/react-native/static-helpers/serialization/serialize-record.js +22 -0
- package/dist/react-native/static-helpers/serialization/serialize-record.js.map +1 -0
- package/dist/react-native/static-helpers/urlTemplate.d.ts +5 -0
- package/dist/react-native/static-helpers/urlTemplate.js +200 -0
- package/dist/react-native/static-helpers/urlTemplate.js.map +1 -0
- package/package.json +180 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { createHttpPoller } from "@azure/core-lro";
|
|
4
|
+
import { createRestError } from "@azure-rest/core-client";
|
|
5
|
+
export function getLongRunningPoller(client, processResponseBody, expectedStatuses, options) {
|
|
6
|
+
const { restoreFrom, getInitialResponse, apiVersion } = options;
|
|
7
|
+
if (!restoreFrom && !getInitialResponse) {
|
|
8
|
+
throw new Error("Either restoreFrom or getInitialResponse must be specified");
|
|
9
|
+
}
|
|
10
|
+
let initialResponse = undefined;
|
|
11
|
+
const pollAbortController = new AbortController();
|
|
12
|
+
const poller = {
|
|
13
|
+
sendInitialRequest: async () => {
|
|
14
|
+
if (!getInitialResponse) {
|
|
15
|
+
throw new Error("getInitialResponse is required when initializing a new poller");
|
|
16
|
+
}
|
|
17
|
+
initialResponse = await getInitialResponse();
|
|
18
|
+
return getLroResponse(initialResponse, expectedStatuses);
|
|
19
|
+
},
|
|
20
|
+
sendPollRequest: async (path, pollOptions) => {
|
|
21
|
+
// The poll request would both listen to the user provided abort signal and the poller's own abort signal
|
|
22
|
+
function abortListener() {
|
|
23
|
+
pollAbortController.abort();
|
|
24
|
+
}
|
|
25
|
+
const abortSignal = pollAbortController.signal;
|
|
26
|
+
if (options.abortSignal?.aborted) {
|
|
27
|
+
pollAbortController.abort();
|
|
28
|
+
}
|
|
29
|
+
else if (pollOptions?.abortSignal?.aborted) {
|
|
30
|
+
pollAbortController.abort();
|
|
31
|
+
}
|
|
32
|
+
else if (!abortSignal.aborted) {
|
|
33
|
+
options.abortSignal?.addEventListener("abort", abortListener, {
|
|
34
|
+
once: true,
|
|
35
|
+
});
|
|
36
|
+
pollOptions?.abortSignal?.addEventListener("abort", abortListener, {
|
|
37
|
+
once: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
let response;
|
|
41
|
+
try {
|
|
42
|
+
const pollingPath = apiVersion ? addApiVersionToUrl(path, apiVersion) : path;
|
|
43
|
+
response = await client.pathUnchecked(pollingPath).get({ abortSignal });
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
options.abortSignal?.removeEventListener("abort", abortListener);
|
|
47
|
+
pollOptions?.abortSignal?.removeEventListener("abort", abortListener);
|
|
48
|
+
}
|
|
49
|
+
return getLroResponse(response, expectedStatuses);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return createHttpPoller(poller, {
|
|
53
|
+
intervalInMs: options?.updateIntervalInMs,
|
|
54
|
+
resourceLocationConfig: options?.resourceLocationConfig,
|
|
55
|
+
restoreFrom: options?.restoreFrom,
|
|
56
|
+
processResult: (result) => {
|
|
57
|
+
return processResponseBody(result);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
63
|
+
* @param response - a rest client http response
|
|
64
|
+
* @param deserializeFn - deserialize function to convert Rest response to modular output
|
|
65
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
66
|
+
*/
|
|
67
|
+
function getLroResponse(response, expectedStatuses) {
|
|
68
|
+
if (!expectedStatuses.includes(response.status)) {
|
|
69
|
+
throw createRestError(response);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
flatResponse: response,
|
|
73
|
+
rawResponse: {
|
|
74
|
+
...response,
|
|
75
|
+
statusCode: Number.parseInt(response.status),
|
|
76
|
+
body: response.body,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Adds the api-version query parameter on a URL if it's not present.
|
|
82
|
+
* @param url - the URL to modify
|
|
83
|
+
* @param apiVersion - the API version to set
|
|
84
|
+
* @returns - the URL with the api-version query parameter set
|
|
85
|
+
*/
|
|
86
|
+
function addApiVersionToUrl(url, apiVersion) {
|
|
87
|
+
// The base URL is only used for parsing and won't appear in the returned URL
|
|
88
|
+
const urlObj = new URL(url, "https://microsoft.com");
|
|
89
|
+
if (!urlObj.searchParams.get("api-version")) {
|
|
90
|
+
// Append one if there is no apiVersion
|
|
91
|
+
return `${url}${Array.from(urlObj.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
|
|
92
|
+
}
|
|
93
|
+
return url;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=pollingHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollingHelpers.js","sourceRoot":"","sources":["../../../src/static-helpers/pollingHelpers.ts"],"names":[],"mappings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AC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,EAAE;YACX,GAAG,QAAQ;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,GAAW,EAAE,UAAkB;IACzD,6EAA6E;IAC7E,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAC5C,uCAAuC;QACvC,OAAO,GAAG,GAAG,GACX,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAC5D,eAAe,UAAU,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PollerLike,\n OperationState,\n ResourceLocationConfig,\n RunningOperation,\n OperationResponse,\n} from \"@azure/core-lro\";\nimport { createHttpPoller } from \"@azure/core-lro\";\n\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\nexport interface GetLongRunningPollerOptions<TResponse> {\n /** Delay to wait until next poll, in milliseconds. */\n updateIntervalInMs?: number;\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * The potential location of the result of the LRO if specified by the LRO extension in the swagger.\n */\n resourceLocationConfig?: ResourceLocationConfig;\n /**\n * The original url of the LRO\n * Should not be null when restoreFrom is set\n */\n initialRequestUrl?: string;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n restoreFrom?: string;\n /**\n * The function to get the initial response\n */\n getInitialResponse?: () => PromiseLike<TResponse>;\n /**\n * The api-version of the LRO\n */\n apiVersion?: string;\n}\nexport function getLongRunningPoller<TResponse extends PathUncheckedResponse, TResult = void>(\n client: Client,\n processResponseBody: (result: TResponse) => Promise<TResult>,\n expectedStatuses: string[],\n options: GetLongRunningPollerOptions<TResponse>,\n): PollerLike<OperationState<TResult>, TResult> {\n const { restoreFrom, getInitialResponse, apiVersion } = options;\n if (!restoreFrom && !getInitialResponse) {\n throw new Error(\"Either restoreFrom or getInitialResponse must be specified\");\n }\n let initialResponse: TResponse | undefined = undefined;\n const pollAbortController = new AbortController();\n const poller: RunningOperation<TResponse> = {\n sendInitialRequest: async () => {\n if (!getInitialResponse) {\n throw new Error(\"getInitialResponse is required when initializing a new poller\");\n }\n initialResponse = await getInitialResponse();\n return getLroResponse(initialResponse, expectedStatuses);\n },\n sendPollRequest: async (\n path: string,\n pollOptions?: {\n abortSignal?: AbortSignalLike;\n },\n ) => {\n // The poll request would both listen to the user provided abort signal and the poller's own abort signal\n function abortListener(): void {\n pollAbortController.abort();\n }\n const abortSignal = pollAbortController.signal;\n if (options.abortSignal?.aborted) {\n pollAbortController.abort();\n } else if (pollOptions?.abortSignal?.aborted) {\n pollAbortController.abort();\n } else if (!abortSignal.aborted) {\n options.abortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n pollOptions?.abortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n const pollingPath = apiVersion ? addApiVersionToUrl(path, apiVersion) : path;\n response = await client.pathUnchecked(pollingPath).get({ abortSignal });\n } finally {\n options.abortSignal?.removeEventListener(\"abort\", abortListener);\n pollOptions?.abortSignal?.removeEventListener(\"abort\", abortListener);\n }\n\n return getLroResponse(response as TResponse, expectedStatuses);\n },\n };\n return createHttpPoller(poller, {\n intervalInMs: options?.updateIntervalInMs,\n resourceLocationConfig: options?.resourceLocationConfig,\n restoreFrom: options?.restoreFrom,\n processResult: (result: unknown) => {\n return processResponseBody(result as TResponse);\n },\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 * @param deserializeFn - deserialize function to convert Rest response to modular output\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResponse extends PathUncheckedResponse>(\n response: TResponse,\n expectedStatuses: string[],\n): OperationResponse<TResponse> {\n if (!expectedStatuses.includes(response.status)) {\n throw createRestError(response);\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\n/**\n * Adds the api-version query parameter on a URL if it's not present.\n * @param url - the URL to modify\n * @param apiVersion - the API version to set\n * @returns - the URL with the api-version query parameter set\n */\nfunction addApiVersionToUrl(url: string, apiVersion: string): string {\n // The base URL is only used for parsing and won't appear in the returned URL\n const urlObj = new URL(url, \"https://microsoft.com\");\n if (!urlObj.searchParams.get(\"api-version\")) {\n // Append one if there is no apiVersion\n return `${url}${\n Array.from(urlObj.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n return url;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-binary-response-browser.mjs","sourceRoot":"","sources":["../../../../src/static-helpers/serialization/get-binary-response-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,gBAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,eAAe,EAAE,CAAC;IAE1D,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAgD,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,OAAO;QACL,GAAG,QAAQ;QACX,IAAI,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC;KAClC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpResponse, StreamableMethod } from \"@azure-rest/core-client\";\n\n/**\n * Gets a response type representing the given streamable response, using the stream methods\n * to bypass Core's default response handling. This works around an issue where binary bodies in Core\n * are coerced into UTF-8, regardless of whether the body is valid UTF-8 or not.\n */\nexport async function getBinaryResponse(\n streamableMethod: StreamableMethod,\n): Promise<HttpResponse & { body?: Uint8Array }> {\n const response = await streamableMethod.asBrowserStream();\n\n if (response.body === undefined) {\n return response as HttpResponse & { body?: Uint8Array };\n }\n\n const arrayBuffer = await new Response(response.body).arrayBuffer();\n return {\n ...response,\n body: new Uint8Array(arrayBuffer),\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HttpResponse, StreamableMethod } from "@azure-rest/core-client";
|
|
2
|
+
/**
|
|
3
|
+
* Gets a response type representing the given streamable response, using the stream methods
|
|
4
|
+
* to bypass Core's default response handling. This works around an issue where binary bodies in Core
|
|
5
|
+
* are coerced into UTF-8, regardless of whether the body is valid UTF-8 or not.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getBinaryResponse(streamableMethod: StreamableMethod): Promise<HttpResponse & {
|
|
8
|
+
body?: Uint8Array;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=get-binary-response-browser.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Gets a response type representing the given streamable response, using the stream methods
|
|
5
|
+
* to bypass Core's default response handling. This works around an issue where binary bodies in Core
|
|
6
|
+
* are coerced into UTF-8, regardless of whether the body is valid UTF-8 or not.
|
|
7
|
+
*/
|
|
8
|
+
export async function getBinaryResponse(streamableMethod) {
|
|
9
|
+
const response = await streamableMethod.asBrowserStream();
|
|
10
|
+
if (response.body === undefined) {
|
|
11
|
+
return response;
|
|
12
|
+
}
|
|
13
|
+
const arrayBuffer = await new Response(response.body).arrayBuffer();
|
|
14
|
+
return {
|
|
15
|
+
...response,
|
|
16
|
+
body: new Uint8Array(arrayBuffer),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=get-binary-response-browser.mjs.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
// CUSTOMIZATION: EMITTER-FIX: Typed `item` parameter as `Record<string, any>` instead of `any`
|
|
4
|
+
// to satisfy Azure SDK ESLint rules (`@typescript-eslint/explicit-module-boundary-types`).
|
|
5
|
+
// The return type annotation and `propertiesToExclude` local variable are now generated upstream.
|
|
6
|
+
export function serializeRecord(item, excludes, serializer) {
|
|
7
|
+
const propertiesToExclude = excludes ?? [];
|
|
8
|
+
const res = {};
|
|
9
|
+
for (const key of Object.keys(item)) {
|
|
10
|
+
if (propertiesToExclude.includes(key) || item[key] === undefined) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (serializer) {
|
|
14
|
+
res[key] = serializer(item[key]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
res[key] = item[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=serialize-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-record.js","sourceRoot":"","sources":["../../../../src/static-helpers/serialization/serialize-record.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,+FAA+F;AAC/F,2FAA2F;AAC3F,kGAAkG;AAClG,MAAM,UAAU,eAAe,CAC7B,IAAyB,EACzB,QAAmB,EACnB,UAA+B;IAE/B,MAAM,mBAAmB,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC3C,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACjE,SAAS;QACX,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAQ,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// CUSTOMIZATION: EMITTER-FIX: Typed `item` parameter as `Record<string, any>` instead of `any`\n// to satisfy Azure SDK ESLint rules (`@typescript-eslint/explicit-module-boundary-types`).\n// The return type annotation and `propertiesToExclude` local variable are now generated upstream.\nexport function serializeRecord(\n item: Record<string, any>,\n excludes?: string[],\n serializer?: (item: any) => any,\n): Record<string, any> {\n const propertiesToExclude = excludes ?? [];\n const res: any = {};\n for (const key of Object.keys(item)) {\n if (propertiesToExclude.includes(key) || item[key] === undefined) {\n continue;\n }\n if (serializer) {\n res[key] = serializer(item[key]);\n } else {\n res[key] = item[key] as any;\n }\n }\n return res;\n}\n"]}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
// ---------------------
|
|
4
|
+
// helpers
|
|
5
|
+
// ---------------------
|
|
6
|
+
function encodeComponent(val, reserved, op) {
|
|
7
|
+
return (reserved ?? op === "+") || op === "#"
|
|
8
|
+
? encodeReservedComponent(val)
|
|
9
|
+
: encodeRFC3986URIComponent(val);
|
|
10
|
+
}
|
|
11
|
+
function encodeReservedComponent(str) {
|
|
12
|
+
return str
|
|
13
|
+
.split(/(%[0-9A-Fa-f]{2})/g)
|
|
14
|
+
.map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part))
|
|
15
|
+
.join("");
|
|
16
|
+
}
|
|
17
|
+
function encodeRFC3986URIComponent(str) {
|
|
18
|
+
return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
19
|
+
}
|
|
20
|
+
function isDefined(val) {
|
|
21
|
+
return val !== undefined && val !== null;
|
|
22
|
+
}
|
|
23
|
+
function getNamedAndIfEmpty(op) {
|
|
24
|
+
return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""];
|
|
25
|
+
}
|
|
26
|
+
function getFirstOrSep(op, isFirst = false) {
|
|
27
|
+
if (isFirst) {
|
|
28
|
+
return !op || op === "+" ? "" : op;
|
|
29
|
+
}
|
|
30
|
+
else if (!op || op === "+" || op === "#") {
|
|
31
|
+
return ",";
|
|
32
|
+
}
|
|
33
|
+
else if (op === "?") {
|
|
34
|
+
return "&";
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return op;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getExpandedValue(option) {
|
|
41
|
+
let isFirst = option.isFirst;
|
|
42
|
+
const { op, varName, varValue: value, reserved } = option;
|
|
43
|
+
const vals = [];
|
|
44
|
+
const [named, ifEmpty] = getNamedAndIfEmpty(op);
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
for (const val of value.filter(isDefined)) {
|
|
47
|
+
// prepare the following parts: separator, varName, value
|
|
48
|
+
vals.push(`${getFirstOrSep(op, isFirst)}`);
|
|
49
|
+
if (named && varName) {
|
|
50
|
+
vals.push(`${encodeURIComponent(varName)}`);
|
|
51
|
+
if (val === "") {
|
|
52
|
+
vals.push(ifEmpty);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
vals.push("=");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
vals.push(encodeComponent(val, reserved, op));
|
|
59
|
+
isFirst = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (typeof value === "object") {
|
|
63
|
+
for (const key of Object.keys(value)) {
|
|
64
|
+
const val = value[key];
|
|
65
|
+
if (!isDefined(val)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// prepare the following parts: separator, key, value
|
|
69
|
+
vals.push(`${getFirstOrSep(op, isFirst)}`);
|
|
70
|
+
if (key) {
|
|
71
|
+
vals.push(`${encodeURIComponent(key)}`);
|
|
72
|
+
if (named && val === "") {
|
|
73
|
+
vals.push(ifEmpty);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
vals.push("=");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
vals.push(encodeComponent(val, reserved, op));
|
|
80
|
+
isFirst = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return vals.join("");
|
|
84
|
+
}
|
|
85
|
+
function getNonExpandedValue(option) {
|
|
86
|
+
const { op, varName, varValue: value, isFirst, reserved } = option;
|
|
87
|
+
const vals = [];
|
|
88
|
+
const first = getFirstOrSep(op, isFirst);
|
|
89
|
+
const [named, ifEmpty] = getNamedAndIfEmpty(op);
|
|
90
|
+
if (named && varName) {
|
|
91
|
+
vals.push(encodeComponent(varName, reserved, op));
|
|
92
|
+
if (value === "") {
|
|
93
|
+
if (!ifEmpty) {
|
|
94
|
+
vals.push(ifEmpty);
|
|
95
|
+
}
|
|
96
|
+
return !vals.join("") ? undefined : `${first}${vals.join("")}`;
|
|
97
|
+
}
|
|
98
|
+
vals.push("=");
|
|
99
|
+
}
|
|
100
|
+
const items = [];
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
for (const val of value.filter(isDefined)) {
|
|
103
|
+
items.push(encodeComponent(val, reserved, op));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (typeof value === "object") {
|
|
107
|
+
for (const key of Object.keys(value)) {
|
|
108
|
+
if (!isDefined(value[key])) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
items.push(encodeRFC3986URIComponent(key));
|
|
112
|
+
items.push(encodeComponent(value[key], reserved, op));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
vals.push(items.join(","));
|
|
116
|
+
return !vals.join(",") ? undefined : `${first}${vals.join("")}`;
|
|
117
|
+
}
|
|
118
|
+
function getVarValue(option) {
|
|
119
|
+
const { op, varName, modifier, isFirst, reserved, varValue: value } = option;
|
|
120
|
+
if (!isDefined(value)) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
else if (["string", "number", "boolean"].includes(typeof value)) {
|
|
124
|
+
let val = value.toString();
|
|
125
|
+
const [named, ifEmpty] = getNamedAndIfEmpty(op);
|
|
126
|
+
const vals = [getFirstOrSep(op, isFirst)];
|
|
127
|
+
if (named && varName) {
|
|
128
|
+
// No need to encode varName considering it is already encoded
|
|
129
|
+
vals.push(varName);
|
|
130
|
+
if (val === "") {
|
|
131
|
+
vals.push(ifEmpty);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
vals.push("=");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (modifier && modifier !== "*") {
|
|
138
|
+
val = val.substring(0, parseInt(modifier, 10));
|
|
139
|
+
}
|
|
140
|
+
vals.push(encodeComponent(val, reserved, op));
|
|
141
|
+
return vals.join("");
|
|
142
|
+
}
|
|
143
|
+
else if (modifier === "*") {
|
|
144
|
+
return getExpandedValue(option);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return getNonExpandedValue(option);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// ---------------------------------------------------------------------------------------------------
|
|
151
|
+
// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570.
|
|
152
|
+
// ---------------------------------------------------------------------------------------------------
|
|
153
|
+
export function expandUrlTemplate(template, context, option) {
|
|
154
|
+
const result = template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expr, text) => {
|
|
155
|
+
if (!expr) {
|
|
156
|
+
return encodeReservedComponent(text);
|
|
157
|
+
}
|
|
158
|
+
let op;
|
|
159
|
+
if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) {
|
|
160
|
+
op = expr[0];
|
|
161
|
+
expr = expr.slice(1);
|
|
162
|
+
}
|
|
163
|
+
const varList = expr.split(/,/g);
|
|
164
|
+
const innerResult = [];
|
|
165
|
+
for (const varSpec of varList) {
|
|
166
|
+
const varMatch = /([^:*]*)(?::(\d+)|(\*))?/.exec(varSpec);
|
|
167
|
+
if (!varMatch || !varMatch[1]) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const varValue = getVarValue({
|
|
171
|
+
isFirst: innerResult.length === 0,
|
|
172
|
+
op,
|
|
173
|
+
varValue: context[varMatch[1]],
|
|
174
|
+
varName: varMatch[1],
|
|
175
|
+
modifier: varMatch[2] || varMatch[3],
|
|
176
|
+
reserved: option?.allowReserved,
|
|
177
|
+
});
|
|
178
|
+
if (varValue) {
|
|
179
|
+
innerResult.push(varValue);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return innerResult.join("");
|
|
183
|
+
});
|
|
184
|
+
return normalizeUnreserved(result);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Normalize an expanded URI by decoding percent-encoded unreserved characters.
|
|
188
|
+
* RFC 3986 unreserved: "-" / "." / "~"
|
|
189
|
+
*/
|
|
190
|
+
function normalizeUnreserved(uri) {
|
|
191
|
+
return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => {
|
|
192
|
+
const char = String.fromCharCode(parseInt(hex, 16));
|
|
193
|
+
// Decode only if it's unreserved
|
|
194
|
+
if (/[.~-]/.test(char)) {
|
|
195
|
+
return char;
|
|
196
|
+
}
|
|
197
|
+
return match; // leave other encodings intact
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=urlTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlTemplate.js","sourceRoot":"","sources":["../../../src/static-helpers/urlTemplate.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmBlC,wBAAwB;AACxB,UAAU;AACV,wBAAwB;AACxB,SAAS,eAAe,CAAC,GAAW,EAAE,QAAkB,EAAE,EAAW;IACnE,OAAO,CAAC,QAAQ,IAAI,EAAE,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG;QAC3C,CAAC,CAAC,uBAAuB,CAAC,GAAG,CAAC;QAC9B,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAW;IAC1C,OAAO,GAAG;SACP,KAAK,CAAC,oBAAoB,CAAC;SAC3B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACpE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,SAAS,yBAAyB,CAAC,GAAW;IAC5C,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,OAAO,CACpC,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO,GAAG,KAAK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C,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QACpD,iCAAiC;QACjC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,+BAA+B;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// ---------------------\n// interfaces\n// ---------------------\ninterface ValueOptions {\n isFirst: boolean; // is first value in the expression\n op?: string; // operator\n varValue?: any; // variable value\n varName?: string; // variable name\n modifier?: string; // modifier e.g *\n reserved?: boolean; // if true we'll keep reserved words with not encoding\n}\n\nexport interface UrlTemplateOptions {\n // if set to true, reserved characters will not be encoded\n allowReserved?: boolean;\n}\n\n// ---------------------\n// helpers\n// ---------------------\nfunction encodeComponent(val: string, reserved?: boolean, op?: string): string {\n return (reserved ?? op === \"+\") || op === \"#\"\n ? encodeReservedComponent(val)\n : encodeRFC3986URIComponent(val);\n}\n\nfunction encodeReservedComponent(str: string): string {\n return str\n .split(/(%[0-9A-Fa-f]{2})/g)\n .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part))\n .join(\"\");\n}\n\nfunction encodeRFC3986URIComponent(str: string): string {\n return encodeURIComponent(str).replace(\n /[!'()*]/g,\n (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n}\n\nfunction isDefined(val: any): boolean {\n return val !== undefined && val !== null;\n}\n\nfunction getNamedAndIfEmpty(op?: string): [boolean, string] {\n return [!!op && [\";\", \"?\", \"&\"].includes(op), !!op && [\"?\", \"&\"].includes(op) ? \"=\" : \"\"];\n}\n\nfunction getFirstOrSep(op?: string, isFirst = false): string {\n if (isFirst) {\n return !op || op === \"+\" ? \"\" : op;\n } else if (!op || op === \"+\" || op === \"#\") {\n return \",\";\n } else if (op === \"?\") {\n return \"&\";\n } else {\n return op;\n }\n}\n\nfunction getExpandedValue(option: ValueOptions): string {\n let isFirst = option.isFirst;\n const { op, varName, varValue: value, reserved } = option;\n const vals: string[] = [];\n const [named, ifEmpty] = getNamedAndIfEmpty(op);\n\n if (Array.isArray(value)) {\n for (const val of value.filter(isDefined)) {\n // prepare the following parts: separator, varName, value\n vals.push(`${getFirstOrSep(op, isFirst)}`);\n if (named && varName) {\n vals.push(`${encodeURIComponent(varName)}`);\n if (val === \"\") {\n vals.push(ifEmpty);\n } else {\n vals.push(\"=\");\n }\n }\n vals.push(encodeComponent(val, reserved, op));\n isFirst = false;\n }\n } else if (typeof value === \"object\") {\n for (const key of Object.keys(value)) {\n const val = value[key];\n if (!isDefined(val)) {\n continue;\n }\n // prepare the following parts: separator, key, value\n vals.push(`${getFirstOrSep(op, isFirst)}`);\n if (key) {\n vals.push(`${encodeURIComponent(key)}`);\n if (named && val === \"\") {\n vals.push(ifEmpty);\n } else {\n vals.push(\"=\");\n }\n }\n vals.push(encodeComponent(val, reserved, op));\n isFirst = false;\n }\n }\n return vals.join(\"\");\n}\n\nfunction getNonExpandedValue(option: ValueOptions): string | undefined {\n const { op, varName, varValue: value, isFirst, reserved } = option;\n const vals: string[] = [];\n const first = getFirstOrSep(op, isFirst);\n const [named, ifEmpty] = getNamedAndIfEmpty(op);\n if (named && varName) {\n vals.push(encodeComponent(varName, reserved, op));\n if (value === \"\") {\n if (!ifEmpty) {\n vals.push(ifEmpty);\n }\n return !vals.join(\"\") ? undefined : `${first}${vals.join(\"\")}`;\n }\n vals.push(\"=\");\n }\n\n const items = [];\n if (Array.isArray(value)) {\n for (const val of value.filter(isDefined)) {\n items.push(encodeComponent(val, reserved, op));\n }\n } else if (typeof value === \"object\") {\n for (const key of Object.keys(value)) {\n if (!isDefined(value[key])) {\n continue;\n }\n items.push(encodeRFC3986URIComponent(key));\n items.push(encodeComponent(value[key], reserved, op));\n }\n }\n vals.push(items.join(\",\"));\n return !vals.join(\",\") ? undefined : `${first}${vals.join(\"\")}`;\n}\n\nfunction getVarValue(option: ValueOptions): string | undefined {\n const { op, varName, modifier, isFirst, reserved, varValue: value } = option;\n\n if (!isDefined(value)) {\n return undefined;\n } else if ([\"string\", \"number\", \"boolean\"].includes(typeof value)) {\n let val = value.toString();\n const [named, ifEmpty] = getNamedAndIfEmpty(op);\n const vals: string[] = [getFirstOrSep(op, isFirst)];\n if (named && varName) {\n // No need to encode varName considering it is already encoded\n vals.push(varName);\n if (val === \"\") {\n vals.push(ifEmpty);\n } else {\n vals.push(\"=\");\n }\n }\n if (modifier && modifier !== \"*\") {\n val = val.substring(0, parseInt(modifier, 10));\n }\n vals.push(encodeComponent(val, reserved, op));\n return vals.join(\"\");\n } else if (modifier === \"*\") {\n return getExpandedValue(option);\n } else {\n return getNonExpandedValue(option);\n }\n}\n\n// ---------------------------------------------------------------------------------------------------\n// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570.\n// ---------------------------------------------------------------------------------------------------\nexport function expandUrlTemplate(\n template: string,\n context: Record<string, any>,\n option?: UrlTemplateOptions,\n): string {\n const result = template.replace(/\\{([^{}]+)\\}|([^{}]+)/g, (_, expr, text) => {\n if (!expr) {\n return encodeReservedComponent(text);\n }\n let op;\n if ([\"+\", \"#\", \".\", \"/\", \";\", \"?\", \"&\"].includes(expr[0])) {\n op = expr[0];\n expr = expr.slice(1);\n }\n const varList = expr.split(/,/g);\n const innerResult = [];\n for (const varSpec of varList) {\n const varMatch = /([^:*]*)(?::(\\d+)|(\\*))?/.exec(varSpec);\n if (!varMatch || !varMatch[1]) {\n continue;\n }\n const varValue = getVarValue({\n isFirst: innerResult.length === 0,\n op,\n varValue: context[varMatch[1]],\n varName: varMatch[1],\n modifier: varMatch[2] || varMatch[3],\n reserved: option?.allowReserved,\n });\n if (varValue) {\n innerResult.push(varValue);\n }\n }\n return innerResult.join(\"\");\n });\n\n return normalizeUnreserved(result);\n}\n\n/**\n * Normalize an expanded URI by decoding percent-encoded unreserved characters.\n * RFC 3986 unreserved: \"-\" / \".\" / \"~\"\n */\nfunction normalizeUnreserved(uri: string): string {\n return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => {\n const char = String.fromCharCode(parseInt(hex, 16));\n // Decode only if it's unreserved\n if (/[.~-]/.test(char)) {\n return char;\n }\n return match; // leave other encodings intact\n });\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Client, ClientOptions } from "@azure-rest/core-client";
|
|
2
|
+
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
|
|
3
|
+
export interface ContentUnderstandingContext extends Client {
|
|
4
|
+
/** The API version to use for this operation. */
|
|
5
|
+
/** Known values of {@link KnownVersions} that the service accepts. */
|
|
6
|
+
apiVersion?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Optional parameters for the client. */
|
|
9
|
+
export interface ContentUnderstandingClientOptionalParams extends ClientOptions {
|
|
10
|
+
/** The API version to use for this operation. */
|
|
11
|
+
/** Known values of {@link KnownVersions} that the service accepts. */
|
|
12
|
+
apiVersion?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createContentUnderstanding(endpoint: string, credential: KeyCredential | TokenCredential, options?: ContentUnderstandingClientOptionalParams): ContentUnderstandingContext;
|
|
15
|
+
//# sourceMappingURL=contentUnderstandingContext.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.createContentUnderstanding = createContentUnderstanding;
|
|
6
|
+
const logger_js_1 = require("../logger.js");
|
|
7
|
+
const core_client_1 = require("@azure-rest/core-client");
|
|
8
|
+
// CUSTOMIZATION: EMITTER-FIX: Renamed 'endpointParam' to 'endpoint' for clarity and consistency.
|
|
9
|
+
// The emitter generates 'endpointParam' but 'endpoint' is the standard name.
|
|
10
|
+
function createContentUnderstanding(endpoint, credential, options = {}) {
|
|
11
|
+
const endpointUrl = options.endpoint ?? `${endpoint}/contentunderstanding`;
|
|
12
|
+
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
|
|
13
|
+
const userAgentInfo = `azsdk-js-ai-content-understanding/1.0.0`;
|
|
14
|
+
const userAgentPrefix = prefixFromOptions
|
|
15
|
+
? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`
|
|
16
|
+
: `azsdk-js-api ${userAgentInfo}`;
|
|
17
|
+
const { apiVersion: _, ...updatedOptions } = {
|
|
18
|
+
...options,
|
|
19
|
+
userAgentOptions: { userAgentPrefix },
|
|
20
|
+
loggingOptions: { logger: options.loggingOptions?.logger ?? logger_js_1.logger.info },
|
|
21
|
+
credentials: {
|
|
22
|
+
scopes: options.credentials?.scopes ?? ["https://cognitiveservices.azure.com/.default"],
|
|
23
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const clientContext = (0, core_client_1.getClient)(endpointUrl, credential, updatedOptions);
|
|
27
|
+
const apiVersion = options.apiVersion;
|
|
28
|
+
return { ...clientContext, apiVersion };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=contentUnderstandingContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentUnderstandingContext.js","sourceRoot":"","sources":["../../../src/api/contentUnderstandingContext.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAuBlC,gEAuBC;AA5CD,4CAAsC;AAGtC,yDAAoD;AAgBpD,iGAAiG;AACjG,6EAA6E;AAC7E,SAAgB,0BAA0B,CACxC,QAAgB,EAChB,UAA2C,EAC3C,UAAoD,EAAE;IAEtD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,GAAG,QAAQ,uBAAuB,CAAC;IAC3E,MAAM,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,EAAE,eAAe,CAAC;IACrE,MAAM,aAAa,GAAG,yCAAyC,CAAC;IAChE,MAAM,eAAe,GAAG,iBAAiB;QACvC,CAAC,CAAC,GAAG,iBAAiB,iBAAiB,aAAa,EAAE;QACtD,CAAC,CAAC,gBAAgB,aAAa,EAAE,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG;QAC3C,GAAG,OAAO;QACV,gBAAgB,EAAE,EAAE,eAAe,EAAE;QACrC,cAAc,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,kBAAM,CAAC,IAAI,EAAE;QACzE,WAAW,EAAE;YACX,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,8CAA8C,CAAC;YACvF,gBAAgB,EAAE,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,2BAA2B;SACvF;KACF,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,uBAAS,EAAC,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC,OAAO,EAAE,GAAG,aAAa,EAAE,UAAU,EAAiC,CAAC;AACzE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { logger } from \"../logger.js\";\nimport { KnownVersions } from \"../models/models.js\";\nimport type { Client, ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\n\nexport interface ContentUnderstandingContext extends Client {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\n/** Optional parameters for the client. */\nexport interface ContentUnderstandingClientOptionalParams extends ClientOptions {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\n// CUSTOMIZATION: EMITTER-FIX: Renamed 'endpointParam' to 'endpoint' for clarity and consistency.\n// The emitter generates 'endpointParam' but 'endpoint' is the standard name.\nexport function createContentUnderstanding(\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options: ContentUnderstandingClientOptionalParams = {},\n): ContentUnderstandingContext {\n const endpointUrl = options.endpoint ?? `${endpoint}/contentunderstanding`;\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentInfo = `azsdk-js-ai-content-understanding/1.0.0`;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`\n : `azsdk-js-api ${userAgentInfo}`;\n const { apiVersion: _, ...updatedOptions } = {\n ...options,\n userAgentOptions: { userAgentPrefix },\n loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cognitiveservices.azure.com/.default\"],\n apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? \"Ocp-Apim-Subscription-Key\",\n },\n };\n const clientContext = getClient(endpointUrl, credential, updatedOptions);\n const apiVersion = options.apiVersion;\n return { ...clientContext, apiVersion } as ContentUnderstandingContext;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createContentUnderstanding, ContentUnderstandingContext, ContentUnderstandingClientOptionalParams, } from "./contentUnderstandingContext.js";
|
|
2
|
+
export { updateDefaults, updateAnalyzer, listAnalyzers, grantCopyAuthorization, getResultFile, getResult, getOperationStatus, getDefaults, getAnalyzer, deleteResult, deleteAnalyzer, createAnalyzer, copyAnalyzer, analyzeBinary, analyze, } from "./operations.js";
|
|
3
|
+
export { UpdateDefaultsOptionalParams, UpdateAnalyzerOptionalParams, ListAnalyzersOptionalParams, GrantCopyAuthorizationOptionalParams, GetResultFileOptionalParams, GetResultOptionalParams, GetOperationStatusOptionalParams, GetDefaultsOptionalParams, GetAnalyzerOptionalParams, DeleteResultOptionalParams, DeleteAnalyzerOptionalParams, CreateAnalyzerOptionalParams, CopyAnalyzerOptionalParams, AnalyzeBinaryOptionalParams, AnalyzeOptionalParams, } from "./options.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.analyze = exports.analyzeBinary = exports.copyAnalyzer = exports.createAnalyzer = exports.deleteAnalyzer = exports.deleteResult = exports.getAnalyzer = exports.getDefaults = exports.getOperationStatus = exports.getResult = exports.getResultFile = exports.grantCopyAuthorization = exports.listAnalyzers = exports.updateAnalyzer = exports.updateDefaults = exports.createContentUnderstanding = void 0;
|
|
6
|
+
var contentUnderstandingContext_js_1 = require("./contentUnderstandingContext.js");
|
|
7
|
+
Object.defineProperty(exports, "createContentUnderstanding", { enumerable: true, get: function () { return contentUnderstandingContext_js_1.createContentUnderstanding; } });
|
|
8
|
+
var operations_js_1 = require("./operations.js");
|
|
9
|
+
Object.defineProperty(exports, "updateDefaults", { enumerable: true, get: function () { return operations_js_1.updateDefaults; } });
|
|
10
|
+
Object.defineProperty(exports, "updateAnalyzer", { enumerable: true, get: function () { return operations_js_1.updateAnalyzer; } });
|
|
11
|
+
Object.defineProperty(exports, "listAnalyzers", { enumerable: true, get: function () { return operations_js_1.listAnalyzers; } });
|
|
12
|
+
Object.defineProperty(exports, "grantCopyAuthorization", { enumerable: true, get: function () { return operations_js_1.grantCopyAuthorization; } });
|
|
13
|
+
Object.defineProperty(exports, "getResultFile", { enumerable: true, get: function () { return operations_js_1.getResultFile; } });
|
|
14
|
+
Object.defineProperty(exports, "getResult", { enumerable: true, get: function () { return operations_js_1.getResult; } });
|
|
15
|
+
Object.defineProperty(exports, "getOperationStatus", { enumerable: true, get: function () { return operations_js_1.getOperationStatus; } });
|
|
16
|
+
Object.defineProperty(exports, "getDefaults", { enumerable: true, get: function () { return operations_js_1.getDefaults; } });
|
|
17
|
+
Object.defineProperty(exports, "getAnalyzer", { enumerable: true, get: function () { return operations_js_1.getAnalyzer; } });
|
|
18
|
+
Object.defineProperty(exports, "deleteResult", { enumerable: true, get: function () { return operations_js_1.deleteResult; } });
|
|
19
|
+
Object.defineProperty(exports, "deleteAnalyzer", { enumerable: true, get: function () { return operations_js_1.deleteAnalyzer; } });
|
|
20
|
+
Object.defineProperty(exports, "createAnalyzer", { enumerable: true, get: function () { return operations_js_1.createAnalyzer; } });
|
|
21
|
+
Object.defineProperty(exports, "copyAnalyzer", { enumerable: true, get: function () { return operations_js_1.copyAnalyzer; } });
|
|
22
|
+
Object.defineProperty(exports, "analyzeBinary", { enumerable: true, get: function () { return operations_js_1.analyzeBinary; } });
|
|
23
|
+
Object.defineProperty(exports, "analyze", { enumerable: true, get: function () { return operations_js_1.analyze; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,mFAI0C;AAHxC,4IAAA,0BAA0B,OAAA;AAI5B,iDAgByB;AAfvB,+GAAA,cAAc,OAAA;AACd,+GAAA,cAAc,OAAA;AACd,8GAAA,aAAa,OAAA;AACb,uHAAA,sBAAsB,OAAA;AACtB,8GAAA,aAAa,OAAA;AACb,0GAAA,SAAS,OAAA;AACT,mHAAA,kBAAkB,OAAA;AAClB,4GAAA,WAAW,OAAA;AACX,4GAAA,WAAW,OAAA;AACX,6GAAA,YAAY,OAAA;AACZ,+GAAA,cAAc,OAAA;AACd,+GAAA,cAAc,OAAA;AACd,6GAAA,YAAY,OAAA;AACZ,8GAAA,aAAa,OAAA;AACb,wGAAA,OAAO,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n createContentUnderstanding,\n ContentUnderstandingContext,\n ContentUnderstandingClientOptionalParams,\n} from \"./contentUnderstandingContext.js\";\nexport {\n updateDefaults,\n updateAnalyzer,\n listAnalyzers,\n grantCopyAuthorization,\n getResultFile,\n getResult,\n getOperationStatus,\n getDefaults,\n getAnalyzer,\n deleteResult,\n deleteAnalyzer,\n createAnalyzer,\n copyAnalyzer,\n analyzeBinary,\n analyze,\n} from \"./operations.js\";\nexport {\n UpdateDefaultsOptionalParams,\n UpdateAnalyzerOptionalParams,\n ListAnalyzersOptionalParams,\n GrantCopyAuthorizationOptionalParams,\n GetResultFileOptionalParams,\n GetResultOptionalParams,\n GetOperationStatusOptionalParams,\n GetDefaultsOptionalParams,\n GetAnalyzerOptionalParams,\n DeleteResultOptionalParams,\n DeleteAnalyzerOptionalParams,\n CreateAnalyzerOptionalParams,\n CopyAnalyzerOptionalParams,\n AnalyzeBinaryOptionalParams,\n AnalyzeOptionalParams,\n} from \"./options.js\";\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ContentUnderstandingContext as Client } from "./index.js";
|
|
2
|
+
import type { AnalysisInput, AnalysisResult, ContentAnalyzerAnalyzeOperationStatus, ContentAnalyzer, ContentAnalyzerOperationStatus, ContentUnderstandingDefaults, CopyAuthorization, _PagedContentAnalyzer } from "../models/models.js";
|
|
3
|
+
import type { PagedAsyncIterableIterator } from "../static-helpers/pagingHelpers.js";
|
|
4
|
+
import type { UpdateDefaultsOptionalParams, UpdateAnalyzerOptionalParams, ListAnalyzersOptionalParams, GrantCopyAuthorizationOptionalParams, GetResultFileOptionalParams, GetResultOptionalParams, GetOperationStatusOptionalParams, GetDefaultsOptionalParams, GetAnalyzerOptionalParams, DeleteResultOptionalParams, DeleteAnalyzerOptionalParams, CreateAnalyzerOptionalParams, CopyAnalyzerOptionalParams, AnalyzeBinaryOptionalParams, AnalyzeOptionalParams } from "./options.js";
|
|
5
|
+
import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client";
|
|
6
|
+
import type { PollerLike, OperationState } from "@azure/core-lro";
|
|
7
|
+
export declare function _updateDefaultsSend(context: Client, options?: UpdateDefaultsOptionalParams): StreamableMethod;
|
|
8
|
+
export declare function _updateDefaultsDeserialize(result: PathUncheckedResponse): Promise<ContentUnderstandingDefaults>;
|
|
9
|
+
/** Update default settings for this Content Understanding resource. */
|
|
10
|
+
export declare function updateDefaults(context: Client, options?: UpdateDefaultsOptionalParams): Promise<ContentUnderstandingDefaults>;
|
|
11
|
+
export declare function _updateAnalyzerSend(context: Client, analyzerId: string, resource: ContentAnalyzer, options?: UpdateAnalyzerOptionalParams): StreamableMethod;
|
|
12
|
+
export declare function _updateAnalyzerDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzer>;
|
|
13
|
+
/** Update analyzer properties. */
|
|
14
|
+
export declare function updateAnalyzer(context: Client, analyzerId: string, resource: ContentAnalyzer, options?: UpdateAnalyzerOptionalParams): Promise<ContentAnalyzer>;
|
|
15
|
+
export declare function _listAnalyzersSend(context: Client, options?: ListAnalyzersOptionalParams): StreamableMethod;
|
|
16
|
+
export declare function _listAnalyzersDeserialize(result: PathUncheckedResponse): Promise<_PagedContentAnalyzer>;
|
|
17
|
+
/** List analyzers. */
|
|
18
|
+
export declare function listAnalyzers(context: Client, options?: ListAnalyzersOptionalParams): PagedAsyncIterableIterator<ContentAnalyzer>;
|
|
19
|
+
export declare function _grantCopyAuthorizationSend(context: Client, analyzerId: string, targetAzureResourceId: string, options?: GrantCopyAuthorizationOptionalParams): StreamableMethod;
|
|
20
|
+
export declare function _grantCopyAuthorizationDeserialize(result: PathUncheckedResponse): Promise<CopyAuthorization>;
|
|
21
|
+
/** Get authorization for copying this analyzer to another location. */
|
|
22
|
+
export declare function grantCopyAuthorization(context: Client, analyzerId: string, targetAzureResourceId: string, options?: GrantCopyAuthorizationOptionalParams): Promise<CopyAuthorization>;
|
|
23
|
+
export declare function _getResultFileSend(context: Client, operationId: string, path: string, options?: GetResultFileOptionalParams): StreamableMethod;
|
|
24
|
+
export declare function _getResultFileDeserialize(result: PathUncheckedResponse): Promise<Uint8Array>;
|
|
25
|
+
/** Get a file associated with the result of an analysis operation. */
|
|
26
|
+
export declare function getResultFile(context: Client, operationId: string, path: string, options?: GetResultFileOptionalParams): Promise<Uint8Array>;
|
|
27
|
+
export declare function _getResultSend(context: Client, operationId: string, options?: GetResultOptionalParams): StreamableMethod;
|
|
28
|
+
export declare function _getResultDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzerAnalyzeOperationStatus>;
|
|
29
|
+
/** Get the result of an analysis operation. */
|
|
30
|
+
export declare function getResult(context: Client, operationId: string, options?: GetResultOptionalParams): Promise<ContentAnalyzerAnalyzeOperationStatus>;
|
|
31
|
+
export declare function _getOperationStatusSend(context: Client, analyzerId: string, operationId: string, options?: GetOperationStatusOptionalParams): StreamableMethod;
|
|
32
|
+
export declare function _getOperationStatusDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzerOperationStatus>;
|
|
33
|
+
/** Get the status of an analyzer creation operation. */
|
|
34
|
+
export declare function getOperationStatus(context: Client, analyzerId: string, operationId: string, options?: GetOperationStatusOptionalParams): Promise<ContentAnalyzerOperationStatus>;
|
|
35
|
+
export declare function _getDefaultsSend(context: Client, options?: GetDefaultsOptionalParams): StreamableMethod;
|
|
36
|
+
export declare function _getDefaultsDeserialize(result: PathUncheckedResponse): Promise<ContentUnderstandingDefaults>;
|
|
37
|
+
/** Return default settings for this Content Understanding resource. */
|
|
38
|
+
export declare function getDefaults(context: Client, options?: GetDefaultsOptionalParams): Promise<ContentUnderstandingDefaults>;
|
|
39
|
+
export declare function _getAnalyzerSend(context: Client, analyzerId: string, options?: GetAnalyzerOptionalParams): StreamableMethod;
|
|
40
|
+
export declare function _getAnalyzerDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzer>;
|
|
41
|
+
/** Get analyzer properties. */
|
|
42
|
+
export declare function getAnalyzer(context: Client, analyzerId: string, options?: GetAnalyzerOptionalParams): Promise<ContentAnalyzer>;
|
|
43
|
+
export declare function _deleteResultSend(context: Client, operationId: string, options?: DeleteResultOptionalParams): StreamableMethod;
|
|
44
|
+
export declare function _deleteResultDeserialize(result: PathUncheckedResponse): Promise<void>;
|
|
45
|
+
/** Mark the result of an analysis operation for deletion. */
|
|
46
|
+
export declare function deleteResult(context: Client, operationId: string, options?: DeleteResultOptionalParams): Promise<void>;
|
|
47
|
+
export declare function _deleteAnalyzerSend(context: Client, analyzerId: string, options?: DeleteAnalyzerOptionalParams): StreamableMethod;
|
|
48
|
+
export declare function _deleteAnalyzerDeserialize(result: PathUncheckedResponse): Promise<void>;
|
|
49
|
+
/** Delete analyzer. */
|
|
50
|
+
export declare function deleteAnalyzer(context: Client, analyzerId: string, options?: DeleteAnalyzerOptionalParams): Promise<void>;
|
|
51
|
+
export declare function _createAnalyzerSend(context: Client, analyzerId: string, resource: ContentAnalyzer, options?: CreateAnalyzerOptionalParams): StreamableMethod;
|
|
52
|
+
export declare function _createAnalyzerDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzer>;
|
|
53
|
+
/** Create a new analyzer asynchronously. */
|
|
54
|
+
export declare function createAnalyzer(context: Client, analyzerId: string, resource: ContentAnalyzer, options?: CreateAnalyzerOptionalParams): PollerLike<OperationState<ContentAnalyzer>, ContentAnalyzer>;
|
|
55
|
+
export declare function _copyAnalyzerSend(context: Client, analyzerId: string, sourceAnalyzerId: string, options?: CopyAnalyzerOptionalParams): StreamableMethod;
|
|
56
|
+
export declare function _copyAnalyzerDeserialize(result: PathUncheckedResponse): Promise<ContentAnalyzer>;
|
|
57
|
+
/** Create a copy of the source analyzer to the current location. */
|
|
58
|
+
export declare function copyAnalyzer(context: Client, analyzerId: string, sourceAnalyzerId: string, options?: CopyAnalyzerOptionalParams): PollerLike<OperationState<ContentAnalyzer>, ContentAnalyzer>;
|
|
59
|
+
export declare function _analyzeBinarySend(context: Client, analyzerId: string, input: Uint8Array, contentType: string, options?: AnalyzeBinaryOptionalParams): StreamableMethod;
|
|
60
|
+
export declare function _analyzeBinaryDeserialize(result: PathUncheckedResponse): Promise<AnalysisResult>;
|
|
61
|
+
/** Extract content and fields from input. */
|
|
62
|
+
export declare function analyzeBinary(context: Client, analyzerId: string, input: Uint8Array, contentType: string, options?: AnalyzeBinaryOptionalParams): PollerLike<OperationState<AnalysisResult>, AnalysisResult>;
|
|
63
|
+
export declare function _analyzeSend(context: Client, analyzerId: string, inputs: AnalysisInput[], options?: AnalyzeOptionalParams): StreamableMethod;
|
|
64
|
+
export declare function _analyzeDeserialize(result: PathUncheckedResponse): Promise<AnalysisResult>;
|
|
65
|
+
/** Extract content and fields from input. */
|
|
66
|
+
export declare function analyze(context: Client, analyzerId: string, inputs: AnalysisInput[], options?: AnalyzeOptionalParams): PollerLike<OperationState<AnalysisResult>, AnalysisResult>;
|
|
67
|
+
//# sourceMappingURL=operations.d.ts.map
|