@resonatehq/sdk 0.5.3 → 0.6.0
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/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 +4 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +5 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/options.d.ts +20 -11
- package/dist/core/options.d.ts.map +1 -1
- package/dist/core/options.js +11 -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 +2 -1
- 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 +36 -26
- package/dist/core/retry.d.ts.map +1 -1
- package/dist/core/retry.js +130 -14
- package/dist/core/retry.js.map +1 -1
- package/dist/core/schedules/schedules.d.ts +1 -1
- package/dist/core/schedules/schedules.d.ts.map +1 -1
- package/dist/core/schedules/schedules.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 +9 -9
- package/dist/core/stores/local.d.ts.map +1 -1
- package/dist/core/stores/local.js +2 -2
- package/dist/core/stores/local.js.map +1 -1
- package/dist/core/stores/remote.d.ts +7 -7
- package/dist/core/stores/remote.d.ts.map +1 -1
- package/dist/core/stores/remote.js +29 -7
- package/dist/core/stores/remote.js.map +1 -1
- package/dist/core/utils.d.ts +82 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +103 -1
- package/dist/core/utils.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -1
- package/dist/resonate.d.ts +163 -49
- package/dist/resonate.d.ts.map +1 -1
- package/dist/resonate.js +626 -146
- package/dist/resonate.js.map +1 -1
- package/package.json +1 -1
- package/dist/async.d.ts +0 -201
- package/dist/async.d.ts.map +0 -1
- package/dist/async.js +0 -331
- package/dist/async.js.map +0 -1
- package/dist/core/execution.d.ts +0 -47
- package/dist/core/execution.d.ts.map +0 -1
- package/dist/core/execution.js +0 -310
- package/dist/core/execution.js.map +0 -1
- package/dist/core/future.d.ts +0 -56
- package/dist/core/future.d.ts.map +0 -1
- package/dist/core/future.js +0 -107
- package/dist/core/future.js.map +0 -1
- package/dist/core/invocation.d.ts +0 -44
- package/dist/core/invocation.d.ts.map +0 -1
- package/dist/core/invocation.js +0 -103
- package/dist/core/invocation.js.map +0 -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
package/dist/core/invocation.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Invocation = void 0;
|
|
4
|
-
const future_1 = require("./future");
|
|
5
|
-
const options_1 = require("./options");
|
|
6
|
-
/////////////////////////////////////////////////////////////////////
|
|
7
|
-
// Invocation
|
|
8
|
-
/////////////////////////////////////////////////////////////////////
|
|
9
|
-
class Invocation {
|
|
10
|
-
name;
|
|
11
|
-
id;
|
|
12
|
-
headers;
|
|
13
|
-
param;
|
|
14
|
-
opts;
|
|
15
|
-
defaults;
|
|
16
|
-
future;
|
|
17
|
-
resolve;
|
|
18
|
-
reject;
|
|
19
|
-
eid;
|
|
20
|
-
idempotencyKey;
|
|
21
|
-
timeout;
|
|
22
|
-
killed = false;
|
|
23
|
-
createdOn = Date.now();
|
|
24
|
-
counter = 0;
|
|
25
|
-
attempt = 0;
|
|
26
|
-
awaited = [];
|
|
27
|
-
blocked = null;
|
|
28
|
-
root;
|
|
29
|
-
parent;
|
|
30
|
-
children = [];
|
|
31
|
-
/**
|
|
32
|
-
* Represents a Resonate function invocation.
|
|
33
|
-
*
|
|
34
|
-
* @constructor
|
|
35
|
-
* @param id - A unique id for this invocation.
|
|
36
|
-
* @param idempotencyKey - An idempotency key used to deduplicate invocations.
|
|
37
|
-
* @param opts - The invocation options.
|
|
38
|
-
* @param parent - The parent invocation.
|
|
39
|
-
*/
|
|
40
|
-
constructor(name, id, headers, param, opts, defaults, parent) {
|
|
41
|
-
this.name = name;
|
|
42
|
-
this.id = id;
|
|
43
|
-
this.headers = headers;
|
|
44
|
-
this.param = param;
|
|
45
|
-
this.opts = opts;
|
|
46
|
-
this.defaults = defaults;
|
|
47
|
-
// create a future and hold on to its resolvers
|
|
48
|
-
const { future, resolve, reject } = future_1.Future.deferred(this);
|
|
49
|
-
this.future = future;
|
|
50
|
-
this.resolve = resolve;
|
|
51
|
-
this.reject = reject;
|
|
52
|
-
this.root = parent?.root ?? this;
|
|
53
|
-
this.parent = parent ?? null;
|
|
54
|
-
// get the execution id from either:
|
|
55
|
-
// - a hard coded string
|
|
56
|
-
// - a function that returns a string given the invocation id
|
|
57
|
-
this.eid = typeof this.opts.eid === "function" ? this.opts.eid(this.id) : this.opts.eid;
|
|
58
|
-
// get the idempotency key from either:
|
|
59
|
-
// - a hard coded string
|
|
60
|
-
// - a function that returns a string given the invocation id
|
|
61
|
-
this.idempotencyKey =
|
|
62
|
-
typeof this.opts.idempotencyKey === "function" ? this.opts.idempotencyKey(this.id) : this.opts.idempotencyKey;
|
|
63
|
-
// the timeout is the minimum of:
|
|
64
|
-
// - the current time plus the user provided relative time
|
|
65
|
-
// - the parent timeout
|
|
66
|
-
this.timeout = Math.min(this.createdOn + this.opts.timeout, this.parent?.timeout ?? Infinity);
|
|
67
|
-
}
|
|
68
|
-
addChild(child) {
|
|
69
|
-
this.children.push(child);
|
|
70
|
-
}
|
|
71
|
-
await(future) {
|
|
72
|
-
this.awaited.push(future);
|
|
73
|
-
}
|
|
74
|
-
block(future) {
|
|
75
|
-
this.blocked = future;
|
|
76
|
-
}
|
|
77
|
-
unblock() {
|
|
78
|
-
this.blocked = null;
|
|
79
|
-
}
|
|
80
|
-
split(args) {
|
|
81
|
-
let opts = args[args.length - 1];
|
|
82
|
-
// merge opts
|
|
83
|
-
if ((0, options_1.isOptions)(opts)) {
|
|
84
|
-
args = args.slice(0, -1);
|
|
85
|
-
opts = {
|
|
86
|
-
...this.defaults,
|
|
87
|
-
...opts,
|
|
88
|
-
tags: { ...this.defaults.tags, ...opts.tags }, // tags are merged
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
// copy defaults
|
|
93
|
-
opts = { ...this.defaults };
|
|
94
|
-
}
|
|
95
|
-
// lock is false by default
|
|
96
|
-
opts.lock = opts.lock ?? false;
|
|
97
|
-
// version cannot be overridden
|
|
98
|
-
opts.version = this.defaults.version;
|
|
99
|
-
return { args, opts };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.Invocation = Invocation;
|
|
103
|
-
//# sourceMappingURL=invocation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invocation.js","sourceRoot":"","sources":["../../lib/core/invocation.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,uCAA+D;AAE/D,qEAAqE;AACrE,aAAa;AACb,qEAAqE;AAErE,MAAa,UAAU;IAgC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B,GAAG,IAAI;gBACP,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,kBAAkB;aAClE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,gBAAgB;YAChB,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC;QAED,2BAA2B;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC;QAE/B,+BAA+B;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAErC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;CACF;AA1GD,gCA0GC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IRetry, IterableRetry } from "../retry";
|
|
2
|
-
export declare class Retry extends IterableRetry implements IRetry {
|
|
3
|
-
private initialDelay;
|
|
4
|
-
private backoffFactor;
|
|
5
|
-
private maxAttempts;
|
|
6
|
-
private maxDelay;
|
|
7
|
-
constructor(initialDelay: number, backoffFactor: number, maxAttempts: number, maxDelay: number);
|
|
8
|
-
static exponential(initialDelay?: number, backoffFactor?: number, maxAttempts?: number, maxDelay?: number): Retry;
|
|
9
|
-
static linear(delay?: number, // 1 second
|
|
10
|
-
maxAttempts?: number): Retry;
|
|
11
|
-
static never(): Retry;
|
|
12
|
-
next<T extends {
|
|
13
|
-
attempt: number;
|
|
14
|
-
timeout: number;
|
|
15
|
-
}>(ctx: T): {
|
|
16
|
-
done: boolean;
|
|
17
|
-
delay?: number;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../lib/core/retries/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjD,qBAAa,KAAM,SAAQ,aAAc,YAAW,MAAM;IAEtD,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,QAAQ;gBAHR,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM;IAK1B,MAAM,CAAC,WAAW,CAChB,YAAY,GAAE,MAAY,EAC1B,aAAa,GAAE,MAAU,EACzB,WAAW,GAAE,MAAiB,EAC9B,QAAQ,GAAE,MAAc,GACvB,KAAK;IAIR,MAAM,CAAC,MAAM,CACX,KAAK,GAAE,MAAa,EAAE,WAAW;IACjC,WAAW,GAAE,MAAiB,GAC7B,KAAK;IAIR,MAAM,CAAC,KAAK,IAAI,KAAK;IAIrB,IAAI,CAAC,CAAC,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;CAiBhG"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Retry = void 0;
|
|
4
|
-
const retry_1 = require("../retry");
|
|
5
|
-
class Retry extends retry_1.IterableRetry {
|
|
6
|
-
initialDelay;
|
|
7
|
-
backoffFactor;
|
|
8
|
-
maxAttempts;
|
|
9
|
-
maxDelay;
|
|
10
|
-
constructor(initialDelay, backoffFactor, maxAttempts, maxDelay) {
|
|
11
|
-
super();
|
|
12
|
-
this.initialDelay = initialDelay;
|
|
13
|
-
this.backoffFactor = backoffFactor;
|
|
14
|
-
this.maxAttempts = maxAttempts;
|
|
15
|
-
this.maxDelay = maxDelay;
|
|
16
|
-
}
|
|
17
|
-
static exponential(initialDelay = 100, backoffFactor = 2, maxAttempts = Infinity, maxDelay = 60000) {
|
|
18
|
-
return new Retry(initialDelay, backoffFactor, maxAttempts, maxDelay);
|
|
19
|
-
}
|
|
20
|
-
static linear(delay = 1000, // 1 second
|
|
21
|
-
maxAttempts = Infinity) {
|
|
22
|
-
return new Retry(delay, 1, maxAttempts, delay);
|
|
23
|
-
}
|
|
24
|
-
static never() {
|
|
25
|
-
return new Retry(0, 0, 1, 0);
|
|
26
|
-
}
|
|
27
|
-
next(ctx) {
|
|
28
|
-
// attempt 0: 0ms delay
|
|
29
|
-
// attampt n: {initial * factor^(attempt-1)}ms delay (or max delay)
|
|
30
|
-
const delay = Math.min(Math.min(ctx.attempt, 1) * this.initialDelay * Math.pow(this.backoffFactor, ctx.attempt - 1), this.maxDelay);
|
|
31
|
-
if (Date.now() + delay >= ctx.timeout || ctx.attempt >= this.maxAttempts) {
|
|
32
|
-
return { done: true };
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
done: false,
|
|
36
|
-
delay: delay,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.Retry = Retry;
|
|
41
|
-
//# sourceMappingURL=retry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../lib/core/retries/retry.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAEjD,MAAa,KAAM,SAAQ,qBAAa;IAE5B;IACA;IACA;IACA;IAJV,YACU,YAAoB,EACpB,aAAqB,EACrB,WAAmB,EACnB,QAAgB;QAExB,KAAK,EAAE,CAAC;QALA,iBAAY,GAAZ,YAAY,CAAQ;QACpB,kBAAa,GAAb,aAAa,CAAQ;QACrB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAQ;IAG1B,CAAC;IAED,MAAM,CAAC,WAAW,CAChB,eAAuB,GAAG,EAC1B,gBAAwB,CAAC,EACzB,cAAsB,QAAQ,EAC9B,WAAmB,KAAK;QAExB,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,MAAM,CACX,QAAgB,IAAI,EAAE,WAAW;IACjC,cAAsB,QAAQ;QAE9B,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,KAAK;QACV,OAAO,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAiD,GAAM;QACzD,uBAAuB;QACvB,mEAAmE;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACpB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,EAC5F,IAAI,CAAC,QAAQ,CACd,CAAC;QAEF,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACzE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;QAED,OAAO;YACL,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF;AA/CD,sBA+CC"}
|
package/dist/generator.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Future, ResonatePromise } from "./core/future";
|
|
2
|
-
import { Invocation } from "./core/invocation";
|
|
3
|
-
import { ResonateOptions, Options, PartialOptions } from "./core/options";
|
|
4
|
-
import { DurablePromise } from "./core/promises/promises";
|
|
5
|
-
import * as schedules from "./core/schedules/schedules";
|
|
6
|
-
import { ResonateBase } from "./resonate";
|
|
7
|
-
export type GFunc = (ctx: Context, ...args: any[]) => Generator<Yieldable>;
|
|
8
|
-
export type IFunc = (info: Info, ...args: any[]) => any;
|
|
9
|
-
export type Params<F> = F extends (ctx: any, ...args: infer P) => any ? P : never;
|
|
10
|
-
export type Return<F> = F extends (...args: any[]) => Generator<any, infer T> ? T : never;
|
|
11
|
-
export type Yieldable = Call | Future<any>;
|
|
12
|
-
export type Call = {
|
|
13
|
-
kind: "call";
|
|
14
|
-
value: ResonateFunction | OrdinaryFunction | DeferredFunction;
|
|
15
|
-
yieldFuture: boolean;
|
|
16
|
-
};
|
|
17
|
-
type ResonateFunction = {
|
|
18
|
-
kind: "resonate";
|
|
19
|
-
func: GFunc;
|
|
20
|
-
args: any[];
|
|
21
|
-
opts: Options;
|
|
22
|
-
};
|
|
23
|
-
type OrdinaryFunction = {
|
|
24
|
-
kind: "ordinary";
|
|
25
|
-
func: IFunc;
|
|
26
|
-
args: any[];
|
|
27
|
-
opts: Options;
|
|
28
|
-
};
|
|
29
|
-
type DeferredFunction = {
|
|
30
|
-
kind: "deferred";
|
|
31
|
-
func: string;
|
|
32
|
-
args: any;
|
|
33
|
-
opts: Options;
|
|
34
|
-
};
|
|
35
|
-
export declare class Resonate extends ResonateBase {
|
|
36
|
-
private 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?: Partial<ResonateOptions>);
|
|
44
|
-
protected execute<F extends GFunc>(name: string, id: string, func: F, args: Params<F>, opts: Options, defaults: Options, durablePromise?: DurablePromise<any>): ResonatePromise<Return<F>>;
|
|
45
|
-
/**
|
|
46
|
-
* Register a function with Resonate. Registered functions can be invoked by calling {@link run}, or by the returned function.
|
|
47
|
-
*
|
|
48
|
-
* @template F The type of the generator function.
|
|
49
|
-
* @param name A unique name to identify the function.
|
|
50
|
-
* @param func The generator function to register with Resonate.
|
|
51
|
-
* @param opts Resonate options, can be constructed by calling {@link options}.
|
|
52
|
-
* @returns Resonate function
|
|
53
|
-
*/
|
|
54
|
-
register<F extends GFunc>(name: string, func: F, opts?: Partial<Options>): (id: string, ...args: Params<F>) => ResonatePromise<Return<F>>;
|
|
55
|
-
/**
|
|
56
|
-
* Register a module with Resonate. Registered functions can be invoked by calling {@link run}.
|
|
57
|
-
*
|
|
58
|
-
* @template F The type of the generator function.
|
|
59
|
-
* @param module The module to register with Resonate.
|
|
60
|
-
* @param opts Resonate options, can be constructed by calling {@link options}.
|
|
61
|
-
* @returns Resonate function
|
|
62
|
-
*/
|
|
63
|
-
registerModule<F extends GFunc>(module: Record<string, F>, opts?: Partial<Options>): void;
|
|
64
|
-
/**
|
|
65
|
-
* Schedule a resonate function.
|
|
66
|
-
*
|
|
67
|
-
* @param name The schedule name.
|
|
68
|
-
* @param cron The schedule cron expression.
|
|
69
|
-
* @param func The function to schedule.
|
|
70
|
-
* @param args The function arguments.
|
|
71
|
-
* @returns The schedule object.
|
|
72
|
-
*/
|
|
73
|
-
schedule<F extends GFunc>(name: string, cron: string, func: F, ...args: [...Params<F>, PartialOptions?]): Promise<schedules.Schedule>;
|
|
74
|
-
/**
|
|
75
|
-
* Schedule a resonate function that is already registered.
|
|
76
|
-
*
|
|
77
|
-
* @param name The schedule name.
|
|
78
|
-
* @param cron The schedule cron expression.
|
|
79
|
-
* @param func The registered function name.
|
|
80
|
-
* @param args The function arguments.
|
|
81
|
-
* @returns The schedule object.
|
|
82
|
-
*/
|
|
83
|
-
schedule(name: string, cron: string, func: string, ...args: [...any, PartialOptions?]): Promise<schedules.Schedule>;
|
|
84
|
-
}
|
|
85
|
-
export declare class Info {
|
|
86
|
-
private invocation;
|
|
87
|
-
constructor(invocation: Invocation<any>);
|
|
88
|
-
/**
|
|
89
|
-
* The running count of function execution attempts.
|
|
90
|
-
*/
|
|
91
|
-
get attempt(): number;
|
|
92
|
-
/**
|
|
93
|
-
* Uniquely identifies the function invocation.
|
|
94
|
-
*/
|
|
95
|
-
get id(): string;
|
|
96
|
-
/**
|
|
97
|
-
* Deduplicates function invocations with the same id.
|
|
98
|
-
*/
|
|
99
|
-
get idempotencyKey(): string;
|
|
100
|
-
/**
|
|
101
|
-
* All configured options for this info.
|
|
102
|
-
*/
|
|
103
|
-
get opts(): Options;
|
|
104
|
-
/**
|
|
105
|
-
* The timestamp in ms, once this time elapses the function invocation will timeout.
|
|
106
|
-
*/
|
|
107
|
-
get timeout(): number;
|
|
108
|
-
/**
|
|
109
|
-
* The resonate function version.
|
|
110
|
-
*/
|
|
111
|
-
get version(): number;
|
|
112
|
-
}
|
|
113
|
-
export declare class Context {
|
|
114
|
-
private invocation;
|
|
115
|
-
constructor(invocation: Invocation<any>);
|
|
116
|
-
/**
|
|
117
|
-
* The running count of child function invocations.
|
|
118
|
-
*/
|
|
119
|
-
get counter(): number;
|
|
120
|
-
/**
|
|
121
|
-
* The time the invocation was created. Will use the durable promise creation time if available.
|
|
122
|
-
*/
|
|
123
|
-
get createdOn(): number;
|
|
124
|
-
/**
|
|
125
|
-
* Uniquely identifies the function invocation.
|
|
126
|
-
*/
|
|
127
|
-
get id(): string;
|
|
128
|
-
/**
|
|
129
|
-
* Deduplicates function invocations with the same id.
|
|
130
|
-
*/
|
|
131
|
-
get idempotencyKey(): string;
|
|
132
|
-
/**
|
|
133
|
-
* All configured options for this context.
|
|
134
|
-
*/
|
|
135
|
-
get opts(): Options;
|
|
136
|
-
/**
|
|
137
|
-
* The timestamp in ms, once this time elapses the function invocation will timeout.
|
|
138
|
-
*/
|
|
139
|
-
get timeout(): number;
|
|
140
|
-
/**
|
|
141
|
-
* The resonate function version.
|
|
142
|
-
*/
|
|
143
|
-
get version(): number;
|
|
144
|
-
/**
|
|
145
|
-
* Invoke a generator function.
|
|
146
|
-
*
|
|
147
|
-
* @template F The type of the generator function.
|
|
148
|
-
* @param func The function to invoke.
|
|
149
|
-
* @param args The function arguments, optionally followed by {@link options}.
|
|
150
|
-
* @returns A {@link Call} that can be yielded for a value.
|
|
151
|
-
*/
|
|
152
|
-
run<F extends GFunc>(func: F, ...args: [...Params<F>, PartialOptions?]): Call;
|
|
153
|
-
/**
|
|
154
|
-
* Invoke a function.
|
|
155
|
-
*
|
|
156
|
-
* @template F The type of the function.
|
|
157
|
-
* @param func The function to invoke.
|
|
158
|
-
* @param args The function arguments, optionally followed by {@link options}.
|
|
159
|
-
* @returns A {@link Call} that can be yielded for a value.
|
|
160
|
-
*/
|
|
161
|
-
run<F extends IFunc>(func: F, ...args: [...Params<F>, PartialOptions?]): Call;
|
|
162
|
-
/**
|
|
163
|
-
* Invoke a remote function.
|
|
164
|
-
*
|
|
165
|
-
* @param func The id of the remote function.
|
|
166
|
-
* @param args The arguments to pass to the remote function.
|
|
167
|
-
* @param opts Optional {@link options}.
|
|
168
|
-
* @returns A {@link Call} that can be yielded for a value.
|
|
169
|
-
*/
|
|
170
|
-
run(func: string, args?: any, opts?: PartialOptions): Call;
|
|
171
|
-
/**
|
|
172
|
-
* Invoke a generator function.
|
|
173
|
-
*
|
|
174
|
-
* @template F The type of the generator function.
|
|
175
|
-
* @param func The function to invoke.
|
|
176
|
-
* @param args The function arguments, optionally followed by {@link options}.
|
|
177
|
-
* @returns A {@link Call} that can be yielded for a {@link Future}.
|
|
178
|
-
*/
|
|
179
|
-
call<F extends GFunc>(func: F, ...args: [...Params<F>, PartialOptions?]): Call;
|
|
180
|
-
/**
|
|
181
|
-
* Invoke a function.
|
|
182
|
-
*
|
|
183
|
-
* @template F The type of the function.
|
|
184
|
-
* @param func The function to invoke.
|
|
185
|
-
* @param args The function arguments, optionally followed by {@link options}.
|
|
186
|
-
* @returns A {@link Call} that can be yielded for a {@link Future}.
|
|
187
|
-
*/
|
|
188
|
-
call<F extends IFunc>(func: F, ...args: [...Params<F>, PartialOptions?]): Call;
|
|
189
|
-
/**
|
|
190
|
-
* Invoke a remote function.
|
|
191
|
-
*
|
|
192
|
-
* @param func The id of the remote function.
|
|
193
|
-
* @param args The arguments to pass to the remote function.
|
|
194
|
-
* @param opts Optional {@link options}.
|
|
195
|
-
* @returns A {@link Call} that can be yielded for a {@link Future}.
|
|
196
|
-
*/
|
|
197
|
-
call(func: string, args?: any, opts?: PartialOptions): Call;
|
|
198
|
-
private _call;
|
|
199
|
-
/**
|
|
200
|
-
* Construct options.
|
|
201
|
-
*
|
|
202
|
-
* @param opts A partial {@link Options} object.
|
|
203
|
-
* @returns Options with the __resonate flag set.
|
|
204
|
-
*/
|
|
205
|
-
options(opts?: Partial<Options>): PartialOptions;
|
|
206
|
-
}
|
|
207
|
-
export {};
|
|
208
|
-
//# sourceMappingURL=generator.d.ts.map
|
package/dist/generator.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../lib/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM1C,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,CAAC,SAAS,CAAC,CAAC;AAE3E,MAAM,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAExD,MAAM,MAAM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