inngest 2.7.1 → 3.0.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/CHANGELOG.md +52 -0
- package/api/api.js +4 -4
- package/api/schema.d.ts +54 -6
- package/api/schema.d.ts.map +1 -1
- package/api/schema.js +17 -7
- package/api/schema.js.map +1 -1
- package/cloudflare.d.ts +6 -3
- package/cloudflare.d.ts.map +1 -1
- package/cloudflare.js +19 -41
- package/cloudflare.js.map +1 -1
- package/components/EventSchemas.d.ts +1 -12
- package/components/EventSchemas.d.ts.map +1 -1
- package/components/EventSchemas.js.map +1 -1
- package/components/Inngest.d.ts +44 -57
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js +91 -59
- package/components/Inngest.js.map +1 -1
- package/components/InngestCommHandler.d.ts +156 -198
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +311 -305
- package/components/InngestCommHandler.js.map +1 -1
- package/components/InngestFunction.d.ts +9 -82
- package/components/InngestFunction.d.ts.map +1 -1
- package/components/InngestFunction.js +21 -413
- package/components/InngestFunction.js.map +1 -1
- package/components/InngestMiddleware.d.ts +37 -26
- package/components/InngestMiddleware.d.ts.map +1 -1
- package/components/InngestMiddleware.js +1 -3
- package/components/InngestMiddleware.js.map +1 -1
- package/components/InngestStepTools.d.ts +69 -37
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +34 -95
- package/components/InngestStepTools.js.map +1 -1
- package/components/NonRetriableError.d.ts.map +1 -1
- package/components/NonRetriableError.js +1 -0
- package/components/NonRetriableError.js.map +1 -1
- package/components/RetryAfterError.d.ts +38 -0
- package/components/RetryAfterError.d.ts.map +1 -0
- package/components/RetryAfterError.js +42 -0
- package/components/RetryAfterError.js.map +1 -0
- package/components/execution/InngestExecution.d.ts +72 -0
- package/components/execution/InngestExecution.d.ts.map +1 -0
- package/components/execution/InngestExecution.js +23 -0
- package/components/execution/InngestExecution.js.map +1 -0
- package/components/execution/v0.d.ts +114 -0
- package/components/execution/v0.d.ts.map +1 -0
- package/components/execution/v0.js +394 -0
- package/components/execution/v0.js.map +1 -0
- package/components/execution/v1.d.ts +88 -0
- package/components/execution/v1.d.ts.map +1 -0
- package/components/execution/v1.js +673 -0
- package/components/execution/v1.js.map +1 -0
- package/deno/fresh.d.ts +3 -3
- package/deno/fresh.d.ts.map +1 -1
- package/deno/fresh.js +17 -38
- package/deno/fresh.js.map +1 -1
- package/digitalocean.d.ts +5 -5
- package/digitalocean.d.ts.map +1 -1
- package/digitalocean.js +14 -46
- package/digitalocean.js.map +1 -1
- package/edge.d.ts +5 -5
- package/edge.d.ts.map +1 -1
- package/edge.js +16 -38
- package/edge.js.map +1 -1
- package/express.d.ts +7 -3
- package/express.d.ts.map +1 -1
- package/express.js +38 -45
- package/express.js.map +1 -1
- package/fastify.d.ts +8 -3
- package/fastify.d.ts.map +1 -1
- package/fastify.js +37 -47
- package/fastify.js.map +1 -1
- package/h3.d.ts +4 -3
- package/h3.d.ts.map +1 -1
- package/h3.js +18 -45
- package/h3.js.map +1 -1
- package/helpers/ServerTiming.d.ts.map +1 -1
- package/helpers/ServerTiming.js +2 -1
- package/helpers/ServerTiming.js.map +1 -1
- package/helpers/consts.d.ts +23 -9
- package/helpers/consts.d.ts.map +1 -1
- package/helpers/consts.js +31 -13
- package/helpers/consts.js.map +1 -1
- package/helpers/devserver.d.ts +0 -34
- package/helpers/devserver.d.ts.map +1 -1
- package/helpers/devserver.js.map +1 -1
- package/helpers/env.d.ts +14 -6
- package/helpers/env.d.ts.map +1 -1
- package/helpers/env.js +4 -4
- package/helpers/env.js.map +1 -1
- package/helpers/errors.d.ts +37 -2
- package/helpers/errors.d.ts.map +1 -1
- package/helpers/errors.js +66 -15
- package/helpers/errors.js.map +1 -1
- package/helpers/functions.d.ts +52 -5
- package/helpers/functions.d.ts.map +1 -1
- package/helpers/functions.js +121 -22
- package/helpers/functions.js.map +1 -1
- package/helpers/promises.d.ts +45 -0
- package/helpers/promises.d.ts.map +1 -1
- package/helpers/promises.js +69 -1
- package/helpers/promises.js.map +1 -1
- package/helpers/strings.d.ts +6 -1
- package/helpers/strings.d.ts.map +1 -1
- package/helpers/strings.js +7 -2
- package/helpers/strings.js.map +1 -1
- package/helpers/types.d.ts +5 -17
- package/helpers/types.d.ts.map +1 -1
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/lambda.d.ts +10 -8
- package/lambda.d.ts.map +1 -1
- package/lambda.js +48 -72
- package/lambda.js.map +1 -1
- package/next.d.ts +11 -5
- package/next.d.ts.map +1 -1
- package/next.js +84 -103
- package/next.js.map +1 -1
- package/nuxt.d.ts +3 -3
- package/nuxt.d.ts.map +1 -1
- package/nuxt.js +5 -6
- package/nuxt.js.map +1 -1
- package/package.json +5 -4
- package/redwood.d.ts +4 -3
- package/redwood.d.ts.map +1 -1
- package/redwood.js +22 -48
- package/redwood.js.map +1 -1
- package/remix.d.ts +7 -5
- package/remix.d.ts.map +1 -1
- package/remix.js +15 -36
- package/remix.js.map +1 -1
- package/types.d.ts +150 -218
- package/types.d.ts.map +1 -1
- package/types.js +38 -45
- package/types.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/helpers/scalar.d.ts +0 -8
- package/helpers/scalar.d.ts.map +0 -1
- package/helpers/scalar.js +0 -19
- package/helpers/scalar.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestStepTools.js","sourceRoot":"","sources":["../../src/components/InngestStepTools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InngestStepTools.js","sourceRoot":"","sources":["../../src/components/InngestStepTools.ts"],"names":[],"mappings":";;;AACA,gDAA6C;AAO7C,oCAQkB;AAqEX,MAAM,cAAc,GAAG,CAAC,OAAwB,EAAe,EAAE;IACtE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,EAAE,EAA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jB;
|
|
1
|
+
{"version":3,"file":"NonRetriableError.d.ts","sourceRoot":"","sources":["../../src/components/NonRetriableError.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C;;;;OAIG;IACH,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAG9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAQJ"}
|
|
@@ -15,6 +15,7 @@ class NonRetriableError extends Error {
|
|
|
15
15
|
super(message);
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
17
17
|
this.cause = options === null || options === void 0 ? void 0 : options.cause;
|
|
18
|
+
this.name = "NonRetriableError";
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.NonRetriableError = NonRetriableError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonRetriableError.js","sourceRoot":"","sources":["../../src/components/NonRetriableError.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAQ1C,YACE,OAAe,EACf,OAOC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,mEAAmE;QACnE,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"NonRetriableError.js","sourceRoot":"","sources":["../../src/components/NonRetriableError.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAQ1C,YACE,OAAe,EACf,OAOC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,mEAAmE;QACnE,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QAE5B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAzBD,8CAyBC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error that, when thrown, indicates to Inngest that the function should be
|
|
3
|
+
* retried after a given amount of time.
|
|
4
|
+
*
|
|
5
|
+
* A `message` must be provided, as well as a `retryAfter` parameter, which can
|
|
6
|
+
* be a `number` of milliseconds, an `ms`-compatible time string, or a `Date`.
|
|
7
|
+
*
|
|
8
|
+
* An optional `cause` can be provided to provide more context to the error.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class RetryAfterError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* The underlying cause of the error, if any.
|
|
15
|
+
*
|
|
16
|
+
* This will be serialized and sent to Inngest.
|
|
17
|
+
*/
|
|
18
|
+
readonly cause?: unknown;
|
|
19
|
+
/**
|
|
20
|
+
* The time after which the function should be retried. Represents either a
|
|
21
|
+
* number of seconds or a RFC3339 date.
|
|
22
|
+
*/
|
|
23
|
+
readonly retryAfter: string;
|
|
24
|
+
constructor(message: string,
|
|
25
|
+
/**
|
|
26
|
+
* The time after which the function should be retried. Represents either a
|
|
27
|
+
* number of seconds or a RFC3339 date.
|
|
28
|
+
*/
|
|
29
|
+
retryAfter: number | string | Date, options?: {
|
|
30
|
+
/**
|
|
31
|
+
* The underlying cause of the error, if any.
|
|
32
|
+
*
|
|
33
|
+
* This will be serialized and sent to Inngest.
|
|
34
|
+
*/
|
|
35
|
+
cause?: unknown;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=RetryAfterError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryAfterError.d.ts","sourceRoot":"","sources":["../../src/components/RetryAfterError.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC;;;;OAIG;IACH,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM;IAEf;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAElC,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAsBJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RetryAfterError = void 0;
|
|
7
|
+
const ms_1 = __importDefault(require("ms"));
|
|
8
|
+
/**
|
|
9
|
+
* An error that, when thrown, indicates to Inngest that the function should be
|
|
10
|
+
* retried after a given amount of time.
|
|
11
|
+
*
|
|
12
|
+
* A `message` must be provided, as well as a `retryAfter` parameter, which can
|
|
13
|
+
* be a `number` of milliseconds, an `ms`-compatible time string, or a `Date`.
|
|
14
|
+
*
|
|
15
|
+
* An optional `cause` can be provided to provide more context to the error.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class RetryAfterError extends Error {
|
|
20
|
+
constructor(message,
|
|
21
|
+
/**
|
|
22
|
+
* The time after which the function should be retried. Represents either a
|
|
23
|
+
* number of seconds or a RFC3339 date.
|
|
24
|
+
*/
|
|
25
|
+
retryAfter, options) {
|
|
26
|
+
super(message);
|
|
27
|
+
if (retryAfter instanceof Date) {
|
|
28
|
+
this.retryAfter = retryAfter.toISOString();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const seconds = `${Math.ceil((typeof retryAfter === "string" ? (0, ms_1.default)(retryAfter) : retryAfter) / 1000)}`;
|
|
32
|
+
if (!isFinite(Number(seconds))) {
|
|
33
|
+
throw new Error("retryAfter must be a number of seconds, a ms-compatible string, or a Date");
|
|
34
|
+
}
|
|
35
|
+
this.retryAfter = seconds;
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
38
|
+
this.cause = options === null || options === void 0 ? void 0 : options.cause;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.RetryAfterError = RetryAfterError;
|
|
42
|
+
//# sourceMappingURL=RetryAfterError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryAfterError.js","sourceRoot":"","sources":["../../src/components/RetryAfterError.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB;;;;;;;;;;GAUG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAcxC,YACE,OAAe;IAEf;;;OAGG;IACH,UAAkC,EAElC,OAOC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,UAAU,YAAY,IAAI,EAAE;YAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;SAC5C;aAAM;YACL,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,IAAI,CAC1B,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,YAAE,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CACtE,EAAE,CAAC;YAEJ,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE;gBAC9B,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;aACH;YAED,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;SAC3B;QACD,mEAAmE;QACnE,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;IAC9B,CAAC;CACF;AApDD,0CAoDC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type Debugger } from "debug";
|
|
2
|
+
import { type Simplify } from "type-fest";
|
|
3
|
+
import { type MaybePromise } from "type-plus";
|
|
4
|
+
import { type ServerTiming } from "../../helpers/ServerTiming";
|
|
5
|
+
import { type AnyContext, type IncomingOp, type OutgoingOp } from "../../types";
|
|
6
|
+
import { type AnyInngest } from "../Inngest";
|
|
7
|
+
import { type ActionResponse } from "../InngestCommHandler";
|
|
8
|
+
import { type AnyInngestFunction } from "../InngestFunction";
|
|
9
|
+
/**
|
|
10
|
+
* The possible results of an execution.
|
|
11
|
+
*/
|
|
12
|
+
export interface ExecutionResults {
|
|
13
|
+
"function-resolved": {
|
|
14
|
+
data: unknown;
|
|
15
|
+
};
|
|
16
|
+
"step-ran": {
|
|
17
|
+
step: OutgoingOp;
|
|
18
|
+
};
|
|
19
|
+
"function-rejected": {
|
|
20
|
+
error: unknown;
|
|
21
|
+
retriable: boolean | string;
|
|
22
|
+
};
|
|
23
|
+
"steps-found": {
|
|
24
|
+
steps: [OutgoingOp, ...OutgoingOp[]];
|
|
25
|
+
};
|
|
26
|
+
"step-not-found": {
|
|
27
|
+
step: OutgoingOp;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type ExecutionResult = {
|
|
31
|
+
[K in keyof ExecutionResults]: Simplify<{
|
|
32
|
+
type: K;
|
|
33
|
+
} & ExecutionResults[K]>;
|
|
34
|
+
}[keyof ExecutionResults];
|
|
35
|
+
export type ExecutionResultHandler<T = ActionResponse> = (result: ExecutionResult) => MaybePromise<T>;
|
|
36
|
+
export type ExecutionResultHandlers<T = ActionResponse> = {
|
|
37
|
+
[E in ExecutionResult as E["type"]]: (result: E) => MaybePromise<T>;
|
|
38
|
+
};
|
|
39
|
+
export interface MemoizedOp extends IncomingOp {
|
|
40
|
+
fulfilled?: boolean;
|
|
41
|
+
seen?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare enum ExecutionVersion {
|
|
44
|
+
V0 = 0,
|
|
45
|
+
V1 = 1
|
|
46
|
+
}
|
|
47
|
+
export declare const PREFERRED_EXECUTION_VERSION = ExecutionVersion.V1;
|
|
48
|
+
/**
|
|
49
|
+
* Options for creating a new {@link InngestExecution} instance.
|
|
50
|
+
*/
|
|
51
|
+
export interface InngestExecutionOptions {
|
|
52
|
+
client: AnyInngest;
|
|
53
|
+
fn: AnyInngestFunction;
|
|
54
|
+
runId: string;
|
|
55
|
+
data: Omit<AnyContext, "step">;
|
|
56
|
+
stepState: Record<string, MemoizedOp>;
|
|
57
|
+
stepCompletionOrder: string[];
|
|
58
|
+
requestedRunStep?: string;
|
|
59
|
+
timer?: ServerTiming;
|
|
60
|
+
isFailureHandler?: boolean;
|
|
61
|
+
disableImmediateExecution?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export type InngestExecutionFactory = (options: InngestExecutionOptions) => IInngestExecution;
|
|
64
|
+
export declare class InngestExecution {
|
|
65
|
+
protected options: InngestExecutionOptions;
|
|
66
|
+
protected debug: Debugger;
|
|
67
|
+
constructor(options: InngestExecutionOptions);
|
|
68
|
+
}
|
|
69
|
+
export interface IInngestExecution {
|
|
70
|
+
start(): Promise<ExecutionResult>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=InngestExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InngestExecution.d.ts","sourceRoot":"","sources":["../../../src/components/execution/InngestExecution.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,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sBACQ,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,UAAU,CAAC;IACnB,EAAE,EAAE,kBAAkB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,MAAM,uBAAuB,GAAG,CACpC,OAAO,EAAE,uBAAuB,KAC7B,iBAAiB,CAAC;AAEvB,qBAAa,gBAAgB;IAGf,SAAS,CAAC,OAAO,EAAE,uBAAuB;IAFtD,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC;gBAEJ,OAAO,EAAE,uBAAuB;CAIvD;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InngestExecution = exports.PREFERRED_EXECUTION_VERSION = exports.ExecutionVersion = void 0;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const consts_1 = require("../../helpers/consts");
|
|
9
|
+
var ExecutionVersion;
|
|
10
|
+
(function (ExecutionVersion) {
|
|
11
|
+
ExecutionVersion[ExecutionVersion["V0"] = 0] = "V0";
|
|
12
|
+
ExecutionVersion[ExecutionVersion["V1"] = 1] = "V1";
|
|
13
|
+
})(ExecutionVersion || (exports.ExecutionVersion = ExecutionVersion = {}));
|
|
14
|
+
exports.PREFERRED_EXECUTION_VERSION = ExecutionVersion.V1;
|
|
15
|
+
class InngestExecution {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.debug = (0, debug_1.default)(consts_1.debugPrefix).extend(this.options.runId);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.InngestExecution = InngestExecution;
|
|
23
|
+
//# sourceMappingURL=InngestExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InngestExecution.js","sourceRoot":"","sources":["../../../src/components/execution/InngestExecution.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAI7C,iDAAmD;AAkCnD,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,mDAAM,CAAA;IACN,mDAAM,CAAA;AACR,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAEY,QAAA,2BAA2B,GACtC,gBAAgB,CAAC,EAA6B,CAAC;AAsBjD,MAAa,gBAAgB;IAG3B,YAAsB,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAA,eAAK,EAAC,oBAAW,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF;AAPD,4CAOC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { StepOpCode, type HashedOp, type OpStack } from "../../types";
|
|
2
|
+
import { type RunHookStack } from "../InngestMiddleware";
|
|
3
|
+
import { InngestExecution, type ExecutionResult, type IInngestExecution, type InngestExecutionFactory, type InngestExecutionOptions } from "./InngestExecution";
|
|
4
|
+
export declare const createV0InngestExecution: InngestExecutionFactory;
|
|
5
|
+
export declare class V0InngestExecution extends InngestExecution implements IInngestExecution {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(options: InngestExecutionOptions);
|
|
8
|
+
start(): Promise<ExecutionResult>;
|
|
9
|
+
}
|
|
10
|
+
interface TickOp extends HashedOp {
|
|
11
|
+
fn?: (...args: unknown[]) => unknown;
|
|
12
|
+
fulfilled: boolean;
|
|
13
|
+
resolve: (value: unknown | PromiseLike<unknown>) => void;
|
|
14
|
+
reject: (reason?: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface V0ExecutionState {
|
|
17
|
+
/**
|
|
18
|
+
* The tree of all found ops in the entire invocation.
|
|
19
|
+
*/
|
|
20
|
+
allFoundOps: Record<string, TickOp>;
|
|
21
|
+
/**
|
|
22
|
+
* All synchronous operations found in this particular tick. The array is
|
|
23
|
+
* reset every tick.
|
|
24
|
+
*/
|
|
25
|
+
tickOps: Record<string, TickOp>;
|
|
26
|
+
/**
|
|
27
|
+
* A hash of operations found within this tick, with keys being the hashed
|
|
28
|
+
* ops themselves (without a position) and the values being the number of
|
|
29
|
+
* times that op has been found.
|
|
30
|
+
*
|
|
31
|
+
* This is used to provide some mutation resilience to the op stack,
|
|
32
|
+
* allowing us to survive same-tick mutations of code by ensuring per-tick
|
|
33
|
+
* hashes are based on uniqueness rather than order.
|
|
34
|
+
*/
|
|
35
|
+
tickOpHashes: Record<string, number>;
|
|
36
|
+
/**
|
|
37
|
+
* Tracks the current operation being processed. This can be used to
|
|
38
|
+
* understand the contextual parent of any recorded operations.
|
|
39
|
+
*/
|
|
40
|
+
currentOp: TickOp | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* If we've found a user function to run, we'll store it here so a component
|
|
43
|
+
* higher up can invoke and await it.
|
|
44
|
+
*/
|
|
45
|
+
userFnToRun?: (...args: unknown[]) => unknown;
|
|
46
|
+
/**
|
|
47
|
+
* A boolean to represent whether the user's function is using any step
|
|
48
|
+
* tools.
|
|
49
|
+
*
|
|
50
|
+
* If the function survives an entire tick of the event loop and hasn't
|
|
51
|
+
* touched any tools, we assume that it is a single-step async function and
|
|
52
|
+
* should be awaited as usual.
|
|
53
|
+
*/
|
|
54
|
+
hasUsedTools: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* A function that should be used to reset the state of the tools after a
|
|
57
|
+
* tick has completed.
|
|
58
|
+
*/
|
|
59
|
+
reset: () => void;
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, any use of step tools will, by default, throw an error. We do
|
|
62
|
+
* this when we detect that a function may be mixing step and non-step code.
|
|
63
|
+
*
|
|
64
|
+
* Created step tooling can decide how to manually handle this on a
|
|
65
|
+
* case-by-case basis.
|
|
66
|
+
*
|
|
67
|
+
* In the future, we can provide a way for a user to override this if they
|
|
68
|
+
* wish to and understand the danger of side-effects.
|
|
69
|
+
*
|
|
70
|
+
* Defaults to `false`.
|
|
71
|
+
*/
|
|
72
|
+
nonStepFnDetected: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* When true, we are currently executing a user's code for a single step
|
|
75
|
+
* within a step function.
|
|
76
|
+
*/
|
|
77
|
+
executingStep: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Initialized middleware hooks for this execution.
|
|
80
|
+
*
|
|
81
|
+
* Middleware hooks are cached to ensure they can only be run once, which
|
|
82
|
+
* means that these hooks can be called in many different places to ensure we
|
|
83
|
+
* handle all possible execution paths.
|
|
84
|
+
*/
|
|
85
|
+
hooks?: RunHookStack;
|
|
86
|
+
/**
|
|
87
|
+
* The op stack to pass to the function as state, likely stored in
|
|
88
|
+
* `ctx._state` in the Inngest payload.
|
|
89
|
+
*
|
|
90
|
+
* This must be provided in order to always be cognizant of step function
|
|
91
|
+
* state and to allow for multi-step functions.
|
|
92
|
+
*/
|
|
93
|
+
opStack: OpStack;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* An operation ready to hash to be used to memoise step function progress.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
export type UnhashedOp = {
|
|
101
|
+
name: string;
|
|
102
|
+
op: StepOpCode;
|
|
103
|
+
opts: Record<string, unknown> | null;
|
|
104
|
+
parent: string | null;
|
|
105
|
+
pos?: number;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Exported for testing.
|
|
109
|
+
*/
|
|
110
|
+
export declare const _internals: {
|
|
111
|
+
hashData: (op: UnhashedOp) => string;
|
|
112
|
+
};
|
|
113
|
+
export {};
|
|
114
|
+
//# sourceMappingURL=v0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v0.d.ts","sourceRoot":"","sources":["../../../src/components/execution/v0.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,UAAU,EAQV,KAAK,QAAQ,EAEb,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQvE,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,wBAAwB,EAAE,uBAEtC,CAAC;AAEF,qBAAa,kBACX,SAAQ,gBACR,YAAW,iBAAiB;;gBAOhB,OAAO,EAAE,uBAAuB;IAQrC,KAAK;CAybb;AAED,UAAU,MAAO,SAAQ,QAAQ;IAC/B,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACzD,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EA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