@smithy/util-waiter 3.2.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +7 -9
- package/dist-es/utils/validate.js +3 -3
- package/package.json +4 -4
package/dist-cjs/index.js
CHANGED
|
@@ -79,7 +79,6 @@ var exponentialBackoffWithJitter = /* @__PURE__ */ __name((minDelay, maxDelay, a
|
|
|
79
79
|
}, "exponentialBackoffWithJitter");
|
|
80
80
|
var randomInRange = /* @__PURE__ */ __name((min, max) => min + Math.random() * (max - min), "randomInRange");
|
|
81
81
|
var runPolling = /* @__PURE__ */ __name(async ({ minDelay, maxDelay, maxWaitTime, abortController, client, abortSignal }, input, acceptorChecks) => {
|
|
82
|
-
var _a;
|
|
83
82
|
const observedResponses = {};
|
|
84
83
|
const { state, reason } = await acceptorChecks(client, input);
|
|
85
84
|
if (reason) {
|
|
@@ -94,7 +93,7 @@ var runPolling = /* @__PURE__ */ __name(async ({ minDelay, maxDelay, maxWaitTime
|
|
|
94
93
|
const waitUntil = Date.now() + maxWaitTime * 1e3;
|
|
95
94
|
const attemptCeiling = Math.log(maxDelay / minDelay) / Math.log(2) + 1;
|
|
96
95
|
while (true) {
|
|
97
|
-
if (
|
|
96
|
+
if (abortController?.signal?.aborted || abortSignal?.aborted) {
|
|
98
97
|
const message = "AbortController signal aborted.";
|
|
99
98
|
observedResponses[message] |= 0;
|
|
100
99
|
observedResponses[message] += 1;
|
|
@@ -118,26 +117,25 @@ var runPolling = /* @__PURE__ */ __name(async ({ minDelay, maxDelay, maxWaitTime
|
|
|
118
117
|
}
|
|
119
118
|
}, "runPolling");
|
|
120
119
|
var createMessageFromResponse = /* @__PURE__ */ __name((reason) => {
|
|
121
|
-
|
|
122
|
-
if (reason == null ? void 0 : reason.$responseBodyText) {
|
|
120
|
+
if (reason?.$responseBodyText) {
|
|
123
121
|
return `Deserialization error for body: ${reason.$responseBodyText}`;
|
|
124
122
|
}
|
|
125
|
-
if (
|
|
123
|
+
if (reason?.$metadata?.httpStatusCode) {
|
|
126
124
|
if (reason.$response || reason.message) {
|
|
127
125
|
return `${reason.$response.statusCode ?? reason.$metadata.httpStatusCode ?? "Unknown"}: ${reason.message}`;
|
|
128
126
|
}
|
|
129
127
|
return `${reason.$metadata.httpStatusCode}: OK`;
|
|
130
128
|
}
|
|
131
|
-
return String(
|
|
129
|
+
return String(reason?.message ?? JSON.stringify(reason) ?? "Unknown");
|
|
132
130
|
}, "createMessageFromResponse");
|
|
133
131
|
|
|
134
132
|
// src/utils/validate.ts
|
|
135
133
|
var validateWaiterOptions = /* @__PURE__ */ __name((options) => {
|
|
136
|
-
if (options.maxWaitTime
|
|
134
|
+
if (options.maxWaitTime <= 0) {
|
|
137
135
|
throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`);
|
|
138
|
-
} else if (options.minDelay
|
|
136
|
+
} else if (options.minDelay <= 0) {
|
|
139
137
|
throw new Error(`WaiterConfiguration.minDelay must be greater than 0`);
|
|
140
|
-
} else if (options.maxDelay
|
|
138
|
+
} else if (options.maxDelay <= 0) {
|
|
141
139
|
throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`);
|
|
142
140
|
} else if (options.maxWaitTime <= options.minDelay) {
|
|
143
141
|
throw new Error(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const validateWaiterOptions = (options) => {
|
|
2
|
-
if (options.maxWaitTime
|
|
2
|
+
if (options.maxWaitTime <= 0) {
|
|
3
3
|
throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`);
|
|
4
4
|
}
|
|
5
|
-
else if (options.minDelay
|
|
5
|
+
else if (options.minDelay <= 0) {
|
|
6
6
|
throw new Error(`WaiterConfiguration.minDelay must be greater than 0`);
|
|
7
7
|
}
|
|
8
|
-
else if (options.maxDelay
|
|
8
|
+
else if (options.maxDelay <= 0) {
|
|
9
9
|
throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`);
|
|
10
10
|
}
|
|
11
11
|
else if (options.maxWaitTime <= options.minDelay) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/util-waiter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Shared utilities for client waiters for the AWS SDK",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@smithy/abort-controller": "^
|
|
7
|
-
"@smithy/types": "^
|
|
6
|
+
"@smithy/abort-controller": "^4.0.0",
|
|
7
|
+
"@smithy/types": "^4.0.0",
|
|
8
8
|
"tslib": "^2.6.2"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"module": "./dist-es/index.js",
|
|
30
30
|
"types": "./dist-types/index.d.ts",
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"typesVersions": {
|
|
35
35
|
"<4.0": {
|