@azure-rest/ai-document-intelligence
Advanced tools
Comparing version 1.0.0-alpha.20240111.1 to 1.0.0-alpha.20240115.1
@@ -12,5 +12,4 @@ // Copyright (c) Microsoft Corporation. | ||
export default function createClient(endpoint, credentials, options = {}) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/documentintelligence`; | ||
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-10-31-preview"; | ||
const baseUrl = options.baseUrl ?? `${endpoint}/documentintelligence`; | ||
options.apiVersion = options.apiVersion ?? "2023-10-31-preview"; | ||
const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`; | ||
@@ -20,10 +19,15 @@ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix | ||
: `${userAgentInfo}`; | ||
options = Object.assign(Object.assign({}, options), { userAgentOptions: { | ||
options = { | ||
...options, | ||
userAgentOptions: { | ||
userAgentPrefix, | ||
}, loggingOptions: { | ||
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info, | ||
}, credentials: { | ||
scopes: (_f = (_e = options.credentials) === null || _e === void 0 ? void 0 : _e.scopes) !== null && _f !== void 0 ? _f : ["https://cognitiveservices.azure.com/.default"], | ||
apiKeyHeaderName: (_h = (_g = options.credentials) === null || _g === void 0 ? void 0 : _g.apiKeyHeaderName) !== null && _h !== void 0 ? _h : "Ocp-Apim-Subscription-Key", | ||
} }); | ||
}, | ||
loggingOptions: { | ||
logger: options.loggingOptions?.logger ?? logger.info, | ||
}, | ||
credentials: { | ||
scopes: options.credentials?.scopes ?? ["https://cognitiveservices.azure.com/.default"], | ||
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key", | ||
}, | ||
}; | ||
const client = getClient(baseUrl, credentials, options); | ||
@@ -30,0 +34,0 @@ return client; |
@@ -31,3 +31,3 @@ // Copyright (c) Microsoft Corporation. | ||
const lroOriginal = response.headers["x-ms-original-url"]; | ||
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url); | ||
const url = new URL(lroOriginal ?? response.request.url); | ||
const method = response.request.method; | ||
@@ -41,3 +41,2 @@ let pathDetails = responseMap[`${method} ${url.pathname}`]; | ||
function getParametrizedPathSuccess(method, path) { | ||
var _a, _b, _c, _d; | ||
const pathParts = path.split("/"); | ||
@@ -61,4 +60,4 @@ // Traverse list to match the longest candidate | ||
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { | ||
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) { | ||
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length; | ||
if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { | ||
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length; | ||
// If the current part of the candidate is a "template" part | ||
@@ -68,3 +67,3 @@ // Try to use the suffix of pattern to match the path | ||
// {guid}:export ==> :export$ | ||
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || ""); | ||
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || ""); | ||
if (!isMatched) { | ||
@@ -71,0 +70,0 @@ found = false; |
@@ -59,3 +59,3 @@ // Copyright (c) Microsoft Corporation. | ||
} | ||
return value !== null && value !== void 0 ? value : []; | ||
return value ?? []; | ||
} | ||
@@ -62,0 +62,0 @@ /** |
@@ -5,3 +5,2 @@ // Copyright (c) Microsoft Corporation. | ||
export async function getLongRunningPoller(client, initialResponse, options = {}) { | ||
var _a; | ||
const poller = { | ||
@@ -21,3 +20,3 @@ requestMethod: initialResponse.request.method, | ||
// depending on the lro pattern that the service implements. If non is provided we default to the initial path. | ||
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get(); | ||
const response = await client.pathUnchecked(path ?? initialResponse.request.url).get(); | ||
const lroResponse = getLroResponse(response); | ||
@@ -28,3 +27,3 @@ lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url; | ||
}; | ||
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true; | ||
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; | ||
return createHttpPoller(poller, options); | ||
@@ -43,5 +42,9 @@ } | ||
flatResponse: response, | ||
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }), | ||
rawResponse: { | ||
...response, | ||
statusCode: Number.parseInt(response.status), | ||
body: response.body, | ||
}, | ||
}; | ||
} | ||
//# sourceMappingURL=pollingHelper.js.map |
@@ -23,5 +23,4 @@ 'use strict'; | ||
function createClient(endpoint, credentials, options = {}) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}/documentintelligence`; | ||
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-10-31-preview"; | ||
const baseUrl = options.baseUrl ?? `${endpoint}/documentintelligence`; | ||
options.apiVersion = options.apiVersion ?? "2023-10-31-preview"; | ||
const userAgentInfo = `azsdk-js-ai-document-intelligence-rest/1.0.0-beta.2`; | ||
@@ -31,10 +30,15 @@ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix | ||
: `${userAgentInfo}`; | ||
options = Object.assign(Object.assign({}, options), { userAgentOptions: { | ||
options = { | ||
...options, | ||
userAgentOptions: { | ||
userAgentPrefix, | ||
}, loggingOptions: { | ||
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info, | ||
}, credentials: { | ||
scopes: (_f = (_e = options.credentials) === null || _e === void 0 ? void 0 : _e.scopes) !== null && _f !== void 0 ? _f : ["https://cognitiveservices.azure.com/.default"], | ||
apiKeyHeaderName: (_h = (_g = options.credentials) === null || _g === void 0 ? void 0 : _g.apiKeyHeaderName) !== null && _h !== void 0 ? _h : "Ocp-Apim-Subscription-Key", | ||
} }); | ||
}, | ||
loggingOptions: { | ||
logger: options.loggingOptions?.logger ?? logger.info, | ||
}, | ||
credentials: { | ||
scopes: options.credentials?.scopes ?? ["https://cognitiveservices.azure.com/.default"], | ||
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key", | ||
}, | ||
}; | ||
const client = coreClient.getClient(baseUrl, credentials, options); | ||
@@ -74,3 +78,3 @@ return client; | ||
const lroOriginal = response.headers["x-ms-original-url"]; | ||
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url); | ||
const url = new URL(lroOriginal ?? response.request.url); | ||
const method = response.request.method; | ||
@@ -84,3 +88,2 @@ let pathDetails = responseMap[`${method} ${url.pathname}`]; | ||
function getParametrizedPathSuccess(method, path) { | ||
var _a, _b, _c, _d; | ||
const pathParts = path.split("/"); | ||
@@ -104,4 +107,4 @@ // Traverse list to match the longest candidate | ||
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { | ||
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) { | ||
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length; | ||
if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { | ||
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length; | ||
// If the current part of the candidate is a "template" part | ||
@@ -111,3 +114,3 @@ // Try to use the suffix of pattern to match the path | ||
// {guid}:export ==> :export$ | ||
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || ""); | ||
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || ""); | ||
if (!isMatched) { | ||
@@ -197,3 +200,3 @@ found = false; | ||
} | ||
return value !== null && value !== void 0 ? value : []; | ||
return value ?? []; | ||
} | ||
@@ -213,3 +216,2 @@ /** | ||
async function getLongRunningPoller(client, initialResponse, options = {}) { | ||
var _a; | ||
const poller = { | ||
@@ -229,3 +231,3 @@ requestMethod: initialResponse.request.method, | ||
// depending on the lro pattern that the service implements. If non is provided we default to the initial path. | ||
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get(); | ||
const response = await client.pathUnchecked(path ?? initialResponse.request.url).get(); | ||
const lroResponse = getLroResponse(response); | ||
@@ -236,3 +238,3 @@ lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url; | ||
}; | ||
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true; | ||
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; | ||
return coreLro.createHttpPoller(poller, options); | ||
@@ -251,3 +253,7 @@ } | ||
flatResponse: response, | ||
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }), | ||
rawResponse: { | ||
...response, | ||
statusCode: Number.parseInt(response.status), | ||
body: response.body, | ||
}, | ||
}; | ||
@@ -254,0 +260,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "Microsoft Corporation", | ||
"version": "1.0.0-alpha.20240111.1", | ||
"version": "1.0.0-alpha.20240115.1", | ||
"description": "Azure Document Intelligence Rest Client", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2089
281436