@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,426 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Context = exports.Info = exports.Resonate = void 0;
27
+ const execution_1 = require("./core/execution");
28
+ const future_1 = require("./core/future");
29
+ const invocation_1 = require("./core/invocation");
30
+ const utils = __importStar(require("./core/utils"));
31
+ const resonate_1 = require("./resonate");
32
+ /////////////////////////////////////////////////////////////////////
33
+ // Resonate
34
+ /////////////////////////////////////////////////////////////////////
35
+ class Resonate extends resonate_1.ResonateBase {
36
+ scheduler;
37
+ /**
38
+ * Creates a Resonate instance. This is the starting point for using Resonate.
39
+ *
40
+ * @constructor
41
+ * @param opts - A partial {@link ResonateOptions} object.
42
+ */
43
+ constructor(opts = {}) {
44
+ super(opts);
45
+ this.scheduler = new Scheduler(this.logger);
46
+ }
47
+ register(name, funcOrVersion, funcOrOpts) {
48
+ return super.register(name, funcOrVersion, funcOrOpts);
49
+ }
50
+ /**
51
+ * Register a module with Resonate. Registered functions can be invoked by calling {@link run}.
52
+ *
53
+ * @template F The type of the generator function.
54
+ * @param module The module to register with Resonate.
55
+ * @param opts Resonate options, can be constructed by calling {@link options}.
56
+ * @returns Resonate function
57
+ */
58
+ registerModule(module, opts = {}) {
59
+ super.registerModule(module, opts);
60
+ }
61
+ execute(name, version, id, func, args, opts) {
62
+ return this.scheduler.add(name, version, id, func, args, opts);
63
+ }
64
+ }
65
+ exports.Resonate = Resonate;
66
+ /////////////////////////////////////////////////////////////////////
67
+ // Context
68
+ /////////////////////////////////////////////////////////////////////
69
+ class Info {
70
+ invocation;
71
+ constructor(invocation) {
72
+ this.invocation = invocation;
73
+ }
74
+ /**
75
+ * The running count of function execution attempts.
76
+ */
77
+ get attempt() {
78
+ return this.invocation.attempt;
79
+ }
80
+ /**
81
+ * Uniquely identifies the function invocation.
82
+ */
83
+ get id() {
84
+ return this.invocation.id;
85
+ }
86
+ /**
87
+ * Deduplicates function invocations with the same id.
88
+ */
89
+ get idempotencyKey() {
90
+ return this.invocation.idempotencyKey;
91
+ }
92
+ /**
93
+ * The timestamp in ms, once this time elapses the function invocation will timeout.
94
+ */
95
+ get timeout() {
96
+ return this.invocation.timeout;
97
+ }
98
+ /**
99
+ * The resonate function version.
100
+ */
101
+ get version() {
102
+ return this.invocation.version;
103
+ }
104
+ }
105
+ exports.Info = Info;
106
+ class Context {
107
+ invocation;
108
+ constructor(invocation) {
109
+ this.invocation = invocation;
110
+ }
111
+ /**
112
+ * The running count of child function invocations.
113
+ */
114
+ get counter() {
115
+ return this.invocation.counter;
116
+ }
117
+ /**
118
+ * Uniquely identifies the function invocation.
119
+ */
120
+ get id() {
121
+ return this.invocation.id;
122
+ }
123
+ /**
124
+ * Deduplicates function invocations with the same id.
125
+ */
126
+ get idempotencyKey() {
127
+ return this.invocation.idempotencyKey;
128
+ }
129
+ /**
130
+ * The timestamp in ms, once this time elapses the function invocation will timeout.
131
+ */
132
+ get timeout() {
133
+ return this.invocation.timeout;
134
+ }
135
+ /**
136
+ * The resonate function version.
137
+ */
138
+ get version() {
139
+ return this.invocation.version;
140
+ }
141
+ run(func, ...args) {
142
+ return this._call(func, args, false);
143
+ }
144
+ call(func, ...args) {
145
+ return this._call(func, args, true);
146
+ }
147
+ _call(func, argsWithOpts, yieldFuture) {
148
+ const { args, opts } = this.invocation.split(argsWithOpts);
149
+ if (typeof func === "string") {
150
+ return { kind: "call", value: { kind: "deferred", func, args: args[0], opts }, yieldFuture };
151
+ }
152
+ else if (func.constructor.name === "GeneratorFunction") {
153
+ return { kind: "call", value: { kind: "resonate", func, args, opts }, yieldFuture };
154
+ }
155
+ else {
156
+ return { kind: "call", value: { kind: "ordinary", func, args, opts }, yieldFuture };
157
+ }
158
+ }
159
+ /**
160
+ * Construct options.
161
+ *
162
+ * @param opts A partial {@link Options} object.
163
+ * @returns Options with the __resonate flag set.
164
+ */
165
+ options(opts = {}) {
166
+ return { ...opts, __resonate: true };
167
+ }
168
+ }
169
+ exports.Context = Context;
170
+ /////////////////////////////////////////////////////////////////////
171
+ // Scheduler
172
+ /////////////////////////////////////////////////////////////////////
173
+ class Scheduler {
174
+ logger;
175
+ // tick is mutually exclusive
176
+ running = false;
177
+ // all top level executions
178
+ cache = {};
179
+ // executions ready to be run
180
+ runnable = [];
181
+ // executions that are awaiting another execution
182
+ awaiting = [];
183
+ // all executions
184
+ executions = [];
185
+ // executions that have been killed
186
+ killed = [];
187
+ constructor(logger) {
188
+ this.logger = logger;
189
+ }
190
+ add(name, version, id, func, args, opts) {
191
+ // if the execution is already running, and not killed,
192
+ // return the promise
193
+ if (this.cache[id] && !this.cache[id].killed) {
194
+ return this.cache[id].execute();
195
+ }
196
+ // the idempotency key is a hash of the id
197
+ const idempotencyKey = utils.hash(id);
198
+ // params, used for recovery
199
+ const param = {
200
+ func: name,
201
+ version,
202
+ args,
203
+ };
204
+ // create a new invocation
205
+ const invocation = new invocation_1.Invocation(name, version, id, idempotencyKey, undefined, param, opts);
206
+ // create a new execution
207
+ const generator = func(new Context(invocation), ...args);
208
+ const execution = new execution_1.GeneratorExecution(invocation, generator);
209
+ const promise = execution.execute();
210
+ // once the durable promise has been created,
211
+ // add the execution to runnable
212
+ execution.create().then((promise) => {
213
+ if (promise && promise.pending) {
214
+ this.runnable.push({ execution, promise, next: { kind: "init" } });
215
+ this.tick();
216
+ }
217
+ });
218
+ // store the invocation, execution, and promise
219
+ // will be used if run is called again with the same id
220
+ this.cache[id] = execution;
221
+ this.executions.push(execution);
222
+ return promise;
223
+ }
224
+ async tick() {
225
+ // need to ensure that tick is mutually exclusive,
226
+ // if tick is already running all continuations will be picked up in the while loop
227
+ if (this.running)
228
+ return;
229
+ this.running = true;
230
+ while (this.runnable.length > 0) {
231
+ // grab the next continuation
232
+ const continuation = this.runnable.shift();
233
+ // step through the generator if in debug mode
234
+ if (this.logger.level === "debug" && (await this.keypress()) === "\u001b") {
235
+ // kill when escape key is pressed
236
+ continuation?.execution.kill("manual kill");
237
+ }
238
+ if (continuation && !continuation.execution.killed) {
239
+ try {
240
+ // apply the next value to the generator
241
+ const result = this.next(continuation);
242
+ // if done, we can resolve the execution
243
+ if (result.done) {
244
+ // need to handle the special case where a generator returns a future
245
+ if (result.value instanceof future_1.Future) {
246
+ result.value.promise.then((v) => continuation.execution.resolve(continuation.promise, v), (e) => continuation.execution.reject(continuation.promise, e));
247
+ }
248
+ else {
249
+ // resolve the durable promise
250
+ await continuation.execution.resolve(continuation.promise, result.value);
251
+ }
252
+ }
253
+ else {
254
+ // apply the yielded value to the generator
255
+ await this.apply(continuation, result.value);
256
+ }
257
+ }
258
+ catch (error) {
259
+ // if anything goes wrong, reject the durable promise
260
+ await continuation.execution.reject(continuation.promise, error);
261
+ }
262
+ // housekeeping
263
+ if (continuation.execution.killed) {
264
+ this.kill(continuation.execution);
265
+ }
266
+ }
267
+ // print all invocations if in debug mode
268
+ this.print();
269
+ }
270
+ // TODO: suspend
271
+ // set running back to false
272
+ this.running = false;
273
+ }
274
+ next({ execution, next }) {
275
+ // apply the next value to the generator
276
+ switch (next.kind) {
277
+ case "init":
278
+ return execution.generator.next();
279
+ case "value":
280
+ return execution.generator.next(next.value);
281
+ case "error":
282
+ return execution.generator.throw(next.error);
283
+ default:
284
+ this.yeet(`permitted continuation values are (init, value, error), received ${next}`);
285
+ }
286
+ }
287
+ async apply(continuation, yielded) {
288
+ // apply the yielded value to the generator
289
+ switch (yielded.kind) {
290
+ case "call":
291
+ await this.applyCall(continuation, yielded);
292
+ break;
293
+ case "future":
294
+ this.applyFuture(continuation, yielded);
295
+ break;
296
+ default:
297
+ this.yeet(`permitted yielded values are (call, future), received ${yielded}`);
298
+ }
299
+ }
300
+ async applyCall(continuation, { value, yieldFuture }) {
301
+ // the parent is the current invocation
302
+ const parent = continuation.execution.invocation;
303
+ // the id is either:
304
+ // 1. a provided string in the case of a deferred execution
305
+ // 2. a generated string in the case of an ordinary execution
306
+ const id = value.kind === "deferred" ? value.func : `${parent.id}.${parent.counter}`;
307
+ // the idempotency key is a hash of the id
308
+ const idempotencyKey = utils.hash(id);
309
+ // human readable name of the function
310
+ const name = value.kind === "deferred" ? value.func : value.func.name;
311
+ // version is inherited from the parent
312
+ const version = parent.version;
313
+ // create a new invocation
314
+ const invocation = new invocation_1.Invocation(name, version, id, idempotencyKey, undefined, undefined, value.opts, parent);
315
+ // add child and increment counter
316
+ parent.addChild(invocation);
317
+ parent.counter++;
318
+ let execution;
319
+ if (value.kind === "resonate") {
320
+ // create a generator execution
321
+ const ctx = new Context(invocation);
322
+ execution = new execution_1.GeneratorExecution(invocation, value.func(ctx, ...value.args));
323
+ const promise = await execution.create();
324
+ if (promise && promise.pending) {
325
+ // if the durable promise is pending, add to runnable
326
+ this.runnable.push({ execution, promise, next: { kind: "init" } });
327
+ }
328
+ }
329
+ else if (value.kind === "ordinary") {
330
+ // create an ordinary execution
331
+ const info = new Info(invocation);
332
+ execution = new execution_1.OrdinaryExecution(invocation, () => value.func(info, ...value.args));
333
+ execution.execute().catch(() => { });
334
+ }
335
+ else if (value.kind === "deferred") {
336
+ // create a deferred execution
337
+ execution = new execution_1.DeferredExecution(invocation);
338
+ execution.execute().catch(() => { });
339
+ }
340
+ else {
341
+ this.yeet(`permitted call values are (resonate, ordinary, deferred), received ${value}`);
342
+ }
343
+ // add to all executions
344
+ this.executions.push(execution);
345
+ if (yieldFuture) {
346
+ // if the call is expected to yield a future, add the future to runnable
347
+ this.runnable.push({
348
+ execution: continuation.execution,
349
+ promise: continuation.promise,
350
+ next: { kind: "value", value: invocation.future },
351
+ });
352
+ }
353
+ else {
354
+ // otherwise, skip ahead to apply future
355
+ this.applyFuture(continuation, invocation.future);
356
+ }
357
+ }
358
+ applyFuture({ execution, promise }, future) {
359
+ if (execution.invocation.future.root !== future.root) {
360
+ this.yeet(`yielded future originates from ${future.root.id}, but this execution originates from ${execution.invocation.future.root.id}`);
361
+ }
362
+ // add to awaiting
363
+ this.awaiting.push(execution);
364
+ execution.invocation.await(future);
365
+ execution.invocation.block(future);
366
+ const apply = (next) => {
367
+ // unblock
368
+ execution.invocation.unblock();
369
+ // remove from awaiting
370
+ this.awaiting = this.awaiting.filter((e) => e !== execution);
371
+ // add to runnable
372
+ this.runnable.push({ execution, promise, next });
373
+ // tick again
374
+ this.tick();
375
+ };
376
+ // add the next value to runnable when the future fulfills
377
+ future.promise.then((value) => apply({ kind: "value", value }), (error) => apply({ kind: "error", error }));
378
+ }
379
+ kill(execution) {
380
+ // add to killed
381
+ const killed = this.executions.filter((e) => e.invocation.root === execution.invocation.root);
382
+ this.killed = this.killed.concat(killed);
383
+ // remove from awaiting and runnable
384
+ this.runnable = this.runnable.filter((c) => c.execution.invocation.root !== execution.invocation.root);
385
+ this.awaiting = this.awaiting.filter((e) => e.invocation.root !== execution.invocation.root);
386
+ }
387
+ async keypress() {
388
+ this.logger.debug("Press any key to continue...");
389
+ return new Promise((resolve) => {
390
+ const onData = (data) => {
391
+ process.stdin.removeListener("data", onData);
392
+ process.stdin.setRawMode(false);
393
+ process.stdin.pause();
394
+ const c = data.toString();
395
+ if (c === "\u0003") {
396
+ this.logger.debug("^C");
397
+ process.exit(1);
398
+ }
399
+ resolve(c);
400
+ };
401
+ process.stdin.resume();
402
+ process.stdin.setRawMode(true);
403
+ process.stdin.once("data", onData);
404
+ });
405
+ }
406
+ print() {
407
+ this.logger.debug("Executions");
408
+ this.logger.table(this.executions.map((e) => ({
409
+ name: e.invocation.name,
410
+ version: e.invocation.version,
411
+ id: e.invocation.id,
412
+ idempotencyKey: e.invocation.idempotencyKey,
413
+ parent: e.invocation.parent ? e.invocation.parent.id : undefined,
414
+ killed: e.killed,
415
+ pending: e.invocation.future.value.kind === "pending",
416
+ awaited: e.invocation.awaited.map((f) => f.id).join(","),
417
+ blocked: e.invocation.blocked?.id,
418
+ })));
419
+ }
420
+ yeet(msg) {
421
+ // an unrecoverable error has occurred, log and exit
422
+ this.logger.error(msg);
423
+ process.exit(1);
424
+ }
425
+ }
426
+ //# sourceMappingURL=generator.js.map
@@ -0,0 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AAO,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO;YAC7B,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE;YACnB,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,cAAc;YAC3C,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;YAChE,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;YACrD,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACxD,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE;SAClC,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,GAAW;QACtB,oDAAoD;QACpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { Resonate, Context } from "./async";
2
+ import * as generator from "./generator";
3
+ export { generator };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.generator = exports.Context = exports.Resonate = void 0;
27
+ var async_1 = require("./async");
28
+ Object.defineProperty(exports, "Resonate", { enumerable: true, get: function () { return async_1.Resonate; } });
29
+ Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return async_1.Context; } });
30
+ const generator = __importStar(require("./generator"));
31
+ exports.generator = generator;
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA4C;AAAnC,iGAAA,QAAQ,OAAA;AAAE,gGAAA,OAAO,OAAA;AAC1B,uDAAyC;AAChC,8BAAS"}
@@ -0,0 +1,74 @@
1
+ import { IEncoder } from "./core/encoder";
2
+ import { ResonatePromise } from "./core/future";
3
+ import { ILogger } from "./core/logger";
4
+ import { ResonateOptions, Options } from "./core/options";
5
+ import { DurablePromise, CreateOptions, CompleteOptions } from "./core/promises/promises";
6
+ import { IRetry } from "./core/retry";
7
+ import { IStore } from "./core/store";
8
+ type Func = (...args: any[]) => any;
9
+ export declare abstract class ResonateBase {
10
+ private readonly functions;
11
+ readonly pid: string;
12
+ readonly timeout: number;
13
+ readonly tags: Record<string, string>;
14
+ protected readonly encoder: IEncoder<unknown, string | undefined>;
15
+ protected readonly logger: ILogger;
16
+ protected readonly retry: IRetry;
17
+ protected readonly store: IStore;
18
+ private interval;
19
+ constructor({ encoder, logger, pid, retry, store, tags, timeout, // 10s
20
+ url, }?: Partial<ResonateOptions>);
21
+ register(name: string, funcOrVersion: Func | number, funcOrOpts: Func | Partial<Options>): (id: string, ...args: any) => ResonatePromise<any>;
22
+ registerModule(module: Record<string, Func>, opts?: Partial<Options>): void;
23
+ /**
24
+ * Run a Resonate function. Functions must first be registered with {@link register}.
25
+ *
26
+ * @template T The return type of the function.
27
+ * @param id A unique id for the function invocation.
28
+ * @param name The function name.
29
+ * @param args The function arguments.
30
+ * @returns A promise that resolve to the function return value.
31
+ */
32
+ run<T>(name: string, id: string, ...args: any[]): ResonatePromise<T>;
33
+ /**
34
+ * Run a Resonate function. Functions must first be registered with {@link register}.
35
+ *
36
+ * @template T The return type of the function.
37
+ * @param name The function name.
38
+ * @param version The function version.
39
+ * @param id A unique id for the function invocation.
40
+ * @param args The function arguments.
41
+ * @returns A promise that resolve to the function return value.
42
+ */
43
+ run<T>(name: string, version: number, id: string, ...args: any[]): ResonatePromise<T>;
44
+ protected abstract execute(name: string, version: number, id: string, func: Func, args: any[], opts: Options): ResonatePromise<any>;
45
+ /**
46
+ * Start the resonate service.
47
+ *
48
+ * @param delay Frequency in ms to check for pending promises.
49
+ */
50
+ start(delay?: number): void;
51
+ /**
52
+ * Stop the resonate service.
53
+ */
54
+ stop(): void;
55
+ private _start;
56
+ get promises(): {
57
+ create: <T>(id: string, timeout: number, opts?: Partial<CreateOptions>) => Promise<DurablePromise<T>>;
58
+ resolve: <T_1>(id: string, value: T_1, opts?: Partial<CompleteOptions>) => Promise<DurablePromise<T_1>>;
59
+ reject: <T_2>(id: string, error: any, opts?: Partial<CompleteOptions>) => Promise<DurablePromise<T_2>>;
60
+ cancel: <T_3>(id: string, error: any, opts?: Partial<CompleteOptions>) => Promise<DurablePromise<T_3>>;
61
+ get: <T_4>(id: string) => Promise<DurablePromise<T_4>>;
62
+ search: (id: string, state?: string, tags?: Record<string, string>, limit?: number) => AsyncGenerator<DurablePromise<any>[], void, unknown>;
63
+ };
64
+ /**
65
+ * Construct options.
66
+ *
67
+ * @param opts A partial {@link Options} object.
68
+ * @returns Options with the __resonate flag set.
69
+ */
70
+ options({ encoder, poll, // every 5s
71
+ retry, store, tags, timeout, }: Partial<Options>): Options;
72
+ }
73
+ export {};
74
+ //# sourceMappingURL=resonate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resonate.d.ts","sourceRoot":"","sources":["../lib/resonate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAStC,KAAK,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAMpC,8BAAsB,YAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsF;IAEhH,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,IAAI,EAAE,MAAM,CAAC,MAAM,EAA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