inngest 0.9.3-beta.1 → 0.10.0-next.1
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/README.md +3 -3
- package/cloudflare.js +1 -1
- package/cloudflare.js.map +1 -1
- package/components/Inngest.d.ts +9 -121
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js +16 -23
- package/components/Inngest.js.map +1 -1
- package/components/InngestCommHandler.d.ts +4 -5
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +89 -101
- package/components/InngestCommHandler.js.map +1 -1
- package/components/InngestFunction.d.ts +0 -4
- package/components/InngestFunction.d.ts.map +1 -1
- package/components/InngestFunction.js +119 -46
- package/components/InngestFunction.js.map +1 -1
- package/components/InngestStepTools.d.ts +73 -22
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +71 -149
- package/components/InngestStepTools.js.map +1 -1
- package/deno/fresh.js +1 -1
- package/deno/fresh.js.map +1 -1
- package/digitalocean.d.ts +3 -1
- package/digitalocean.d.ts.map +1 -1
- package/digitalocean.js +1 -1
- package/digitalocean.js.map +1 -1
- package/express.js +1 -1
- package/express.js.map +1 -1
- package/helpers/consts.d.ts +0 -3
- package/helpers/consts.d.ts.map +1 -1
- package/helpers/consts.js +1 -5
- package/helpers/consts.js.map +1 -1
- package/helpers/promises.d.ts +17 -0
- package/helpers/promises.d.ts.map +1 -0
- package/helpers/promises.js +26 -0
- package/helpers/promises.js.map +1 -0
- package/helpers/types.d.ts +7 -0
- package/helpers/types.d.ts.map +1 -1
- package/index.d.ts +1 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -5
- package/index.js.map +1 -1
- package/landing.d.ts +1 -1
- package/landing.d.ts.map +1 -1
- package/landing.js +1 -1
- package/landing.js.map +1 -1
- package/next.js +1 -1
- package/next.js.map +1 -1
- package/nuxt.d.ts +9 -0
- package/nuxt.d.ts.map +1 -0
- package/nuxt.js +68 -0
- package/nuxt.js.map +1 -0
- package/package.json +4 -3
- package/redwood.js +2 -2
- package/redwood.js.map +1 -1
- package/remix.js +1 -1
- package/remix.js.map +1 -1
- package/types.d.ts +81 -32
- package/types.d.ts.map +1 -1
- package/types.js +8 -1
- package/types.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/helpers/func.d.ts +0 -27
- package/helpers/func.d.ts.map +0 -1
- package/helpers/func.js +0 -83
- package/helpers/func.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,9 +35,9 @@ Inngest allows you to:
|
|
|
35
35
|
<br />
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
|
-
<a href="#getting-started">Getting started</a> ·
|
|
39
|
-
<a href="#features">Features</a> ·
|
|
40
|
-
<a href="#contributing">Contributing</a> ·
|
|
38
|
+
<a href="#getting-started">Getting started</a> ·
|
|
39
|
+
<a href="#features">Features</a> ·
|
|
40
|
+
<a href="#contributing">Contributing</a> ·
|
|
41
41
|
<a href="https://www.inngest.com/docs">Documentation</a>
|
|
42
42
|
</p>
|
|
43
43
|
|
package/cloudflare.js
CHANGED
|
@@ -44,11 +44,11 @@ const serve = (nameOrInngest, fns, opts) => {
|
|
|
44
44
|
if (req.method === "POST") {
|
|
45
45
|
return {
|
|
46
46
|
fnId: url.searchParams.get(consts_1.queryKeys.FnId),
|
|
47
|
+
stepId: url.searchParams.get(consts_1.queryKeys.StepId),
|
|
47
48
|
data: (await req.json()),
|
|
48
49
|
env,
|
|
49
50
|
isProduction,
|
|
50
51
|
url,
|
|
51
|
-
signature: req.headers.get(consts_1.headerKeys.Signature) || undefined,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
},
|
package/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":";;;AAAA,wEAGyC;AACzC,
|
|
1
|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E;oBACzB,OAAO;wBACL,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAS,CAAC,IAAI,CAAW;wBACpD,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAS,CAAC,MAAM,CAAW;wBACxD,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwB;wBAC/C,GAAG;wBACH,YAAY;wBACZ,GAAG;qBACJ,CAAC;iBACH;YACH,CAAC;SACF,CAAC;IACJ,CAAC,EACD,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAY,EAAE;QACtC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,MAAM;YACN,OAAO;SACR,CAAC,CAAC;IACL,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC,CAAC;AArEW,QAAA,KAAK,SAqEhB"}
|
package/components/Inngest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PartialK, SendEventPayload, SingleOrArray } from "../helpers/types";
|
|
2
|
-
import type { ClientOptions, EventPayload, FunctionOptions,
|
|
2
|
+
import type { ClientOptions, EventPayload, FunctionOptions, Handler, TriggerOptions } from "../types";
|
|
3
3
|
import { InngestFunction } from "./InngestFunction";
|
|
4
4
|
export declare const eventKeyWarning = "Could not find an event key to send events; sending will throw unless an event key is added. Please pass one to the constructor, set the INNGEST_EVENT_KEY environment variable, or use inngest.setEventKey() at runtime.";
|
|
5
5
|
export declare const eventKeyError = "Could not find an event key to send events. Please pass one to the constructor, set the INNGEST_EVENT_KEY environment variable, or use inngest.setEventKey() at runtime.";
|
|
@@ -73,6 +73,11 @@ export declare class Inngest<Events extends Record<string, EventPayload>> {
|
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
75
|
constructor({ name, eventKey, inngestBaseUrl, fetch, }: ClientOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Given a potential fetch function, return the fetch function to use based on
|
|
78
|
+
* this and the environment.
|
|
79
|
+
*/
|
|
80
|
+
private static parseFetch;
|
|
76
81
|
/**
|
|
77
82
|
* Set the event key for this instance of Inngest. This is useful if for some
|
|
78
83
|
* reason the key is not available at time of instantiation or present in the
|
|
@@ -135,125 +140,8 @@ export declare class Inngest<Events extends Record<string, EventPayload>> {
|
|
|
135
140
|
* ```
|
|
136
141
|
*/
|
|
137
142
|
send<Payload extends SendEventPayload<Events>>(payload: Payload): Promise<void>;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
* These can be used to build multi-step, serverless workflows with delays,
|
|
143
|
-
* conditional logic, and coordination between events.
|
|
144
|
-
*/
|
|
145
|
-
createStepFunction<Event extends keyof Events, Name extends string, Fn extends MultiStepFn<Events, Event, Name, "step">>(
|
|
146
|
-
/**
|
|
147
|
-
* The name of this function as it will appear in the Inngst Cloud UI.
|
|
148
|
-
*/
|
|
149
|
-
name: Name,
|
|
150
|
-
/**
|
|
151
|
-
* The event to listen for.
|
|
152
|
-
*/
|
|
153
|
-
event: Event,
|
|
154
|
-
/**
|
|
155
|
-
* The step function flow to run when the event is received.
|
|
156
|
-
*/
|
|
157
|
-
fn: Fn): InngestFunction<Events>;
|
|
158
|
-
/**
|
|
159
|
-
* Given an event to listen to, run the given step function when that event is
|
|
160
|
-
* seen.
|
|
161
|
-
*
|
|
162
|
-
* These can be used to build multi-step, serverless workflows with delays,
|
|
163
|
-
* conditional logic, and coordination between events.
|
|
164
|
-
*/
|
|
165
|
-
createStepFunction<Event extends keyof Events, Opts extends FunctionOptions, Fn extends MultiStepFn<Events, Event, Opts extends FunctionOptions ? Opts["name"] : string, "step">>(
|
|
166
|
-
/**
|
|
167
|
-
* Options for this Inngest function - useful for defining a custom ID.
|
|
168
|
-
*/
|
|
169
|
-
opts: Opts,
|
|
170
|
-
/**
|
|
171
|
-
* The event to listen for.
|
|
172
|
-
*/
|
|
173
|
-
event: Event,
|
|
174
|
-
/**
|
|
175
|
-
* The function to run when the event is received.
|
|
176
|
-
*/
|
|
177
|
-
fn: Fn): InngestFunction<Events>;
|
|
178
|
-
/**
|
|
179
|
-
* Given an event to listen to, run the given function when that event is
|
|
180
|
-
* seen.
|
|
181
|
-
*/
|
|
182
|
-
createFunction<Event extends keyof Events, Name extends string, Fn extends SingleStepFn<Events[Event], Name, "step">>(
|
|
183
|
-
/**
|
|
184
|
-
* The name of this function as it will appear in the Inngst Cloud UI.
|
|
185
|
-
*/
|
|
186
|
-
name: Name,
|
|
187
|
-
/**
|
|
188
|
-
* The event to listen for.
|
|
189
|
-
*/
|
|
190
|
-
event: Event,
|
|
191
|
-
/**
|
|
192
|
-
* The function to run when the event is received.
|
|
193
|
-
*/
|
|
194
|
-
fn: Fn): InngestFunction<Events>;
|
|
195
|
-
/**
|
|
196
|
-
* Given an event to listen to, run the given function when that event is
|
|
197
|
-
* seen.
|
|
198
|
-
*/
|
|
199
|
-
createFunction<Event extends keyof Events, Opts extends FunctionOptions, Fn extends SingleStepFn<Events[Event], Opts extends FunctionOptions ? Opts["name"] : string, "step">>(
|
|
200
|
-
/**
|
|
201
|
-
* Options for this Inngest function - useful for defining a custom ID.
|
|
202
|
-
*/
|
|
203
|
-
opts: Opts,
|
|
204
|
-
/**
|
|
205
|
-
* The event to listen for.
|
|
206
|
-
*/
|
|
207
|
-
event: Event,
|
|
208
|
-
/**
|
|
209
|
-
* The function to run when the event is received.
|
|
210
|
-
*/
|
|
211
|
-
fn: Fn): InngestFunction<Events>;
|
|
212
|
-
/**
|
|
213
|
-
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
214
|
-
*/
|
|
215
|
-
createScheduledFunction<Name extends string>(
|
|
216
|
-
/**
|
|
217
|
-
* The name of this function as it will appear in the Inngest Cloud UI.
|
|
218
|
-
*/
|
|
219
|
-
name: Name,
|
|
220
|
-
/**
|
|
221
|
-
* The cron definition to schedule your function.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
*
|
|
225
|
-
* "* * * * *" // Every minute
|
|
226
|
-
* "0 * * * *" // Every hour
|
|
227
|
-
* "0 0 * * *" // At the start of every day
|
|
228
|
-
* "0 0 0 * *" // At the start of the first day of the month
|
|
229
|
-
*/
|
|
230
|
-
cron: string,
|
|
231
|
-
/**
|
|
232
|
-
* The function to run.
|
|
233
|
-
*/
|
|
234
|
-
fn: SingleStepFn<null, Name, "step">): InngestFunction<Events>;
|
|
235
|
-
/**
|
|
236
|
-
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
237
|
-
*/
|
|
238
|
-
createScheduledFunction<Opts extends FunctionOptions>(
|
|
239
|
-
/**
|
|
240
|
-
* Options for this Inngest function - useful for defining a custom ID.
|
|
241
|
-
*/
|
|
242
|
-
opts: Opts,
|
|
243
|
-
/**
|
|
244
|
-
* The cron definition to schedule your function.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
*
|
|
248
|
-
* "* * * * *" // Every minute
|
|
249
|
-
* "0 * * * *" // Every hour
|
|
250
|
-
* "0 0 * * *" // At the start of every day
|
|
251
|
-
* "0 0 0 * *" // At the start of the first day of the month
|
|
252
|
-
*/
|
|
253
|
-
cron: string,
|
|
254
|
-
/**
|
|
255
|
-
* The function to run.
|
|
256
|
-
*/
|
|
257
|
-
fn: SingleStepFn<null, Opts extends FunctionOptions ? Opts["name"] : string, "step">): InngestFunction<Events>;
|
|
143
|
+
createFunction<Trigger extends TriggerOptions<keyof Events & string>, NameOrOpts extends string | FunctionOptions>(nameOrOpts: NameOrOpts, trigger: Trigger, fn: Handler<Events, Trigger extends string ? Trigger : Trigger extends {
|
|
144
|
+
event: string;
|
|
145
|
+
} ? Trigger["event"] : string, NameOrOpts extends FunctionOptions ? NameOrOpts : never>): InngestFunction<Events>;
|
|
258
146
|
}
|
|
259
147
|
//# sourceMappingURL=Inngest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.d.ts","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"Inngest.d.ts","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,OAAO,EACP,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOpD,eAAO,MAAM,eAAe,8NACiM,CAAC;AAE9N,eAAO,MAAM,aAAa,6KACkJ,CAAC;AAE7K;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;;IAC9D;;;OAGG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAM;IAEtB;;OAEG;IACH,SAAgB,cAAc,EAAE,GAAG,CAAC;IAEpC;;OAEG;IACH,OAAO,CAAC,aAAa,CAAyD;IAE9E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBACS,EACV,IAAI,EACJ,QAAQ,EACR,cAAkC,EAClC,KAAK,GACN,EAAE,aAAa;IAqBhB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAgDzB;;;;OAIG;IACI,WAAW;IAChB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GACf,IAAI;IAKP;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,IAAI,CAAC,KAAK,SAAS,MAAM,MAAM,EAC1C,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GACxE,OAAO,CAAC,IAAI,CAAC;IAChB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,IAAI,CAAC,OAAO,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACxD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;IAmFT,cAAc,CACnB,OAAO,SAAS,cAAc,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EACrD,UAAU,SAAS,MAAM,GAAG,eAAe,EAE3C,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,OAAO,CACT,MAAM,EACN,OAAO,SAAS,MAAM,GAClB,OAAO,GACP,OAAO,SAAS;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GACjC,OAAO,CAAC,OAAO,CAAC,GAChB,MAAM,EACV,UAAU,SAAS,eAAe,GAAG,UAAU,GAAG,KAAK,CACxD,GACA,eAAe,CAAC,MAAM,CAAC;CAO3B"}
|
package/components/Inngest.js
CHANGED
|
@@ -86,8 +86,21 @@ class Inngest {
|
|
|
86
86
|
"Content-Type": "application/json",
|
|
87
87
|
"User-Agent": `InngestJS v${version_1.version}`,
|
|
88
88
|
};
|
|
89
|
+
this.fetch = Inngest.parseFetch(fetch);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Given a potential fetch function, return the fetch function to use based on
|
|
93
|
+
* this and the environment.
|
|
94
|
+
*/
|
|
95
|
+
static parseFetch(fetchArg) {
|
|
96
|
+
if (fetchArg) {
|
|
97
|
+
return fetchArg;
|
|
98
|
+
}
|
|
99
|
+
if (typeof fetch !== "undefined") {
|
|
100
|
+
return fetch;
|
|
101
|
+
}
|
|
89
102
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
90
|
-
|
|
103
|
+
return require("cross-fetch");
|
|
91
104
|
}
|
|
92
105
|
/**
|
|
93
106
|
* Set the event key for this instance of Inngest. This is useful if for some
|
|
@@ -158,28 +171,8 @@ class Inngest {
|
|
|
158
171
|
}
|
|
159
172
|
throw await __classPrivateFieldGet(this, _Inngest_instances, "m", _Inngest_getResponseError).call(this, response);
|
|
160
173
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* seen.
|
|
164
|
-
*
|
|
165
|
-
* These can be used to build multi-step, serverless workflows with delays,
|
|
166
|
-
* conditional logic, and coordination between events.
|
|
167
|
-
*/
|
|
168
|
-
createStepFunction(nameOrOpts, event, fn) {
|
|
169
|
-
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { event: event }, fn);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Given an event to listen to, run the given function when that event is
|
|
173
|
-
* seen.
|
|
174
|
-
*/
|
|
175
|
-
createFunction(nameOrOpts, event, fn) {
|
|
176
|
-
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { event: event }, fn);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
180
|
-
*/
|
|
181
|
-
createScheduledFunction(nameOrOpts, cron, fn) {
|
|
182
|
-
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { cron }, fn);
|
|
174
|
+
createFunction(nameOrOpts, trigger, fn) {
|
|
175
|
+
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, typeof trigger === "string" ? { event: trigger } : trigger, fn);
|
|
183
176
|
}
|
|
184
177
|
}
|
|
185
178
|
exports.Inngest = Inngest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA4C;AAC5C,oDAAwE;AACxE,wCAAmE;AAcnE,wCAAqC;AACrC,uDAAoD;AAOvC,QAAA,eAAe,GAC1B,2NAA2N,CAAC;AAEjN,QAAA,aAAa,GACxB,0KAA0K,CAAC;AAE7K;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,OAAO;IA0BlB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,cAAc,GAAG,iBAAiB,EAClC,KAAK,GACS;;QA/ChB;;WAEG;QACK,aAAQ,GAAG,EAAE,CAAC;QAOtB;;WAEG;QACK,kBAAa,GAAQ,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAmC5E,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;SACzE;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,IAAA,gBAAU,EAAC,gBAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,cAAc,iBAAO,EAAE;SACtC,CAAC;QAEF,
|
|
1
|
+
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA4C;AAC5C,oDA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YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,8BAA8B,CAAC;YAC9C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,WAAW,CAAC;YAC3B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC1D,MAAM;QACR,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,YAAY,GAAG,6BAA6B,CAAC;YAC7C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,yBAAyB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,uBAAuB,CAAC;YACvC,MAAM;KACT;IACD,OAAO,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MaybePromise } from "../helpers/types";
|
|
2
|
-
import
|
|
2
|
+
import { FunctionConfig, RegisterOptions, RegisterRequest, StepRunResponse } from "../types";
|
|
3
3
|
import type { Inngest } from "./Inngest";
|
|
4
4
|
import type { InngestFunction } from "./InngestFunction";
|
|
5
5
|
/**
|
|
@@ -170,7 +170,6 @@ export declare class InngestCommHandler<H extends Handler, TransformedRes> {
|
|
|
170
170
|
* to find and register functions when interacting with Inngest Cloud.
|
|
171
171
|
*/
|
|
172
172
|
private readonly fns;
|
|
173
|
-
private allowExpiredSignatures;
|
|
174
173
|
constructor(
|
|
175
174
|
/**
|
|
176
175
|
* The name of the framework this handler is designed for. Should be
|
|
@@ -282,7 +281,7 @@ export declare class InngestCommHandler<H extends Handler, TransformedRes> {
|
|
|
282
281
|
* found (e.g. env vars, options, etc).
|
|
283
282
|
*/
|
|
284
283
|
private handleAction;
|
|
285
|
-
protected runStep(functionId: string, stepId: string, data: any): Promise<StepRunResponse>;
|
|
284
|
+
protected runStep(functionId: string, stepId: string | null, data: any): Promise<StepRunResponse>;
|
|
286
285
|
protected configs(url: URL): FunctionConfig[];
|
|
287
286
|
/**
|
|
288
287
|
* Returns an SDK header split in to three parts so that they can be used for
|
|
@@ -310,7 +309,7 @@ export declare class InngestCommHandler<H extends Handler, TransformedRes> {
|
|
|
310
309
|
private get isProd();
|
|
311
310
|
private upsertSigningKeyFromEnv;
|
|
312
311
|
protected shouldShowLandingPage(strEnvVar: string | undefined): boolean;
|
|
313
|
-
protected validateSignature(
|
|
312
|
+
protected validateSignature(): boolean;
|
|
314
313
|
protected signResponse(): string;
|
|
315
314
|
}
|
|
316
315
|
/**
|
|
@@ -367,11 +366,11 @@ type HandlerAction = {
|
|
|
367
366
|
} | {
|
|
368
367
|
action: "run";
|
|
369
368
|
fnId: string;
|
|
369
|
+
stepId: string | null;
|
|
370
370
|
data: Record<string, any>;
|
|
371
371
|
env: Record<string, string | undefined>;
|
|
372
372
|
isProduction: boolean;
|
|
373
373
|
url: URL;
|
|
374
|
-
signature: string | undefined;
|
|
375
374
|
} | {
|
|
376
375
|
action: "bad-method";
|
|
377
376
|
env: Record<string, string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestCommHandler.d.ts","sourceRoot":"","sources":["../../src/components/InngestCommHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InngestCommHandler.d.ts","sourceRoot":"","sources":["../../src/components/InngestCommHandler.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EACL,cAAc,EAGd,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,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AAC;IACtB,GAAG,EAAE,GAAG,CAAC;CACV,GACD;IACE,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,GAAG,EAAE,GAAG,CAAC;IACT,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CAC1B,GACD;IACE,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,YAAY,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,GAAG,CAAC;CACV,GACD;IACE,MAAM,EAAE,YAAY,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,YAAY,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,GAAG,CAAC;CACV,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InngestCommHandler = void 0;
|
|
4
4
|
const hash_js_1 = require("hash.js");
|
|
5
|
+
const serialize_error_cjs_1 = require("serialize-error-cjs");
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const consts_1 = require("../helpers/consts");
|
|
7
8
|
const devserver_1 = require("../helpers/devserver");
|
|
@@ -127,7 +128,6 @@ class InngestCommHandler {
|
|
|
127
128
|
* abstract this.
|
|
128
129
|
*/
|
|
129
130
|
transformRes) {
|
|
130
|
-
var _a;
|
|
131
131
|
/**
|
|
132
132
|
* A property that can be set to indicate whether or not we believe we are in
|
|
133
133
|
* production mode.
|
|
@@ -147,13 +147,6 @@ class InngestCommHandler {
|
|
|
147
147
|
: appNameOrInngest.name;
|
|
148
148
|
this.handler = handler;
|
|
149
149
|
this.transformRes = transformRes;
|
|
150
|
-
/**
|
|
151
|
-
* Provide a hidden option to allow expired signatures to be accepted during
|
|
152
|
-
* testing.
|
|
153
|
-
*/
|
|
154
|
-
this.allowExpiredSignatures = Boolean(
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, prefer-rest-params
|
|
156
|
-
(_a = arguments["3"]) === null || _a === void 0 ? void 0 : _a.__testingAllowExpiredSignatures);
|
|
157
150
|
this.fns = functions.reduce((acc, fn) => {
|
|
158
151
|
const id = fn.id(this.name);
|
|
159
152
|
if (acc[id]) {
|
|
@@ -241,10 +234,8 @@ class InngestCommHandler {
|
|
|
241
234
|
try {
|
|
242
235
|
const runRes = await actions.run();
|
|
243
236
|
if (runRes) {
|
|
244
|
-
this._isProd = runRes.isProduction;
|
|
245
237
|
this.upsertSigningKeyFromEnv(runRes.env);
|
|
246
|
-
this.
|
|
247
|
-
const stepRes = await this.runStep(runRes.fnId, "step", runRes.data);
|
|
238
|
+
const stepRes = await this.runStep(runRes.fnId, runRes.stepId, runRes.data);
|
|
248
239
|
if (stepRes.status === 500 || stepRes.status === 400) {
|
|
249
240
|
return {
|
|
250
241
|
status: stepRes.status,
|
|
@@ -260,7 +251,6 @@ class InngestCommHandler {
|
|
|
260
251
|
}
|
|
261
252
|
const viewRes = await actions.view();
|
|
262
253
|
if (viewRes) {
|
|
263
|
-
this._isProd = viewRes.isProduction;
|
|
264
254
|
this.upsertSigningKeyFromEnv(viewRes.env);
|
|
265
255
|
const showLandingPage = this.shouldShowLandingPage(viewRes.env[consts_1.envKeys.LandingPage]);
|
|
266
256
|
if (this._isProd || !showLandingPage) {
|
|
@@ -286,7 +276,6 @@ class InngestCommHandler {
|
|
|
286
276
|
}
|
|
287
277
|
const registerRes = await actions.register();
|
|
288
278
|
if (registerRes) {
|
|
289
|
-
this._isProd = registerRes.isProduction;
|
|
290
279
|
this.upsertSigningKeyFromEnv(registerRes.env);
|
|
291
280
|
const { status, message } = await this.register(this.reqUrl(registerRes.url), registerRes.env[consts_1.envKeys.DevServerUrl], registerRes.deployId);
|
|
292
281
|
return {
|
|
@@ -299,8 +288,7 @@ class InngestCommHandler {
|
|
|
299
288
|
catch (err) {
|
|
300
289
|
return {
|
|
301
290
|
status: 500,
|
|
302
|
-
|
|
303
|
-
body: JSON.stringify(err.stack || err.message || err),
|
|
291
|
+
body: JSON.stringify(Object.assign({ type: "internal" }, (0, serialize_error_cjs_1.serializeError)(err))),
|
|
304
292
|
headers: Object.assign(Object.assign({}, headers), { "Content-Type": "application/json" }),
|
|
305
293
|
};
|
|
306
294
|
}
|
|
@@ -311,31 +299,104 @@ class InngestCommHandler {
|
|
|
311
299
|
};
|
|
312
300
|
}
|
|
313
301
|
async runStep(functionId, stepId, data) {
|
|
302
|
+
var _a, _b;
|
|
314
303
|
try {
|
|
315
304
|
const fn = this.fns[functionId];
|
|
316
305
|
if (!fn) {
|
|
317
306
|
throw new Error(`Could not find function with ID "${functionId}"`);
|
|
318
307
|
}
|
|
319
|
-
const { event, steps } = zod_1.z
|
|
308
|
+
const { event, steps, ctx } = zod_1.z
|
|
320
309
|
.object({
|
|
321
310
|
event: zod_1.z.object({}).passthrough(),
|
|
322
|
-
|
|
311
|
+
/**
|
|
312
|
+
* When handling per-step errors, steps will need to be an object with
|
|
313
|
+
* either a `data` or an `error` key.
|
|
314
|
+
*
|
|
315
|
+
* For now, we support the current method of steps just being a map of
|
|
316
|
+
* step ID to step data.
|
|
317
|
+
*
|
|
318
|
+
* TODO When the executor does support per-step errors, we can uncomment
|
|
319
|
+
* the expected schema below.
|
|
320
|
+
*/
|
|
321
|
+
steps: zod_1.z
|
|
322
|
+
.record(zod_1.z.any().refine((v) => typeof v !== "undefined", {
|
|
323
|
+
message: "Values in steps must be defined",
|
|
324
|
+
}))
|
|
325
|
+
.optional()
|
|
326
|
+
.nullable(),
|
|
327
|
+
// steps: z.record(incomingOpSchema.passthrough()).optional().nullable(),
|
|
328
|
+
ctx: zod_1.z
|
|
329
|
+
.object({
|
|
330
|
+
stack: zod_1.z
|
|
331
|
+
.object({
|
|
332
|
+
stack: zod_1.z
|
|
333
|
+
.array(zod_1.z.string())
|
|
334
|
+
.nullable()
|
|
335
|
+
.transform((v) => (Array.isArray(v) ? v : [])),
|
|
336
|
+
current: zod_1.z.number(),
|
|
337
|
+
})
|
|
338
|
+
.passthrough()
|
|
339
|
+
.optional()
|
|
340
|
+
.nullable(),
|
|
341
|
+
})
|
|
342
|
+
.optional()
|
|
343
|
+
.nullable(),
|
|
323
344
|
})
|
|
324
345
|
.parse(data);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
346
|
+
/**
|
|
347
|
+
* TODO When the executor does support per-step errors, this map will need
|
|
348
|
+
* to adjust to ensure we're not double-stacking the op inside `data`.
|
|
349
|
+
*/
|
|
350
|
+
const opStack = (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.stack) === null || _a === void 0 ? void 0 : _a.stack.slice(0, ctx.stack.current).map((opId) => {
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
352
|
+
const step = steps === null || steps === void 0 ? void 0 : steps[opId];
|
|
353
|
+
if (typeof step === "undefined") {
|
|
354
|
+
throw new Error(`Could not find step with ID "${opId}"`);
|
|
355
|
+
}
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
357
|
+
return { id: opId, data: step };
|
|
358
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
359
|
+
const ret = await fn["runFn"]({ event }, opStack,
|
|
360
|
+
/**
|
|
361
|
+
* TODO The executor is sending `"step"` as the step ID when it is not
|
|
362
|
+
* wanting to run a specific step. This is not needed and we should
|
|
363
|
+
* remove this on the executor side.
|
|
364
|
+
*/
|
|
365
|
+
stepId === "step" ? null : stepId || null);
|
|
366
|
+
if (ret[0] === "single" || ret[0] === "multi-complete") {
|
|
328
367
|
return {
|
|
329
|
-
status:
|
|
368
|
+
status: 200,
|
|
330
369
|
body: ret[1],
|
|
331
370
|
};
|
|
332
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* If the function has run user code and is intending to return an error,
|
|
374
|
+
* interrupt this flow and instead throw a 500 to Inngest.
|
|
375
|
+
*
|
|
376
|
+
* The executor doesn't yet support per-step errors, so returning an
|
|
377
|
+
* `error` key here would cause the executor to misunderstand what is
|
|
378
|
+
* happening.
|
|
379
|
+
*
|
|
380
|
+
* TODO When the executor does support per-step errors, we can remove this
|
|
381
|
+
* comment and check and functionality should resume as normal.
|
|
382
|
+
*/
|
|
383
|
+
if (ret[0] === "multi-run" && ret[1].error) {
|
|
384
|
+
throw new Error("Step returned error; not yet supported");
|
|
385
|
+
}
|
|
333
386
|
return {
|
|
334
|
-
status:
|
|
335
|
-
body: ret[1],
|
|
387
|
+
status: 206,
|
|
388
|
+
body: Array.isArray(ret[1]) ? ret[1] : [ret[1]],
|
|
336
389
|
};
|
|
337
390
|
}
|
|
338
|
-
catch (
|
|
391
|
+
catch (unserializedErr) {
|
|
392
|
+
/**
|
|
393
|
+
* Always serialize the error before sending it back to Inngest. Errors,
|
|
394
|
+
* by default, do not niceley serialize to JSON, so we use the a package
|
|
395
|
+
* to do this.
|
|
396
|
+
*
|
|
397
|
+
* See {@link https://www.npmjs.com/package/serialize-error}
|
|
398
|
+
*/
|
|
399
|
+
const error = JSON.stringify((0, serialize_error_cjs_1.serializeError)(unserializedErr));
|
|
339
400
|
/**
|
|
340
401
|
* If we've caught a non-retriable error, we'll return a 400 to Inngest
|
|
341
402
|
* to indicate that the error is not transient and should not be retried.
|
|
@@ -343,30 +404,9 @@ class InngestCommHandler {
|
|
|
343
404
|
* The errors caught here are caught from the main function as well as
|
|
344
405
|
* inside individual steps, so this safely catches all areas.
|
|
345
406
|
*/
|
|
346
|
-
if (err instanceof NonRetriableError_1.NonRetriableError) {
|
|
347
|
-
return {
|
|
348
|
-
status: 400,
|
|
349
|
-
error: JSON.stringify({
|
|
350
|
-
message: err.message,
|
|
351
|
-
stack: err.stack,
|
|
352
|
-
name: err.name,
|
|
353
|
-
cause: err.cause
|
|
354
|
-
? err.cause instanceof Error
|
|
355
|
-
? err.cause.stack || err.cause.message
|
|
356
|
-
: JSON.stringify(err.cause)
|
|
357
|
-
: undefined,
|
|
358
|
-
}),
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
if (err instanceof Error) {
|
|
362
|
-
return {
|
|
363
|
-
status: 500,
|
|
364
|
-
error: err.stack || err.message,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
407
|
return {
|
|
368
|
-
status: 500,
|
|
369
|
-
error
|
|
408
|
+
status: unserializedErr instanceof NonRetriableError_1.NonRetriableError ? 400 : 500,
|
|
409
|
+
error,
|
|
370
410
|
};
|
|
371
411
|
}
|
|
372
412
|
}
|
|
@@ -476,64 +516,12 @@ class InngestCommHandler {
|
|
|
476
516
|
var _a, _b;
|
|
477
517
|
return (_b = (_a = this.showLandingPage) !== null && _a !== void 0 ? _a : (0, scalar_1.strBoolean)(strEnvVar)) !== null && _b !== void 0 ? _b : true;
|
|
478
518
|
}
|
|
479
|
-
validateSignature(
|
|
480
|
-
|
|
481
|
-
throw new Error(`No ${consts_1.headerKeys.Signature} provided`);
|
|
482
|
-
}
|
|
483
|
-
if (!this.isProd && !this.signingKey) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
if (!this.signingKey) {
|
|
487
|
-
console.warn("No signing key provided to validate signature. Find your dev keys at https://app.inngest.com/test/secrets");
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
if (!sig) {
|
|
491
|
-
console.warn(`No ${consts_1.headerKeys.Signature} provided`);
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
new RequestSignature(sig).verifySignature({
|
|
495
|
-
body,
|
|
496
|
-
allowExpiredSignatures: this.allowExpiredSignatures,
|
|
497
|
-
signingKey: this.signingKey,
|
|
498
|
-
});
|
|
519
|
+
validateSignature() {
|
|
520
|
+
return true;
|
|
499
521
|
}
|
|
500
522
|
signResponse() {
|
|
501
523
|
return "";
|
|
502
524
|
}
|
|
503
525
|
}
|
|
504
526
|
exports.InngestCommHandler = InngestCommHandler;
|
|
505
|
-
class RequestSignature {
|
|
506
|
-
constructor(sig) {
|
|
507
|
-
const params = new URLSearchParams(sig);
|
|
508
|
-
this.timestamp = params.get("t") || "";
|
|
509
|
-
this.signature = params.get("s") || "";
|
|
510
|
-
if (!this.timestamp || !this.signature) {
|
|
511
|
-
throw new Error(`Invalid ${consts_1.headerKeys.Signature} provided`);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
hasExpired(allowExpiredSignatures) {
|
|
515
|
-
if (allowExpiredSignatures) {
|
|
516
|
-
return false;
|
|
517
|
-
}
|
|
518
|
-
const delta = Date.now() - new Date(parseInt(this.timestamp) * 1000).valueOf();
|
|
519
|
-
return delta > 1000 * 60 * 5;
|
|
520
|
-
}
|
|
521
|
-
verifySignature({ body, signingKey, allowExpiredSignatures, }) {
|
|
522
|
-
if (this.hasExpired(allowExpiredSignatures)) {
|
|
523
|
-
throw new Error("Signature has expired");
|
|
524
|
-
}
|
|
525
|
-
// Calculate the HMAC of the request body ourselves.
|
|
526
|
-
const encoded = typeof body === "string" ? body : JSON.stringify(body);
|
|
527
|
-
// Remove the /signkey-[test|prod]-/ prefix from our signing key to calculate the HMAC.
|
|
528
|
-
const key = signingKey.replace(/signkey-\w+-/, "");
|
|
529
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
530
|
-
const mac = (0, hash_js_1.hmac)(hash_js_1.sha256, key)
|
|
531
|
-
.update(encoded)
|
|
532
|
-
.update(this.timestamp)
|
|
533
|
-
.digest("hex");
|
|
534
|
-
if (mac !== this.signature) {
|
|
535
|
-
throw new Error("Invalid signature");
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
527
|
//# sourceMappingURL=InngestCommHandler.js.map
|