mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-20 13:38:28 +02:00
feat: update dependencies, node
This commit is contained in:
parent
0ec953ee6d
commit
29cb413d63
507 changed files with 84113 additions and 61309 deletions
4
node_modules/@azure/core-lro/dist-esm/src/http/models.js
generated
vendored
Normal file
4
node_modules/@azure/core-lro/dist-esm/src/http/models.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=models.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/http/models.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/http/models.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/http/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\n// TODO: rename to ResourceLocationConfig\n/**\n * The potential location of the result of the LRO if specified by the LRO extension in the swagger.\n */\nexport type LroResourceLocationConfig = \"azure-async-operation\" | \"location\" | \"original-uri\";\n\n/**\n * The type of a LRO response body. This is just a convenience type for checking the status of the operation.\n */\n\nexport interface ResponseBody extends Record<string, unknown> {\n /** The status of the operation. */\n status?: unknown;\n /** The state of the provisioning process */\n provisioningState?: unknown;\n /** The properties of the provisioning process */\n properties?: { provisioningState?: unknown } & Record<string, unknown>;\n}\n\n/**\n * Simple type of the raw response.\n */\nexport interface RawResponse {\n /** The HTTP status code */\n statusCode: number;\n /** A HttpHeaders collection in the response represented as a simple JSON object where all header names have been normalized to be lower-case. */\n headers: {\n [headerName: string]: string;\n };\n /** The parsed response body */\n body?: unknown;\n}\n\n// TODO: rename to OperationResponse\n/**\n * The type of the response of a LRO.\n */\nexport interface LroResponse<T = unknown> {\n /** The flattened response */\n flatResponse: T;\n /** The raw response */\n rawResponse: RawResponse;\n}\n\n/**\n * Description of a long running operation.\n */\nexport interface LongRunningOperation<T = unknown> {\n /**\n * The request path. This should be set if the operation is a PUT and needs\n * to poll from the same request path.\n */\n requestPath?: string;\n /**\n * The HTTP request method. This should be set if the operation is a PUT or a\n * DELETE.\n */\n requestMethod?: string;\n /**\n * A function that can be used to send initial request to the service.\n */\n sendInitialRequest: () => Promise<LroResponse<unknown>>;\n /**\n * A function that can be used to poll for the current status of a long running operation.\n */\n sendPollRequest: (\n path: string,\n options?: { abortSignal?: AbortSignalLike }\n ) => Promise<LroResponse<T>>;\n}\n\nexport type HttpOperationMode = \"OperationLocation\" | \"ResourceLocation\" | \"Body\";\n\n/**\n * Options for `createPoller`.\n */\nexport interface CreateHttpPollerOptions<TResult, TState> {\n /**\n * Defines how much time the poller is going to wait before making a new request to the service.\n */\n intervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n restoreFrom?: string;\n /**\n * The potential location of the result of the LRO if specified by the LRO extension in the swagger.\n */\n resourceLocationConfig?: LroResourceLocationConfig;\n /**\n * A function to process the result of the LRO.\n */\n processResult?: (result: unknown, state: TState) => TResult;\n /**\n * A function to process the state of the LRO.\n */\n updateState?: (state: TState, response: LroResponse) => void;\n /**\n * A function to be called each time the operation location is updated by the\n * service.\n */\n withOperationLocation?: (operationLocation: string) => void;\n /**\n * Control whether to throw an exception if the operation failed or was canceled.\n */\n resolveOnUnsuccessful?: boolean;\n}\n"]}
|
256
node_modules/@azure/core-lro/dist-esm/src/http/operation.js
generated
vendored
Normal file
256
node_modules/@azure/core-lro/dist-esm/src/http/operation.js
generated
vendored
Normal file
|
@ -0,0 +1,256 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { initOperation, pollOperation } from "../poller/operation";
|
||||
import { logger } from "../logger";
|
||||
function getOperationLocationPollingUrl(inputs) {
|
||||
const { azureAsyncOperation, operationLocation } = inputs;
|
||||
return operationLocation !== null && operationLocation !== void 0 ? operationLocation : azureAsyncOperation;
|
||||
}
|
||||
function getLocationHeader(rawResponse) {
|
||||
return rawResponse.headers["location"];
|
||||
}
|
||||
function getOperationLocationHeader(rawResponse) {
|
||||
return rawResponse.headers["operation-location"];
|
||||
}
|
||||
function getAzureAsyncOperationHeader(rawResponse) {
|
||||
return rawResponse.headers["azure-asyncoperation"];
|
||||
}
|
||||
function findResourceLocation(inputs) {
|
||||
const { location, requestMethod, requestPath, resourceLocationConfig } = inputs;
|
||||
switch (requestMethod) {
|
||||
case "PUT": {
|
||||
return requestPath;
|
||||
}
|
||||
case "DELETE": {
|
||||
return undefined;
|
||||
}
|
||||
default: {
|
||||
switch (resourceLocationConfig) {
|
||||
case "azure-async-operation": {
|
||||
return undefined;
|
||||
}
|
||||
case "original-uri": {
|
||||
return requestPath;
|
||||
}
|
||||
case "location":
|
||||
default: {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export function inferLroMode(inputs) {
|
||||
const { rawResponse, requestMethod, requestPath, resourceLocationConfig } = inputs;
|
||||
const operationLocation = getOperationLocationHeader(rawResponse);
|
||||
const azureAsyncOperation = getAzureAsyncOperationHeader(rawResponse);
|
||||
const pollingUrl = getOperationLocationPollingUrl({ operationLocation, azureAsyncOperation });
|
||||
const location = getLocationHeader(rawResponse);
|
||||
const normalizedRequestMethod = requestMethod === null || requestMethod === void 0 ? void 0 : requestMethod.toLocaleUpperCase();
|
||||
if (pollingUrl !== undefined) {
|
||||
return {
|
||||
mode: "OperationLocation",
|
||||
operationLocation: pollingUrl,
|
||||
resourceLocation: findResourceLocation({
|
||||
requestMethod: normalizedRequestMethod,
|
||||
location,
|
||||
requestPath,
|
||||
resourceLocationConfig,
|
||||
}),
|
||||
};
|
||||
}
|
||||
else if (location !== undefined) {
|
||||
return {
|
||||
mode: "ResourceLocation",
|
||||
operationLocation: location,
|
||||
};
|
||||
}
|
||||
else if (normalizedRequestMethod === "PUT" && requestPath) {
|
||||
return {
|
||||
mode: "Body",
|
||||
operationLocation: requestPath,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function transformStatus(inputs) {
|
||||
const { status, statusCode } = inputs;
|
||||
if (typeof status !== "string" && status !== undefined) {
|
||||
throw new Error(`Polling was unsuccessful. Expected status to have a string value or no value but it has instead: ${status}. This doesn't necessarily indicate the operation has failed. Check your Azure subscription or resource status for more information.`);
|
||||
}
|
||||
switch (status === null || status === void 0 ? void 0 : status.toLocaleLowerCase()) {
|
||||
case undefined:
|
||||
return toOperationStatus(statusCode);
|
||||
case "succeeded":
|
||||
return "succeeded";
|
||||
case "failed":
|
||||
return "failed";
|
||||
case "running":
|
||||
case "accepted":
|
||||
case "started":
|
||||
case "canceling":
|
||||
case "cancelling":
|
||||
return "running";
|
||||
case "canceled":
|
||||
case "cancelled":
|
||||
return "canceled";
|
||||
default: {
|
||||
logger.warning(`LRO: unrecognized operation status: ${status}`);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStatus(rawResponse) {
|
||||
var _a;
|
||||
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
|
||||
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;
|
||||
return transformStatus({ status, statusCode: rawResponse.statusCode });
|
||||
}
|
||||
function toOperationStatus(statusCode) {
|
||||
if (statusCode === 202) {
|
||||
return "running";
|
||||
}
|
||||
else if (statusCode < 300) {
|
||||
return "succeeded";
|
||||
}
|
||||
else {
|
||||
return "failed";
|
||||
}
|
||||
}
|
||||
export function parseRetryAfter({ rawResponse }) {
|
||||
const retryAfter = rawResponse.headers["retry-after"];
|
||||
if (retryAfter !== undefined) {
|
||||
// Retry-After header value is either in HTTP date format, or in seconds
|
||||
const retryAfterInSeconds = parseInt(retryAfter);
|
||||
return isNaN(retryAfterInSeconds)
|
||||
? calculatePollingIntervalFromDate(new Date(retryAfter))
|
||||
: retryAfterInSeconds * 1000;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function calculatePollingIntervalFromDate(retryAfterDate) {
|
||||
const timeNow = Math.floor(new Date().getTime());
|
||||
const retryAfterTime = retryAfterDate.getTime();
|
||||
if (timeNow < retryAfterTime) {
|
||||
return retryAfterTime - timeNow;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
export function getStatusFromInitialResponse(inputs) {
|
||||
const { response, state, operationLocation } = inputs;
|
||||
function helper() {
|
||||
var _a;
|
||||
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
|
||||
switch (mode) {
|
||||
case undefined:
|
||||
return toOperationStatus(response.rawResponse.statusCode);
|
||||
case "Body":
|
||||
return getOperationStatus(response, state);
|
||||
default:
|
||||
return "running";
|
||||
}
|
||||
}
|
||||
const status = helper();
|
||||
return status === "running" && operationLocation === undefined ? "succeeded" : status;
|
||||
}
|
||||
/**
|
||||
* Initiates the long-running operation.
|
||||
*/
|
||||
export async function initHttpOperation(inputs) {
|
||||
const { stateProxy, resourceLocationConfig, processResult, lro, setErrorAsResult } = inputs;
|
||||
return initOperation({
|
||||
init: async () => {
|
||||
const response = await lro.sendInitialRequest();
|
||||
const config = inferLroMode({
|
||||
rawResponse: response.rawResponse,
|
||||
requestPath: lro.requestPath,
|
||||
requestMethod: lro.requestMethod,
|
||||
resourceLocationConfig,
|
||||
});
|
||||
return Object.assign({ response, operationLocation: config === null || config === void 0 ? void 0 : config.operationLocation, resourceLocation: config === null || config === void 0 ? void 0 : config.resourceLocation }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
|
||||
},
|
||||
stateProxy,
|
||||
processResult: processResult
|
||||
? ({ flatResponse }, state) => processResult(flatResponse, state)
|
||||
: ({ flatResponse }) => flatResponse,
|
||||
getOperationStatus: getStatusFromInitialResponse,
|
||||
setErrorAsResult,
|
||||
});
|
||||
}
|
||||
export function getOperationLocation({ rawResponse }, state) {
|
||||
var _a;
|
||||
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
|
||||
switch (mode) {
|
||||
case "OperationLocation": {
|
||||
return getOperationLocationPollingUrl({
|
||||
operationLocation: getOperationLocationHeader(rawResponse),
|
||||
azureAsyncOperation: getAzureAsyncOperationHeader(rawResponse),
|
||||
});
|
||||
}
|
||||
case "ResourceLocation": {
|
||||
return getLocationHeader(rawResponse);
|
||||
}
|
||||
case "Body":
|
||||
default: {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
export function getOperationStatus({ rawResponse }, state) {
|
||||
var _a;
|
||||
const mode = (_a = state.config.metadata) === null || _a === void 0 ? void 0 : _a["mode"];
|
||||
switch (mode) {
|
||||
case "OperationLocation": {
|
||||
return getStatus(rawResponse);
|
||||
}
|
||||
case "ResourceLocation": {
|
||||
return toOperationStatus(rawResponse.statusCode);
|
||||
}
|
||||
case "Body": {
|
||||
return getProvisioningState(rawResponse);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Internal error: Unexpected operation mode: ${mode}`);
|
||||
}
|
||||
}
|
||||
export function getResourceLocation({ flatResponse }, state) {
|
||||
if (typeof flatResponse === "object") {
|
||||
const resourceLocation = flatResponse.resourceLocation;
|
||||
if (resourceLocation !== undefined) {
|
||||
state.config.resourceLocation = resourceLocation;
|
||||
}
|
||||
}
|
||||
return state.config.resourceLocation;
|
||||
}
|
||||
/** Polls the long-running operation. */
|
||||
export async function pollHttpOperation(inputs) {
|
||||
const { lro, stateProxy, options, processResult, updateState, setDelay, state, setErrorAsResult, } = inputs;
|
||||
return pollOperation({
|
||||
state,
|
||||
stateProxy,
|
||||
setDelay,
|
||||
processResult: processResult
|
||||
? ({ flatResponse }, inputState) => processResult(flatResponse, inputState)
|
||||
: ({ flatResponse }) => flatResponse,
|
||||
updateState,
|
||||
getPollingInterval: parseRetryAfter,
|
||||
getOperationLocation,
|
||||
getOperationStatus,
|
||||
getResourceLocation,
|
||||
options,
|
||||
/**
|
||||
* The expansion here is intentional because `lro` could be an object that
|
||||
* references an inner this, so we need to preserve a reference to it.
|
||||
*/
|
||||
poll: async (location, inputOptions) => lro.sendPollRequest(location, inputOptions),
|
||||
setErrorAsResult,
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=operation.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/http/operation.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/http/operation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
42
node_modules/@azure/core-lro/dist-esm/src/http/poller.js
generated
vendored
Normal file
42
node_modules/@azure/core-lro/dist-esm/src/http/poller.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { getOperationLocation, getOperationStatus, getResourceLocation, getStatusFromInitialResponse, inferLroMode, parseRetryAfter, } from "./operation";
|
||||
import { buildCreatePoller } from "../poller/poller";
|
||||
/**
|
||||
* Creates a poller that can be used to poll a long-running operation.
|
||||
* @param lro - Description of the long-running operation
|
||||
* @param options - options to configure the poller
|
||||
* @returns an initialized poller
|
||||
*/
|
||||
export async function createHttpPoller(lro, options) {
|
||||
const { resourceLocationConfig, intervalInMs, processResult, restoreFrom, updateState, withOperationLocation, resolveOnUnsuccessful = false, } = options || {};
|
||||
return buildCreatePoller({
|
||||
getStatusFromInitialResponse,
|
||||
getStatusFromPollResponse: getOperationStatus,
|
||||
getOperationLocation,
|
||||
getResourceLocation,
|
||||
getPollingInterval: parseRetryAfter,
|
||||
resolveOnUnsuccessful,
|
||||
})({
|
||||
init: async () => {
|
||||
const response = await lro.sendInitialRequest();
|
||||
const config = inferLroMode({
|
||||
rawResponse: response.rawResponse,
|
||||
requestPath: lro.requestPath,
|
||||
requestMethod: lro.requestMethod,
|
||||
resourceLocationConfig,
|
||||
});
|
||||
return Object.assign({ response, operationLocation: config === null || config === void 0 ? void 0 : config.operationLocation, resourceLocation: config === null || config === void 0 ? void 0 : config.resourceLocation }, ((config === null || config === void 0 ? void 0 : config.mode) ? { metadata: { mode: config.mode } } : {}));
|
||||
},
|
||||
poll: lro.sendPollRequest,
|
||||
}, {
|
||||
intervalInMs,
|
||||
withOperationLocation,
|
||||
restoreFrom,
|
||||
updateState,
|
||||
processResult: processResult
|
||||
? ({ flatResponse }, state) => processResult(flatResponse, state)
|
||||
: ({ flatResponse }) => flatResponse,
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=poller.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/http/poller.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/http/poller.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../src/http/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,4BAA4B,EAC5B,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAyB,EACzB,OAAkD;IAElD,MAAM,EACJ,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,qBAAqB,GAAG,KAAK,GAC9B,GAAG,OAAO,IAAI,EAAE,CAAC;IAClB,OAAO,iBAAiB,CAA+B;QACrD,4BAA4B;QAC5B,yBAAyB,EAAE,kBAAkB;QAC7C,oBAAoB;QACpB,mBAAmB;QACnB,kBAAkB,EAAE,eAAe;QACnC,qBAAqB;KACtB,CAAC,CACA;QACE,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,kBAAkB,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,YAAY,CAAC;gBAC1B,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,aAAa,EAAE,GAAG,CAAC,aAAa;gBAChC,sBAAsB;aACvB,CAAC,CAAC;YACH,uBACE,QAAQ,EACR,iBAAiB,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,iBAAiB,EAC5C,gBAAgB,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,IACvC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC5D;QACJ,CAAC;QACD,IAAI,EAAE,GAAG,CAAC,eAAe;KAC1B,EACD;QACE,YAAY;QACZ,qBAAqB;QACrB,WAAW;QACX,WAAW;QACX,aAAa,EAAE,aAAa;YAC1B,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,KAAK,CAAC;YACjE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAuB;KAClD,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LongRunningOperation, LroResponse } from \"./models\";\nimport { OperationState, SimplePollerLike } from \"../poller/models\";\nimport {\n getOperationLocation,\n getOperationStatus,\n getResourceLocation,\n getStatusFromInitialResponse,\n inferLroMode,\n parseRetryAfter,\n} from \"./operation\";\nimport { CreateHttpPollerOptions } from \"./models\";\nimport { buildCreatePoller } from \"../poller/poller\";\n\n/**\n * Creates a poller that can be used to poll a long-running operation.\n * @param lro - Description of the long-running operation\n * @param options - options to configure the poller\n * @returns an initialized poller\n */\nexport async function createHttpPoller<TResult, TState extends OperationState<TResult>>(\n lro: LongRunningOperation,\n options?: CreateHttpPollerOptions<TResult, TState>\n): Promise<SimplePollerLike<TState, TResult>> {\n const {\n resourceLocationConfig,\n intervalInMs,\n processResult,\n restoreFrom,\n updateState,\n withOperationLocation,\n resolveOnUnsuccessful = false,\n } = options || {};\n return buildCreatePoller<LroResponse, TResult, TState>({\n getStatusFromInitialResponse,\n getStatusFromPollResponse: getOperationStatus,\n getOperationLocation,\n getResourceLocation,\n getPollingInterval: parseRetryAfter,\n resolveOnUnsuccessful,\n })(\n {\n init: async () => {\n const response = await lro.sendInitialRequest();\n const config = inferLroMode({\n rawResponse: response.rawResponse,\n requestPath: lro.requestPath,\n requestMethod: lro.requestMethod,\n resourceLocationConfig,\n });\n return {\n response,\n operationLocation: config?.operationLocation,\n resourceLocation: config?.resourceLocation,\n ...(config?.mode ? { metadata: { mode: config.mode } } : {}),\n };\n },\n poll: lro.sendPollRequest,\n },\n {\n intervalInMs,\n withOperationLocation,\n restoreFrom,\n updateState,\n processResult: processResult\n ? ({ flatResponse }, state) => processResult(flatResponse, state)\n : ({ flatResponse }) => flatResponse as TResult,\n }\n );\n}\n"]}
|
19
node_modules/@azure/core-lro/dist-esm/src/index.js
generated
vendored
19
node_modules/@azure/core-lro/dist-esm/src/index.js
generated
vendored
|
@ -1,6 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export * from "./pollOperation";
|
||||
export * from "./poller";
|
||||
export * from "./lroEngine";
|
||||
export { createHttpPoller } from "./http/poller";
|
||||
/**
|
||||
* This can be uncommented to expose the protocol-agnostic poller
|
||||
*/
|
||||
// export {
|
||||
// BuildCreatePollerOptions,
|
||||
// Operation,
|
||||
// CreatePollerOptions,
|
||||
// OperationConfig,
|
||||
// RestorableOperationState,
|
||||
// } from "./poller/models";
|
||||
// export { buildCreatePoller } from "./poller/poller";
|
||||
/** legacy */
|
||||
export * from "./legacy/lroEngine";
|
||||
export * from "./legacy/poller";
|
||||
export * from "./legacy/pollOperation";
|
||||
//# sourceMappingURL=index.js.map
|
2
node_modules/@azure/core-lro/dist-esm/src/index.js.map
generated
vendored
2
node_modules/@azure/core-lro/dist-esm/src/index.js.map
generated
vendored
|
@ -1 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./pollOperation\";\nexport * from \"./poller\";\nexport * from \"./lroEngine\";\n"]}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAejD;;GAEG;AACH,WAAW;AACX,8BAA8B;AAC9B,eAAe;AACf,yBAAyB;AACzB,qBAAqB;AACrB,8BAA8B;AAC9B,4BAA4B;AAC5B,uDAAuD;AAEvD,aAAa;AACb,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { createHttpPoller } from \"./http/poller\";\nexport {\n CancelOnProgress,\n OperationState,\n OperationStatus,\n SimplePollerLike,\n} from \"./poller/models\";\nexport { CreateHttpPollerOptions } from \"./http/models\";\nexport {\n LroResourceLocationConfig,\n LongRunningOperation,\n LroResponse,\n RawResponse,\n} from \"./http/models\";\n\n/**\n * This can be uncommented to expose the protocol-agnostic poller\n */\n// export {\n// BuildCreatePollerOptions,\n// Operation,\n// CreatePollerOptions,\n// OperationConfig,\n// RestorableOperationState,\n// } from \"./poller/models\";\n// export { buildCreatePoller } from \"./poller/poller\";\n\n/** legacy */\nexport * from \"./legacy/lroEngine\";\nexport * from \"./legacy/poller\";\nexport * from \"./legacy/pollOperation\";\nexport { PollerLike } from \"./legacy/models\";\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/index.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/legacy/lroEngine/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { LroEngine } from \"./lroEngine\";\nexport { LroEngineOptions } from \"./models\";\n"]}
|
|
@ -1,26 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { GenericPollOperation } from "./operation";
|
||||
import { POLL_INTERVAL_IN_MS } from "../../poller/constants";
|
||||
import { Poller } from "../poller";
|
||||
function deserializeState(serializedState) {
|
||||
try {
|
||||
return JSON.parse(serializedState).state;
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(`LroEngine: Unable to deserialize state: ${serializedState}`);
|
||||
}
|
||||
}
|
||||
import { deserializeState } from "../../poller/operation";
|
||||
/**
|
||||
* The LRO Engine, a class that performs polling.
|
||||
*/
|
||||
export class LroEngine extends Poller {
|
||||
constructor(lro, options) {
|
||||
const { intervalInMs = 2000, resumeFrom } = options || {};
|
||||
const { intervalInMs = POLL_INTERVAL_IN_MS, resumeFrom, resolveOnUnsuccessful = false, isDone, lroResourceLocationConfig, processResult, updateState, } = options || {};
|
||||
const state = resumeFrom
|
||||
? deserializeState(resumeFrom)
|
||||
: {};
|
||||
const operation = new GenericPollOperation(state, lro, options === null || options === void 0 ? void 0 : options.lroResourceLocationConfig, options === null || options === void 0 ? void 0 : options.processResult, options === null || options === void 0 ? void 0 : options.updateState, options === null || options === void 0 ? void 0 : options.isDone);
|
||||
const operation = new GenericPollOperation(state, lro, !resolveOnUnsuccessful, lroResourceLocationConfig, processResult, updateState, isDone);
|
||||
super(operation);
|
||||
this.resolveOnUnsuccessful = resolveOnUnsuccessful;
|
||||
this.config = { intervalInMs: intervalInMs };
|
||||
operation.setPollerConfig(this.config);
|
||||
}
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/lroEngine.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/lroEngine.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"lroEngine.js","sourceRoot":"","sources":["../../../../src/legacy/lroEngine/lroEngine.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,SAA+D,SAAQ,MAGnF;IAGC,YAAY,GAAkC,EAAE,OAA2C;QACzF,MAAM,EACJ,YAAY,GAAG,mBAAmB,EAClC,UAAU,EACV,qBAAqB,GAAG,KAAK,EAC7B,MAAM,EACN,yBAAyB,EACzB,aAAa,EACb,WAAW,GACZ,GAAG,OAAO,IAAI,EAAE,CAAC;QAClB,MAAM,KAAK,GAAqC,UAAU;YACxD,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC;YAC9B,CAAC,CAAE,EAAuC,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,oBAAoB,CACxC,KAAK,EACL,GAAG,EACH,CAAC,qBAAqB,EACtB,yBAAyB,EACzB,aAAa,EACb,WAAW,EACX,MAAM,CACP,CAAC;QACF,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QAEnD,IAAI,CAAC,MAAM,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;QAC7C,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LroEngineOptions, PollerConfig } from \"./models\";\nimport { GenericPollOperation } from \"./operation\";\nimport { LongRunningOperation } from \"../../http/models\";\nimport { POLL_INTERVAL_IN_MS } from \"../../poller/constants\";\nimport { PollOperationState } from \"../pollOperation\";\nimport { Poller } from \"../poller\";\nimport { RestorableOperationState } from \"../../poller/models\";\nimport { deserializeState } from \"../../poller/operation\";\n\n/**\n * The LRO Engine, a class that performs polling.\n */\nexport class LroEngine<TResult, TState extends PollOperationState<TResult>> extends Poller<\n TState,\n TResult\n> {\n private config: PollerConfig;\n\n constructor(lro: LongRunningOperation<TResult>, options?: LroEngineOptions<TResult, TState>) {\n const {\n intervalInMs = POLL_INTERVAL_IN_MS,\n resumeFrom,\n resolveOnUnsuccessful = false,\n isDone,\n lroResourceLocationConfig,\n processResult,\n updateState,\n } = options || {};\n const state: RestorableOperationState<TState> = resumeFrom\n ? deserializeState(resumeFrom)\n : ({} as RestorableOperationState<TState>);\n const operation = new GenericPollOperation(\n state,\n lro,\n !resolveOnUnsuccessful,\n lroResourceLocationConfig,\n processResult,\n updateState,\n isDone\n );\n super(operation);\n this.resolveOnUnsuccessful = resolveOnUnsuccessful;\n\n this.config = { intervalInMs: intervalInMs };\n operation.setPollerConfig(this.config);\n }\n\n /**\n * The method used by the poller to wait before attempting to update its operation.\n */\n delay(): Promise<void> {\n return new Promise((resolve) => setTimeout(() => resolve(), this.config.intervalInMs));\n }\n}\n"]}
|
4
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/models.js
generated
vendored
Normal file
4
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/models.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=models.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/models.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/models.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/legacy/lroEngine/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LroResourceLocationConfig, RawResponse } from \"../../http/models\";\n\n/**\n * Options for the LRO poller.\n */\nexport interface LroEngineOptions<TResult, TState> {\n /**\n * Defines how much time the poller is going to wait before making a new request to the service.\n */\n intervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * The potential location of the result of the LRO if specified by the LRO extension in the swagger.\n */\n lroResourceLocationConfig?: LroResourceLocationConfig;\n /**\n * A function to process the result of the LRO.\n */\n processResult?: (result: unknown, state: TState) => TResult;\n /**\n * A function to process the state of the LRO.\n */\n updateState?: (state: TState, lastResponse: RawResponse) => void;\n /**\n * A predicate to determine whether the LRO finished processing.\n */\n isDone?: (lastResponse: unknown, state: TState) => boolean;\n /**\n * Control whether to throw an exception if the operation failed or was canceled.\n */\n resolveOnUnsuccessful?: boolean;\n}\n\nexport interface PollerConfig {\n intervalInMs: number;\n}\n"]}
|
84
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/operation.js
generated
vendored
Normal file
84
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/operation.js
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { initHttpOperation, pollHttpOperation } from "../../http/operation";
|
||||
import { logger } from "../../logger";
|
||||
const createStateProxy = () => ({
|
||||
initState: (config) => ({ config, isStarted: true }),
|
||||
setCanceled: (state) => (state.isCancelled = true),
|
||||
setError: (state, error) => (state.error = error),
|
||||
setResult: (state, result) => (state.result = result),
|
||||
setRunning: (state) => (state.isStarted = true),
|
||||
setSucceeded: (state) => (state.isCompleted = true),
|
||||
setFailed: () => {
|
||||
/** empty body */
|
||||
},
|
||||
getError: (state) => state.error,
|
||||
getResult: (state) => state.result,
|
||||
isCanceled: (state) => !!state.isCancelled,
|
||||
isFailed: (state) => !!state.error,
|
||||
isRunning: (state) => !!state.isStarted,
|
||||
isSucceeded: (state) => Boolean(state.isCompleted && !state.isCancelled && !state.error),
|
||||
});
|
||||
export class GenericPollOperation {
|
||||
constructor(state, lro, setErrorAsResult, lroResourceLocationConfig, processResult, updateState, isDone) {
|
||||
this.state = state;
|
||||
this.lro = lro;
|
||||
this.setErrorAsResult = setErrorAsResult;
|
||||
this.lroResourceLocationConfig = lroResourceLocationConfig;
|
||||
this.processResult = processResult;
|
||||
this.updateState = updateState;
|
||||
this.isDone = isDone;
|
||||
}
|
||||
setPollerConfig(pollerConfig) {
|
||||
this.pollerConfig = pollerConfig;
|
||||
}
|
||||
async update(options) {
|
||||
var _a;
|
||||
const stateProxy = createStateProxy();
|
||||
if (!this.state.isStarted) {
|
||||
this.state = Object.assign(Object.assign({}, this.state), (await initHttpOperation({
|
||||
lro: this.lro,
|
||||
stateProxy,
|
||||
resourceLocationConfig: this.lroResourceLocationConfig,
|
||||
processResult: this.processResult,
|
||||
setErrorAsResult: this.setErrorAsResult,
|
||||
})));
|
||||
}
|
||||
const updateState = this.updateState;
|
||||
const isDone = this.isDone;
|
||||
if (!this.state.isCompleted && this.state.error === undefined) {
|
||||
await pollHttpOperation({
|
||||
lro: this.lro,
|
||||
state: this.state,
|
||||
stateProxy,
|
||||
processResult: this.processResult,
|
||||
updateState: updateState
|
||||
? (state, { rawResponse }) => updateState(state, rawResponse)
|
||||
: undefined,
|
||||
isDone: isDone
|
||||
? ({ flatResponse }, state) => isDone(flatResponse, state)
|
||||
: undefined,
|
||||
options,
|
||||
setDelay: (intervalInMs) => {
|
||||
this.pollerConfig.intervalInMs = intervalInMs;
|
||||
},
|
||||
setErrorAsResult: this.setErrorAsResult,
|
||||
});
|
||||
}
|
||||
(_a = options === null || options === void 0 ? void 0 : options.fireProgress) === null || _a === void 0 ? void 0 : _a.call(options, this.state);
|
||||
return this;
|
||||
}
|
||||
async cancel() {
|
||||
logger.error("`cancelOperation` is deprecated because it wasn't implemented");
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Serializes the Poller operation.
|
||||
*/
|
||||
toString() {
|
||||
return JSON.stringify({
|
||||
state: this.state,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=operation.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/operation.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/lroEngine/operation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/@azure/core-lro/dist-esm/src/legacy/models.js
generated
vendored
Normal file
4
node_modules/@azure/core-lro/dist-esm/src/legacy/models.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=models.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/models.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/models.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/legacy/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { CancelOnProgress } from \"../poller/models\";\nimport { PollOperationState } from \"./pollOperation\";\n\n/**\n * Abstract representation of a poller, intended to expose just the minimal API that the user needs to work with.\n */\n// eslint-disable-next-line no-use-before-define\nexport interface PollerLike<TState extends PollOperationState<TResult>, TResult> {\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Stops the poller. After this, no manual or automated requests can be sent.\n */\n stopPolling(): void;\n /**\n * Returns true if the poller is stopped.\n */\n isStopped(): boolean;\n /**\n * Attempts to cancel the underlying operation.\n * @deprecated `cancelOperation` has been deprecated because it was not implemented.\n */\n cancelOperation(options?: { abortSignal?: AbortSignalLike }): Promise<void>;\n /**\n * Returns the state of the operation.\n * The TState defined in PollerLike can be a subset of the TState defined in\n * the Poller implementation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a serialized version of the poller's operation\n * by invoking the operation's toString method.\n */\n toString(): string;\n}\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/pollOperation.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/pollOperation.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"pollOperation.js","sourceRoot":"","sources":["../../../src/legacy/pollOperation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\n/**\n * PollOperationState contains an opinionated list of the smallest set of properties needed\n * to define any long running operation poller.\n *\n * While the Poller class works as the local control mechanism to start triggering, wait for,\n * and potentially cancel a long running operation, the PollOperationState documents the status\n * of the remote long running operation.\n *\n * It should be updated at least when the operation starts, when it's finished, and when it's cancelled.\n * Though, implementations can have any other number of properties that can be updated by other reasons.\n */\nexport interface PollOperationState<TResult> {\n /**\n * True if the operation has started.\n */\n isStarted?: boolean;\n /**\n * True if the operation has been completed.\n */\n isCompleted?: boolean;\n /**\n * True if the operation has been cancelled.\n */\n isCancelled?: boolean;\n /**\n * Will exist if the operation encountered any error.\n */\n error?: Error;\n /**\n * Will exist if the operation concluded in a result of an expected type.\n */\n result?: TResult;\n}\n\n/**\n * PollOperation is an interface that defines how to update the local reference of the state of the remote\n * long running operation, just as well as how to request the cancellation of the same operation.\n *\n * It also has a method to serialize the operation so that it can be stored and resumed at any time.\n */\nexport interface PollOperation<TState, TResult> {\n /**\n * The state of the operation.\n * It will be used to store the basic properties of PollOperationState<TResult>,\n * plus any custom property that the implementation may require.\n */\n state: TState;\n\n /**\n * Defines how to request the remote service for updates on the status of the long running operation.\n *\n * It optionally receives an object with an abortSignal property, from \\@azure/abort-controller's AbortSignalLike.\n * Also optionally receives a \"fireProgress\" function, which, if called, is responsible for triggering the\n * poller's onProgress callbacks.\n *\n * @param options - Optional properties passed to the operation's update method.\n */\n update(options?: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: TState) => void;\n }): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Attempts to cancel the underlying operation.\n *\n * It only optionally receives an object with an abortSignal property, from \\@azure/abort-controller's AbortSignalLike.\n *\n * It returns a promise that should be resolved with an updated version of the poller's operation.\n *\n * @param options - Optional properties passed to the operation's update method.\n *\n * @deprecated `cancel` has been deprecated because it was not implemented.\n */\n cancel(options?: { abortSignal?: AbortSignalLike }): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Serializes the operation.\n * Useful when wanting to create a poller that monitors an existing operation.\n */\n toString(): string;\n}\n"]}
|
|
@ -12,8 +12,8 @@ export class PollerStoppedError extends Error {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* When a poller is cancelled through the `cancelOperation` method,
|
||||
* the poller will be rejected with an instance of the PollerCancelledError.
|
||||
* When the operation is cancelled, the poller will be rejected with an instance
|
||||
* of the PollerCancelledError.
|
||||
*/
|
||||
export class PollerCancelledError extends Error {
|
||||
constructor(message) {
|
||||
|
@ -151,6 +151,8 @@ export class Poller {
|
|||
* @param operation - Must contain the basic properties of `PollOperation<State, TResult>`.
|
||||
*/
|
||||
constructor(operation) {
|
||||
/** controls whether to throw an error if the operation failed or was canceled. */
|
||||
this.resolveOnUnsuccessful = false;
|
||||
this.stopped = true;
|
||||
this.pollProgressCallbacks = [];
|
||||
this.operation = operation;
|
||||
|
@ -169,12 +171,12 @@ export class Poller {
|
|||
* Starts a loop that will break only if the poller is done
|
||||
* or if the poller is stopped.
|
||||
*/
|
||||
async startPolling() {
|
||||
async startPolling(pollOptions = {}) {
|
||||
if (this.stopped) {
|
||||
this.stopped = false;
|
||||
}
|
||||
while (!this.isStopped() && !this.isDone()) {
|
||||
await this.poll();
|
||||
await this.poll(pollOptions);
|
||||
await this.delay();
|
||||
}
|
||||
}
|
||||
|
@ -187,29 +189,13 @@ export class Poller {
|
|||
* @param options - Optional properties passed to the operation's update method.
|
||||
*/
|
||||
async pollOnce(options = {}) {
|
||||
try {
|
||||
if (!this.isDone()) {
|
||||
this.operation = await this.operation.update({
|
||||
abortSignal: options.abortSignal,
|
||||
fireProgress: this.fireProgress.bind(this),
|
||||
});
|
||||
if (this.isDone() && this.resolve) {
|
||||
// If the poller has finished polling, this means we now have a result.
|
||||
// However, it can be the case that TResult is instantiated to void, so
|
||||
// we are not expecting a result anyway. To assert that we might not
|
||||
// have a result eventually after finishing polling, we cast the result
|
||||
// to TResult.
|
||||
this.resolve(this.operation.state.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
this.operation.state.error = e;
|
||||
if (this.reject) {
|
||||
this.reject(e);
|
||||
}
|
||||
throw e;
|
||||
if (!this.isDone()) {
|
||||
this.operation = await this.operation.update({
|
||||
abortSignal: options.abortSignal,
|
||||
fireProgress: this.fireProgress.bind(this),
|
||||
});
|
||||
}
|
||||
this.processUpdatedState();
|
||||
}
|
||||
/**
|
||||
* fireProgress calls the functions passed in via onProgress the method of the poller.
|
||||
|
@ -225,14 +211,10 @@ export class Poller {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Invokes the underlying operation's cancel method, and rejects the
|
||||
* pollUntilDone promise.
|
||||
* Invokes the underlying operation's cancel method.
|
||||
*/
|
||||
async cancelOnce(options = {}) {
|
||||
this.operation = await this.operation.cancel(options);
|
||||
if (this.reject) {
|
||||
this.reject(new PollerCancelledError("Poller cancelled"));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a promise that will resolve once a single polling request finishes.
|
||||
|
@ -252,13 +234,41 @@ export class Poller {
|
|||
}
|
||||
return this.pollOncePromise;
|
||||
}
|
||||
processUpdatedState() {
|
||||
if (this.operation.state.error) {
|
||||
this.stopped = true;
|
||||
if (!this.resolveOnUnsuccessful) {
|
||||
this.reject(this.operation.state.error);
|
||||
throw this.operation.state.error;
|
||||
}
|
||||
}
|
||||
if (this.operation.state.isCancelled) {
|
||||
this.stopped = true;
|
||||
if (!this.resolveOnUnsuccessful) {
|
||||
const error = new PollerCancelledError("Operation was canceled");
|
||||
this.reject(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
if (this.isDone() && this.resolve) {
|
||||
// If the poller has finished polling, this means we now have a result.
|
||||
// However, it can be the case that TResult is instantiated to void, so
|
||||
// we are not expecting a result anyway. To assert that we might not
|
||||
// have a result eventually after finishing polling, we cast the result
|
||||
// to TResult.
|
||||
this.resolve(this.getResult());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a promise that will resolve once the underlying operation is completed.
|
||||
*/
|
||||
async pollUntilDone() {
|
||||
async pollUntilDone(pollOptions = {}) {
|
||||
if (this.stopped) {
|
||||
this.startPolling().catch(this.reject);
|
||||
this.startPolling(pollOptions).catch(this.reject);
|
||||
}
|
||||
// This is needed because the state could have been updated by
|
||||
// `cancelOperation`, e.g. the operation is canceled or an error occurred.
|
||||
this.processUpdatedState();
|
||||
return this.promise;
|
||||
}
|
||||
/**
|
||||
|
@ -307,9 +317,6 @@ export class Poller {
|
|||
* @param options - Optional properties passed to the operation's update method.
|
||||
*/
|
||||
cancelOperation(options = {}) {
|
||||
if (!this.stopped) {
|
||||
this.stopped = true;
|
||||
}
|
||||
if (!this.cancelPromise) {
|
||||
this.cancelPromise = this.cancelOnce(options);
|
||||
}
|
1
node_modules/@azure/core-lro/dist-esm/src/legacy/poller.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/legacy/poller.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@azure/core-lro/dist-esm/src/logger.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/logger.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The `@azure/logger` configuration for this package.\n * @internal\n */\nexport const logger = createClientLogger(\"core-lro\");\n"]}
|
25
node_modules/@azure/core-lro/dist-esm/src/lroEngine/bodyPolling.js
generated
vendored
25
node_modules/@azure/core-lro/dist-esm/src/lroEngine/bodyPolling.js
generated
vendored
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { failureStates, successStates, } from "./models";
|
||||
import { isUnexpectedPollingResponse } from "./requestUtils";
|
||||
function getProvisioningState(rawResponse) {
|
||||
var _a, _b;
|
||||
const { properties, provisioningState } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
|
||||
const state = (_b = properties === null || properties === void 0 ? void 0 : properties.provisioningState) !== null && _b !== void 0 ? _b : provisioningState;
|
||||
return typeof state === "string" ? state.toLowerCase() : "succeeded";
|
||||
}
|
||||
export function isBodyPollingDone(rawResponse) {
|
||||
const state = getProvisioningState(rawResponse);
|
||||
if (isUnexpectedPollingResponse(rawResponse) || failureStates.includes(state)) {
|
||||
throw new Error(`The long running operation has failed. The provisioning state: ${state}.`);
|
||||
}
|
||||
return successStates.includes(state);
|
||||
}
|
||||
/**
|
||||
* Creates a polling strategy based on BodyPolling which uses the provisioning state
|
||||
* from the result to determine the current operation state
|
||||
*/
|
||||
export function processBodyPollingOperationResult(response) {
|
||||
return Object.assign(Object.assign({}, response), { done: isBodyPollingDone(response.rawResponse) });
|
||||
}
|
||||
//# sourceMappingURL=bodyPolling.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/bodyPolling.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/bodyPolling.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"bodyPolling.js","sourceRoot":"","sources":["../../../src/lroEngine/bodyPolling.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAKL,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,SAAS,oBAAoB,CAAC,WAAwB;;IACpD,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAC,WAAW,CAAC,IAAgB,mCAAI,EAAE,CAAC;IAC9E,MAAM,KAAK,GAAuB,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,mCAAI,iBAAiB,CAAC;IACrF,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAwB;IACxD,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAChD,IAAI,2BAA2B,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7E,MAAM,IAAI,KAAK,CAAC,kEAAkE,KAAK,GAAG,CAAC,CAAC;KAC7F;IACD,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAA8B;IAE9B,uCACK,QAAQ,KACX,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,IAC7C;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n LroBody,\n LroResponse,\n LroStatus,\n RawResponse,\n failureStates,\n successStates,\n} from \"./models\";\nimport { isUnexpectedPollingResponse } from \"./requestUtils\";\n\nfunction getProvisioningState(rawResponse: RawResponse): string {\n const { properties, provisioningState } = (rawResponse.body as LroBody) ?? {};\n const state: string | undefined = properties?.provisioningState ?? provisioningState;\n return typeof state === \"string\" ? state.toLowerCase() : \"succeeded\";\n}\n\nexport function isBodyPollingDone(rawResponse: RawResponse): boolean {\n const state = getProvisioningState(rawResponse);\n if (isUnexpectedPollingResponse(rawResponse) || failureStates.includes(state)) {\n throw new Error(`The long running operation has failed. The provisioning state: ${state}.`);\n }\n return successStates.includes(state);\n}\n\n/**\n * Creates a polling strategy based on BodyPolling which uses the provisioning state\n * from the result to determine the current operation state\n */\nexport function processBodyPollingOperationResult<TResult>(\n response: LroResponse<TResult>\n): LroStatus<TResult> {\n return {\n ...response,\n done: isBodyPollingDone(response.rawResponse),\n };\n}\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/index.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/index.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lroEngine/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { LroEngine } from \"./lroEngine\";\nexport {\n LroResourceLocationConfig,\n LongRunningOperation,\n LroResponse,\n LroEngineOptions,\n RawResponse,\n} from \"./models\";\n"]}
|
47
node_modules/@azure/core-lro/dist-esm/src/lroEngine/locationPolling.js
generated
vendored
47
node_modules/@azure/core-lro/dist-esm/src/lroEngine/locationPolling.js
generated
vendored
|
@ -1,47 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { failureStates, successStates, } from "./models";
|
||||
import { isUnexpectedPollingResponse } from "./requestUtils";
|
||||
function isPollingDone(rawResponse) {
|
||||
var _a;
|
||||
if (isUnexpectedPollingResponse(rawResponse) || rawResponse.statusCode === 202) {
|
||||
return false;
|
||||
}
|
||||
const { status } = (_a = rawResponse.body) !== null && _a !== void 0 ? _a : {};
|
||||
const state = typeof status === "string" ? status.toLowerCase() : "succeeded";
|
||||
if (isUnexpectedPollingResponse(rawResponse) || failureStates.includes(state)) {
|
||||
throw new Error(`The long running operation has failed. The provisioning state: ${state}.`);
|
||||
}
|
||||
return successStates.includes(state);
|
||||
}
|
||||
/**
|
||||
* Sends a request to the URI of the provisioned resource if needed.
|
||||
*/
|
||||
async function sendFinalRequest(lro, resourceLocation, lroResourceLocationConfig) {
|
||||
switch (lroResourceLocationConfig) {
|
||||
case "original-uri":
|
||||
return lro.sendPollRequest(lro.requestPath);
|
||||
case "azure-async-operation":
|
||||
return undefined;
|
||||
case "location":
|
||||
default:
|
||||
return lro.sendPollRequest(resourceLocation !== null && resourceLocation !== void 0 ? resourceLocation : lro.requestPath);
|
||||
}
|
||||
}
|
||||
export function processLocationPollingOperationResult(lro, resourceLocation, lroResourceLocationConfig) {
|
||||
return (response) => {
|
||||
if (isPollingDone(response.rawResponse)) {
|
||||
if (resourceLocation === undefined) {
|
||||
return Object.assign(Object.assign({}, response), { done: true });
|
||||
}
|
||||
else {
|
||||
return Object.assign(Object.assign({}, response), { done: false, next: async () => {
|
||||
const finalResponse = await sendFinalRequest(lro, resourceLocation, lroResourceLocationConfig);
|
||||
return Object.assign(Object.assign({}, (finalResponse !== null && finalResponse !== void 0 ? finalResponse : response)), { done: true });
|
||||
} });
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, response), { done: false });
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=locationPolling.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/locationPolling.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/locationPolling.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"locationPolling.js","sourceRoot":"","sources":["../../../src/lroEngine/locationPolling.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAOL,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,SAAS,aAAa,CAAC,WAAwB;;IAC7C,IAAI,2BAA2B,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,UAAU,KAAK,GAAG,EAAE;QAC9E,OAAO,KAAK,CAAC;KACd;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAC,WAAW,CAAC,IAAgB,mCAAI,EAAE,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9E,IAAI,2BAA2B,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7E,MAAM,IAAI,KAAK,CAAC,kEAAkE,KAAK,GAAG,CAAC,CAAC;KAC7F;IACD,OAAO,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,gBAAgB,CAC7B,GAAkC,EAClC,gBAAwB,EACxB,yBAAqD;IAErD,QAAQ,yBAAyB,EAAE;QACjC,KAAK,cAAc;YACjB,OAAO,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9C,KAAK,uBAAuB;YAC1B,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU,CAAC;QAChB;YACE,OAAO,GAAG,CAAC,eAAe,CAAC,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,GAAG,CAAC,WAAW,CAAC,CAAC;KACnE;AACH,CAAC;AAED,MAAM,UAAU,qCAAqC,CACnD,GAAkC,EAClC,gBAAyB,EACzB,yBAAqD;IAErD,OAAO,CAAC,QAA8B,EAAsB,EAAE;QAC5D,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;YACvC,IAAI,gBAAgB,KAAK,SAAS,EAAE;gBAClC,uCAAY,QAAQ,KAAE,IAAI,EAAE,IAAI,IAAG;aACpC;iBAAM;gBACL,uCACK,QAAQ,KACX,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,KAAK,IAAI,EAAE;wBACf,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAC1C,GAAG,EACH,gBAAgB,EAChB,yBAAyB,CAC1B,CAAC;wBACF,uCACK,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,QAAQ,CAAC,KAC9B,IAAI,EAAE,IAAI,IACV;oBACJ,CAAC,IACD;aACH;SACF;QACD,uCACK,QAAQ,KACX,IAAI,EAAE,KAAK,IACX;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n LongRunningOperation,\n LroBody,\n LroResourceLocationConfig,\n LroResponse,\n LroStatus,\n RawResponse,\n failureStates,\n successStates,\n} from \"./models\";\nimport { isUnexpectedPollingResponse } from \"./requestUtils\";\n\nfunction isPollingDone(rawResponse: RawResponse): boolean {\n if (isUnexpectedPollingResponse(rawResponse) || rawResponse.statusCode === 202) {\n return false;\n }\n const { status } = (rawResponse.body as LroBody) ?? {};\n const state = typeof status === \"string\" ? status.toLowerCase() : \"succeeded\";\n if (isUnexpectedPollingResponse(rawResponse) || failureStates.includes(state)) {\n throw new Error(`The long running operation has failed. The provisioning state: ${state}.`);\n }\n return successStates.includes(state);\n}\n\n/**\n * Sends a request to the URI of the provisioned resource if needed.\n */\nasync function sendFinalRequest<TResult>(\n lro: LongRunningOperation<TResult>,\n resourceLocation: string,\n lroResourceLocationConfig?: LroResourceLocationConfig\n): Promise<LroResponse<TResult> | undefined> {\n switch (lroResourceLocationConfig) {\n case \"original-uri\":\n return lro.sendPollRequest(lro.requestPath);\n case \"azure-async-operation\":\n return undefined;\n case \"location\":\n default:\n return lro.sendPollRequest(resourceLocation ?? lro.requestPath);\n }\n}\n\nexport function processLocationPollingOperationResult<TResult>(\n lro: LongRunningOperation<TResult>,\n resourceLocation?: string,\n lroResourceLocationConfig?: LroResourceLocationConfig\n): (response: LroResponse<TResult>) => LroStatus<TResult> {\n return (response: LroResponse<TResult>): LroStatus<TResult> => {\n if (isPollingDone(response.rawResponse)) {\n if (resourceLocation === undefined) {\n return { ...response, done: true };\n } else {\n return {\n ...response,\n done: false,\n next: async () => {\n const finalResponse = await sendFinalRequest(\n lro,\n resourceLocation,\n lroResourceLocationConfig\n );\n return {\n ...(finalResponse ?? response),\n done: true,\n };\n },\n };\n }\n }\n return {\n ...response,\n done: false,\n };\n };\n}\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/logger.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/logger.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/lroEngine/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The `@azure/logger` configuration for this package.\n * @internal\n */\nexport const logger = createClientLogger(\"core-lro\");\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/lroEngine.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/lroEngine.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"lroEngine.js","sourceRoot":"","sources":["../../../src/lroEngine/lroEngine.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,SAAS,gBAAgB,CACvB,eAAuB;IAEvB,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,2CAA2C,eAAe,EAAE,CAAC,CAAC;KAC/E;AACH,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,SAA+D,SAAQ,MAGnF;IAGC,YAAY,GAAkC,EAAE,OAA2C;QACzF,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAkD,UAAU;YACrE,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC;YAC9B,CAAC,CAAE,EAAoD,CAAC;QAE1D,MAAM,SAAS,GAAG,IAAI,oBAAoB,CACxC,KAAK,EACL,GAAG,EACH,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,yBAAyB,EAClC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EACtB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EACpB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAChB,CAAC;QACF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;QAC7C,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACzF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n LongRunningOperation,\n LroEngineOptions,\n PollerConfig,\n ResumablePollOperationState,\n} from \"./models\";\nimport { GenericPollOperation } from \"./operation\";\nimport { PollOperationState } from \"../pollOperation\";\nimport { Poller } from \"../poller\";\n\nfunction deserializeState<TResult, TState>(\n serializedState: string\n): TState & ResumablePollOperationState<TResult> {\n try {\n return JSON.parse(serializedState).state;\n } catch (e) {\n throw new Error(`LroEngine: Unable to deserialize state: ${serializedState}`);\n }\n}\n\n/**\n * The LRO Engine, a class that performs polling.\n */\nexport class LroEngine<TResult, TState extends PollOperationState<TResult>> extends Poller<\n TState,\n TResult\n> {\n private config: PollerConfig;\n\n constructor(lro: LongRunningOperation<TResult>, options?: LroEngineOptions<TResult, TState>) {\n const { intervalInMs = 2000, resumeFrom } = options || {};\n const state: TState & ResumablePollOperationState<TResult> = resumeFrom\n ? deserializeState(resumeFrom)\n : ({} as TState & ResumablePollOperationState<TResult>);\n\n const operation = new GenericPollOperation(\n state,\n lro,\n options?.lroResourceLocationConfig,\n options?.processResult,\n options?.updateState,\n options?.isDone\n );\n super(operation);\n\n this.config = { intervalInMs: intervalInMs };\n operation.setPollerConfig(this.config);\n }\n\n /**\n * The method used by the poller to wait before attempting to update its operation.\n */\n delay(): Promise<void> {\n return new Promise((resolve) => setTimeout(() => resolve(), this.config.intervalInMs));\n }\n}\n"]}
|
9
node_modules/@azure/core-lro/dist-esm/src/lroEngine/models.js
generated
vendored
9
node_modules/@azure/core-lro/dist-esm/src/lroEngine/models.js
generated
vendored
|
@ -1,9 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export const successStates = ["succeeded"];
|
||||
export const failureStates = ["failed", "canceled", "cancelled"];
|
||||
/**
|
||||
* The LRO states that signal that the LRO has completed.
|
||||
*/
|
||||
export const terminalStates = successStates.concat(failureStates);
|
||||
//# sourceMappingURL=models.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/models.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/models.js.map
generated
vendored
File diff suppressed because one or more lines are too long
93
node_modules/@azure/core-lro/dist-esm/src/lroEngine/operation.js
generated
vendored
93
node_modules/@azure/core-lro/dist-esm/src/lroEngine/operation.js
generated
vendored
|
@ -1,93 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { createGetLroStatusFromResponse, createInitializeState, createPoll } from "./stateMachine";
|
||||
import { getPollingUrl } from "./requestUtils";
|
||||
import { logger } from "./logger";
|
||||
export class GenericPollOperation {
|
||||
constructor(state, lro, lroResourceLocationConfig, processResult, updateState, isDone) {
|
||||
this.state = state;
|
||||
this.lro = lro;
|
||||
this.lroResourceLocationConfig = lroResourceLocationConfig;
|
||||
this.processResult = processResult;
|
||||
this.updateState = updateState;
|
||||
this.isDone = isDone;
|
||||
}
|
||||
setPollerConfig(pollerConfig) {
|
||||
this.pollerConfig = pollerConfig;
|
||||
}
|
||||
/**
|
||||
* General update function for LROPoller, the general process is as follows
|
||||
* 1. Check initial operation result to determine the strategy to use
|
||||
* - Strategies: Location, Azure-AsyncOperation, Original Uri
|
||||
* 2. Check if the operation result has a terminal state
|
||||
* - Terminal state will be determined by each strategy
|
||||
* 2.1 If it is terminal state Check if a final GET request is required, if so
|
||||
* send final GET request and return result from operation. If no final GET
|
||||
* is required, just return the result from operation.
|
||||
* - Determining what to call for final request is responsibility of each strategy
|
||||
* 2.2 If it is not terminal state, call the polling operation and go to step 1
|
||||
* - Determining what to call for polling is responsibility of each strategy
|
||||
* - Strategies will always use the latest URI for polling if provided otherwise
|
||||
* the last known one
|
||||
*/
|
||||
async update(options) {
|
||||
var _a, _b, _c;
|
||||
const state = this.state;
|
||||
let lastResponse = undefined;
|
||||
if (!state.isStarted) {
|
||||
const initializeState = createInitializeState(state, this.lro.requestPath, this.lro.requestMethod);
|
||||
lastResponse = await this.lro.sendInitialRequest();
|
||||
initializeState(lastResponse);
|
||||
}
|
||||
if (!state.isCompleted) {
|
||||
if (!this.poll || !this.getLroStatusFromResponse) {
|
||||
if (!state.config) {
|
||||
throw new Error("Bad state: LRO mode is undefined. Please check if the serialized state is well-formed.");
|
||||
}
|
||||
const isDone = this.isDone;
|
||||
this.getLroStatusFromResponse = isDone
|
||||
? (response) => (Object.assign(Object.assign({}, response), { done: isDone(response.flatResponse, this.state) }))
|
||||
: createGetLroStatusFromResponse(this.lro, state.config, this.lroResourceLocationConfig);
|
||||
this.poll = createPoll(this.lro);
|
||||
}
|
||||
if (!state.pollingURL) {
|
||||
throw new Error("Bad state: polling URL is undefined. Please check if the serialized state is well-formed.");
|
||||
}
|
||||
const currentState = await this.poll(state.pollingURL, this.pollerConfig, this.getLroStatusFromResponse);
|
||||
logger.verbose(`LRO: polling response: ${JSON.stringify(currentState.rawResponse)}`);
|
||||
if (currentState.done) {
|
||||
state.result = this.processResult
|
||||
? this.processResult(currentState.flatResponse, state)
|
||||
: currentState.flatResponse;
|
||||
state.isCompleted = true;
|
||||
}
|
||||
else {
|
||||
this.poll = (_a = currentState.next) !== null && _a !== void 0 ? _a : this.poll;
|
||||
state.pollingURL = getPollingUrl(currentState.rawResponse, state.pollingURL);
|
||||
}
|
||||
lastResponse = currentState;
|
||||
}
|
||||
logger.verbose(`LRO: current state: ${JSON.stringify(state)}`);
|
||||
if (lastResponse) {
|
||||
(_b = this.updateState) === null || _b === void 0 ? void 0 : _b.call(this, state, lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.rawResponse);
|
||||
}
|
||||
else {
|
||||
logger.error(`LRO: no response was received`);
|
||||
}
|
||||
(_c = options === null || options === void 0 ? void 0 : options.fireProgress) === null || _c === void 0 ? void 0 : _c.call(options, state);
|
||||
return this;
|
||||
}
|
||||
async cancel() {
|
||||
this.state.isCancelled = true;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Serializes the Poller operation.
|
||||
*/
|
||||
toString() {
|
||||
return JSON.stringify({
|
||||
state: this.state,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=operation.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/operation.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/operation.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
node_modules/@azure/core-lro/dist-esm/src/lroEngine/passthrough.js
generated
vendored
6
node_modules/@azure/core-lro/dist-esm/src/lroEngine/passthrough.js
generated
vendored
|
@ -1,6 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export function processPassthroughOperationResult(response) {
|
||||
return Object.assign(Object.assign({}, response), { done: true });
|
||||
}
|
||||
//# sourceMappingURL=passthrough.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/passthrough.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/passthrough.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"passthrough.js","sourceRoot":"","sources":["../../../src/lroEngine/passthrough.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,UAAU,iCAAiC,CAC/C,QAA8B;IAE9B,uCACK,QAAQ,KACX,IAAI,EAAE,IAAI,IACV;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LroResponse, LroStatus } from \"./models\";\n\nexport function processPassthroughOperationResult<TResult>(\n response: LroResponse<TResult>\n): LroStatus<TResult> {\n return {\n ...response,\n done: true,\n };\n}\n"]}
|
78
node_modules/@azure/core-lro/dist-esm/src/lroEngine/requestUtils.js
generated
vendored
78
node_modules/@azure/core-lro/dist-esm/src/lroEngine/requestUtils.js
generated
vendored
|
@ -1,78 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* Detects where the continuation token is and returns it. Notice that azure-asyncoperation
|
||||
* must be checked first before the other location headers because there are scenarios
|
||||
* where both azure-asyncoperation and location could be present in the same response but
|
||||
* azure-asyncoperation should be the one to use for polling.
|
||||
*/
|
||||
export function getPollingUrl(rawResponse, defaultPath) {
|
||||
var _a, _b, _c;
|
||||
return ((_c = (_b = (_a = getAzureAsyncOperation(rawResponse)) !== null && _a !== void 0 ? _a : getOperationLocation(rawResponse)) !== null && _b !== void 0 ? _b : getLocation(rawResponse)) !== null && _c !== void 0 ? _c : defaultPath);
|
||||
}
|
||||
function getLocation(rawResponse) {
|
||||
return rawResponse.headers["location"];
|
||||
}
|
||||
function getOperationLocation(rawResponse) {
|
||||
return rawResponse.headers["operation-location"];
|
||||
}
|
||||
function getAzureAsyncOperation(rawResponse) {
|
||||
return rawResponse.headers["azure-asyncoperation"];
|
||||
}
|
||||
function findResourceLocation(requestMethod, rawResponse, requestPath) {
|
||||
switch (requestMethod) {
|
||||
case "PUT": {
|
||||
return requestPath;
|
||||
}
|
||||
case "POST":
|
||||
case "PATCH": {
|
||||
return getLocation(rawResponse);
|
||||
}
|
||||
default: {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
export function inferLroMode(requestPath, requestMethod, rawResponse) {
|
||||
if (getAzureAsyncOperation(rawResponse) !== undefined ||
|
||||
getOperationLocation(rawResponse) !== undefined) {
|
||||
return {
|
||||
mode: "Location",
|
||||
resourceLocation: findResourceLocation(requestMethod, rawResponse, requestPath),
|
||||
};
|
||||
}
|
||||
else if (getLocation(rawResponse) !== undefined) {
|
||||
return {
|
||||
mode: "Location",
|
||||
};
|
||||
}
|
||||
else if (["PUT", "PATCH"].includes(requestMethod)) {
|
||||
return {
|
||||
mode: "Body",
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
class SimpleRestError extends Error {
|
||||
constructor(message, statusCode) {
|
||||
super(message);
|
||||
this.name = "RestError";
|
||||
this.statusCode = statusCode;
|
||||
Object.setPrototypeOf(this, SimpleRestError.prototype);
|
||||
}
|
||||
}
|
||||
export function isUnexpectedInitialResponse(rawResponse) {
|
||||
const code = rawResponse.statusCode;
|
||||
if (![203, 204, 202, 201, 200, 500].includes(code)) {
|
||||
throw new SimpleRestError(`Received unexpected HTTP status code ${code} in the initial response. This may indicate a server issue.`, code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isUnexpectedPollingResponse(rawResponse) {
|
||||
const code = rawResponse.statusCode;
|
||||
if (![202, 201, 200, 500].includes(code)) {
|
||||
throw new SimpleRestError(`Received unexpected HTTP status code ${code} while polling. This may indicate a server issue.`, code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//# sourceMappingURL=requestUtils.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/requestUtils.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/requestUtils.js.map
generated
vendored
File diff suppressed because one or more lines are too long
74
node_modules/@azure/core-lro/dist-esm/src/lroEngine/stateMachine.js
generated
vendored
74
node_modules/@azure/core-lro/dist-esm/src/lroEngine/stateMachine.js
generated
vendored
|
@ -1,74 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { getPollingUrl, inferLroMode, isUnexpectedInitialResponse } from "./requestUtils";
|
||||
import { isBodyPollingDone, processBodyPollingOperationResult } from "./bodyPolling";
|
||||
import { logger } from "./logger";
|
||||
import { processLocationPollingOperationResult } from "./locationPolling";
|
||||
import { processPassthroughOperationResult } from "./passthrough";
|
||||
/**
|
||||
* creates a stepping function that maps an LRO state to another.
|
||||
*/
|
||||
export function createGetLroStatusFromResponse(lroPrimitives, config, lroResourceLocationConfig) {
|
||||
switch (config.mode) {
|
||||
case "Location": {
|
||||
return processLocationPollingOperationResult(lroPrimitives, config.resourceLocation, lroResourceLocationConfig);
|
||||
}
|
||||
case "Body": {
|
||||
return processBodyPollingOperationResult;
|
||||
}
|
||||
default: {
|
||||
return processPassthroughOperationResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a polling operation.
|
||||
*/
|
||||
export function createPoll(lroPrimitives) {
|
||||
return async (path, pollerConfig, getLroStatusFromResponse) => {
|
||||
const response = await lroPrimitives.sendPollRequest(path);
|
||||
const retryAfter = response.rawResponse.headers["retry-after"];
|
||||
if (retryAfter !== undefined) {
|
||||
// Retry-After header value is either in HTTP date format, or in seconds
|
||||
const retryAfterInSeconds = parseInt(retryAfter);
|
||||
pollerConfig.intervalInMs = isNaN(retryAfterInSeconds)
|
||||
? calculatePollingIntervalFromDate(new Date(retryAfter), pollerConfig.intervalInMs)
|
||||
: retryAfterInSeconds * 1000;
|
||||
}
|
||||
return getLroStatusFromResponse(response);
|
||||
};
|
||||
}
|
||||
function calculatePollingIntervalFromDate(retryAfterDate, defaultIntervalInMs) {
|
||||
const timeNow = Math.floor(new Date().getTime());
|
||||
const retryAfterTime = retryAfterDate.getTime();
|
||||
if (timeNow < retryAfterTime) {
|
||||
return retryAfterTime - timeNow;
|
||||
}
|
||||
return defaultIntervalInMs;
|
||||
}
|
||||
/**
|
||||
* Creates a callback to be used to initialize the polling operation state.
|
||||
* @param state - of the polling operation
|
||||
* @param operationSpec - of the LRO
|
||||
* @param callback - callback to be called when the operation is done
|
||||
* @returns callback that initializes the state of the polling operation
|
||||
*/
|
||||
export function createInitializeState(state, requestPath, requestMethod) {
|
||||
return (response) => {
|
||||
if (isUnexpectedInitialResponse(response.rawResponse))
|
||||
return true;
|
||||
state.initialRawResponse = response.rawResponse;
|
||||
state.isStarted = true;
|
||||
state.pollingURL = getPollingUrl(state.initialRawResponse, requestPath);
|
||||
state.config = inferLroMode(requestPath, requestMethod, state.initialRawResponse);
|
||||
/** short circuit polling if body polling is done in the initial request */
|
||||
if (state.config.mode === undefined ||
|
||||
(state.config.mode === "Body" && isBodyPollingDone(state.initialRawResponse))) {
|
||||
state.result = response.flatResponse;
|
||||
state.isCompleted = true;
|
||||
}
|
||||
logger.verbose(`LRO: initial state: ${JSON.stringify(state)}`);
|
||||
return Boolean(state.isCompleted);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=stateMachine.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/stateMachine.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/lroEngine/stateMachine.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
node_modules/@azure/core-lro/dist-esm/src/pollOperation.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/pollOperation.js.map
generated
vendored
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"pollOperation.js","sourceRoot":"","sources":["../../src/pollOperation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\n/**\n * PollOperationState contains an opinionated list of the smallest set of properties needed\n * to define any long running operation poller.\n *\n * While the Poller class works as the local control mechanism to start triggering, wait for,\n * and potentially cancel a long running operation, the PollOperationState documents the status\n * of the remote long running operation.\n *\n * It should be updated at least when the operation starts, when it's finished, and when it's cancelled.\n * Though, implementations can have any other number of properties that can be updated by other reasons.\n */\nexport interface PollOperationState<TResult> {\n /**\n * True if the operation has started.\n */\n isStarted?: boolean;\n /**\n * True if the operation has been completed.\n */\n isCompleted?: boolean;\n /**\n * True if the operation has been cancelled.\n */\n isCancelled?: boolean;\n /**\n * Will exist if the operation encountered any error.\n */\n error?: Error;\n /**\n * Will exist if the operation concluded in a result of an expected type.\n */\n result?: TResult;\n}\n\n/**\n * PollOperation is an interface that defines how to update the local reference of the state of the remote\n * long running operation, just as well as how to request the cancellation of the same operation.\n *\n * It also has a method to serialize the operation so that it can be stored and resumed at any time.\n */\nexport interface PollOperation<TState, TResult> {\n /**\n * The state of the operation.\n * It will be used to store the basic properties of PollOperationState<TResult>,\n * plus any custom property that the implementation may require.\n */\n state: TState;\n\n /**\n * Defines how to request the remote service for updates on the status of the long running operation.\n *\n * It optionally receives an object with an abortSignal property, from \\@azure/abort-controller's AbortSignalLike.\n * Also optionally receives a \"fireProgress\" function, which, if called, is responsible for triggering the\n * poller's onProgress callbacks.\n *\n * @param options - Optional properties passed to the operation's update method.\n */\n update(options?: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: TState) => void;\n }): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Attempts to cancel the underlying operation.\n *\n * It only optionally receives an object with an abortSignal property, from \\@azure/abort-controller's AbortSignalLike.\n *\n * It returns a promise that should be resolved with an updated version of the poller's operation.\n *\n * @param options - Optional properties passed to the operation's update method.\n */\n cancel(options?: { abortSignal?: AbortSignalLike }): Promise<PollOperation<TState, TResult>>;\n\n /**\n * Serializes the operation.\n * Useful when wanting to create a poller that monitors an existing operation.\n */\n toString(): string;\n}\n"]}
|
1
node_modules/@azure/core-lro/dist-esm/src/poller.js.map
generated
vendored
1
node_modules/@azure/core-lro/dist-esm/src/poller.js.map
generated
vendored
File diff suppressed because one or more lines are too long
11
node_modules/@azure/core-lro/dist-esm/src/poller/constants.js
generated
vendored
Normal file
11
node_modules/@azure/core-lro/dist-esm/src/poller/constants.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* The default time interval to wait before sending the next polling request.
|
||||
*/
|
||||
export const POLL_INTERVAL_IN_MS = 2000;
|
||||
/**
|
||||
* The closed set of terminal states.
|
||||
*/
|
||||
export const terminalStates = ["succeeded", "canceled", "failed"];
|
||||
//# sourceMappingURL=constants.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/poller/constants.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/poller/constants.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/poller/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * The default time interval to wait before sending the next polling request.\n */\nexport const POLL_INTERVAL_IN_MS = 2000;\n/**\n * The closed set of terminal states.\n */\nexport const terminalStates = [\"succeeded\", \"canceled\", \"failed\"];\n"]}
|
4
node_modules/@azure/core-lro/dist-esm/src/poller/models.js
generated
vendored
Normal file
4
node_modules/@azure/core-lro/dist-esm/src/poller/models.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=models.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/poller/models.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/poller/models.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
132
node_modules/@azure/core-lro/dist-esm/src/poller/operation.js
generated
vendored
Normal file
132
node_modules/@azure/core-lro/dist-esm/src/poller/operation.js
generated
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { logger } from "../logger";
|
||||
import { terminalStates } from "./constants";
|
||||
/**
|
||||
* Deserializes the state
|
||||
*/
|
||||
export function deserializeState(serializedState) {
|
||||
try {
|
||||
return JSON.parse(serializedState).state;
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(`Unable to deserialize input state: ${serializedState}`);
|
||||
}
|
||||
}
|
||||
function setStateError(inputs) {
|
||||
const { state, stateProxy } = inputs;
|
||||
return (error) => {
|
||||
stateProxy.setError(state, error);
|
||||
stateProxy.setFailed(state);
|
||||
throw error;
|
||||
};
|
||||
}
|
||||
function processOperationStatus(result) {
|
||||
const { state, stateProxy, status, isDone, processResult, response, setErrorAsResult } = result;
|
||||
switch (status) {
|
||||
case "succeeded": {
|
||||
stateProxy.setSucceeded(state);
|
||||
break;
|
||||
}
|
||||
case "failed": {
|
||||
stateProxy.setError(state, new Error(`The long-running operation has failed`));
|
||||
stateProxy.setFailed(state);
|
||||
break;
|
||||
}
|
||||
case "canceled": {
|
||||
stateProxy.setCanceled(state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((isDone === null || isDone === void 0 ? void 0 : isDone(response, state)) ||
|
||||
(isDone === undefined &&
|
||||
["succeeded", "canceled"].concat(setErrorAsResult ? [] : ["failed"]).includes(status))) {
|
||||
stateProxy.setResult(state, buildResult({
|
||||
response,
|
||||
state,
|
||||
processResult,
|
||||
}));
|
||||
}
|
||||
}
|
||||
function buildResult(inputs) {
|
||||
const { processResult, response, state } = inputs;
|
||||
return processResult ? processResult(response, state) : response;
|
||||
}
|
||||
/**
|
||||
* Initiates the long-running operation.
|
||||
*/
|
||||
export async function initOperation(inputs) {
|
||||
const { init, stateProxy, processResult, getOperationStatus, withOperationLocation, setErrorAsResult, } = inputs;
|
||||
const { operationLocation, resourceLocation, metadata, response } = await init();
|
||||
if (operationLocation)
|
||||
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
|
||||
const config = {
|
||||
metadata,
|
||||
operationLocation,
|
||||
resourceLocation,
|
||||
};
|
||||
logger.verbose(`LRO: Operation description:`, config);
|
||||
const state = stateProxy.initState(config);
|
||||
const status = getOperationStatus({ response, state, operationLocation });
|
||||
processOperationStatus({ state, status, stateProxy, response, setErrorAsResult, processResult });
|
||||
return state;
|
||||
}
|
||||
async function pollOperationHelper(inputs) {
|
||||
const { poll, state, stateProxy, operationLocation, getOperationStatus, getResourceLocation, options, } = inputs;
|
||||
const response = await poll(operationLocation, options).catch(setStateError({
|
||||
state,
|
||||
stateProxy,
|
||||
}));
|
||||
const status = getOperationStatus(response, state);
|
||||
logger.verbose(`LRO: Status:\n\tPolling from: ${state.config.operationLocation}\n\tOperation status: ${status}\n\tPolling status: ${terminalStates.includes(status) ? "Stopped" : "Running"}`);
|
||||
if (status === "succeeded") {
|
||||
const resourceLocation = getResourceLocation(response, state);
|
||||
if (resourceLocation !== undefined) {
|
||||
return {
|
||||
response: await poll(resourceLocation).catch(setStateError({ state, stateProxy })),
|
||||
status,
|
||||
};
|
||||
}
|
||||
}
|
||||
return { response, status };
|
||||
}
|
||||
/** Polls the long-running operation. */
|
||||
export async function pollOperation(inputs) {
|
||||
const { poll, state, stateProxy, options, getOperationStatus, getResourceLocation, getOperationLocation, withOperationLocation, getPollingInterval, processResult, updateState, setDelay, isDone, setErrorAsResult, } = inputs;
|
||||
const { operationLocation } = state.config;
|
||||
if (operationLocation !== undefined) {
|
||||
const { response, status } = await pollOperationHelper({
|
||||
poll,
|
||||
getOperationStatus,
|
||||
state,
|
||||
stateProxy,
|
||||
operationLocation,
|
||||
getResourceLocation,
|
||||
options,
|
||||
});
|
||||
processOperationStatus({
|
||||
status,
|
||||
response,
|
||||
state,
|
||||
stateProxy,
|
||||
isDone,
|
||||
processResult,
|
||||
setErrorAsResult,
|
||||
});
|
||||
if (!terminalStates.includes(status)) {
|
||||
const intervalInMs = getPollingInterval === null || getPollingInterval === void 0 ? void 0 : getPollingInterval(response);
|
||||
if (intervalInMs)
|
||||
setDelay(intervalInMs);
|
||||
const location = getOperationLocation === null || getOperationLocation === void 0 ? void 0 : getOperationLocation(response, state);
|
||||
if (location !== undefined) {
|
||||
const isUpdated = operationLocation !== location;
|
||||
state.config.operationLocation = location;
|
||||
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(location, isUpdated);
|
||||
}
|
||||
else
|
||||
withOperationLocation === null || withOperationLocation === void 0 ? void 0 : withOperationLocation(operationLocation, false);
|
||||
}
|
||||
updateState === null || updateState === void 0 ? void 0 : updateState(state, response);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=operation.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/poller/operation.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/poller/operation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
147
node_modules/@azure/core-lro/dist-esm/src/poller/poller.js
generated
vendored
Normal file
147
node_modules/@azure/core-lro/dist-esm/src/poller/poller.js
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
import { deserializeState, initOperation, pollOperation } from "./operation";
|
||||
import { POLL_INTERVAL_IN_MS } from "./constants";
|
||||
import { delayMs } from "./util/delayMs";
|
||||
const createStateProxy = () => ({
|
||||
/**
|
||||
* The state at this point is created to be of type OperationState<TResult>.
|
||||
* It will be updated later to be of type TState when the
|
||||
* customer-provided callback, `updateState`, is called during polling.
|
||||
*/
|
||||
initState: (config) => ({ status: "running", config }),
|
||||
setCanceled: (state) => (state.status = "canceled"),
|
||||
setError: (state, error) => (state.error = error),
|
||||
setResult: (state, result) => (state.result = result),
|
||||
setRunning: (state) => (state.status = "running"),
|
||||
setSucceeded: (state) => (state.status = "succeeded"),
|
||||
setFailed: (state) => (state.status = "failed"),
|
||||
getError: (state) => state.error,
|
||||
getResult: (state) => state.result,
|
||||
isCanceled: (state) => state.status === "canceled",
|
||||
isFailed: (state) => state.status === "failed",
|
||||
isRunning: (state) => state.status === "running",
|
||||
isSucceeded: (state) => state.status === "succeeded",
|
||||
});
|
||||
/**
|
||||
* Returns a poller factory.
|
||||
*/
|
||||
export function buildCreatePoller(inputs) {
|
||||
const { getOperationLocation, getStatusFromInitialResponse, getStatusFromPollResponse, getResourceLocation, getPollingInterval, resolveOnUnsuccessful, } = inputs;
|
||||
return async ({ init, poll }, options) => {
|
||||
const { processResult, updateState, withOperationLocation: withOperationLocationCallback, intervalInMs = POLL_INTERVAL_IN_MS, restoreFrom, } = options || {};
|
||||
const stateProxy = createStateProxy();
|
||||
const withOperationLocation = withOperationLocationCallback
|
||||
? (() => {
|
||||
let called = false;
|
||||
return (operationLocation, isUpdated) => {
|
||||
if (isUpdated)
|
||||
withOperationLocationCallback(operationLocation);
|
||||
else if (!called)
|
||||
withOperationLocationCallback(operationLocation);
|
||||
called = true;
|
||||
};
|
||||
})()
|
||||
: undefined;
|
||||
const state = restoreFrom
|
||||
? deserializeState(restoreFrom)
|
||||
: await initOperation({
|
||||
init,
|
||||
stateProxy,
|
||||
processResult,
|
||||
getOperationStatus: getStatusFromInitialResponse,
|
||||
withOperationLocation,
|
||||
setErrorAsResult: !resolveOnUnsuccessful,
|
||||
});
|
||||
let resultPromise;
|
||||
let cancelJob;
|
||||
const abortController = new AbortController();
|
||||
const handlers = new Map();
|
||||
const handleProgressEvents = async () => handlers.forEach((h) => h(state));
|
||||
let currentPollIntervalInMs = intervalInMs;
|
||||
const poller = {
|
||||
getOperationState: () => state,
|
||||
getResult: () => state.result,
|
||||
isDone: () => ["succeeded", "failed", "canceled"].includes(state.status),
|
||||
isStopped: () => resultPromise === undefined,
|
||||
stopPolling: () => {
|
||||
abortController.abort();
|
||||
cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob();
|
||||
},
|
||||
toString: () => JSON.stringify({
|
||||
state,
|
||||
}),
|
||||
onProgress: (callback) => {
|
||||
const s = Symbol();
|
||||
handlers.set(s, callback);
|
||||
return () => handlers.delete(s);
|
||||
},
|
||||
pollUntilDone: (pollOptions) => (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
|
||||
const { abortSignal: inputAbortSignal } = pollOptions || {};
|
||||
const { signal: abortSignal } = inputAbortSignal
|
||||
? new AbortController([inputAbortSignal, abortController.signal])
|
||||
: abortController;
|
||||
if (!poller.isDone()) {
|
||||
await poller.poll({ abortSignal });
|
||||
while (!poller.isDone()) {
|
||||
const delay = delayMs(currentPollIntervalInMs);
|
||||
cancelJob = delay.cancel;
|
||||
await delay;
|
||||
await poller.poll({ abortSignal });
|
||||
}
|
||||
}
|
||||
switch (state.status) {
|
||||
case "succeeded": {
|
||||
return poller.getResult();
|
||||
}
|
||||
case "canceled": {
|
||||
if (!resolveOnUnsuccessful)
|
||||
throw new Error("Operation was canceled");
|
||||
return poller.getResult();
|
||||
}
|
||||
case "failed": {
|
||||
if (!resolveOnUnsuccessful)
|
||||
throw state.error;
|
||||
return poller.getResult();
|
||||
}
|
||||
case "notStarted":
|
||||
case "running": {
|
||||
// Unreachable
|
||||
throw new Error(`polling completed without succeeding or failing`);
|
||||
}
|
||||
}
|
||||
})().finally(() => {
|
||||
resultPromise = undefined;
|
||||
}))),
|
||||
async poll(pollOptions) {
|
||||
await pollOperation({
|
||||
poll,
|
||||
state,
|
||||
stateProxy,
|
||||
getOperationLocation,
|
||||
withOperationLocation,
|
||||
getPollingInterval,
|
||||
getOperationStatus: getStatusFromPollResponse,
|
||||
getResourceLocation,
|
||||
processResult,
|
||||
updateState,
|
||||
options: pollOptions,
|
||||
setDelay: (pollIntervalInMs) => {
|
||||
currentPollIntervalInMs = pollIntervalInMs;
|
||||
},
|
||||
setErrorAsResult: !resolveOnUnsuccessful,
|
||||
});
|
||||
await handleProgressEvents();
|
||||
if (state.status === "canceled" && !resolveOnUnsuccessful) {
|
||||
throw new Error("Operation was canceled");
|
||||
}
|
||||
if (state.status === "failed" && !resolveOnUnsuccessful) {
|
||||
throw state.error;
|
||||
}
|
||||
},
|
||||
};
|
||||
return poller;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=poller.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/poller/poller.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/poller/poller.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
node_modules/@azure/core-lro/dist-esm/src/poller/util/delayMs.js
generated
vendored
Normal file
52
node_modules/@azure/core-lro/dist-esm/src/poller/util/delayMs.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* Map an optional value through a function
|
||||
* @internal
|
||||
*/
|
||||
const maybemap = (value, f) => value === undefined ? undefined : f(value);
|
||||
const INTERRUPTED = new Error("The poller is already stopped");
|
||||
/**
|
||||
* A promise that delays resolution until a certain amount of time (in milliseconds) has passed, with facilities for
|
||||
* robust cancellation.
|
||||
*
|
||||
* ### Example:
|
||||
*
|
||||
* ```javascript
|
||||
* let toCancel;
|
||||
*
|
||||
* // Wait 20 seconds, and optionally allow the function to be cancelled.
|
||||
* await delayMs(20000, (cancel) => { toCancel = cancel });
|
||||
*
|
||||
* // ... if `toCancel` is called before the 20 second timer expires, then the delayMs promise will reject.
|
||||
* ```
|
||||
*
|
||||
* @internal
|
||||
* @param ms - the number of milliseconds to wait before resolving
|
||||
* @param cb - a callback that can provide the caller with a cancellation function
|
||||
*/
|
||||
export function delayMs(ms) {
|
||||
let aborted = false;
|
||||
let toReject;
|
||||
return Object.assign(new Promise((resolve, reject) => {
|
||||
let token;
|
||||
toReject = () => {
|
||||
maybemap(token, clearTimeout);
|
||||
reject(INTERRUPTED);
|
||||
};
|
||||
// In the rare case that the operation is _already_ aborted, we will reject instantly. This could happen, for
|
||||
// example, if the user calls the cancellation function immediately without yielding execution.
|
||||
if (aborted) {
|
||||
toReject();
|
||||
}
|
||||
else {
|
||||
token = setTimeout(resolve, ms);
|
||||
}
|
||||
}), {
|
||||
cancel: () => {
|
||||
aborted = true;
|
||||
toReject === null || toReject === void 0 ? void 0 : toReject();
|
||||
},
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=delayMs.js.map
|
1
node_modules/@azure/core-lro/dist-esm/src/poller/util/delayMs.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-lro/dist-esm/src/poller/util/delayMs.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"delayMs.js","sourceRoot":"","sources":["../../../../src/poller/util/delayMs.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,QAAQ,GAAG,CAAS,KAAqB,EAAE,CAAgB,EAAkB,EAAE,CACnF,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAI7C,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AAa/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,QAAkC,CAAC;IAEvC,OAAO,MAAM,CAAC,MAAM,CAClB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,IAAI,KAAoC,CAAC;QACzC,QAAQ,GAAG,GAAG,EAAE;YACd,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAC9B,MAAM,CAAC,WAAW,CAAC,CAAC;QACtB,CAAC,CAAC;QAEF,6GAA6G;QAC7G,+FAA+F;QAC/F,IAAI,OAAO,EAAE;YACX,QAAQ,EAAE,CAAC;SACZ;aAAM;YACL,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjC;IACH,CAAC,CAAC,EACF;QACE,MAAM,EAAE,GAAG,EAAE;YACX,OAAO,GAAG,IAAI,CAAC;YACf,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAC;QACf,CAAC;KACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Map an optional value through a function\n * @internal\n */\nconst maybemap = <T1, T2>(value: T1 | undefined, f: (v: T1) => T2): T2 | undefined =>\n value === undefined ? undefined : f(value);\n\ntype CancellationToken = Parameters<typeof clearTimeout>[0];\n\nconst INTERRUPTED = new Error(\"The poller is already stopped\");\n\n/**\n * A PromiseLike object that supports cancellation.\n * @internal\n */\ninterface CancelablePromiseLike<T> extends PromiseLike<T> {\n /**\n * Cancel the promise (cause it to reject).\n */\n cancel(): void;\n}\n\n/**\n * A promise that delays resolution until a certain amount of time (in milliseconds) has passed, with facilities for\n * robust cancellation.\n *\n * ### Example:\n *\n * ```javascript\n * let toCancel;\n *\n * // Wait 20 seconds, and optionally allow the function to be cancelled.\n * await delayMs(20000, (cancel) => { toCancel = cancel });\n *\n * // ... if `toCancel` is called before the 20 second timer expires, then the delayMs promise will reject.\n * ```\n *\n * @internal\n * @param ms - the number of milliseconds to wait before resolving\n * @param cb - a callback that can provide the caller with a cancellation function\n */\nexport function delayMs(ms: number): CancelablePromiseLike<void> {\n let aborted = false;\n let toReject: (() => void) | undefined;\n\n return Object.assign(\n new Promise<void>((resolve, reject) => {\n let token: CancellationToken | undefined;\n toReject = () => {\n maybemap(token, clearTimeout);\n reject(INTERRUPTED);\n };\n\n // In the rare case that the operation is _already_ aborted, we will reject instantly. This could happen, for\n // example, if the user calls the cancellation function immediately without yielding execution.\n if (aborted) {\n toReject();\n } else {\n token = setTimeout(resolve, ms);\n }\n }),\n {\n cancel: () => {\n aborted = true;\n toReject?.();\n },\n }\n );\n}\n"]}
|
Loading…
Add table
Add a link
Reference in a new issue