@smithy/util-waiter 1.0.1 → 1.0.3
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-types/ts3.4/createWaiter.d.ts +11 -0
- package/dist-types/ts3.4/index.d.ts +2 -0
- package/dist-types/ts3.4/poller.d.ts +10 -0
- package/dist-types/ts3.4/utils/index.d.ts +8 -0
- package/dist-types/ts3.4/utils/sleep.d.ts +4 -0
- package/dist-types/ts3.4/utils/validate.d.ts +8 -0
- package/dist-types/ts3.4/waiter.d.ts +44 -0
- package/package.json +4 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WaiterOptions, WaiterResult } from "./waiter";
|
|
2
|
+
/**
|
|
3
|
+
* Create a waiter promise that only resolves when:
|
|
4
|
+
* 1. Abort controller is signaled
|
|
5
|
+
* 2. Max wait time is reached
|
|
6
|
+
* 3. `acceptorChecks` succeeds, or fails
|
|
7
|
+
* Otherwise, it invokes `acceptorChecks` with exponential-backoff delay.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const createWaiter: <Client, Input>(options: WaiterOptions<Client>, input: Input, acceptorChecks: (client: Client, input: Input) => Promise<WaiterResult>) => Promise<WaiterResult>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WaiterOptions, WaiterResult } from "./waiter";
|
|
2
|
+
/**
|
|
3
|
+
* Function that runs polling as part of waiters. This will make one inital attempt and then
|
|
4
|
+
* subsequent attempts with an increasing delay.
|
|
5
|
+
* @param params - options passed to the waiter.
|
|
6
|
+
* @param client - AWS SDK Client
|
|
7
|
+
* @param input - client input
|
|
8
|
+
* @param stateChecker - function that checks the acceptor states on each poll.
|
|
9
|
+
*/
|
|
10
|
+
export declare const runPolling: <Client, Input>({ minDelay, maxDelay, maxWaitTime, abortController, client, abortSignal }: WaiterOptions<Client>, input: Input, acceptorChecks: (client: Client, input: Input) => Promise<WaiterResult>) => Promise<WaiterResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WaiterOptions } from "../waiter";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Validates that waiter options are passed correctly
|
|
6
|
+
* @param options - a waiter configuration object
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateWaiterOptions: <Client>(options: WaiterOptions<Client>) => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WaiterConfiguration as WaiterConfiguration__ } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export interface WaiterConfiguration<T> extends WaiterConfiguration__<T> {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const waiterServiceDefaults: {
|
|
11
|
+
minDelay: number;
|
|
12
|
+
maxDelay: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export type WaiterOptions<Client> = WaiterConfiguration<Client> & Required<Pick<WaiterConfiguration<Client>, "minDelay" | "maxDelay">>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare enum WaiterState {
|
|
22
|
+
ABORTED = "ABORTED",
|
|
23
|
+
FAILURE = "FAILURE",
|
|
24
|
+
SUCCESS = "SUCCESS",
|
|
25
|
+
RETRY = "RETRY",
|
|
26
|
+
TIMEOUT = "TIMEOUT"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export type WaiterResult = {
|
|
32
|
+
state: WaiterState;
|
|
33
|
+
/**
|
|
34
|
+
* (optional) Indicates a reason for why a waiter has reached its state.
|
|
35
|
+
*/
|
|
36
|
+
reason?: any;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*
|
|
41
|
+
* Handles and throws exceptions resulting from the waiterResult
|
|
42
|
+
* @param result - WaiterResult
|
|
43
|
+
*/
|
|
44
|
+
export declare const checkExceptions: (result: WaiterResult) => WaiterResult;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/util-waiter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Shared utilities for client waiters for the AWS SDK",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@smithy/abort-controller": "^1.0.
|
|
7
|
-
"@smithy/types": "^
|
|
6
|
+
"@smithy/abort-controller": "^1.0.3",
|
|
7
|
+
"@smithy/types": "^2.0.0",
|
|
8
8
|
"tslib": "^2.5.0"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
11
|
+
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
12
12
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
13
13
|
"build:es": "tsc -p tsconfig.es.json",
|
|
14
14
|
"build:types": "tsc -p tsconfig.types.json",
|