@vertexvis/api-client-node 0.22.1 → 0.22.2
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/client/helpers/queued-jobs.d.ts +1 -1
- package/dist/cjs/client/helpers/queued-jobs.js +7 -4
- package/dist/cjs/client/index.d.ts +5 -0
- package/dist/esm/client/helpers/queued-jobs.d.ts +1 -1
- package/dist/esm/client/helpers/queued-jobs.js +7 -4
- package/dist/esm/client/index.d.ts +5 -0
- package/package.json +2 -2
|
@@ -32,7 +32,7 @@ interface PollJobRes<T> {
|
|
|
32
32
|
* @param req - {@link PollQueuedJobReq}.
|
|
33
33
|
* @returns {@link PollQueuedJobRes}.
|
|
34
34
|
*/
|
|
35
|
-
export declare function pollQueuedJob<T>({ id, getQueuedJob, allow404, limit, polling: { intervalMs, maxAttempts }, }: PollQueuedJobReq): Promise<PollQueuedJobRes<T>>;
|
|
35
|
+
export declare function pollQueuedJob<T>({ id, getQueuedJob, allow404, limit, polling: { intervalMs, maxAttempts, backoff }, }: PollQueuedJobReq): Promise<PollQueuedJobRes<T>>;
|
|
36
36
|
export declare function isPollError<T>(r: PollRes<T>): r is QueuedJob | Failure;
|
|
37
37
|
export declare function isBatch(obj: PollRes<Batch>): obj is Batch;
|
|
38
38
|
export declare function throwOnError<T>(r: PollQueuedJobRes<T>): never;
|
|
@@ -29,7 +29,8 @@ const Debug = false;
|
|
|
29
29
|
* @param req - {@link PollQueuedJobReq}.
|
|
30
30
|
* @returns {@link PollQueuedJobRes}.
|
|
31
31
|
*/
|
|
32
|
-
function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { intervalMs, maxAttempts }, }) {
|
|
32
|
+
function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { intervalMs, maxAttempts, backoff }, }) {
|
|
33
|
+
var _a, _b;
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
function poll(attempt) {
|
|
35
36
|
var _a, _b;
|
|
@@ -72,7 +73,8 @@ function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { i
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
let attempts = 1;
|
|
75
|
-
let
|
|
76
|
+
let backoffMs = (_a = backoff === null || backoff === void 0 ? void 0 : backoff[attempts]) !== null && _a !== void 0 ? _a : 0;
|
|
77
|
+
const pollRes = yield poll(attempts);
|
|
76
78
|
/* eslint-disable no-await-in-loop */
|
|
77
79
|
while (!completeJob(pollRes.res) &&
|
|
78
80
|
(allowed404(allow404, pollRes.status) ||
|
|
@@ -80,8 +82,9 @@ function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { i
|
|
|
80
82
|
isClientError(pollRes.res)) &&
|
|
81
83
|
attempts <= maxAttempts) {
|
|
82
84
|
attempts += 1;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
backoffMs = (_b = backoff === null || backoff === void 0 ? void 0 : backoff[attempts]) !== null && _b !== void 0 ? _b : backoffMs;
|
|
86
|
+
yield (0, utils_1.delay)(intervalMs + backoffMs);
|
|
87
|
+
yield poll(attempts);
|
|
85
88
|
}
|
|
86
89
|
/* eslint-enable no-await-in-loop */
|
|
87
90
|
// At this point, the result is one of the following,
|
|
@@ -26,6 +26,11 @@ export interface Polling {
|
|
|
26
26
|
readonly intervalMs: number;
|
|
27
27
|
/** Maximum number of polling attempts. */
|
|
28
28
|
readonly maxAttempts: number;
|
|
29
|
+
/**
|
|
30
|
+
* A map of polling attempt numbers to a delay in milliseconds.
|
|
31
|
+
* Once the attempts are reach, the backoff will be added to `intervalMs`.
|
|
32
|
+
*/
|
|
33
|
+
readonly backoff?: Record<number, number | undefined>;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Render image arguments. Render functions return Streams. Here's an
|
|
@@ -32,7 +32,7 @@ interface PollJobRes<T> {
|
|
|
32
32
|
* @param req - {@link PollQueuedJobReq}.
|
|
33
33
|
* @returns {@link PollQueuedJobRes}.
|
|
34
34
|
*/
|
|
35
|
-
export declare function pollQueuedJob<T>({ id, getQueuedJob, allow404, limit, polling: { intervalMs, maxAttempts }, }: PollQueuedJobReq): Promise<PollQueuedJobRes<T>>;
|
|
35
|
+
export declare function pollQueuedJob<T>({ id, getQueuedJob, allow404, limit, polling: { intervalMs, maxAttempts, backoff }, }: PollQueuedJobReq): Promise<PollQueuedJobRes<T>>;
|
|
36
36
|
export declare function isPollError<T>(r: PollRes<T>): r is QueuedJob | Failure;
|
|
37
37
|
export declare function isBatch(obj: PollRes<Batch>): obj is Batch;
|
|
38
38
|
export declare function throwOnError<T>(r: PollQueuedJobRes<T>): never;
|
|
@@ -23,7 +23,8 @@ const Debug = false;
|
|
|
23
23
|
* @param req - {@link PollQueuedJobReq}.
|
|
24
24
|
* @returns {@link PollQueuedJobRes}.
|
|
25
25
|
*/
|
|
26
|
-
export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { intervalMs, maxAttempts }, }) {
|
|
26
|
+
export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { intervalMs, maxAttempts, backoff }, }) {
|
|
27
|
+
var _a, _b;
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
function poll(attempt) {
|
|
29
30
|
var _a, _b;
|
|
@@ -66,7 +67,8 @@ export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polli
|
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
let attempts = 1;
|
|
69
|
-
let
|
|
70
|
+
let backoffMs = (_a = backoff === null || backoff === void 0 ? void 0 : backoff[attempts]) !== null && _a !== void 0 ? _a : 0;
|
|
71
|
+
const pollRes = yield poll(attempts);
|
|
70
72
|
/* eslint-disable no-await-in-loop */
|
|
71
73
|
while (!completeJob(pollRes.res) &&
|
|
72
74
|
(allowed404(allow404, pollRes.status) ||
|
|
@@ -74,8 +76,9 @@ export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polli
|
|
|
74
76
|
isClientError(pollRes.res)) &&
|
|
75
77
|
attempts <= maxAttempts) {
|
|
76
78
|
attempts += 1;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
backoffMs = (_b = backoff === null || backoff === void 0 ? void 0 : backoff[attempts]) !== null && _b !== void 0 ? _b : backoffMs;
|
|
80
|
+
yield delay(intervalMs + backoffMs);
|
|
81
|
+
yield poll(attempts);
|
|
79
82
|
}
|
|
80
83
|
/* eslint-enable no-await-in-loop */
|
|
81
84
|
// At this point, the result is one of the following,
|
|
@@ -26,6 +26,11 @@ export interface Polling {
|
|
|
26
26
|
readonly intervalMs: number;
|
|
27
27
|
/** Maximum number of polling attempts. */
|
|
28
28
|
readonly maxAttempts: number;
|
|
29
|
+
/**
|
|
30
|
+
* A map of polling attempt numbers to a delay in milliseconds.
|
|
31
|
+
* Once the attempts are reach, the backoff will be added to `intervalMs`.
|
|
32
|
+
*/
|
|
33
|
+
readonly backoff?: Record<number, number | undefined>;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Render image arguments. Render functions return Streams. Here's an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertexvis/api-client-node",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "The Vertex REST API client for Node.js.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vertex Developers <support@vertexvis.com> (https://developer.vertexvis.com)",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"axios": "^1.6.
|
|
36
|
+
"axios": "^1.6.1",
|
|
37
37
|
"p-limit": "^3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|