mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-26 21:35:35 +00:00
"update dependencies and changelog"
This commit is contained in:
parent
7c7e41ab01
commit
865fd1f6db
4 changed files with 130 additions and 34 deletions
56
dist/save/index.js
vendored
56
dist/save/index.js
vendored
|
@ -14634,16 +14634,45 @@ function setStateError(inputs) {
|
|||
throw error;
|
||||
};
|
||||
}
|
||||
function appendReadableErrorMessage(currentMessage, innerMessage) {
|
||||
let message = currentMessage;
|
||||
if (message.slice(-1) !== ".") {
|
||||
message = message + ".";
|
||||
}
|
||||
return message + " " + innerMessage;
|
||||
}
|
||||
function simplifyError(err) {
|
||||
let message = err.message;
|
||||
let code = err.code;
|
||||
let curErr = err;
|
||||
while (curErr.innererror) {
|
||||
curErr = curErr.innererror;
|
||||
code = curErr.code;
|
||||
message = appendReadableErrorMessage(message, curErr.message);
|
||||
}
|
||||
return {
|
||||
code,
|
||||
message,
|
||||
};
|
||||
}
|
||||
function processOperationStatus(result) {
|
||||
const { state, stateProxy, status, isDone, processResult, response, setErrorAsResult } = result;
|
||||
const { state, stateProxy, status, isDone, processResult, getError, response, setErrorAsResult } = result;
|
||||
switch (status) {
|
||||
case "succeeded": {
|
||||
stateProxy.setSucceeded(state);
|
||||
break;
|
||||
}
|
||||
case "failed": {
|
||||
stateProxy.setError(state, new Error(`The long-running operation has failed`));
|
||||
const err = getError === null || getError === void 0 ? void 0 : getError(response);
|
||||
let postfix = "";
|
||||
if (err) {
|
||||
const { code, message } = simplifyError(err);
|
||||
postfix = `. ${code}. ${message}`;
|
||||
}
|
||||
const errStr = `The long-running operation has failed${postfix}`;
|
||||
stateProxy.setError(state, new Error(errStr));
|
||||
stateProxy.setFailed(state);
|
||||
logger.warning(errStr);
|
||||
break;
|
||||
}
|
||||
case "canceled": {
|
||||
|
@ -14706,7 +14735,7 @@ async function pollOperationHelper(inputs) {
|
|||
}
|
||||
/** Polls the long-running operation. */
|
||||
async function pollOperation(inputs) {
|
||||
const { poll, state, stateProxy, options, getOperationStatus, getResourceLocation, getOperationLocation, isOperationError, withOperationLocation, getPollingInterval, processResult, updateState, setDelay, isDone, setErrorAsResult, } = inputs;
|
||||
const { poll, state, stateProxy, options, getOperationStatus, getResourceLocation, getOperationLocation, isOperationError, withOperationLocation, getPollingInterval, processResult, getError, updateState, setDelay, isDone, setErrorAsResult, } = inputs;
|
||||
const { operationLocation } = state.config;
|
||||
if (operationLocation !== undefined) {
|
||||
const { response, status } = await pollOperationHelper({
|
||||
|
@ -14726,6 +14755,7 @@ async function pollOperation(inputs) {
|
|||
stateProxy,
|
||||
isDone,
|
||||
processResult,
|
||||
getError,
|
||||
setErrorAsResult,
|
||||
});
|
||||
if (!terminalStates.includes(status)) {
|
||||
|
@ -14879,6 +14909,18 @@ function parseRetryAfter({ rawResponse }) {
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
function getErrorFromResponse(response) {
|
||||
const error = response.flatResponse.error;
|
||||
if (!error) {
|
||||
logger.warning(`The long-running operation failed but there is no error property in the response's body`);
|
||||
return;
|
||||
}
|
||||
if (!error.code || !error.message) {
|
||||
logger.warning(`The long-running operation failed but the error property in the response's body doesn't contain code or message`);
|
||||
return;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
function calculatePollingIntervalFromDate(retryAfterDate) {
|
||||
const timeNow = Math.floor(new Date().getTime());
|
||||
const retryAfterTime = retryAfterDate.getTime();
|
||||
|
@ -14986,6 +15028,7 @@ async function pollHttpOperation(inputs) {
|
|||
processResult: processResult
|
||||
? ({ flatResponse }, inputState) => processResult(flatResponse, inputState)
|
||||
: ({ flatResponse }) => flatResponse,
|
||||
getError: getErrorFromResponse,
|
||||
updateState,
|
||||
getPollingInterval: parseRetryAfter,
|
||||
getOperationLocation,
|
||||
|
@ -15027,7 +15070,7 @@ const createStateProxy$1 = () => ({
|
|||
* Returns a poller factory.
|
||||
*/
|
||||
function buildCreatePoller(inputs) {
|
||||
const { getOperationLocation, getStatusFromInitialResponse, getStatusFromPollResponse, isOperationError, getResourceLocation, getPollingInterval, resolveOnUnsuccessful, } = inputs;
|
||||
const { getOperationLocation, getStatusFromInitialResponse, getStatusFromPollResponse, isOperationError, getResourceLocation, getPollingInterval, getError, resolveOnUnsuccessful, } = inputs;
|
||||
return async ({ init, poll }, options) => {
|
||||
const { processResult, updateState, withOperationLocation: withOperationLocationCallback, intervalInMs = POLL_INTERVAL_IN_MS, restoreFrom, } = options || {};
|
||||
const stateProxy = createStateProxy$1();
|
||||
|
@ -15132,6 +15175,7 @@ function buildCreatePoller(inputs) {
|
|||
getOperationStatus: getStatusFromPollResponse,
|
||||
getResourceLocation,
|
||||
processResult,
|
||||
getError,
|
||||
updateState,
|
||||
options: pollOptions,
|
||||
setDelay: (pollIntervalInMs) => {
|
||||
|
@ -15170,6 +15214,7 @@ async function createHttpPoller(lro, options) {
|
|||
getOperationLocation,
|
||||
getResourceLocation,
|
||||
getPollingInterval: parseRetryAfter,
|
||||
getError: getErrorFromResponse,
|
||||
resolveOnUnsuccessful,
|
||||
})({
|
||||
init: async () => {
|
||||
|
@ -16255,6 +16300,9 @@ function objectHasProperty(thing, property) {
|
|||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/*
|
||||
* NOTE: When moving this file, please update "react-native" section in package.json.
|
||||
*/
|
||||
/**
|
||||
* Generated Universally Unique Identifier
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue