Socket
Book a DemoInstallSign in
Socket

@azure/core-lro

Package Overview
Dependencies
Maintainers
2
Versions
486
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-lro - npm Package Compare versions

Comparing version

to
3.3.1-alpha.20250722.2

29

dist/browser/http/operation.js

@@ -7,3 +7,3 @@ // Copyright (c) Microsoft Corporation.

const { azureAsyncOperation, operationLocation } = inputs;
return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation;
return operationLocation ?? azureAsyncOperation;
}

@@ -20,3 +20,2 @@ function getLocationHeader(rawResponse) {

function findResourceLocation(inputs) {
var _a;
const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;

@@ -35,3 +34,3 @@ // If skipFinalGet is true, return undefined to skip the final GET request

case "PATCH": {
return (_a = getDefault()) !== null && _a !== void 0 ? _a : requestPath;
return getDefault() ?? requestPath;
}

@@ -65,3 +64,3 @@ default: {

const location = getLocationHeader(rawResponse);
const normalizedRequestMethod = requestMethod === null || requestMethod === void 0 ? void 0 : requestMethod.toLocaleUpperCase();
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
if (pollingUrl !== undefined) {

@@ -108,3 +107,3 @@ return {

logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);
const lowerCaseStatus = status === null || status === void 0 ? void 0 : status.toLocaleLowerCase();
const lowerCaseStatus = status?.toLocaleLowerCase();
if (!lowerCaseStatus) {

@@ -125,10 +124,8 @@ return toOperationStatus(statusCode);

function getStatus(rawResponse) {
var _a;
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const { status } = rawResponse.body ?? {};
return transformStatus({ status, statusCode: rawResponse.statusCode });
}
function getProvisioningState(rawResponse) {
var _a, _b;
const { properties, provisioningState } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const status = (_b = properties === null || properties === void 0 ? void 0 : properties.provisioningState) !== null && _b !== void 0 ? _b : provisioningState;
const { properties, provisioningState } = rawResponse.body ?? {};
const status = properties?.provisioningState ?? provisioningState;
return transformStatus({ status, statusCode: rawResponse.statusCode });

@@ -181,4 +178,3 @@ }

function helper() {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -197,4 +193,3 @@ case undefined:

export function getOperationLocation({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -217,4 +212,3 @@ case "OperationLocation": {

export function getOperationStatus({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -235,4 +229,3 @@ case "OperationLocation": {

function accessBodyProperty({ flatResponse, rawResponse }, prop) {
var _a, _b;
return (_a = flatResponse === null || flatResponse === void 0 ? void 0 : flatResponse[prop]) !== null && _a !== void 0 ? _a : (_b = rawResponse.body) === null || _b === void 0 ? void 0 : _b[prop];
return flatResponse?.[prop] ?? rawResponse.body?.[prop];
}

@@ -239,0 +232,0 @@ export function getResourceLocation(res, state) {

@@ -27,3 +27,10 @@ // Copyright (c) Microsoft Corporation.

const config = inferLroMode(response.rawResponse, resourceLocationConfig, skipFinalGet);
return Object.assign({ response, operationLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.operationLocation, baseUrl }), resourceLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.resourceLocation, baseUrl }), initialRequestUrl: config === null || config === void 0 ? void 0 : config.initialRequestUrl, requestMethod: config === null || config === void 0 ? void 0 : config.requestMethod }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
return {
response,
operationLocation: rewriteUrl({ url: config?.operationLocation, baseUrl }),
resourceLocation: rewriteUrl({ url: config?.resourceLocation, baseUrl }),
initialRequestUrl: config?.initialRequestUrl,
requestMethod: config?.requestMethod,
...(config?.mode ? { metadata: { mode: config.mode } } : {}),
};
},

@@ -30,0 +37,0 @@ poll: lro.sendPollRequest,

@@ -25,3 +25,3 @@ // Copyright (c) Microsoft Corporation.

}
catch (_a) {
catch {
// If inputUrl is relative, resolve using the provided baseUrl.

@@ -28,0 +28,0 @@ try {

@@ -55,3 +55,3 @@ // Copyright (c) Microsoft Corporation.

case "failed": {
const err = getError === null || getError === void 0 ? void 0 : getError(response);
const err = getError?.(response);
let postfix = "";

@@ -73,3 +73,3 @@ if (err) {

}
if ((isDone === null || isDone === void 0 ? void 0 : isDone(response, state)) ||
if (isDone?.(response, state) ||
(isDone === undefined &&

@@ -95,3 +95,3 @@ ["succeeded", "canceled"].concat(setErrorAsResult ? [] : ["failed"]).includes(status))) {

if (operationLocation)
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
const config = {

@@ -159,17 +159,17 @@ metadata,

if (!terminalStates.includes(status)) {
const intervalInMs = getPollingInterval === null || getPollingInterval === void 0 ? void 0 : getPollingInterval(response);
const intervalInMs = getPollingInterval?.(response);
if (intervalInMs)
setDelay(intervalInMs);
const location = getOperationLocation === null || getOperationLocation === void 0 ? void 0 : getOperationLocation(response, state);
const location = getOperationLocation?.(response, state);
if (location !== undefined) {
const isUpdated = operationLocation !== location;
state.config.operationLocation = location;
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(location, isUpdated);
withOperationLocation?.(location, isUpdated);
}
else
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
}
updateState === null || updateState === void 0 ? void 0 : updateState(state, response);
updateState?.(state, response);
}
}
//# sourceMappingURL=operation.js.map

@@ -51,7 +51,6 @@ // Copyright (c) Microsoft Corporation.

get result() {
return state === null || state === void 0 ? void 0 : state.result;
return state?.result;
},
get isDone() {
var _a;
return ["succeeded", "failed", "canceled"].includes((_a = state === null || state === void 0 ? void 0 : state.status) !== null && _a !== void 0 ? _a : "");
return ["succeeded", "failed", "canceled"].includes(state?.status ?? "");
},

@@ -73,3 +72,3 @@ onProgress: (callback) => {

pollUntilDone: async (pollOptions) => {
resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
resultPromise ??= (async () => {
await statePromise;

@@ -85,7 +84,7 @@ if (!state) {

const abortSignal = abortController.signal;
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
if (inputAbortSignal?.aborted) {
abortController.abort();
}
else if (!abortSignal.aborted) {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true });
inputAbortSignal?.addEventListener("abort", abortListener, { once: true });
}

@@ -102,3 +101,3 @@ try {

finally {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
inputAbortSignal?.removeEventListener("abort", abortListener);
}

@@ -123,3 +122,3 @@ if (resolveOnUnsuccessful) {

resultPromise = undefined;
}));
});
return resultPromise;

@@ -126,0 +125,0 @@ },

@@ -18,3 +18,3 @@ "use strict";

const { azureAsyncOperation, operationLocation } = inputs;
return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation;
return operationLocation ?? azureAsyncOperation;
}

@@ -31,3 +31,2 @@ function getLocationHeader(rawResponse) {

function findResourceLocation(inputs) {
var _a;
const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;

@@ -46,3 +45,3 @@ // If skipFinalGet is true, return undefined to skip the final GET request

case "PATCH": {
return (_a = getDefault()) !== null && _a !== void 0 ? _a : requestPath;
return getDefault() ?? requestPath;
}

@@ -76,3 +75,3 @@ default: {

const location = getLocationHeader(rawResponse);
const normalizedRequestMethod = requestMethod === null || requestMethod === void 0 ? void 0 : requestMethod.toLocaleUpperCase();
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
if (pollingUrl !== undefined) {

@@ -119,3 +118,3 @@ return {

logger_js_1.logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);
const lowerCaseStatus = status === null || status === void 0 ? void 0 : status.toLocaleLowerCase();
const lowerCaseStatus = status?.toLocaleLowerCase();
if (!lowerCaseStatus) {

@@ -136,10 +135,8 @@ return toOperationStatus(statusCode);

function getStatus(rawResponse) {
var _a;
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const { status } = rawResponse.body ?? {};
return transformStatus({ status, statusCode: rawResponse.statusCode });
}
function getProvisioningState(rawResponse) {
var _a, _b;
const { properties, provisioningState } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const status = (_b = properties === null || properties === void 0 ? void 0 : properties.provisioningState) !== null && _b !== void 0 ? _b : provisioningState;
const { properties, provisioningState } = rawResponse.body ?? {};
const status = properties?.provisioningState ?? provisioningState;
return transformStatus({ status, statusCode: rawResponse.statusCode });

@@ -192,4 +189,3 @@ }

function helper() {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -208,4 +204,3 @@ case undefined:

function getOperationLocation({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -228,4 +223,3 @@ case "OperationLocation": {

function getOperationStatus({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -246,4 +240,3 @@ case "OperationLocation": {

function accessBodyProperty({ flatResponse, rawResponse }, prop) {
var _a, _b;
return (_a = flatResponse === null || flatResponse === void 0 ? void 0 : flatResponse[prop]) !== null && _a !== void 0 ? _a : (_b = rawResponse.body) === null || _b === void 0 ? void 0 : _b[prop];
return flatResponse?.[prop] ?? rawResponse.body?.[prop];
}

@@ -250,0 +243,0 @@ function getResourceLocation(res, state) {

@@ -30,3 +30,10 @@ "use strict";

const config = (0, operation_js_1.inferLroMode)(response.rawResponse, resourceLocationConfig, skipFinalGet);
return Object.assign({ response, operationLocation: (0, utils_js_1.rewriteUrl)({ url: config === null || config === void 0 ? void 0 : config.operationLocation, baseUrl }), resourceLocation: (0, utils_js_1.rewriteUrl)({ url: config === null || config === void 0 ? void 0 : config.resourceLocation, baseUrl }), initialRequestUrl: config === null || config === void 0 ? void 0 : config.initialRequestUrl, requestMethod: config === null || config === void 0 ? void 0 : config.requestMethod }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
return {
response,
operationLocation: (0, utils_js_1.rewriteUrl)({ url: config?.operationLocation, baseUrl }),
resourceLocation: (0, utils_js_1.rewriteUrl)({ url: config?.resourceLocation, baseUrl }),
initialRequestUrl: config?.initialRequestUrl,
requestMethod: config?.requestMethod,
...(config?.mode ? { metadata: { mode: config.mode } } : {}),
};
},

@@ -33,0 +40,0 @@ poll: lro.sendPollRequest,

@@ -28,3 +28,3 @@ "use strict";

}
catch (_a) {
catch {
// If inputUrl is relative, resolve using the provided baseUrl.

@@ -31,0 +31,0 @@ try {

@@ -60,3 +60,3 @@ "use strict";

case "failed": {
const err = getError === null || getError === void 0 ? void 0 : getError(response);
const err = getError?.(response);
let postfix = "";

@@ -78,3 +78,3 @@ if (err) {

}
if ((isDone === null || isDone === void 0 ? void 0 : isDone(response, state)) ||
if (isDone?.(response, state) ||
(isDone === undefined &&

@@ -100,3 +100,3 @@ ["succeeded", "canceled"].concat(setErrorAsResult ? [] : ["failed"]).includes(status))) {

if (operationLocation)
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
const config = {

@@ -164,17 +164,17 @@ metadata,

if (!constants_js_1.terminalStates.includes(status)) {
const intervalInMs = getPollingInterval === null || getPollingInterval === void 0 ? void 0 : getPollingInterval(response);
const intervalInMs = getPollingInterval?.(response);
if (intervalInMs)
setDelay(intervalInMs);
const location = getOperationLocation === null || getOperationLocation === void 0 ? void 0 : getOperationLocation(response, state);
const location = getOperationLocation?.(response, state);
if (location !== undefined) {
const isUpdated = operationLocation !== location;
state.config.operationLocation = location;
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(location, isUpdated);
withOperationLocation?.(location, isUpdated);
}
else
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
}
updateState === null || updateState === void 0 ? void 0 : updateState(state, response);
updateState?.(state, response);
}
}
//# sourceMappingURL=operation.js.map

@@ -54,7 +54,6 @@ "use strict";

get result() {
return state === null || state === void 0 ? void 0 : state.result;
return state?.result;
},
get isDone() {
var _a;
return ["succeeded", "failed", "canceled"].includes((_a = state === null || state === void 0 ? void 0 : state.status) !== null && _a !== void 0 ? _a : "");
return ["succeeded", "failed", "canceled"].includes(state?.status ?? "");
},

@@ -76,3 +75,3 @@ onProgress: (callback) => {

pollUntilDone: async (pollOptions) => {
resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
resultPromise ??= (async () => {
await statePromise;

@@ -88,7 +87,7 @@ if (!state) {

const abortSignal = abortController.signal;
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
if (inputAbortSignal?.aborted) {
abortController.abort();
}
else if (!abortSignal.aborted) {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true });
inputAbortSignal?.addEventListener("abort", abortListener, { once: true });
}

@@ -105,3 +104,3 @@ try {

finally {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
inputAbortSignal?.removeEventListener("abort", abortListener);
}

@@ -126,3 +125,3 @@ if (resolveOnUnsuccessful) {

resultPromise = undefined;
}));
});
return resultPromise;

@@ -129,0 +128,0 @@ },

@@ -0,0 +0,0 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.

@@ -7,3 +7,3 @@ // Copyright (c) Microsoft Corporation.

const { azureAsyncOperation, operationLocation } = inputs;
return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation;
return operationLocation ?? azureAsyncOperation;
}

@@ -20,3 +20,2 @@ function getLocationHeader(rawResponse) {

function findResourceLocation(inputs) {
var _a;
const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;

@@ -35,3 +34,3 @@ // If skipFinalGet is true, return undefined to skip the final GET request

case "PATCH": {
return (_a = getDefault()) !== null && _a !== void 0 ? _a : requestPath;
return getDefault() ?? requestPath;
}

@@ -65,3 +64,3 @@ default: {

const location = getLocationHeader(rawResponse);
const normalizedRequestMethod = requestMethod === null || requestMethod === void 0 ? void 0 : requestMethod.toLocaleUpperCase();
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
if (pollingUrl !== undefined) {

@@ -108,3 +107,3 @@ return {

logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);
const lowerCaseStatus = status === null || status === void 0 ? void 0 : status.toLocaleLowerCase();
const lowerCaseStatus = status?.toLocaleLowerCase();
if (!lowerCaseStatus) {

@@ -125,10 +124,8 @@ return toOperationStatus(statusCode);

function getStatus(rawResponse) {
var _a;
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const { status } = rawResponse.body ?? {};
return transformStatus({ status, statusCode: rawResponse.statusCode });
}
function getProvisioningState(rawResponse) {
var _a, _b;
const { properties, provisioningState } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const status = (_b = properties === null || properties === void 0 ? void 0 : properties.provisioningState) !== null && _b !== void 0 ? _b : provisioningState;
const { properties, provisioningState } = rawResponse.body ?? {};
const status = properties?.provisioningState ?? provisioningState;
return transformStatus({ status, statusCode: rawResponse.statusCode });

@@ -181,4 +178,3 @@ }

function helper() {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -197,4 +193,3 @@ case undefined:

export function getOperationLocation({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -217,4 +212,3 @@ case "OperationLocation": {

export function getOperationStatus({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -235,4 +229,3 @@ case "OperationLocation": {

function accessBodyProperty({ flatResponse, rawResponse }, prop) {
var _a, _b;
return (_a = flatResponse === null || flatResponse === void 0 ? void 0 : flatResponse[prop]) !== null && _a !== void 0 ? _a : (_b = rawResponse.body) === null || _b === void 0 ? void 0 : _b[prop];
return flatResponse?.[prop] ?? rawResponse.body?.[prop];
}

@@ -239,0 +232,0 @@ export function getResourceLocation(res, state) {

@@ -27,3 +27,10 @@ // Copyright (c) Microsoft Corporation.

const config = inferLroMode(response.rawResponse, resourceLocationConfig, skipFinalGet);
return Object.assign({ response, operationLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.operationLocation, baseUrl }), resourceLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.resourceLocation, baseUrl }), initialRequestUrl: config === null || config === void 0 ? void 0 : config.initialRequestUrl, requestMethod: config === null || config === void 0 ? void 0 : config.requestMethod }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
return {
response,
operationLocation: rewriteUrl({ url: config?.operationLocation, baseUrl }),
resourceLocation: rewriteUrl({ url: config?.resourceLocation, baseUrl }),
initialRequestUrl: config?.initialRequestUrl,
requestMethod: config?.requestMethod,
...(config?.mode ? { metadata: { mode: config.mode } } : {}),
};
},

@@ -30,0 +37,0 @@ poll: lro.sendPollRequest,

@@ -25,3 +25,3 @@ // Copyright (c) Microsoft Corporation.

}
catch (_a) {
catch {
// If inputUrl is relative, resolve using the provided baseUrl.

@@ -28,0 +28,0 @@ try {

@@ -55,3 +55,3 @@ // Copyright (c) Microsoft Corporation.

case "failed": {
const err = getError === null || getError === void 0 ? void 0 : getError(response);
const err = getError?.(response);
let postfix = "";

@@ -73,3 +73,3 @@ if (err) {

}
if ((isDone === null || isDone === void 0 ? void 0 : isDone(response, state)) ||
if (isDone?.(response, state) ||
(isDone === undefined &&

@@ -95,3 +95,3 @@ ["succeeded", "canceled"].concat(setErrorAsResult ? [] : ["failed"]).includes(status))) {

if (operationLocation)
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
const config = {

@@ -159,17 +159,17 @@ metadata,

if (!terminalStates.includes(status)) {
const intervalInMs = getPollingInterval === null || getPollingInterval === void 0 ? void 0 : getPollingInterval(response);
const intervalInMs = getPollingInterval?.(response);
if (intervalInMs)
setDelay(intervalInMs);
const location = getOperationLocation === null || getOperationLocation === void 0 ? void 0 : getOperationLocation(response, state);
const location = getOperationLocation?.(response, state);
if (location !== undefined) {
const isUpdated = operationLocation !== location;
state.config.operationLocation = location;
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(location, isUpdated);
withOperationLocation?.(location, isUpdated);
}
else
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
}
updateState === null || updateState === void 0 ? void 0 : updateState(state, response);
updateState?.(state, response);
}
}
//# sourceMappingURL=operation.js.map

@@ -51,7 +51,6 @@ // Copyright (c) Microsoft Corporation.

get result() {
return state === null || state === void 0 ? void 0 : state.result;
return state?.result;
},
get isDone() {
var _a;
return ["succeeded", "failed", "canceled"].includes((_a = state === null || state === void 0 ? void 0 : state.status) !== null && _a !== void 0 ? _a : "");
return ["succeeded", "failed", "canceled"].includes(state?.status ?? "");
},

@@ -73,3 +72,3 @@ onProgress: (callback) => {

pollUntilDone: async (pollOptions) => {
resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
resultPromise ??= (async () => {
await statePromise;

@@ -85,7 +84,7 @@ if (!state) {

const abortSignal = abortController.signal;
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
if (inputAbortSignal?.aborted) {
abortController.abort();
}
else if (!abortSignal.aborted) {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true });
inputAbortSignal?.addEventListener("abort", abortListener, { once: true });
}

@@ -102,3 +101,3 @@ try {

finally {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
inputAbortSignal?.removeEventListener("abort", abortListener);
}

@@ -123,3 +122,3 @@ if (resolveOnUnsuccessful) {

resultPromise = undefined;
}));
});
return resultPromise;

@@ -126,0 +125,0 @@ },

@@ -7,3 +7,3 @@ // Copyright (c) Microsoft Corporation.

const { azureAsyncOperation, operationLocation } = inputs;
return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation;
return operationLocation ?? azureAsyncOperation;
}

@@ -20,3 +20,2 @@ function getLocationHeader(rawResponse) {

function findResourceLocation(inputs) {
var _a;
const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;

@@ -35,3 +34,3 @@ // If skipFinalGet is true, return undefined to skip the final GET request

case "PATCH": {
return (_a = getDefault()) !== null && _a !== void 0 ? _a : requestPath;
return getDefault() ?? requestPath;
}

@@ -65,3 +64,3 @@ default: {

const location = getLocationHeader(rawResponse);
const normalizedRequestMethod = requestMethod === null || requestMethod === void 0 ? void 0 : requestMethod.toLocaleUpperCase();
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
if (pollingUrl !== undefined) {

@@ -108,3 +107,3 @@ return {

logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);
const lowerCaseStatus = status === null || status === void 0 ? void 0 : status.toLocaleLowerCase();
const lowerCaseStatus = status?.toLocaleLowerCase();
if (!lowerCaseStatus) {

@@ -125,10 +124,8 @@ return toOperationStatus(statusCode);

function getStatus(rawResponse) {
var _a;
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const { status } = rawResponse.body ?? {};
return transformStatus({ status, statusCode: rawResponse.statusCode });
}
function getProvisioningState(rawResponse) {
var _a, _b;
const { properties, provisioningState } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
const status = (_b = properties === null || properties === void 0 ? void 0 : properties.provisioningState) !== null && _b !== void 0 ? _b : provisioningState;
const { properties, provisioningState } = rawResponse.body ?? {};
const status = properties?.provisioningState ?? provisioningState;
return transformStatus({ status, statusCode: rawResponse.statusCode });

@@ -181,4 +178,3 @@ }

function helper() {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -197,4 +193,3 @@ case undefined:

export function getOperationLocation({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -217,4 +212,3 @@ case "OperationLocation": {

export function getOperationStatus({ rawResponse }, state) {
var _a;
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
const mode = state.config.metadata?.["mode"];
switch (mode) {

@@ -235,4 +229,3 @@ case "OperationLocation": {

function accessBodyProperty({ flatResponse, rawResponse }, prop) {
var _a, _b;
return (_a = flatResponse === null || flatResponse === void 0 ? void 0 : flatResponse[prop]) !== null && _a !== void 0 ? _a : (_b = rawResponse.body) === null || _b === void 0 ? void 0 : _b[prop];
return flatResponse?.[prop] ?? rawResponse.body?.[prop];
}

@@ -239,0 +232,0 @@ export function getResourceLocation(res, state) {

@@ -27,3 +27,10 @@ // Copyright (c) Microsoft Corporation.

const config = inferLroMode(response.rawResponse, resourceLocationConfig, skipFinalGet);
return Object.assign({ response, operationLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.operationLocation, baseUrl }), resourceLocation: rewriteUrl({ url: config === null || config === void 0 ? void 0 : config.resourceLocation, baseUrl }), initialRequestUrl: config === null || config === void 0 ? void 0 : config.initialRequestUrl, requestMethod: config === null || config === void 0 ? void 0 : config.requestMethod }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
return {
response,
operationLocation: rewriteUrl({ url: config?.operationLocation, baseUrl }),
resourceLocation: rewriteUrl({ url: config?.resourceLocation, baseUrl }),
initialRequestUrl: config?.initialRequestUrl,
requestMethod: config?.requestMethod,
...(config?.mode ? { metadata: { mode: config.mode } } : {}),
};
},

@@ -30,0 +37,0 @@ poll: lro.sendPollRequest,

@@ -25,3 +25,3 @@ // Copyright (c) Microsoft Corporation.

}
catch (_a) {
catch {
// If inputUrl is relative, resolve using the provided baseUrl.

@@ -28,0 +28,0 @@ try {

@@ -55,3 +55,3 @@ // Copyright (c) Microsoft Corporation.

case "failed": {
const err = getError === null || getError === void 0 ? void 0 : getError(response);
const err = getError?.(response);
let postfix = "";

@@ -73,3 +73,3 @@ if (err) {

}
if ((isDone === null || isDone === void 0 ? void 0 : isDone(response, state)) ||
if (isDone?.(response, state) ||
(isDone === undefined &&

@@ -95,3 +95,3 @@ ["succeeded", "canceled"].concat(setErrorAsResult ? [] : ["failed"]).includes(status))) {

if (operationLocation)
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
const config = {

@@ -159,17 +159,17 @@ metadata,

if (!terminalStates.includes(status)) {
const intervalInMs = getPollingInterval === null || getPollingInterval === void 0 ? void 0 : getPollingInterval(response);
const intervalInMs = getPollingInterval?.(response);
if (intervalInMs)
setDelay(intervalInMs);
const location = getOperationLocation === null || getOperationLocation === void 0 ? void 0 : getOperationLocation(response, state);
const location = getOperationLocation?.(response, state);
if (location !== undefined) {
const isUpdated = operationLocation !== location;
state.config.operationLocation = location;
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(location, isUpdated);
withOperationLocation?.(location, isUpdated);
}
else
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
withOperationLocation?.(operationLocation, false);
}
updateState === null || updateState === void 0 ? void 0 : updateState(state, response);
updateState?.(state, response);
}
}
//# sourceMappingURL=operation.js.map

@@ -51,7 +51,6 @@ // Copyright (c) Microsoft Corporation.

get result() {
return state === null || state === void 0 ? void 0 : state.result;
return state?.result;
},
get isDone() {
var _a;
return ["succeeded", "failed", "canceled"].includes((_a = state === null || state === void 0 ? void 0 : state.status) !== null && _a !== void 0 ? _a : "");
return ["succeeded", "failed", "canceled"].includes(state?.status ?? "");
},

@@ -73,3 +72,3 @@ onProgress: (callback) => {

pollUntilDone: async (pollOptions) => {
resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
resultPromise ??= (async () => {
await statePromise;

@@ -85,7 +84,7 @@ if (!state) {

const abortSignal = abortController.signal;
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
if (inputAbortSignal?.aborted) {
abortController.abort();
}
else if (!abortSignal.aborted) {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, { once: true });
inputAbortSignal?.addEventListener("abort", abortListener, { once: true });
}

@@ -102,3 +101,3 @@ try {

finally {
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
inputAbortSignal?.removeEventListener("abort", abortListener);
}

@@ -123,3 +122,3 @@ if (resolveOnUnsuccessful) {

resultPromise = undefined;
}));
});
return resultPromise;

@@ -126,0 +125,0 @@ },

@@ -5,3 +5,3 @@ {

"sdk-type": "client",
"version": "3.3.0",
"version": "3.3.1-alpha.20250722.2",
"type": "module",

@@ -94,7 +94,7 @@ "description": "Isomorphic client library for supporting long-running operations in node.js and browser.",

"devDependencies": {
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/core-util": "^1.11.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
"@types/node": "^20.0.0",

@@ -132,5 +132,5 @@ "@vitest/browser": "^3.0.9",

"selfLink": false,
"project": "./tsconfig.src.json"
"project": "../../../tsconfig.src.build.json"
},
"module": "./dist/esm/index.js"
}

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

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

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

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.