@resonatehq/sdk 0.5.2 → 0.5.5
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/async.d.ts +23 -5
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +94 -22
- package/dist/async.js.map +1 -1
- package/dist/core/calls.d.ts +23 -0
- package/dist/core/calls.d.ts.map +1 -0
- package/dist/core/calls.js +13 -0
- package/dist/core/calls.js.map +1 -0
- package/dist/core/encoders/json.d.ts.map +1 -1
- package/dist/core/encoders/json.js +12 -0
- package/dist/core/encoders/json.js.map +1 -1
- package/dist/core/errors.d.ts +7 -6
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +7 -6
- package/dist/core/errors.js.map +1 -1
- package/dist/core/execution.d.ts +0 -10
- package/dist/core/execution.d.ts.map +1 -1
- package/dist/core/execution.js +10 -105
- package/dist/core/execution.js.map +1 -1
- package/dist/core/invocation.d.ts +4 -7
- package/dist/core/invocation.d.ts.map +1 -1
- package/dist/core/invocation.js +6 -28
- package/dist/core/invocation.js.map +1 -1
- package/dist/core/options.d.ts +58 -10
- package/dist/core/options.d.ts.map +1 -1
- package/dist/core/options.js.map +1 -1
- package/dist/core/promises/promises.d.ts +2 -2
- package/dist/core/promises/promises.d.ts.map +1 -1
- package/dist/core/promises/promises.js +8 -4
- package/dist/core/promises/promises.js.map +1 -1
- package/dist/core/promises/types.d.ts +10 -83
- package/dist/core/promises/types.d.ts.map +1 -1
- package/dist/core/promises/types.js +10 -10
- package/dist/core/promises/types.js.map +1 -1
- package/dist/core/retry.d.ts +35 -26
- package/dist/core/retry.d.ts.map +1 -1
- package/dist/core/retry.js +111 -14
- package/dist/core/retry.js.map +1 -1
- package/dist/core/storages/memory.d.ts.map +1 -1
- package/dist/core/storages/memory.js +2 -0
- package/dist/core/storages/memory.js.map +1 -1
- package/dist/core/storages/withTimeout.d.ts +6 -6
- package/dist/core/storages/withTimeout.d.ts.map +1 -1
- package/dist/core/storages/withTimeout.js +2 -13
- package/dist/core/storages/withTimeout.js.map +1 -1
- package/dist/core/store.d.ts +7 -7
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/stores/local.d.ts +16 -13
- package/dist/core/stores/local.d.ts.map +1 -1
- package/dist/core/stores/local.js +15 -11
- package/dist/core/stores/local.js.map +1 -1
- package/dist/core/stores/remote.d.ts +27 -24
- package/dist/core/stores/remote.d.ts.map +1 -1
- package/dist/core/stores/remote.js +162 -158
- package/dist/core/stores/remote.js.map +1 -1
- package/dist/core/utils.d.ts +27 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +37 -1
- package/dist/core/utils.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/resonate.d.ts +12 -16
- package/dist/resonate.d.ts.map +1 -1
- package/dist/resonate.js +85 -47
- package/dist/resonate.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/retries/retry.d.ts +0 -20
- package/dist/core/retries/retry.d.ts.map +0 -1
- package/dist/core/retries/retry.js +0 -41
- package/dist/core/retries/retry.js.map +0 -1
- package/dist/generator.d.ts +0 -208
- package/dist/generator.d.ts.map +0 -1
- package/dist/generator.js +0 -427
- package/dist/generator.js.map +0 -1
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
state: "PENDING";
|
|
4
|
-
id: string;
|
|
5
|
-
timeout: number;
|
|
6
|
-
param: {
|
|
7
|
-
headers: Record<string, string> | undefined;
|
|
8
|
-
data: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
value: {
|
|
11
|
-
headers: undefined;
|
|
12
|
-
data: undefined;
|
|
13
|
-
};
|
|
14
|
-
createdOn: number;
|
|
15
|
-
completedOn: undefined;
|
|
16
|
-
idempotencyKeyForCreate: string | undefined;
|
|
17
|
-
idempotencyKeyForComplete: undefined;
|
|
18
|
-
tags: Record<string, string> | undefined;
|
|
19
|
-
};
|
|
20
|
-
export type ResolvedPromise = {
|
|
21
|
-
state: "RESOLVED";
|
|
22
|
-
id: string;
|
|
23
|
-
timeout: number;
|
|
24
|
-
param: {
|
|
25
|
-
headers: Record<string, string> | undefined;
|
|
26
|
-
data: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
value: {
|
|
29
|
-
headers: Record<string, string> | undefined;
|
|
30
|
-
data: string | undefined;
|
|
31
|
-
};
|
|
32
|
-
createdOn: number;
|
|
33
|
-
completedOn: number;
|
|
34
|
-
idempotencyKeyForCreate: string | undefined;
|
|
35
|
-
idempotencyKeyForComplete: string | undefined;
|
|
36
|
-
tags: Record<string, string> | undefined;
|
|
37
|
-
};
|
|
38
|
-
export type RejectedPromise = {
|
|
39
|
-
state: "REJECTED";
|
|
1
|
+
export type DurablePromiseRecord = {
|
|
2
|
+
state: "PENDING" | "RESOLVED" | "REJECTED" | "REJECTED_CANCELED" | "REJECTED_TIMEDOUT";
|
|
40
3
|
id: string;
|
|
41
4
|
timeout: number;
|
|
42
5
|
param: {
|
|
@@ -48,52 +11,16 @@ export type RejectedPromise = {
|
|
|
48
11
|
data: string | undefined;
|
|
49
12
|
};
|
|
50
13
|
createdOn: number;
|
|
51
|
-
completedOn: number;
|
|
14
|
+
completedOn: number | undefined;
|
|
52
15
|
idempotencyKeyForCreate: string | undefined;
|
|
53
16
|
idempotencyKeyForComplete: string | undefined;
|
|
54
17
|
tags: Record<string, string> | undefined;
|
|
55
18
|
};
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
value: {
|
|
65
|
-
headers: Record<string, string> | undefined;
|
|
66
|
-
data: string | undefined;
|
|
67
|
-
};
|
|
68
|
-
createdOn: number;
|
|
69
|
-
completedOn: number;
|
|
70
|
-
idempotencyKeyForCreate: string | undefined;
|
|
71
|
-
idempotencyKeyForComplete: string | undefined;
|
|
72
|
-
tags: Record<string, string> | undefined;
|
|
73
|
-
};
|
|
74
|
-
export type TimedoutPromise = {
|
|
75
|
-
state: "REJECTED_TIMEDOUT";
|
|
76
|
-
id: string;
|
|
77
|
-
timeout: number;
|
|
78
|
-
param: {
|
|
79
|
-
headers: Record<string, string> | undefined;
|
|
80
|
-
data: string | undefined;
|
|
81
|
-
};
|
|
82
|
-
value: {
|
|
83
|
-
headers: undefined;
|
|
84
|
-
data: undefined;
|
|
85
|
-
};
|
|
86
|
-
createdOn: number;
|
|
87
|
-
completedOn: number;
|
|
88
|
-
idempotencyKeyForCreate: string | undefined;
|
|
89
|
-
idempotencyKeyForComplete: undefined;
|
|
90
|
-
tags: Record<string, string> | undefined;
|
|
91
|
-
};
|
|
92
|
-
export declare function isDurablePromise(p: unknown): p is DurablePromise;
|
|
93
|
-
export declare function isPendingPromise(p: unknown): p is PendingPromise;
|
|
94
|
-
export declare function isResolvedPromise(p: unknown): p is ResolvedPromise;
|
|
95
|
-
export declare function isRejectedPromise(p: unknown): p is RejectedPromise;
|
|
96
|
-
export declare function isCanceledPromise(p: unknown): p is CanceledPromise;
|
|
97
|
-
export declare function isTimedoutPromise(p: unknown): p is TimedoutPromise;
|
|
98
|
-
export declare function isCompletedPromise(p: unknown): p is ResolvedPromise | RejectedPromise | CanceledPromise | TimedoutPromise;
|
|
19
|
+
export declare function isDurablePromiseRecord(p: unknown): p is DurablePromiseRecord;
|
|
20
|
+
export declare function isPendingPromise(p: DurablePromiseRecord): boolean;
|
|
21
|
+
export declare function isResolvedPromise(p: DurablePromiseRecord): boolean;
|
|
22
|
+
export declare function isRejectedPromise(p: DurablePromiseRecord): boolean;
|
|
23
|
+
export declare function isCanceledPromise(p: DurablePromiseRecord): boolean;
|
|
24
|
+
export declare function isTimedoutPromise(p: DurablePromiseRecord): boolean;
|
|
25
|
+
export declare function isCompletedPromise(p: DurablePromiseRecord): boolean;
|
|
99
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/core/promises/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/core/promises/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;IACvF,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;QAC5C,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1B,CAAC;IACF,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;QAC5C,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1B,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC1C,CAAC;AAGF,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,oBAAoB,CAQ5E;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAEjE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAElE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAElE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAElE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAElE;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAEnE"}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCompletedPromise = exports.isTimedoutPromise = exports.isCanceledPromise = exports.isRejectedPromise = exports.isResolvedPromise = exports.isPendingPromise = exports.
|
|
4
|
-
//
|
|
5
|
-
function
|
|
3
|
+
exports.isCompletedPromise = exports.isTimedoutPromise = exports.isCanceledPromise = exports.isRejectedPromise = exports.isResolvedPromise = exports.isPendingPromise = exports.isDurablePromiseRecord = void 0;
|
|
4
|
+
// This is an unsound type guard, we should be more strict in what we call a DurablePromise
|
|
5
|
+
function isDurablePromiseRecord(p) {
|
|
6
6
|
return (p !== null &&
|
|
7
7
|
typeof p === "object" &&
|
|
8
8
|
"state" in p &&
|
|
9
9
|
typeof p.state === "string" &&
|
|
10
10
|
["PENDING", "RESOLVED", "REJECTED", "REJECTED_CANCELED", "REJECTED_TIMEDOUT"].includes(p.state));
|
|
11
11
|
}
|
|
12
|
-
exports.
|
|
12
|
+
exports.isDurablePromiseRecord = isDurablePromiseRecord;
|
|
13
13
|
function isPendingPromise(p) {
|
|
14
|
-
return
|
|
14
|
+
return p.state === "PENDING";
|
|
15
15
|
}
|
|
16
16
|
exports.isPendingPromise = isPendingPromise;
|
|
17
17
|
function isResolvedPromise(p) {
|
|
18
|
-
return
|
|
18
|
+
return p.state === "RESOLVED";
|
|
19
19
|
}
|
|
20
20
|
exports.isResolvedPromise = isResolvedPromise;
|
|
21
21
|
function isRejectedPromise(p) {
|
|
22
|
-
return
|
|
22
|
+
return p.state === "REJECTED";
|
|
23
23
|
}
|
|
24
24
|
exports.isRejectedPromise = isRejectedPromise;
|
|
25
25
|
function isCanceledPromise(p) {
|
|
26
|
-
return
|
|
26
|
+
return p.state === "REJECTED_CANCELED";
|
|
27
27
|
}
|
|
28
28
|
exports.isCanceledPromise = isCanceledPromise;
|
|
29
29
|
function isTimedoutPromise(p) {
|
|
30
|
-
return
|
|
30
|
+
return p.state === "REJECTED_TIMEDOUT";
|
|
31
31
|
}
|
|
32
32
|
exports.isTimedoutPromise = isTimedoutPromise;
|
|
33
33
|
function isCompletedPromise(p) {
|
|
34
|
-
return
|
|
34
|
+
return ["RESOLVED", "REJECTED", "REJECTED_CANCELED", "REJECTED_TIMEDOUT"].includes(p.state);
|
|
35
35
|
}
|
|
36
36
|
exports.isCompletedPromise = isCompletedPromise;
|
|
37
37
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../lib/core/promises/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../lib/core/promises/types.ts"],"names":[],"mappings":";;;AAmBA,2FAA2F;AAC3F,SAAgB,sBAAsB,CAAC,CAAU;IAC/C,OAAO,CACL,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,KAAK,QAAQ;QACrB,OAAO,IAAI,CAAC;QACZ,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;QAC3B,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAChG,CAAC;AACJ,CAAC;AARD,wDAQC;AAED,SAAgB,gBAAgB,CAAC,CAAuB;IACtD,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC;AAC/B,CAAC;AAFD,4CAEC;AAED,SAAgB,iBAAiB,CAAC,CAAuB;IACvD,OAAO,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC;AAChC,CAAC;AAFD,8CAEC;AAED,SAAgB,iBAAiB,CAAC,CAAuB;IACvD,OAAO,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC;AAChC,CAAC;AAFD,8CAEC;AAED,SAAgB,iBAAiB,CAAC,CAAuB;IACvD,OAAO,CAAC,CAAC,KAAK,KAAK,mBAAmB,CAAC;AACzC,CAAC;AAFD,8CAEC;AAED,SAAgB,iBAAiB,CAAC,CAAuB;IACvD,OAAO,CAAC,CAAC,KAAK,KAAK,mBAAmB,CAAC;AACzC,CAAC;AAFD,8CAEC;AAED,SAAgB,kBAAkB,CAAC,CAAuB;IACxD,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9F,CAAC;AAFD,gDAEC"}
|
package/dist/core/retry.d.ts
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
export type RetryPolicy = Exponential | Linear | Never;
|
|
2
|
+
export type Exponential = {
|
|
3
|
+
kind: "exponential";
|
|
4
|
+
initialDelayMs: number;
|
|
5
|
+
backoffFactor: number;
|
|
6
|
+
maxAttempts: number;
|
|
7
|
+
maxDelayMs: number;
|
|
8
|
+
};
|
|
9
|
+
export type Linear = {
|
|
10
|
+
kind: "linear";
|
|
11
|
+
delayMs: number;
|
|
12
|
+
maxAttempts: number;
|
|
13
|
+
};
|
|
14
|
+
export type Never = {
|
|
15
|
+
kind: "never";
|
|
16
|
+
};
|
|
17
|
+
export declare function isRetryPolicy(value: unknown): value is RetryPolicy;
|
|
18
|
+
export declare function exponential(initialDelayMs?: number, backoffFactor?: number, maxAttempts?: number, maxDelayMs?: number): Exponential;
|
|
19
|
+
export declare function linear(delayMs?: number, maxAttempts?: number): Linear;
|
|
20
|
+
export declare function never(): Never;
|
|
21
|
+
/**
|
|
22
|
+
* Returns an iterable iterator that yields delay values for each retry attempt,
|
|
23
|
+
* based on the specified retry policy.
|
|
24
|
+
* The iterator stops yielding delay values when either the timeout is reached or the maximum
|
|
25
|
+
* number of attempts is exceeded.
|
|
26
|
+
*
|
|
27
|
+
* @param ctx - The context object containing the retry policy, attempt number, and timeout.
|
|
28
|
+
* @returns An iterable iterator that yields delay values for each retry attempt.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export declare function retryIterator<T extends {
|
|
32
|
+
retryPolicy: RetryPolicy;
|
|
33
|
+
attempt: number;
|
|
34
|
+
timeout: number;
|
|
35
|
+
}>(ctx: T): IterableIterator<number>;
|
|
27
36
|
//# sourceMappingURL=retry.d.ts.map
|
package/dist/core/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../lib/core/retry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../lib/core/retry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAqClE;AACD,wBAAgB,WAAW,CACzB,cAAc,GAAE,MAAY,EAC5B,aAAa,GAAE,MAAU,EACzB,WAAW,GAAE,MAAiB,EAC9B,UAAU,GAAE,MAAc,GACzB,WAAW,CAQb;AAED,wBAAgB,MAAM,CAAC,OAAO,GAAE,MAAa,EAAE,WAAW,GAAE,MAAiB,GAAG,MAAM,CAMrF;AAED,wBAAgB,KAAK,IAAI,KAAK,CAE7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACpG,GAAG,EAAE,CAAC,GACL,gBAAgB,CAAC,MAAM,CAAC,CA8B1B"}
|
package/dist/core/retry.js
CHANGED
|
@@ -1,22 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.retryIterator = exports.never = exports.linear = exports.exponential = exports.isRetryPolicy = void 0;
|
|
4
|
+
function isRetryPolicy(value) {
|
|
5
|
+
// Check if the value is an object
|
|
6
|
+
if (typeof value !== "object" || value === null) {
|
|
7
|
+
return false;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
// Check if the object has a 'kind' property and if its value is a valid kind string
|
|
10
|
+
const kindValue = value.kind;
|
|
11
|
+
if (kindValue !== "exponential" && kindValue !== "linear" && kindValue !== "never") {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// Check if the object matches the corresponding type based on the 'kind' value
|
|
15
|
+
switch (kindValue) {
|
|
16
|
+
case "exponential":
|
|
17
|
+
return ("initialDelayMs" in value &&
|
|
18
|
+
"backoffFactor" in value &&
|
|
19
|
+
"maxAttempts" in value &&
|
|
20
|
+
"maxDelayMs" in value &&
|
|
21
|
+
typeof value.initialDelayMs === "number" &&
|
|
22
|
+
typeof value.backoffFactor === "number" &&
|
|
23
|
+
typeof value.maxAttempts === "number" &&
|
|
24
|
+
typeof value.maxDelayMs === "number");
|
|
25
|
+
case "linear":
|
|
26
|
+
return ("delayMs" in value &&
|
|
27
|
+
"maxAttempts" in value &&
|
|
28
|
+
typeof value.delayMs === "number" &&
|
|
29
|
+
typeof value.maxAttempts === "number");
|
|
30
|
+
case "never":
|
|
31
|
+
return true; // No additional properties to check for 'never' type
|
|
32
|
+
default:
|
|
33
|
+
return false; // unreachable
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.isRetryPolicy = isRetryPolicy;
|
|
37
|
+
function exponential(initialDelayMs = 100, backoffFactor = 2, maxAttempts = Infinity, maxDelayMs = 60000) {
|
|
38
|
+
return {
|
|
39
|
+
kind: "exponential",
|
|
40
|
+
initialDelayMs,
|
|
41
|
+
backoffFactor,
|
|
42
|
+
maxAttempts,
|
|
43
|
+
maxDelayMs,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.exponential = exponential;
|
|
47
|
+
function linear(delayMs = 1000, maxAttempts = Infinity) {
|
|
48
|
+
return {
|
|
49
|
+
kind: "linear",
|
|
50
|
+
delayMs,
|
|
51
|
+
maxAttempts,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.linear = linear;
|
|
55
|
+
function never() {
|
|
56
|
+
return { kind: "never" };
|
|
57
|
+
}
|
|
58
|
+
exports.never = never;
|
|
59
|
+
/**
|
|
60
|
+
* Returns an iterable iterator that yields delay values for each retry attempt,
|
|
61
|
+
* based on the specified retry policy.
|
|
62
|
+
* The iterator stops yielding delay values when either the timeout is reached or the maximum
|
|
63
|
+
* number of attempts is exceeded.
|
|
64
|
+
*
|
|
65
|
+
* @param ctx - The context object containing the retry policy, attempt number, and timeout.
|
|
66
|
+
* @returns An iterable iterator that yields delay values for each retry attempt.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
function retryIterator(ctx) {
|
|
70
|
+
const { initialDelay, backoffFactor, maxAttempts, maxDelay } = retryDefaults(ctx.retryPolicy);
|
|
71
|
+
const __next = (itCtx) => {
|
|
72
|
+
// attempt 0: 0ms delay
|
|
73
|
+
// attampt n: {initial * factor^(attempt-1)}ms delay (or max delay)
|
|
74
|
+
const delay = Math.min(Math.min(itCtx.attempt, 1) * initialDelay * Math.pow(backoffFactor, itCtx.attempt - 1), maxDelay);
|
|
75
|
+
if (Date.now() + delay >= itCtx.timeout || itCtx.attempt >= maxAttempts) {
|
|
76
|
+
return { done: true };
|
|
77
|
+
}
|
|
10
78
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return { done, value: delay || 0 };
|
|
14
|
-
},
|
|
15
|
-
[Symbol.iterator]() {
|
|
16
|
-
return this;
|
|
17
|
-
},
|
|
79
|
+
done: false,
|
|
80
|
+
delay: delay,
|
|
18
81
|
};
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
next() {
|
|
85
|
+
const { done, delay } = __next(ctx);
|
|
86
|
+
return { done, value: delay || 0 };
|
|
87
|
+
},
|
|
88
|
+
[Symbol.iterator]() {
|
|
89
|
+
return this;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.retryIterator = retryIterator;
|
|
94
|
+
function retryDefaults(retryPolicy) {
|
|
95
|
+
switch (retryPolicy.kind) {
|
|
96
|
+
case "exponential":
|
|
97
|
+
return {
|
|
98
|
+
initialDelay: retryPolicy.initialDelayMs,
|
|
99
|
+
backoffFactor: retryPolicy.backoffFactor,
|
|
100
|
+
maxAttempts: retryPolicy.maxAttempts,
|
|
101
|
+
maxDelay: retryPolicy.maxDelayMs,
|
|
102
|
+
};
|
|
103
|
+
case "linear":
|
|
104
|
+
return {
|
|
105
|
+
initialDelay: retryPolicy.delayMs,
|
|
106
|
+
backoffFactor: 1,
|
|
107
|
+
maxAttempts: retryPolicy.maxAttempts,
|
|
108
|
+
maxDelay: retryPolicy.delayMs,
|
|
109
|
+
};
|
|
110
|
+
case "never":
|
|
111
|
+
return {
|
|
112
|
+
initialDelay: 0,
|
|
113
|
+
backoffFactor: 0,
|
|
114
|
+
maxAttempts: 1,
|
|
115
|
+
maxDelay: 0,
|
|
116
|
+
};
|
|
19
117
|
}
|
|
20
118
|
}
|
|
21
|
-
exports.IterableRetry = IterableRetry;
|
|
22
119
|
//# sourceMappingURL=retry.js.map
|
package/dist/core/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../lib/core/retry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../lib/core/retry.ts"],"names":[],"mappings":";;;AAoBA,SAAgB,aAAa,CAAC,KAAc;IAC1C,kCAAkC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oFAAoF;IACpF,MAAM,SAAS,GAAI,KAAqB,CAAC,IAAI,CAAC;IAC9C,IAAI,SAAS,KAAK,aAAa,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QACnF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+EAA+E;IAC/E,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,CACL,gBAAgB,IAAI,KAAK;gBACzB,eAAe,IAAI,KAAK;gBACxB,aAAa,IAAI,KAAK;gBACtB,YAAY,IAAI,KAAK;gBACrB,OAAQ,KAAqB,CAAC,cAAc,KAAK,QAAQ;gBACzD,OAAQ,KAAqB,CAAC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B,WAAW,EAAE,CAAC;gBACd,QAAQ,EAAE,CAAC;aACZ,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../lib/core/storages/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,CAAyB;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../lib/core/storages/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,CAAyB;IAGhC,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAUtF,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAW5D,GAAG,IAAI,cAAc,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC;CAGxC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MemoryStorage = void 0;
|
|
4
4
|
class MemoryStorage {
|
|
5
5
|
items = {};
|
|
6
|
+
// read-modify-write
|
|
6
7
|
async rmw(id, func) {
|
|
7
8
|
const item = func(this.items[id]);
|
|
8
9
|
if (item) {
|
|
@@ -10,6 +11,7 @@ class MemoryStorage {
|
|
|
10
11
|
}
|
|
11
12
|
return item;
|
|
12
13
|
}
|
|
14
|
+
// read-modify-delete
|
|
13
15
|
async rmd(id, func) {
|
|
14
16
|
const item = this.items[id];
|
|
15
17
|
let result = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../lib/core/storages/memory.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAChB,KAAK,GAAsB,EAAE,CAAC;IAEtC,KAAK,CAAC,GAAG,CAA0B,EAAU,EAAE,IAAgC;QAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,IAA0B;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,CAAC,GAAG;QACR,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../lib/core/storages/memory.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAChB,KAAK,GAAsB,EAAE,CAAC;IAEtC,oBAAoB;IACpB,KAAK,CAAC,GAAG,CAA0B,EAAU,EAAE,IAAgC;QAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBAAqB;IACrB,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,IAA0B;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,CAAC,GAAG;QACR,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;AA5BD,sCA4BC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DurablePromiseRecord } from "../promises/types";
|
|
2
2
|
import { IStorage } from "../storage";
|
|
3
|
-
export declare class WithTimeout implements IStorage<
|
|
3
|
+
export declare class WithTimeout implements IStorage<DurablePromiseRecord> {
|
|
4
4
|
private storage;
|
|
5
|
-
constructor(storage?: IStorage<
|
|
6
|
-
rmw<T extends
|
|
7
|
-
rmd(id: string, func: (item:
|
|
8
|
-
all(): AsyncGenerator<
|
|
5
|
+
constructor(storage?: IStorage<DurablePromiseRecord>);
|
|
6
|
+
rmw<T extends DurablePromiseRecord | undefined>(id: string, func: (item: DurablePromiseRecord | undefined) => T): Promise<T>;
|
|
7
|
+
rmd(id: string, func: (item: DurablePromiseRecord) => boolean): Promise<boolean>;
|
|
8
|
+
all(): AsyncGenerator<DurablePromiseRecord[], void>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=withTimeout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTimeout.d.ts","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"withTimeout.d.ts","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,qBAAa,WAAY,YAAW,QAAQ,CAAC,oBAAoB,CAAC;IACpD,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,QAAQ,CAAC,oBAAoB,CAA6C;IAEvG,GAAG,CAAC,CAAC,SAAS,oBAAoB,GAAG,SAAS,EAC5C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,IAAI,EAAE,oBAAoB,GAAG,SAAS,KAAK,CAAC,GAClD,OAAO,CAAC,CAAC,CAAC;IAIb,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzE,GAAG,IAAI,cAAc,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC;CAK3D"}
|
|
@@ -23,7 +23,8 @@ class WithTimeout {
|
|
|
23
23
|
exports.WithTimeout = WithTimeout;
|
|
24
24
|
function timeout(promise) {
|
|
25
25
|
if ((0, types_1.isPendingPromise)(promise) && Date.now() >= promise.timeout) {
|
|
26
|
-
|
|
26
|
+
return {
|
|
27
|
+
state: promise.tags?.["resonate:timeout"] === "true" ? "RESOLVED" : "REJECTED_TIMEDOUT",
|
|
27
28
|
id: promise.id,
|
|
28
29
|
timeout: promise.timeout,
|
|
29
30
|
param: promise.param,
|
|
@@ -37,18 +38,6 @@ function timeout(promise) {
|
|
|
37
38
|
idempotencyKeyForComplete: undefined,
|
|
38
39
|
tags: promise.tags,
|
|
39
40
|
};
|
|
40
|
-
if (promise.tags?.["resonate:timeout"] === "true") {
|
|
41
|
-
return {
|
|
42
|
-
state: "RESOLVED",
|
|
43
|
-
...body,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return {
|
|
48
|
-
state: "REJECTED_TIMEDOUT",
|
|
49
|
-
...body,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
41
|
}
|
|
53
42
|
return promise;
|
|
54
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":";;;AAAA,6CAA2E;AAE3E,qCAAyC;AAEzC,MAAa,WAAW;IACF;IAApB,YAAoB,UAA0C,IAAI,sBAAa,EAAwB;QAAnF,YAAO,GAAP,OAAO,CAA4E;IAAG,CAAC;IAE3G,GAAG,CACD,EAAU,EACV,IAAmD;QAEnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,GAAG,CAAC,EAAU,EAAE,IAA6C;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,CAAC,GAAG;QACR,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;YAChD,MAAM,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAnBD,kCAmBC;AAED,SAAS,OAAO,CAAiC,OAAU;IACzD,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/D,OAAO;YACL,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,kBAAkB,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB;YACvF,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE;gBACL,OAAO,EAAE,SAAS;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;YACxD,yBAAyB,EAAE,SAAS;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/core/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DurablePromiseRecord } from "./promises/types";
|
|
2
2
|
import { Schedule } from "./schedules/types";
|
|
3
3
|
/**
|
|
4
4
|
* Store Interface
|
|
@@ -24,7 +24,7 @@ export interface IPromiseStore {
|
|
|
24
24
|
* @param tags Key value pairs associated with the promise.
|
|
25
25
|
* @returns A durable promise that is pending, canceled, resolved, or rejected.
|
|
26
26
|
*/
|
|
27
|
-
create(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined, timeout: number, tags: Record<string, string> | undefined): Promise<
|
|
27
|
+
create(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined, timeout: number, tags: Record<string, string> | undefined): Promise<DurablePromiseRecord>;
|
|
28
28
|
/**
|
|
29
29
|
* Cancels a new promise.
|
|
30
30
|
*
|
|
@@ -35,7 +35,7 @@ export interface IPromiseStore {
|
|
|
35
35
|
* @param data Encoded data of type string.
|
|
36
36
|
* @returns A durable promise that is canceled, resolved, or rejected.
|
|
37
37
|
*/
|
|
38
|
-
cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
38
|
+
cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
39
39
|
/**
|
|
40
40
|
* Resolves a promise.
|
|
41
41
|
*
|
|
@@ -46,7 +46,7 @@ export interface IPromiseStore {
|
|
|
46
46
|
* @param data Encoded data of type string.
|
|
47
47
|
* @returns A durable promise that is canceled, resolved, or rejected.
|
|
48
48
|
*/
|
|
49
|
-
resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
49
|
+
resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
50
50
|
/**
|
|
51
51
|
* Rejects a promise
|
|
52
52
|
*
|
|
@@ -57,14 +57,14 @@ export interface IPromiseStore {
|
|
|
57
57
|
* @param data Encoded data of type string.
|
|
58
58
|
* @returns A durable promise that is canceled, resolved, or rejected.
|
|
59
59
|
*/
|
|
60
|
-
reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
60
|
+
reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
61
61
|
/**
|
|
62
62
|
* Retrieves a promise based on its id.
|
|
63
63
|
*
|
|
64
64
|
* @param id Unique identifier for the promise to be retrieved.
|
|
65
65
|
* @returns A durable promise that is pending, canceled, resolved, or rejected.
|
|
66
66
|
*/
|
|
67
|
-
get(id: string): Promise<
|
|
67
|
+
get(id: string): Promise<DurablePromiseRecord>;
|
|
68
68
|
/**
|
|
69
69
|
* Search for promises.
|
|
70
70
|
*
|
|
@@ -74,7 +74,7 @@ export interface IPromiseStore {
|
|
|
74
74
|
* @param limit Maximum number of promises to return.
|
|
75
75
|
* @returns A list of Durable Promises.
|
|
76
76
|
*/
|
|
77
|
-
search(id: string, state: string | undefined, tags: Record<string, string> | undefined, limit?: number): AsyncGenerator<
|
|
77
|
+
search(id: string, state: string | undefined, tags: Record<string, string> | undefined, limit?: number): AsyncGenerator<DurablePromiseRecord[], void>;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Schedule Store API
|
package/dist/core/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../lib/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../lib/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;OAWG;IACH,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C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CACpD"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ILogger } from "../logger";
|
|
2
|
-
import {
|
|
2
|
+
import { StoreOptions } from "../options";
|
|
3
|
+
import { DurablePromiseRecord } from "../promises/types";
|
|
3
4
|
import { Schedule } from "../schedules/types";
|
|
4
5
|
import { IStorage } from "../storage";
|
|
5
6
|
import { IStore, IPromiseStore, IScheduleStore, ILockStore } from "../store";
|
|
6
7
|
export declare class LocalStore implements IStore {
|
|
7
|
-
private logger;
|
|
8
8
|
promises: LocalPromiseStore;
|
|
9
9
|
schedules: LocalScheduleStore;
|
|
10
10
|
locks: LocalLockStore;
|
|
11
|
+
readonly logger: ILogger;
|
|
11
12
|
private toSchedule;
|
|
12
13
|
private next;
|
|
13
|
-
constructor(
|
|
14
|
+
constructor(opts?: Partial<StoreOptions>, promiseStorage?: IStorage<DurablePromiseRecord>, scheduleStorage?: IStorage<Schedule>, lockStorage?: IStorage<{
|
|
14
15
|
id: string;
|
|
15
16
|
eid: string;
|
|
16
17
|
}>);
|
|
@@ -22,19 +23,20 @@ export declare class LocalStore implements IStore {
|
|
|
22
23
|
private generatePromiseId;
|
|
23
24
|
}
|
|
24
25
|
export declare class LocalPromiseStore implements IPromiseStore {
|
|
26
|
+
private store;
|
|
25
27
|
private storage;
|
|
26
|
-
constructor(storage
|
|
27
|
-
create(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined, timeout: number, tags: Record<string, string> | undefined): Promise<
|
|
28
|
-
resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
29
|
-
reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
30
|
-
cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<
|
|
31
|
-
get(id: string): Promise<
|
|
32
|
-
search(id: string, state?: string, tags?: Record<string, string>, limit?: number): AsyncGenerator<
|
|
28
|
+
constructor(store: LocalStore, storage: IStorage<DurablePromiseRecord>);
|
|
29
|
+
create(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined, timeout: number, tags: Record<string, string> | undefined): Promise<DurablePromiseRecord>;
|
|
30
|
+
resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
31
|
+
reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
32
|
+
cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<DurablePromiseRecord>;
|
|
33
|
+
get(id: string): Promise<DurablePromiseRecord>;
|
|
34
|
+
search(id: string, state?: string, tags?: Record<string, string>, limit?: number): AsyncGenerator<DurablePromiseRecord[], void>;
|
|
33
35
|
}
|
|
34
36
|
export declare class LocalScheduleStore implements IScheduleStore {
|
|
35
|
-
private storage;
|
|
36
37
|
private store;
|
|
37
|
-
|
|
38
|
+
private storage;
|
|
39
|
+
constructor(store: LocalStore, storage: IStorage<Schedule>);
|
|
38
40
|
create(id: string, ikey: string | undefined, description: string | undefined, cron: string, tags: Record<string, string> | undefined, promiseId: string, promiseTimeout: number, promiseHeaders: Record<string, string>, promiseData: string | undefined, promiseTags: Record<string, string> | undefined): Promise<Schedule>;
|
|
39
41
|
update(id: string, lastRunTime: number): Promise<Schedule | undefined>;
|
|
40
42
|
delete(id: string): Promise<void>;
|
|
@@ -43,8 +45,9 @@ export declare class LocalScheduleStore implements IScheduleStore {
|
|
|
43
45
|
private nextRunTime;
|
|
44
46
|
}
|
|
45
47
|
export declare class LocalLockStore implements ILockStore {
|
|
48
|
+
private store;
|
|
46
49
|
private storage;
|
|
47
|
-
constructor(storage
|
|
50
|
+
constructor(store: LocalStore, storage: IStorage<{
|
|
48
51
|
id: string;
|
|
49
52
|
eid: string;
|
|
50
53
|
}>);
|