@azure-rest/agrifood-farming 1.0.0-alpha.20240115.1 → 1.0.0-alpha.20240129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +17 -24
- package/dist/index.js.map +1 -1
- package/dist-esm/src/farmBeats.js +7 -12
- package/dist-esm/src/farmBeats.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/paginateHelper.js +1 -1
- package/dist-esm/src/paginateHelper.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/serializeHelper.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,24 +15,19 @@ var coreLro = require('@azure/core-lro');
|
|
|
15
15
|
* @param options type: ClientOptions, the parameter for all optional parameters
|
|
16
16
|
*/
|
|
17
17
|
function createClient($host, credentials, options = {}) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
options =
|
|
21
|
-
|
|
22
|
-
credentials: {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${$host}`;
|
|
20
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-11-01-preview";
|
|
21
|
+
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
23
22
|
scopes: ["https://farmbeats.azure.net/.default"],
|
|
24
|
-
}
|
|
25
|
-
};
|
|
23
|
+
} });
|
|
26
24
|
const userAgentInfo = `azsdk-js-agrifood-farming-rest/1.0.0-beta.2`;
|
|
27
25
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
28
26
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
29
27
|
: `${userAgentInfo}`;
|
|
30
|
-
options = {
|
|
31
|
-
...options,
|
|
32
|
-
userAgentOptions: {
|
|
28
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
33
29
|
userAgentPrefix,
|
|
34
|
-
}
|
|
35
|
-
};
|
|
30
|
+
} });
|
|
36
31
|
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
37
32
|
return client;
|
|
38
33
|
}
|
|
@@ -243,7 +238,7 @@ const responseMap = {
|
|
|
243
238
|
};
|
|
244
239
|
function isUnexpected(response) {
|
|
245
240
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
246
|
-
const url = new URL(lroOriginal
|
|
241
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
247
242
|
const method = response.request.method;
|
|
248
243
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
249
244
|
if (!pathDetails) {
|
|
@@ -252,6 +247,7 @@ function isUnexpected(response) {
|
|
|
252
247
|
return !pathDetails.includes(response.status);
|
|
253
248
|
}
|
|
254
249
|
function getParametrizedPathSuccess(method, path) {
|
|
250
|
+
var _a, _b, _c, _d;
|
|
255
251
|
const pathParts = path.split("/");
|
|
256
252
|
// Traverse list to match the longest candidate
|
|
257
253
|
// matchedLen: the length of candidate path
|
|
@@ -270,13 +266,13 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
270
266
|
// track if we have found a match to return the values found.
|
|
271
267
|
let found = true;
|
|
272
268
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
273
|
-
if (candidateParts[i]
|
|
274
|
-
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]
|
|
269
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
270
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
275
271
|
// If the current part of the candidate is a "template" part
|
|
276
272
|
// Try to use the suffix of pattern to match the path
|
|
277
273
|
// {guid} ==> $
|
|
278
274
|
// {guid}:export ==> :export$
|
|
279
|
-
const isMatched = new RegExp(`${candidateParts[i]
|
|
275
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
280
276
|
if (!isMatched) {
|
|
281
277
|
found = false;
|
|
282
278
|
break;
|
|
@@ -361,7 +357,7 @@ function getElements(body, itemName) {
|
|
|
361
357
|
if (!Array.isArray(value)) {
|
|
362
358
|
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
363
359
|
}
|
|
364
|
-
return value
|
|
360
|
+
return value !== null && value !== void 0 ? value : [];
|
|
365
361
|
}
|
|
366
362
|
/**
|
|
367
363
|
* Checks if a request failed
|
|
@@ -383,6 +379,7 @@ function checkPagingRequest(response) {
|
|
|
383
379
|
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
384
380
|
*/
|
|
385
381
|
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
382
|
+
var _a;
|
|
386
383
|
const poller = {
|
|
387
384
|
requestMethod: initialResponse.request.method,
|
|
388
385
|
requestPath: initialResponse.request.url,
|
|
@@ -397,13 +394,13 @@ async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
397
394
|
// to get the latest status. We use the client provided and the polling path
|
|
398
395
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
399
396
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
400
|
-
const response = await client.pathUnchecked(path
|
|
397
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
401
398
|
const lroResponse = getLroResponse(response);
|
|
402
399
|
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
403
400
|
return lroResponse;
|
|
404
401
|
},
|
|
405
402
|
};
|
|
406
|
-
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful
|
|
403
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
407
404
|
return coreLro.createHttpPoller(poller, options);
|
|
408
405
|
}
|
|
409
406
|
/**
|
|
@@ -417,11 +414,7 @@ function getLroResponse(response) {
|
|
|
417
414
|
}
|
|
418
415
|
return {
|
|
419
416
|
flatResponse: response,
|
|
420
|
-
rawResponse: {
|
|
421
|
-
...response,
|
|
422
|
-
statusCode: Number.parseInt(response.status),
|
|
423
|
-
body: response.body,
|
|
424
|
-
},
|
|
417
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
425
418
|
};
|
|
426
419
|
}
|
|
427
420
|
|