@azure/core-lro 3.3.2-alpha.20260311.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -15
- package/dist/browser/http/models.js.map +1 -1
- package/dist/browser/http/operation.js +1 -1
- package/dist/browser/http/operation.js.map +1 -1
- package/dist/commonjs/http/models.js +1 -0
- package/dist/commonjs/http/models.js.map +2 -2
- package/dist/commonjs/http/operation.js +2 -1
- package/dist/commonjs/http/operation.js.map +3 -3
- package/dist/commonjs/http/poller.js +1 -0
- package/dist/commonjs/http/poller.js.map +1 -1
- package/dist/commonjs/http/utils.js +1 -0
- package/dist/commonjs/http/utils.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/logger.js +1 -0
- package/dist/commonjs/logger.js.map +1 -1
- package/dist/commonjs/poller/constants.js +1 -0
- package/dist/commonjs/poller/constants.js.map +1 -1
- package/dist/commonjs/poller/models.js +1 -0
- package/dist/commonjs/poller/models.js.map +1 -1
- package/dist/commonjs/poller/operation.js +1 -0
- package/dist/commonjs/poller/operation.js.map +1 -1
- package/dist/commonjs/poller/poller.js +1 -0
- package/dist/commonjs/poller/poller.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/esm/http/models.js +4 -0
- package/dist/esm/http/models.js.map +1 -7
- package/dist/esm/http/operation.js +217 -219
- package/dist/esm/http/operation.js.map +1 -7
- package/dist/esm/http/poller.js +44 -58
- package/dist/esm/http/poller.js.map +1 -7
- package/dist/esm/http/utils.js +41 -32
- package/dist/esm/http/utils.js.map +1 -7
- package/dist/esm/index.js +5 -6
- package/dist/esm/index.js.map +1 -7
- package/dist/esm/logger.js +8 -4
- package/dist/esm/logger.js.map +1 -7
- package/dist/esm/poller/constants.js +11 -6
- package/dist/esm/poller/constants.js.map +1 -7
- package/dist/esm/poller/models.js +4 -0
- package/dist/esm/poller/models.js.map +1 -7
- package/dist/esm/poller/operation.js +150 -176
- package/dist/esm/poller/operation.js.map +1 -7
- package/dist/esm/poller/poller.js +176 -177
- package/dist/esm/poller/poller.js.map +1 -7
- package/dist/react-native/http/models.js.map +1 -1
- package/dist/react-native/http/operation.js +1 -1
- package/dist/react-native/http/operation.js.map +1 -1
- package/package.json +33 -22
|
@@ -1,259 +1,257 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
1
3
|
import { pollOperation } from "../poller/operation.js";
|
|
2
4
|
import { logger } from "../logger.js";
|
|
3
5
|
function getOperationLocationPollingUrl(inputs) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
const { azureAsyncOperation, operationLocation } = inputs;
|
|
7
|
+
return operationLocation ?? azureAsyncOperation;
|
|
6
8
|
}
|
|
7
9
|
function getLocationHeader(rawResponse) {
|
|
8
|
-
|
|
10
|
+
return rawResponse.headers["location"];
|
|
9
11
|
}
|
|
10
12
|
function getOperationLocationHeader(rawResponse) {
|
|
11
|
-
|
|
13
|
+
return rawResponse.headers["operation-location"];
|
|
12
14
|
}
|
|
13
15
|
function getAzureAsyncOperationHeader(rawResponse) {
|
|
14
|
-
|
|
16
|
+
return rawResponse.headers["azure-asyncoperation"];
|
|
15
17
|
}
|
|
16
18
|
function findResourceLocation(inputs) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
switch (requestMethod) {
|
|
22
|
-
case "PUT": {
|
|
23
|
-
return requestPath;
|
|
19
|
+
const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;
|
|
20
|
+
// If skipFinalGet is true, return undefined to skip the final GET request
|
|
21
|
+
if (skipFinalGet) {
|
|
22
|
+
return undefined;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
switch (requestMethod) {
|
|
25
|
+
case "PUT": {
|
|
26
|
+
return requestPath;
|
|
27
|
+
}
|
|
28
|
+
case "DELETE": {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
case "PATCH": {
|
|
32
|
+
return getDefault() ?? requestPath;
|
|
33
|
+
}
|
|
34
|
+
default: {
|
|
35
|
+
return getDefault();
|
|
36
|
+
}
|
|
27
37
|
}
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
function getDefault() {
|
|
39
|
+
switch (resourceLocationConfig) {
|
|
40
|
+
case "operation-location":
|
|
41
|
+
case "azure-async-operation": {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
case "original-uri": {
|
|
45
|
+
return requestPath;
|
|
46
|
+
}
|
|
47
|
+
case "location":
|
|
48
|
+
default: {
|
|
49
|
+
return location;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
30
52
|
}
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
}
|
|
54
|
+
export function inferLroMode(rawResponse, resourceLocationConfig, skipFinalGet) {
|
|
55
|
+
const requestPath = rawResponse.request.url;
|
|
56
|
+
const requestMethod = rawResponse.request.method;
|
|
57
|
+
const operationLocation = getOperationLocationHeader(rawResponse);
|
|
58
|
+
const azureAsyncOperation = getAzureAsyncOperationHeader(rawResponse);
|
|
59
|
+
const pollingUrl = getOperationLocationPollingUrl({ operationLocation, azureAsyncOperation });
|
|
60
|
+
const location = getLocationHeader(rawResponse);
|
|
61
|
+
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
|
|
62
|
+
if (pollingUrl !== undefined) {
|
|
63
|
+
return {
|
|
64
|
+
mode: "OperationLocation",
|
|
65
|
+
operationLocation: pollingUrl,
|
|
66
|
+
resourceLocation: findResourceLocation({
|
|
67
|
+
requestMethod: normalizedRequestMethod,
|
|
68
|
+
location,
|
|
69
|
+
requestPath,
|
|
70
|
+
resourceLocationConfig,
|
|
71
|
+
skipFinalGet,
|
|
72
|
+
}),
|
|
73
|
+
initialRequestUrl: requestPath,
|
|
74
|
+
requestMethod,
|
|
75
|
+
};
|
|
33
76
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
77
|
+
else if (location !== undefined) {
|
|
78
|
+
return {
|
|
79
|
+
mode: "ResourceLocation",
|
|
80
|
+
operationLocation: location,
|
|
81
|
+
initialRequestUrl: requestPath,
|
|
82
|
+
requestMethod,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
else if (normalizedRequestMethod === "PUT" && requestPath) {
|
|
86
|
+
return {
|
|
87
|
+
mode: "Body",
|
|
88
|
+
operationLocation: requestPath,
|
|
89
|
+
initialRequestUrl: requestPath,
|
|
90
|
+
requestMethod,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return undefined;
|
|
48
95
|
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function inferLroMode(rawResponse, resourceLocationConfig, skipFinalGet) {
|
|
52
|
-
const requestPath = rawResponse.request.url;
|
|
53
|
-
const requestMethod = rawResponse.request.method;
|
|
54
|
-
const operationLocation = getOperationLocationHeader(rawResponse);
|
|
55
|
-
const azureAsyncOperation = getAzureAsyncOperationHeader(rawResponse);
|
|
56
|
-
const pollingUrl = getOperationLocationPollingUrl({ operationLocation, azureAsyncOperation });
|
|
57
|
-
const location = getLocationHeader(rawResponse);
|
|
58
|
-
const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();
|
|
59
|
-
if (pollingUrl !== void 0) {
|
|
60
|
-
return {
|
|
61
|
-
mode: "OperationLocation",
|
|
62
|
-
operationLocation: pollingUrl,
|
|
63
|
-
resourceLocation: findResourceLocation({
|
|
64
|
-
requestMethod: normalizedRequestMethod,
|
|
65
|
-
location,
|
|
66
|
-
requestPath,
|
|
67
|
-
resourceLocationConfig,
|
|
68
|
-
skipFinalGet
|
|
69
|
-
}),
|
|
70
|
-
initialRequestUrl: requestPath,
|
|
71
|
-
requestMethod
|
|
72
|
-
};
|
|
73
|
-
} else if (location !== void 0) {
|
|
74
|
-
return {
|
|
75
|
-
mode: "ResourceLocation",
|
|
76
|
-
operationLocation: location,
|
|
77
|
-
initialRequestUrl: requestPath,
|
|
78
|
-
requestMethod
|
|
79
|
-
};
|
|
80
|
-
} else if (normalizedRequestMethod === "PUT" && requestPath) {
|
|
81
|
-
return {
|
|
82
|
-
mode: "Body",
|
|
83
|
-
operationLocation: requestPath,
|
|
84
|
-
initialRequestUrl: requestPath,
|
|
85
|
-
requestMethod
|
|
86
|
-
};
|
|
87
|
-
} else {
|
|
88
|
-
return void 0;
|
|
89
|
-
}
|
|
90
96
|
}
|
|
91
97
|
function transformStatus(inputs) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return "
|
|
111
|
-
}
|
|
112
|
-
return "running";
|
|
98
|
+
const { status, statusCode } = inputs;
|
|
99
|
+
if (typeof status !== "string" && status !== undefined) {
|
|
100
|
+
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.`);
|
|
101
|
+
}
|
|
102
|
+
logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);
|
|
103
|
+
const lowerCaseStatus = status?.toLocaleLowerCase();
|
|
104
|
+
if (!lowerCaseStatus) {
|
|
105
|
+
return toOperationStatus(statusCode);
|
|
106
|
+
}
|
|
107
|
+
if (lowerCaseStatus.includes("succeeded")) {
|
|
108
|
+
return "succeeded";
|
|
109
|
+
}
|
|
110
|
+
if (lowerCaseStatus.includes("fail")) {
|
|
111
|
+
return "failed";
|
|
112
|
+
}
|
|
113
|
+
if (["canceled", "cancelled"].includes(lowerCaseStatus)) {
|
|
114
|
+
return "canceled";
|
|
115
|
+
}
|
|
116
|
+
return "running";
|
|
113
117
|
}
|
|
114
118
|
function getStatus(rawResponse) {
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
const { status } = rawResponse.body ?? {};
|
|
120
|
+
return transformStatus({ status, statusCode: rawResponse.statusCode });
|
|
117
121
|
}
|
|
118
122
|
function getProvisioningState(rawResponse) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const { properties, provisioningState } = rawResponse.body ?? {};
|
|
124
|
+
const status = properties?.provisioningState ?? provisioningState;
|
|
125
|
+
return transformStatus({ status, statusCode: rawResponse.statusCode });
|
|
122
126
|
}
|
|
123
127
|
function toOperationStatus(statusCode) {
|
|
124
|
-
|
|
125
|
-
return "running";
|
|
126
|
-
} else if (statusCode < 300) {
|
|
127
|
-
return "succeeded";
|
|
128
|
-
} else {
|
|
129
|
-
return "failed";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function parseRetryAfter({ rawResponse }) {
|
|
133
|
-
const retryAfter = rawResponse.headers["retry-after"];
|
|
134
|
-
if (retryAfter !== void 0) {
|
|
135
|
-
const retryAfterInSeconds = parseInt(retryAfter);
|
|
136
|
-
return isNaN(retryAfterInSeconds) ? calculatePollingIntervalFromDate(new Date(retryAfter)) : retryAfterInSeconds * 1e3;
|
|
137
|
-
}
|
|
138
|
-
return void 0;
|
|
139
|
-
}
|
|
140
|
-
function getErrorFromResponse(response) {
|
|
141
|
-
const error = accessBodyProperty(response, "error");
|
|
142
|
-
if (!error) {
|
|
143
|
-
logger.warning(
|
|
144
|
-
`The long-running operation failed but there is no error property in the response's body`
|
|
145
|
-
);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!error.code || !error.message) {
|
|
149
|
-
logger.warning(
|
|
150
|
-
`The long-running operation failed but the error property in the response's body doesn't contain code or message`
|
|
151
|
-
);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
return error;
|
|
155
|
-
}
|
|
156
|
-
function calculatePollingIntervalFromDate(retryAfterDate) {
|
|
157
|
-
const timeNow = Math.floor((/* @__PURE__ */ new Date()).getTime());
|
|
158
|
-
const retryAfterTime = retryAfterDate.getTime();
|
|
159
|
-
if (timeNow < retryAfterTime) {
|
|
160
|
-
return retryAfterTime - timeNow;
|
|
161
|
-
}
|
|
162
|
-
return void 0;
|
|
163
|
-
}
|
|
164
|
-
function getStatusFromInitialResponse(inputs) {
|
|
165
|
-
const { response, state, operationLocation } = inputs;
|
|
166
|
-
function helper() {
|
|
167
|
-
const mode = state.config.metadata?.["mode"];
|
|
168
|
-
switch (mode) {
|
|
169
|
-
case void 0:
|
|
170
|
-
return toOperationStatus(response.rawResponse.statusCode);
|
|
171
|
-
case "Body":
|
|
172
|
-
return getOperationStatus(response, state);
|
|
173
|
-
default:
|
|
128
|
+
if (statusCode === 202) {
|
|
174
129
|
return "running";
|
|
175
130
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
131
|
+
else if (statusCode < 300) {
|
|
132
|
+
return "succeeded";
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return "failed";
|
|
136
|
+
}
|
|
179
137
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
138
|
+
export function parseRetryAfter({ rawResponse }) {
|
|
139
|
+
const retryAfter = rawResponse.headers["retry-after"];
|
|
140
|
+
if (retryAfter !== undefined) {
|
|
141
|
+
// Retry-After header value is either in HTTP date format, or in seconds
|
|
142
|
+
const retryAfterInSeconds = parseInt(retryAfter);
|
|
143
|
+
return isNaN(retryAfterInSeconds)
|
|
144
|
+
? calculatePollingIntervalFromDate(new Date(retryAfter))
|
|
145
|
+
: retryAfterInSeconds * 1000;
|
|
188
146
|
}
|
|
189
|
-
|
|
190
|
-
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
export function getErrorFromResponse(response) {
|
|
150
|
+
const error = accessBodyProperty(response, "error");
|
|
151
|
+
if (!error) {
|
|
152
|
+
logger.warning(`The long-running operation failed but there is no error property in the response's body`);
|
|
153
|
+
return;
|
|
191
154
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
155
|
+
if (!error.code || !error.message) {
|
|
156
|
+
logger.warning(`The long-running operation failed but the error property in the response's body doesn't contain code or message`);
|
|
157
|
+
return;
|
|
195
158
|
}
|
|
196
|
-
|
|
159
|
+
return error;
|
|
197
160
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
161
|
+
function calculatePollingIntervalFromDate(retryAfterDate) {
|
|
162
|
+
const timeNow = Math.floor(new Date().getTime());
|
|
163
|
+
const retryAfterTime = retryAfterDate.getTime();
|
|
164
|
+
if (timeNow < retryAfterTime) {
|
|
165
|
+
return retryAfterTime - timeNow;
|
|
203
166
|
}
|
|
204
|
-
|
|
205
|
-
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
export function getStatusFromInitialResponse(inputs) {
|
|
170
|
+
const { response, state, operationLocation } = inputs;
|
|
171
|
+
function helper() {
|
|
172
|
+
const mode = state.config.metadata?.["mode"];
|
|
173
|
+
switch (mode) {
|
|
174
|
+
case undefined:
|
|
175
|
+
return toOperationStatus(response.rawResponse.statusCode);
|
|
176
|
+
case "Body":
|
|
177
|
+
return getOperationStatus(response, state);
|
|
178
|
+
default:
|
|
179
|
+
return "running";
|
|
180
|
+
}
|
|
206
181
|
}
|
|
207
|
-
|
|
208
|
-
|
|
182
|
+
const status = helper();
|
|
183
|
+
return status === "running" && operationLocation === undefined ? "succeeded" : status;
|
|
184
|
+
}
|
|
185
|
+
export function getOperationLocation({ rawResponse }, state) {
|
|
186
|
+
const mode = state.config.metadata?.["mode"];
|
|
187
|
+
switch (mode) {
|
|
188
|
+
case "OperationLocation": {
|
|
189
|
+
return getOperationLocationPollingUrl({
|
|
190
|
+
operationLocation: getOperationLocationHeader(rawResponse),
|
|
191
|
+
azureAsyncOperation: getAzureAsyncOperationHeader(rawResponse),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
case "ResourceLocation": {
|
|
195
|
+
return getLocationHeader(rawResponse);
|
|
196
|
+
}
|
|
197
|
+
case "Body":
|
|
198
|
+
default: {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export function getOperationStatus({ rawResponse }, state) {
|
|
204
|
+
const mode = state.config.metadata?.["mode"];
|
|
205
|
+
switch (mode) {
|
|
206
|
+
case "OperationLocation": {
|
|
207
|
+
return getStatus(rawResponse);
|
|
208
|
+
}
|
|
209
|
+
case "ResourceLocation": {
|
|
210
|
+
return toOperationStatus(rawResponse.statusCode);
|
|
211
|
+
}
|
|
212
|
+
case "Body": {
|
|
213
|
+
return getProvisioningState(rawResponse);
|
|
214
|
+
}
|
|
215
|
+
default:
|
|
216
|
+
throw new Error(`Internal error: Unexpected operation mode: ${mode}`);
|
|
209
217
|
}
|
|
210
|
-
default:
|
|
211
|
-
throw new Error(`Internal error: Unexpected operation mode: ${mode}`);
|
|
212
|
-
}
|
|
213
218
|
}
|
|
214
219
|
function accessBodyProperty({ flatResponse, rawResponse }, prop) {
|
|
215
|
-
|
|
220
|
+
return flatResponse?.[prop] ?? rawResponse.body?.[prop];
|
|
216
221
|
}
|
|
217
|
-
function getResourceLocation(res, state) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
export function getResourceLocation(res, state) {
|
|
223
|
+
const loc = accessBodyProperty(res, "resourceLocation");
|
|
224
|
+
if (loc && typeof loc === "string") {
|
|
225
|
+
state.config.resourceLocation = loc;
|
|
226
|
+
}
|
|
227
|
+
return state.config.resourceLocation;
|
|
223
228
|
}
|
|
224
|
-
function isOperationError(e) {
|
|
225
|
-
|
|
229
|
+
export function isOperationError(e) {
|
|
230
|
+
return e.name === "RestError";
|
|
226
231
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
232
|
+
/** Polls the long-running operation. */
|
|
233
|
+
export async function pollHttpOperation(inputs) {
|
|
234
|
+
const { lro, options, processResult, updateState, setDelay, state, setErrorAsResult } = inputs;
|
|
235
|
+
return pollOperation({
|
|
236
|
+
state,
|
|
237
|
+
setDelay,
|
|
238
|
+
processResult: processResult
|
|
239
|
+
? ({ flatResponse }, inputState) => processResult(flatResponse, inputState)
|
|
240
|
+
: ({ flatResponse }) => flatResponse,
|
|
241
|
+
getError: getErrorFromResponse,
|
|
242
|
+
updateState,
|
|
243
|
+
getPollingInterval: parseRetryAfter,
|
|
244
|
+
getOperationLocation,
|
|
245
|
+
getOperationStatus,
|
|
246
|
+
isOperationError,
|
|
247
|
+
getResourceLocation,
|
|
248
|
+
options,
|
|
249
|
+
/**
|
|
250
|
+
* The expansion here is intentional because `lro` could be an object that
|
|
251
|
+
* references an inner this, so we need to preserve a reference to it.
|
|
252
|
+
*/
|
|
253
|
+
poll: (location, inputOptions) => lro.sendPollRequest(location, inputOptions),
|
|
254
|
+
setErrorAsResult,
|
|
255
|
+
});
|
|
248
256
|
}
|
|
249
|
-
|
|
250
|
-
getErrorFromResponse,
|
|
251
|
-
getOperationLocation,
|
|
252
|
-
getOperationStatus,
|
|
253
|
-
getResourceLocation,
|
|
254
|
-
getStatusFromInitialResponse,
|
|
255
|
-
inferLroMode,
|
|
256
|
-
isOperationError,
|
|
257
|
-
parseRetryAfter,
|
|
258
|
-
pollHttpOperation
|
|
259
|
-
};
|
|
257
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["/mnt/vss/_work/1/s/sdk/core/core-lro/src/http/operation.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpOperationMode,\n RunningOperation,\n ResourceLocationConfig,\n OperationResponse,\n RawResponse,\n ResponseBody,\n} from \"./models.js\";\nimport type {\n LroError,\n OperationConfig,\n OperationState,\n OperationStatus,\n RestorableOperationState,\n} from \"../poller/models.js\";\nimport { pollOperation } from \"../poller/operation.js\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { logger } from \"../logger.js\";\n\nfunction getOperationLocationPollingUrl(inputs: {\n operationLocation?: string;\n azureAsyncOperation?: string;\n}): string | undefined {\n const { azureAsyncOperation, operationLocation } = inputs;\n return operationLocation ?? azureAsyncOperation;\n}\n\nfunction getLocationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"location\"];\n}\n\nfunction getOperationLocationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"operation-location\"];\n}\n\nfunction getAzureAsyncOperationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"azure-asyncoperation\"];\n}\n\nfunction findResourceLocation(inputs: {\n requestMethod?: string;\n location?: string;\n requestPath?: string;\n resourceLocationConfig?: ResourceLocationConfig;\n skipFinalGet?: boolean;\n}): string | undefined {\n const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;\n\n // If skipFinalGet is true, return undefined to skip the final GET request\n if (skipFinalGet) {\n return undefined;\n }\n\n switch (requestMethod) {\n case \"PUT\": {\n return requestPath;\n }\n case \"DELETE\": {\n return undefined;\n }\n case \"PATCH\": {\n return getDefault() ?? requestPath;\n }\n default: {\n return getDefault();\n }\n }\n\n function getDefault(): string | undefined {\n switch (resourceLocationConfig) {\n case \"operation-location\":\n case \"azure-async-operation\": {\n return undefined;\n }\n case \"original-uri\": {\n return requestPath;\n }\n case \"location\":\n default: {\n return location;\n }\n }\n }\n}\n\nexport function inferLroMode(\n rawResponse: RawResponse,\n resourceLocationConfig?: ResourceLocationConfig,\n skipFinalGet?: boolean,\n): (OperationConfig & { mode: HttpOperationMode }) | undefined {\n const requestPath = rawResponse.request.url;\n const requestMethod = rawResponse.request.method;\n const operationLocation = getOperationLocationHeader(rawResponse);\n const azureAsyncOperation = getAzureAsyncOperationHeader(rawResponse);\n const pollingUrl = getOperationLocationPollingUrl({ operationLocation, azureAsyncOperation });\n const location = getLocationHeader(rawResponse);\n const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();\n if (pollingUrl !== undefined) {\n return {\n mode: \"OperationLocation\",\n operationLocation: pollingUrl,\n resourceLocation: findResourceLocation({\n requestMethod: normalizedRequestMethod,\n location,\n requestPath,\n resourceLocationConfig,\n skipFinalGet,\n }),\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else if (location !== undefined) {\n return {\n mode: \"ResourceLocation\",\n operationLocation: location,\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else if (normalizedRequestMethod === \"PUT\" && requestPath) {\n return {\n mode: \"Body\",\n operationLocation: requestPath,\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else {\n return undefined;\n }\n}\n\nfunction transformStatus(inputs: { status: unknown; statusCode: number }): OperationStatus {\n const { status, statusCode } = inputs;\n if (typeof status !== \"string\" && status !== undefined) {\n throw new Error(\n `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.`,\n );\n }\n logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);\n const lowerCaseStatus = status?.toLocaleLowerCase();\n if (!lowerCaseStatus) {\n return toOperationStatus(statusCode);\n }\n if (lowerCaseStatus.includes(\"succeeded\")) {\n return \"succeeded\";\n }\n if (lowerCaseStatus.includes(\"fail\")) {\n return \"failed\";\n }\n if ([\"canceled\", \"cancelled\"].includes(lowerCaseStatus)) {\n return \"canceled\";\n }\n return \"running\";\n}\n\nfunction getStatus(rawResponse: RawResponse): OperationStatus {\n const { status } = (rawResponse.body as ResponseBody) ?? {};\n return transformStatus({ status, statusCode: rawResponse.statusCode });\n}\n\nfunction getProvisioningState(rawResponse: RawResponse): OperationStatus {\n const { properties, provisioningState } = (rawResponse.body as ResponseBody) ?? {};\n const status = properties?.provisioningState ?? provisioningState;\n return transformStatus({ status, statusCode: rawResponse.statusCode });\n}\n\nfunction toOperationStatus(statusCode: number): OperationStatus {\n if (statusCode === 202) {\n return \"running\";\n } else if (statusCode < 300) {\n return \"succeeded\";\n } else {\n return \"failed\";\n }\n}\n\nexport function parseRetryAfter<T>({ rawResponse }: OperationResponse<T>): number | undefined {\n const retryAfter: string | undefined = rawResponse.headers[\"retry-after\"];\n if (retryAfter !== undefined) {\n // Retry-After header value is either in HTTP date format, or in seconds\n const retryAfterInSeconds = parseInt(retryAfter);\n return isNaN(retryAfterInSeconds)\n ? calculatePollingIntervalFromDate(new Date(retryAfter))\n : retryAfterInSeconds * 1000;\n }\n return undefined;\n}\n\nexport function getErrorFromResponse<T>(response: OperationResponse<T>): LroError | undefined {\n const error = accessBodyProperty(response, \"error\");\n if (!error) {\n logger.warning(\n `The long-running operation failed but there is no error property in the response's body`,\n );\n return;\n }\n if (!error.code || !error.message) {\n logger.warning(\n `The long-running operation failed but the error property in the response's body doesn't contain code or message`,\n );\n return;\n }\n return error as LroError;\n}\n\nfunction calculatePollingIntervalFromDate(retryAfterDate: Date): number | undefined {\n const timeNow = Math.floor(new Date().getTime());\n const retryAfterTime = retryAfterDate.getTime();\n if (timeNow < retryAfterTime) {\n return retryAfterTime - timeNow;\n }\n return undefined;\n}\n\nexport function getStatusFromInitialResponse<\n TResult,\n TState extends OperationState<TResult>,\n>(inputs: {\n response: OperationResponse<unknown>;\n state: RestorableOperationState<TResult, TState>;\n operationLocation?: string;\n}): OperationStatus {\n const { response, state, operationLocation } = inputs;\n function helper(): OperationStatus {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case undefined:\n return toOperationStatus(response.rawResponse.statusCode);\n case \"Body\":\n return getOperationStatus(response, state);\n default:\n return \"running\";\n }\n }\n const status = helper();\n return status === \"running\" && operationLocation === undefined ? \"succeeded\" : status;\n}\n\nexport function getOperationLocation<TResult, TState extends OperationState<TResult>>(\n { rawResponse }: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): string | undefined {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case \"OperationLocation\": {\n return getOperationLocationPollingUrl({\n operationLocation: getOperationLocationHeader(rawResponse),\n azureAsyncOperation: getAzureAsyncOperationHeader(rawResponse),\n });\n }\n case \"ResourceLocation\": {\n return getLocationHeader(rawResponse);\n }\n case \"Body\":\n default: {\n return undefined;\n }\n }\n}\n\nexport function getOperationStatus<TResult, TState extends OperationState<TResult>>(\n { rawResponse }: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): OperationStatus {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case \"OperationLocation\": {\n return getStatus(rawResponse);\n }\n case \"ResourceLocation\": {\n return toOperationStatus(rawResponse.statusCode);\n }\n case \"Body\": {\n return getProvisioningState(rawResponse);\n }\n default:\n throw new Error(`Internal error: Unexpected operation mode: ${mode}`);\n }\n}\n\nfunction accessBodyProperty<P extends string>(\n { flatResponse, rawResponse }: OperationResponse,\n prop: P,\n): ResponseBody[P] {\n return (flatResponse as ResponseBody)?.[prop] ?? (rawResponse.body as ResponseBody)?.[prop];\n}\n\nexport function getResourceLocation<TResult, TState extends OperationState<TResult>>(\n res: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): string | undefined {\n const loc = accessBodyProperty(res, \"resourceLocation\");\n if (loc && typeof loc === \"string\") {\n state.config.resourceLocation = loc;\n }\n return state.config.resourceLocation;\n}\n\nexport function isOperationError(e: Error): boolean {\n return e.name === \"RestError\";\n}\n\n/** Polls the long-running operation. */\nexport async function pollHttpOperation<TState extends OperationState<TResult>, TResult>(inputs: {\n lro: RunningOperation;\n processResult?: (result: unknown, state: TState) => Promise<TResult>;\n updateState?: (state: TState, lastResponse: OperationResponse) => void;\n isDone?: (lastResponse: OperationResponse, state: TState) => boolean;\n setDelay: (intervalInMs: number) => void;\n options?: { abortSignal?: AbortSignalLike };\n state: RestorableOperationState<TResult, TState>;\n setErrorAsResult: boolean;\n}): Promise<void> {\n const { lro, options, processResult, updateState, setDelay, state, setErrorAsResult } = inputs;\n return pollOperation({\n state,\n setDelay,\n processResult: processResult\n ? ({ flatResponse }, inputState) => processResult(flatResponse, inputState)\n : ({ flatResponse }) => flatResponse as Promise<TResult>,\n getError: getErrorFromResponse,\n updateState,\n getPollingInterval: parseRetryAfter,\n getOperationLocation,\n getOperationStatus,\n isOperationError,\n getResourceLocation,\n options,\n /**\n * The expansion here is intentional because `lro` could be an object that\n * references an inner this, so we need to preserve a reference to it.\n */\n poll: async (location: string, inputOptions?: { abortSignal?: AbortSignalLike }) =>\n lro.sendPollRequest(location, inputOptions),\n setErrorAsResult,\n });\n}\n"],
|
|
5
|
-
"mappings": "AAkBA,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AAEvB,SAAS,+BAA+B,QAGjB;AACrB,QAAM,EAAE,qBAAqB,kBAAkB,IAAI;AACnD,SAAO,qBAAqB;AAC9B;AAEA,SAAS,kBAAkB,aAA8C;AACvE,SAAO,YAAY,QAAQ,UAAU;AACvC;AAEA,SAAS,2BAA2B,aAA8C;AAChF,SAAO,YAAY,QAAQ,oBAAoB;AACjD;AAEA,SAAS,6BAA6B,aAA8C;AAClF,SAAO,YAAY,QAAQ,sBAAsB;AACnD;AAEA,SAAS,qBAAqB,QAMP;AACrB,QAAM,EAAE,UAAU,eAAe,aAAa,wBAAwB,aAAa,IAAI;AAGvF,MAAI,cAAc;AAChB,WAA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C,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpOperationMode,\n RunningOperation,\n ResourceLocationConfig,\n OperationResponse,\n RawResponse,\n ResponseBody,\n} from \"./models.js\";\nimport type {\n LroError,\n OperationConfig,\n OperationState,\n OperationStatus,\n RestorableOperationState,\n} from \"../poller/models.js\";\nimport { pollOperation } from \"../poller/operation.js\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { logger } from \"../logger.js\";\n\nfunction getOperationLocationPollingUrl(inputs: {\n operationLocation?: string;\n azureAsyncOperation?: string;\n}): string | undefined {\n const { azureAsyncOperation, operationLocation } = inputs;\n return operationLocation ?? azureAsyncOperation;\n}\n\nfunction getLocationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"location\"];\n}\n\nfunction getOperationLocationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"operation-location\"];\n}\n\nfunction getAzureAsyncOperationHeader(rawResponse: RawResponse): string | undefined {\n return rawResponse.headers[\"azure-asyncoperation\"];\n}\n\nfunction findResourceLocation(inputs: {\n requestMethod?: string;\n location?: string;\n requestPath?: string;\n resourceLocationConfig?: ResourceLocationConfig;\n skipFinalGet?: boolean;\n}): string | undefined {\n const { location, requestMethod, requestPath, resourceLocationConfig, skipFinalGet } = inputs;\n\n // If skipFinalGet is true, return undefined to skip the final GET request\n if (skipFinalGet) {\n return undefined;\n }\n\n switch (requestMethod) {\n case \"PUT\": {\n return requestPath;\n }\n case \"DELETE\": {\n return undefined;\n }\n case \"PATCH\": {\n return getDefault() ?? requestPath;\n }\n default: {\n return getDefault();\n }\n }\n\n function getDefault(): string | undefined {\n switch (resourceLocationConfig) {\n case \"operation-location\":\n case \"azure-async-operation\": {\n return undefined;\n }\n case \"original-uri\": {\n return requestPath;\n }\n case \"location\":\n default: {\n return location;\n }\n }\n }\n}\n\nexport function inferLroMode(\n rawResponse: RawResponse,\n resourceLocationConfig?: ResourceLocationConfig,\n skipFinalGet?: boolean,\n): (OperationConfig & { mode: HttpOperationMode }) | undefined {\n const requestPath = rawResponse.request.url;\n const requestMethod = rawResponse.request.method;\n const operationLocation = getOperationLocationHeader(rawResponse);\n const azureAsyncOperation = getAzureAsyncOperationHeader(rawResponse);\n const pollingUrl = getOperationLocationPollingUrl({ operationLocation, azureAsyncOperation });\n const location = getLocationHeader(rawResponse);\n const normalizedRequestMethod = requestMethod?.toLocaleUpperCase();\n if (pollingUrl !== undefined) {\n return {\n mode: \"OperationLocation\",\n operationLocation: pollingUrl,\n resourceLocation: findResourceLocation({\n requestMethod: normalizedRequestMethod,\n location,\n requestPath,\n resourceLocationConfig,\n skipFinalGet,\n }),\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else if (location !== undefined) {\n return {\n mode: \"ResourceLocation\",\n operationLocation: location,\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else if (normalizedRequestMethod === \"PUT\" && requestPath) {\n return {\n mode: \"Body\",\n operationLocation: requestPath,\n initialRequestUrl: requestPath,\n requestMethod,\n };\n } else {\n return undefined;\n }\n}\n\nfunction transformStatus(inputs: { status: unknown; statusCode: number }): OperationStatus {\n const { status, statusCode } = inputs;\n if (typeof status !== \"string\" && status !== undefined) {\n throw new Error(\n `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.`,\n );\n }\n logger.verbose(`LRO: Transforming status: ${status} with status code: ${statusCode}.`);\n const lowerCaseStatus = status?.toLocaleLowerCase();\n if (!lowerCaseStatus) {\n return toOperationStatus(statusCode);\n }\n if (lowerCaseStatus.includes(\"succeeded\")) {\n return \"succeeded\";\n }\n if (lowerCaseStatus.includes(\"fail\")) {\n return \"failed\";\n }\n if ([\"canceled\", \"cancelled\"].includes(lowerCaseStatus)) {\n return \"canceled\";\n }\n return \"running\";\n}\n\nfunction getStatus(rawResponse: RawResponse): OperationStatus {\n const { status } = (rawResponse.body as ResponseBody) ?? {};\n return transformStatus({ status, statusCode: rawResponse.statusCode });\n}\n\nfunction getProvisioningState(rawResponse: RawResponse): OperationStatus {\n const { properties, provisioningState } = (rawResponse.body as ResponseBody) ?? {};\n const status = properties?.provisioningState ?? provisioningState;\n return transformStatus({ status, statusCode: rawResponse.statusCode });\n}\n\nfunction toOperationStatus(statusCode: number): OperationStatus {\n if (statusCode === 202) {\n return \"running\";\n } else if (statusCode < 300) {\n return \"succeeded\";\n } else {\n return \"failed\";\n }\n}\n\nexport function parseRetryAfter<T>({ rawResponse }: OperationResponse<T>): number | undefined {\n const retryAfter: string | undefined = rawResponse.headers[\"retry-after\"];\n if (retryAfter !== undefined) {\n // Retry-After header value is either in HTTP date format, or in seconds\n const retryAfterInSeconds = parseInt(retryAfter);\n return isNaN(retryAfterInSeconds)\n ? calculatePollingIntervalFromDate(new Date(retryAfter))\n : retryAfterInSeconds * 1000;\n }\n return undefined;\n}\n\nexport function getErrorFromResponse<T>(response: OperationResponse<T>): LroError | undefined {\n const error = accessBodyProperty(response, \"error\");\n if (!error) {\n logger.warning(\n `The long-running operation failed but there is no error property in the response's body`,\n );\n return;\n }\n if (!error.code || !error.message) {\n logger.warning(\n `The long-running operation failed but the error property in the response's body doesn't contain code or message`,\n );\n return;\n }\n return error as LroError;\n}\n\nfunction calculatePollingIntervalFromDate(retryAfterDate: Date): number | undefined {\n const timeNow = Math.floor(new Date().getTime());\n const retryAfterTime = retryAfterDate.getTime();\n if (timeNow < retryAfterTime) {\n return retryAfterTime - timeNow;\n }\n return undefined;\n}\n\nexport function getStatusFromInitialResponse<\n TResult,\n TState extends OperationState<TResult>,\n>(inputs: {\n response: OperationResponse<unknown>;\n state: RestorableOperationState<TResult, TState>;\n operationLocation?: string;\n}): OperationStatus {\n const { response, state, operationLocation } = inputs;\n function helper(): OperationStatus {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case undefined:\n return toOperationStatus(response.rawResponse.statusCode);\n case \"Body\":\n return getOperationStatus(response, state);\n default:\n return \"running\";\n }\n }\n const status = helper();\n return status === \"running\" && operationLocation === undefined ? \"succeeded\" : status;\n}\n\nexport function getOperationLocation<TResult, TState extends OperationState<TResult>>(\n { rawResponse }: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): string | undefined {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case \"OperationLocation\": {\n return getOperationLocationPollingUrl({\n operationLocation: getOperationLocationHeader(rawResponse),\n azureAsyncOperation: getAzureAsyncOperationHeader(rawResponse),\n });\n }\n case \"ResourceLocation\": {\n return getLocationHeader(rawResponse);\n }\n case \"Body\":\n default: {\n return undefined;\n }\n }\n}\n\nexport function getOperationStatus<TResult, TState extends OperationState<TResult>>(\n { rawResponse }: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): OperationStatus {\n const mode = state.config.metadata?.[\"mode\"];\n switch (mode) {\n case \"OperationLocation\": {\n return getStatus(rawResponse);\n }\n case \"ResourceLocation\": {\n return toOperationStatus(rawResponse.statusCode);\n }\n case \"Body\": {\n return getProvisioningState(rawResponse);\n }\n default:\n throw new Error(`Internal error: Unexpected operation mode: ${mode}`);\n }\n}\n\nfunction accessBodyProperty<P extends string>(\n { flatResponse, rawResponse }: OperationResponse,\n prop: P,\n): ResponseBody[P] {\n return (flatResponse as ResponseBody)?.[prop] ?? (rawResponse.body as ResponseBody)?.[prop];\n}\n\nexport function getResourceLocation<TResult, TState extends OperationState<TResult>>(\n res: OperationResponse,\n state: RestorableOperationState<TResult, TState>,\n): string | undefined {\n const loc = accessBodyProperty(res, \"resourceLocation\");\n if (loc && typeof loc === \"string\") {\n state.config.resourceLocation = loc;\n }\n return state.config.resourceLocation;\n}\n\nexport function isOperationError(e: Error): boolean {\n return e.name === \"RestError\";\n}\n\n/** Polls the long-running operation. */\nexport async function pollHttpOperation<TState extends OperationState<TResult>, TResult>(inputs: {\n lro: RunningOperation;\n processResult?: (result: unknown, state: TState) => Promise<TResult>;\n updateState?: (state: TState, lastResponse: OperationResponse) => void;\n isDone?: (lastResponse: OperationResponse, state: TState) => boolean;\n setDelay: (intervalInMs: number) => void;\n options?: { abortSignal?: AbortSignalLike };\n state: RestorableOperationState<TResult, TState>;\n setErrorAsResult: boolean;\n}): Promise<void> {\n const { lro, options, processResult, updateState, setDelay, state, setErrorAsResult } = inputs;\n return pollOperation({\n state,\n setDelay,\n processResult: processResult\n ? ({ flatResponse }, inputState) => processResult(flatResponse, inputState)\n : ({ flatResponse }) => flatResponse as Promise<TResult>,\n getError: getErrorFromResponse,\n updateState,\n getPollingInterval: parseRetryAfter,\n getOperationLocation,\n getOperationStatus,\n isOperationError,\n getResourceLocation,\n options,\n /**\n * The expansion here is intentional because `lro` could be an object that\n * references an inner this, so we need to preserve a reference to it.\n */\n poll: (location: string, inputOptions?: { abortSignal?: AbortSignalLike }) =>\n lro.sendPollRequest(location, inputOptions),\n setErrorAsResult,\n });\n}\n"]}
|