@resonatehq/sdk 0.3.3 → 0.3.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.
Files changed (105) hide show
  1. package/dist/async.d.ts +144 -0
  2. package/dist/async.d.ts.map +1 -0
  3. package/dist/async.js +235 -0
  4. package/dist/async.js.map +1 -0
  5. package/dist/core/encoder.d.ts +5 -0
  6. package/dist/core/encoder.d.ts.map +1 -0
  7. package/dist/core/encoder.js +3 -0
  8. package/dist/core/encoder.js.map +1 -0
  9. package/dist/core/encoders/base64.d.ts +6 -0
  10. package/dist/core/encoders/base64.d.ts.map +1 -0
  11. package/dist/core/encoders/base64.js +13 -0
  12. package/dist/core/encoders/base64.js.map +1 -0
  13. package/dist/core/encoders/json.d.ts +6 -0
  14. package/dist/core/encoders/json.d.ts.map +1 -0
  15. package/dist/core/encoders/json.js +65 -0
  16. package/dist/core/encoders/json.js.map +1 -0
  17. package/dist/core/errors.d.ts +21 -0
  18. package/dist/core/errors.d.ts.map +1 -0
  19. package/dist/core/errors.js +38 -0
  20. package/dist/core/errors.js.map +1 -0
  21. package/dist/core/execution.d.ts +44 -0
  22. package/dist/core/execution.d.ts.map +1 -0
  23. package/dist/core/execution.js +206 -0
  24. package/dist/core/execution.js.map +1 -0
  25. package/dist/core/future.d.ts +54 -0
  26. package/dist/core/future.d.ts.map +1 -0
  27. package/dist/core/future.js +101 -0
  28. package/dist/core/future.js.map +1 -0
  29. package/dist/core/invocation.d.ts +43 -0
  30. package/dist/core/invocation.d.ts.map +1 -0
  31. package/dist/core/invocation.js +77 -0
  32. package/dist/core/invocation.js.map +1 -0
  33. package/dist/core/logger.d.ts +10 -0
  34. package/dist/core/logger.d.ts.map +1 -0
  35. package/dist/core/logger.js +3 -0
  36. package/dist/core/logger.js.map +1 -0
  37. package/dist/core/loggers/logger.d.ts +13 -0
  38. package/dist/core/loggers/logger.d.ts.map +1 -0
  39. package/dist/core/loggers/logger.js +48 -0
  40. package/dist/core/loggers/logger.js.map +1 -0
  41. package/dist/core/options.d.ts +84 -0
  42. package/dist/core/options.d.ts.map +1 -0
  43. package/dist/core/options.js +8 -0
  44. package/dist/core/options.js.map +1 -0
  45. package/dist/core/promises/promises.d.ts +48 -0
  46. package/dist/core/promises/promises.d.ts.map +1 -0
  47. package/dist/core/promises/promises.js +133 -0
  48. package/dist/core/promises/promises.js.map +1 -0
  49. package/dist/core/promises/types.d.ts +99 -0
  50. package/dist/core/promises/types.d.ts.map +1 -0
  51. package/dist/core/promises/types.js +40 -0
  52. package/dist/core/promises/types.js.map +1 -0
  53. package/dist/core/retries/retry.d.ts +20 -0
  54. package/dist/core/retries/retry.d.ts.map +1 -0
  55. package/dist/core/retries/retry.js +41 -0
  56. package/dist/core/retries/retry.js.map +1 -0
  57. package/dist/core/retry.d.ts +27 -0
  58. package/dist/core/retry.d.ts.map +1 -0
  59. package/dist/core/retry.js +22 -0
  60. package/dist/core/retry.js.map +1 -0
  61. package/dist/core/schedules/types.d.ts +19 -0
  62. package/dist/core/schedules/types.d.ts.map +1 -0
  63. package/dist/core/schedules/types.js +8 -0
  64. package/dist/core/schedules/types.js.map +1 -0
  65. package/dist/core/storage.d.ts +6 -0
  66. package/dist/core/storage.d.ts.map +1 -0
  67. package/dist/core/storage.js +3 -0
  68. package/dist/core/storage.js.map +1 -0
  69. package/dist/core/storages/memory.d.ts +8 -0
  70. package/dist/core/storages/memory.d.ts.map +1 -0
  71. package/dist/core/storages/memory.js +27 -0
  72. package/dist/core/storages/memory.js.map +1 -0
  73. package/dist/core/storages/withTimeout.d.ts +10 -0
  74. package/dist/core/storages/withTimeout.d.ts.map +1 -0
  75. package/dist/core/storages/withTimeout.js +43 -0
  76. package/dist/core/storages/withTimeout.js.map +1 -0
  77. package/dist/core/store.d.ts +139 -0
  78. package/dist/core/store.d.ts.map +1 -0
  79. package/dist/core/store.js +3 -0
  80. package/dist/core/store.js.map +1 -0
  81. package/dist/core/stores/local.d.ts +54 -0
  82. package/dist/core/stores/local.d.ts.map +1 -0
  83. package/dist/core/stores/local.js +399 -0
  84. package/dist/core/stores/local.js.map +1 -0
  85. package/dist/core/stores/remote.d.ts +48 -0
  86. package/dist/core/stores/remote.d.ts.map +1 -0
  87. package/dist/core/stores/remote.js +407 -0
  88. package/dist/core/stores/remote.js.map +1 -0
  89. package/dist/core/utils.d.ts +3 -0
  90. package/dist/core/utils.d.ts.map +1 -0
  91. package/dist/core/utils.js +19 -0
  92. package/dist/core/utils.js.map +1 -0
  93. package/dist/generator.d.ts +187 -0
  94. package/dist/generator.d.ts.map +1 -0
  95. package/dist/generator.js +426 -0
  96. package/dist/generator.js.map +1 -0
  97. package/dist/index.d.ts +4 -0
  98. package/dist/index.d.ts.map +1 -0
  99. package/dist/index.js +32 -0
  100. package/dist/index.js.map +1 -0
  101. package/dist/resonate.d.ts +74 -0
  102. package/dist/resonate.d.ts.map +1 -0
  103. package/dist/resonate.js +172 -0
  104. package/dist/resonate.js.map +1 -0
  105. package/package.json +15 -11
@@ -0,0 +1,8 @@
1
+ import { IStorage } from "../storage";
2
+ export declare class MemoryStorage<T> implements IStorage<T> {
3
+ private items;
4
+ rmw<X extends T | undefined>(id: string, func: (item: T | undefined) => X): Promise<X>;
5
+ rmd(id: string, func: (item: T) => boolean): Promise<boolean>;
6
+ all(): AsyncGenerator<T[], void>;
7
+ }
8
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +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;IAEhC,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;IAStF,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"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemoryStorage = void 0;
4
+ class MemoryStorage {
5
+ items = {};
6
+ async rmw(id, func) {
7
+ const item = func(this.items[id]);
8
+ if (item) {
9
+ this.items[id] = item;
10
+ }
11
+ return item;
12
+ }
13
+ async rmd(id, func) {
14
+ const item = this.items[id];
15
+ let result = false;
16
+ if (item && func(item)) {
17
+ delete this.items[id];
18
+ result = true;
19
+ }
20
+ return result;
21
+ }
22
+ async *all() {
23
+ yield Object.values(this.items);
24
+ }
25
+ }
26
+ exports.MemoryStorage = MemoryStorage;
27
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +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;AA1BD,sCA0BC"}
@@ -0,0 +1,10 @@
1
+ import { DurablePromise } from "../promises/types";
2
+ import { IStorage } from "../storage";
3
+ export declare class WithTimeout implements IStorage<DurablePromise> {
4
+ private storage;
5
+ constructor(storage: IStorage<DurablePromise>);
6
+ rmw<T extends DurablePromise | undefined>(id: string, func: (item: DurablePromise | undefined) => T): Promise<T>;
7
+ rmd(id: string, func: (item: DurablePromise) => boolean): Promise<boolean>;
8
+ all(): AsyncGenerator<DurablePromise[], void>;
9
+ }
10
+ //# sourceMappingURL=withTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.d.ts","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAqC,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,WAAY,YAAW,QAAQ,CAAC,cAAc,CAAC;IAC9C,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC;IAErD,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;IAIhH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAInE,GAAG,IAAI,cAAc,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC;CAKrD"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithTimeout = void 0;
4
+ const types_1 = require("../promises/types");
5
+ class WithTimeout {
6
+ storage;
7
+ constructor(storage) {
8
+ this.storage = storage;
9
+ }
10
+ rmw(id, func) {
11
+ return this.storage.rmw(id, (p) => func(p ? timeout(p) : undefined));
12
+ }
13
+ rmd(id, func) {
14
+ return this.storage.rmd(id, (p) => func(timeout(p)));
15
+ }
16
+ async *all() {
17
+ for await (const promises of this.storage.all()) {
18
+ yield promises.map(timeout);
19
+ }
20
+ }
21
+ }
22
+ exports.WithTimeout = WithTimeout;
23
+ function timeout(promise) {
24
+ if ((0, types_1.isPendingPromise)(promise) && Date.now() >= promise.timeout) {
25
+ return {
26
+ state: "REJECTED_TIMEDOUT",
27
+ id: promise.id,
28
+ timeout: promise.timeout,
29
+ param: promise.param,
30
+ value: {
31
+ headers: undefined,
32
+ data: undefined,
33
+ },
34
+ createdOn: promise.createdOn,
35
+ completedOn: promise.timeout,
36
+ idempotencyKeyForCreate: promise.idempotencyKeyForCreate,
37
+ idempotencyKeyForComplete: undefined,
38
+ tags: promise.tags,
39
+ };
40
+ }
41
+ return promise;
42
+ }
43
+ //# sourceMappingURL=withTimeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withTimeout.js","sourceRoot":"","sources":["../../../lib/core/storages/withTimeout.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AAGtF,MAAa,WAAW;IACF;IAApB,YAAoB,OAAiC;QAAjC,YAAO,GAAP,OAAO,CAA0B;IAAG,CAAC;IAEzD,GAAG,CAAuC,EAAU,EAAE,IAA6C;QACjG,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,IAAuC;QACrD,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;AAhBD,kCAgBC;AAED,SAAS,OAAO,CAA2B,OAAU;IACnD,IAAI,IAAA,wBAAgB,EAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/D,OAAO;YACL,KAAK,EAAE,mBAAmB;YAC1B,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"}
@@ -0,0 +1,139 @@
1
+ import { DurablePromise, PendingPromise, ResolvedPromise, RejectedPromise, CanceledPromise, TimedoutPromise } from "./promises/types";
2
+ import { Schedule } from "./schedules/types";
3
+ /**
4
+ * Store Interface
5
+ */
6
+ export interface IStore {
7
+ readonly promises: IPromiseStore;
8
+ readonly schedules: IScheduleStore;
9
+ readonly locks: ILockStore;
10
+ }
11
+ /**
12
+ * Promise Store API
13
+ */
14
+ export interface IPromiseStore {
15
+ /**
16
+ * Creates a new durable promise
17
+ *
18
+ * @param id Unique identifier for the promise.
19
+ * @param ikey Idempotency key associated with the create operation.
20
+ * @param strict If true, deduplicates only if the promise is pending.
21
+ * @param headers Key value pairs associated with the data.
22
+ * @param data Encoded data of type string.
23
+ * @param timeout Time (in milliseconds) after which the promise is considered expired.
24
+ * @param tags Key value pairs associated with the promise.
25
+ * @returns A durable promise that is pending, canceled, resolved, or rejected.
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<PendingPromise | CanceledPromise | ResolvedPromise | RejectedPromise | TimedoutPromise>;
28
+ /**
29
+ * Cancels a new promise.
30
+ *
31
+ * @param id Unique identifier for the promise.
32
+ * @param ikey Idempotency key associated with the create operation.
33
+ * @param strict If true, deduplicates only if the promise is canceled.
34
+ * @param headers Key value pairs associated with the data.
35
+ * @param data Encoded data of type string.
36
+ * @returns A durable promise that is canceled, resolved, or rejected.
37
+ */
38
+ cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<CanceledPromise | ResolvedPromise | RejectedPromise | TimedoutPromise>;
39
+ /**
40
+ * Resolves a promise.
41
+ *
42
+ * @param id Unique identifier for the promise to be resolved.
43
+ * @param ikey Idempotency key associated with the resolve promise.
44
+ * @param strict If true, deduplicates only if the promise is resolved.
45
+ * @param headers Key value pairs associated with the data.
46
+ * @param data Encoded data of type string.
47
+ * @returns A durable promise that is canceled, resolved, or rejected.
48
+ */
49
+ resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<CanceledPromise | ResolvedPromise | RejectedPromise | TimedoutPromise>;
50
+ /**
51
+ * Rejects a promise
52
+ *
53
+ * @param id Unique identifier for the promise to be rejected.
54
+ * @param ikey Integration key associated with the promise.
55
+ * @param strict If true, deduplicates only if the promise is rejected.
56
+ * @param headers Key value pairs associated with the data.
57
+ * @param data Encoded data of type string.
58
+ * @returns A durable promise that is canceled, resolved, or rejected.
59
+ */
60
+ reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<CanceledPromise | ResolvedPromise | RejectedPromise | TimedoutPromise>;
61
+ /**
62
+ * Retrieves a promise based on its id.
63
+ *
64
+ * @param id Unique identifier for the promise to be retrieved.
65
+ * @returns A durable promise that is pending, canceled, resolved, or rejected.
66
+ */
67
+ get(id: string): Promise<DurablePromise>;
68
+ /**
69
+ * Search for promises.
70
+ *
71
+ * @param id Ids to match, can include wildcards.
72
+ * @param tags Tags to match.
73
+ * @returns A list of Durable Promises.
74
+ */
75
+ search(id: string, state: string | undefined, tags: Record<string, string> | undefined, limit?: number): AsyncGenerator<DurablePromise[], void>;
76
+ }
77
+ /**
78
+ * Schedule Store API
79
+ */
80
+ export interface IScheduleStore {
81
+ /**
82
+ * Creates a new schedule.
83
+ *
84
+ * @param id Unique identifier for the schedule.
85
+ * @param ikey Idempotency key associated with the create operation.
86
+ * @param description Description of the schedule.
87
+ * @param cron CRON expression defining the schedule's execution time.
88
+ * @param tags Key-value pairs associated with the schedule.
89
+ * @param promiseId Unique identifier for the associated promise.
90
+ * @param promiseTimeout Timeout for the associated promise in milliseconds.
91
+ * @param promiseHeaders Headers associated with the promise data.
92
+ * @param promiseData Encoded data for the promise of type string.
93
+ * @param promiseTags Key-value pairs associated with the promise.
94
+ * @returns A Promise resolving to the created schedule.
95
+ */
96
+ create(id: string, ikey: string | undefined, description: string | undefined, cron: string, tags: Record<string, string> | undefined, promiseId: string, promiseTimeout: number, promiseHeaders: Record<string, string> | undefined, promiseData: string | undefined, promiseTags: Record<string, string> | undefined): Promise<Schedule>;
97
+ /**
98
+ * Retrieves a schedule based on its id.
99
+ *
100
+ * @param id Unique identifier for the promise to be retrieved.
101
+ * @returns A promise schedule that is pending, canceled, resolved, or rejected.
102
+ */
103
+ get(id: string): Promise<Schedule>;
104
+ /**
105
+ * Deletes a schedule based on its id.
106
+ * @param id Unique identifier for the promise to be deleted.
107
+ * @returns A promise schedule that is pending, canceled, resolved, or rejected.
108
+ */
109
+ delete(id: string): Promise<void>;
110
+ /**
111
+ * Search for schedules.
112
+ *
113
+ * @param id Ids to match, can include wildcards.
114
+ * @param tags Tags to match.
115
+ * @returns A list of promise schedules.
116
+ */
117
+ search(id: string, tags: Record<string, string> | undefined, limit?: number): AsyncGenerator<Schedule[], void>;
118
+ }
119
+ /**
120
+ * Lock Store API
121
+ */
122
+ export interface ILockStore {
123
+ /**
124
+ * Try to acquire a lock.
125
+ *
126
+ * @param id Id of lock.
127
+ * @param eid Execution id of lock.
128
+ * @returns A boolean indicating whether or not the lock was acquired.
129
+ */
130
+ tryAcquire(id: string, eid: string): Promise<boolean>;
131
+ /**
132
+ * Release a lock.
133
+ *
134
+ * @param id Id of lock.
135
+ * @param eid Execution id of lock.
136
+ */
137
+ release(id: string, eid: string): Promise<void>;
138
+ }
139
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../lib/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,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,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AC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;CAChH;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../lib/core/store.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ import { ILogger } from "../logger";
2
+ import { DurablePromise, PendingPromise, ResolvedPromise, RejectedPromise, CanceledPromise, TimedoutPromise } from "../promises/types";
3
+ import { Schedule } from "../schedules/types";
4
+ import { IStorage } from "../storage";
5
+ import { IStore, IPromiseStore, IScheduleStore, ILockStore } from "../store";
6
+ export declare class LocalStore implements IStore {
7
+ private logger;
8
+ promises: LocalPromiseStore;
9
+ schedules: LocalScheduleStore;
10
+ locks: LocalLockStore;
11
+ private toSchedule;
12
+ private next;
13
+ constructor(logger?: ILogger, promiseStorage?: IStorage<DurablePromise>, scheduleStorage?: IStorage<Schedule>, lockStorage?: IStorage<{
14
+ id: string;
15
+ eid: string;
16
+ }>);
17
+ addSchedule(schedule: Schedule): void;
18
+ deleteSchedule(id: string): void;
19
+ private init;
20
+ private setSchedule;
21
+ private schedulePromise;
22
+ private generatePromiseId;
23
+ }
24
+ export declare class LocalPromiseStore implements IPromiseStore {
25
+ private storage;
26
+ constructor(storage?: IStorage<DurablePromise>);
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<PendingPromise | ResolvedPromise | RejectedPromise | CanceledPromise | TimedoutPromise>;
28
+ resolve(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<ResolvedPromise | RejectedPromise | CanceledPromise | TimedoutPromise>;
29
+ reject(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<ResolvedPromise | RejectedPromise | CanceledPromise | TimedoutPromise>;
30
+ cancel(id: string, ikey: string | undefined, strict: boolean, headers: Record<string, string> | undefined, data: string | undefined): Promise<ResolvedPromise | RejectedPromise | CanceledPromise | TimedoutPromise>;
31
+ get(id: string): Promise<DurablePromise>;
32
+ search(id: string, state?: string, tags?: Record<string, string>, limit?: number): AsyncGenerator<DurablePromise[], void>;
33
+ }
34
+ export declare class LocalScheduleStore implements IScheduleStore {
35
+ private storage;
36
+ private store;
37
+ constructor(storage?: IStorage<Schedule>, store?: LocalStore | undefined);
38
+ 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
+ update(id: string, lastRunTime: number): Promise<Schedule | undefined>;
40
+ delete(id: string): Promise<void>;
41
+ get(id: string): Promise<Schedule>;
42
+ search(id: string, tags?: Record<string, string>, limit?: number): AsyncGenerator<Schedule[], void>;
43
+ private nextRunTime;
44
+ }
45
+ export declare class LocalLockStore implements ILockStore {
46
+ private storage;
47
+ constructor(storage?: IStorage<{
48
+ id: string;
49
+ eid: string;
50
+ }>);
51
+ tryAcquire(id: string, eid: string): Promise<boolean>;
52
+ release(id: string, eid: string): Promise<void>;
53
+ }
54
+ //# sourceMappingURL=local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../lib/core/stores/local.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO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