inngest 2.4.2-pr-294.2 → 2.5.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 +24 -0
- package/components/Inngest.d.ts +6 -26
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js.map +1 -1
- package/components/InngestCommHandler.d.ts +8 -9
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +113 -69
- package/components/InngestCommHandler.js.map +1 -1
- package/components/InngestFunction.d.ts +82 -4
- package/components/InngestFunction.d.ts.map +1 -1
- package/components/InngestFunction.js +406 -9
- package/components/InngestFunction.js.map +1 -1
- package/components/InngestMiddleware.d.ts +15 -7
- package/components/InngestMiddleware.d.ts.map +1 -1
- package/components/InngestMiddleware.js +3 -1
- package/components/InngestMiddleware.js.map +1 -1
- package/components/InngestStepTools.d.ts +11 -9
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +61 -67
- package/components/InngestStepTools.js.map +1 -1
- package/express.d.ts.map +1 -1
- package/express.js +6 -3
- package/express.js.map +1 -1
- package/helpers/functions.d.ts +2 -0
- package/helpers/functions.d.ts.map +1 -1
- package/helpers/functions.js +2 -0
- package/helpers/functions.js.map +1 -1
- package/helpers/promises.d.ts +0 -36
- package/helpers/promises.d.ts.map +1 -1
- package/helpers/promises.js +1 -49
- package/helpers/promises.js.map +1 -1
- package/helpers/types.d.ts +5 -0
- package/helpers/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/types.d.ts +34 -26
- package/types.d.ts.map +1 -1
- package/types.js +0 -9
- 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/components/InngestExecution.d.ts +0 -146
- package/components/InngestExecution.d.ts.map +0 -1
- package/components/InngestExecution.js +0 -468
- package/components/InngestExecution.js.map +0 -1
|
@@ -21,12 +21,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
}
|
|
22
22
|
return t;
|
|
23
23
|
};
|
|
24
|
-
var _InngestFunction_instances, _InngestFunction_client, _InngestFunction_generateId;
|
|
24
|
+
var _InngestFunction_instances, _InngestFunction_fn, _InngestFunction_onFailureFn, _InngestFunction_client, _InngestFunction_generateId;
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.InngestFunction = void 0;
|
|
26
|
+
exports.createExecutionState = exports.InngestFunction = void 0;
|
|
27
|
+
const zod_1 = require("zod");
|
|
27
28
|
const consts_1 = require("../helpers/consts");
|
|
29
|
+
const errors_1 = require("../helpers/errors");
|
|
30
|
+
const promises_1 = require("../helpers/promises");
|
|
28
31
|
const strings_1 = require("../helpers/strings");
|
|
29
|
-
const
|
|
32
|
+
const types_1 = require("../types");
|
|
33
|
+
const InngestMiddleware_1 = require("./InngestMiddleware");
|
|
34
|
+
const InngestStepTools_1 = require("./InngestStepTools");
|
|
35
|
+
const NonRetriableError_1 = require("./NonRetriableError");
|
|
30
36
|
/**
|
|
31
37
|
* A stateless Inngest function, wrapping up function configuration and any
|
|
32
38
|
* in-memory steps to run when triggered.
|
|
@@ -50,12 +56,14 @@ class InngestFunction {
|
|
|
50
56
|
*/
|
|
51
57
|
opts, trigger, fn) {
|
|
52
58
|
_InngestFunction_instances.add(this);
|
|
59
|
+
_InngestFunction_fn.set(this, void 0);
|
|
60
|
+
_InngestFunction_onFailureFn.set(this, void 0);
|
|
53
61
|
_InngestFunction_client.set(this, void 0);
|
|
54
62
|
__classPrivateFieldSet(this, _InngestFunction_client, client, "f");
|
|
55
63
|
this.opts = opts;
|
|
56
64
|
this.trigger = trigger;
|
|
57
|
-
this
|
|
58
|
-
this
|
|
65
|
+
__classPrivateFieldSet(this, _InngestFunction_fn, fn, "f");
|
|
66
|
+
__classPrivateFieldSet(this, _InngestFunction_onFailureFn, this.opts.onFailure, "f");
|
|
59
67
|
this.middleware = __classPrivateFieldGet(this, _InngestFunction_client, "f")["initializeMiddleware"](this.opts.middleware, { registerInput: { fn: this }, prefixStack: __classPrivateFieldGet(this, _InngestFunction_client, "f")["middleware"] });
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
@@ -119,7 +127,7 @@ class InngestFunction {
|
|
|
119
127
|
}, []);
|
|
120
128
|
}
|
|
121
129
|
const config = [fn];
|
|
122
|
-
if (this
|
|
130
|
+
if (__classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f")) {
|
|
123
131
|
const failureOpts = Object.assign({}, opts);
|
|
124
132
|
const id = `${fn.id}${InngestFunction.failureSuffix}`;
|
|
125
133
|
const name = `${fn.name} (failure)`;
|
|
@@ -145,14 +153,403 @@ class InngestFunction {
|
|
|
145
153
|
}
|
|
146
154
|
return config;
|
|
147
155
|
}
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Run this function, optionally providing an op stack to pass as state.
|
|
158
|
+
*
|
|
159
|
+
* It is a `private` method to prevent users from being exposed to it
|
|
160
|
+
* directly, but ensuring it is available to the generated handler.
|
|
161
|
+
*
|
|
162
|
+
* For a single-step function that doesn't use any step tooling, this will
|
|
163
|
+
* await the result of the function given to this instance of
|
|
164
|
+
* `InngestFunction` and return the data and a boolean indicating that the
|
|
165
|
+
* function is complete and should not be called again.
|
|
166
|
+
*
|
|
167
|
+
* For a multi-step function, also try to await the result of the function
|
|
168
|
+
* given to this instance of `InngestFunction`, though will check whether an
|
|
169
|
+
* op has been submitted for use (or a Promise is pending, such as a step
|
|
170
|
+
* running) after the function has completed.
|
|
171
|
+
*/
|
|
172
|
+
async runFn(
|
|
173
|
+
/**
|
|
174
|
+
* The data to pass to the function, probably straight from Inngest.
|
|
175
|
+
*/
|
|
176
|
+
data,
|
|
177
|
+
/**
|
|
178
|
+
* The op stack to pass to the function as state, likely stored in
|
|
179
|
+
* `ctx._state` in the Inngest payload.
|
|
180
|
+
*
|
|
181
|
+
* This must be provided in order to always be cognizant of step function
|
|
182
|
+
* state and to allow for multi-step functions.
|
|
183
|
+
*/
|
|
184
|
+
opStack,
|
|
185
|
+
/**
|
|
186
|
+
* The step ID that Inngest wants to run and receive data from. If this is
|
|
187
|
+
* defined, the step's user code will be run after filling the op stack. If
|
|
188
|
+
* this is `null`, the function will be run and next operations will be
|
|
189
|
+
* returned instead.
|
|
190
|
+
*/
|
|
191
|
+
requestedRunStep, timer,
|
|
192
|
+
/**
|
|
193
|
+
* TODO Ugly boolean option; wrap this.
|
|
194
|
+
*/
|
|
195
|
+
isFailureHandler) {
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
197
|
+
const ctx = data;
|
|
198
|
+
const hookStack = await (0, InngestMiddleware_1.getHookStack)(this.middleware, "onFunctionRun", { ctx, fn: this, steps: opStack }, {
|
|
199
|
+
transformInput: (prev, output) => {
|
|
200
|
+
return {
|
|
201
|
+
ctx: Object.assign(Object.assign({}, prev.ctx), output === null || output === void 0 ? void 0 : output.ctx),
|
|
202
|
+
fn: this,
|
|
203
|
+
steps: prev.steps.map((step, i) => {
|
|
204
|
+
var _a;
|
|
205
|
+
return (Object.assign(Object.assign({}, step), (_a = output === null || output === void 0 ? void 0 : output.steps) === null || _a === void 0 ? void 0 : _a[i]));
|
|
206
|
+
}),
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
transformOutput: (prev, output) => {
|
|
210
|
+
return {
|
|
211
|
+
result: Object.assign(Object.assign({}, prev.result), output === null || output === void 0 ? void 0 : output.result),
|
|
212
|
+
step: prev.step,
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
const createFinalError = async (err, step) => {
|
|
217
|
+
var _a;
|
|
218
|
+
await ((_a = hookStack.afterExecution) === null || _a === void 0 ? void 0 : _a.call(hookStack));
|
|
219
|
+
const result = {
|
|
220
|
+
error: err,
|
|
221
|
+
};
|
|
222
|
+
try {
|
|
223
|
+
result.data = (0, errors_1.serializeError)(err);
|
|
224
|
+
}
|
|
225
|
+
catch (serializationErr) {
|
|
226
|
+
console.warn("Could not serialize error to return to Inngest; stringifying instead", serializationErr);
|
|
227
|
+
result.data = err;
|
|
228
|
+
}
|
|
229
|
+
const hookOutput = await applyHookToOutput(hookStack.transformOutput, {
|
|
230
|
+
result,
|
|
231
|
+
step,
|
|
232
|
+
});
|
|
233
|
+
return new errors_1.OutgoingResultError(hookOutput);
|
|
234
|
+
};
|
|
235
|
+
const state = (0, exports.createExecutionState)();
|
|
236
|
+
const memoizingStop = timer.start("memoizing");
|
|
237
|
+
/**
|
|
238
|
+
* Create some values to be mutated and passed to the step tools. Once the
|
|
239
|
+
* user's function has run, we can check the mutated state of these to see
|
|
240
|
+
* if an op has been submitted or not.
|
|
241
|
+
*/
|
|
242
|
+
const step = (0, InngestStepTools_1.createStepTools)(__classPrivateFieldGet(this, _InngestFunction_client, "f"), state);
|
|
243
|
+
try {
|
|
244
|
+
/**
|
|
245
|
+
* Create args to pass in to our function. We blindly pass in the data and
|
|
246
|
+
* add tools.
|
|
247
|
+
*/
|
|
248
|
+
let fnArg = Object.assign(Object.assign({}, data), { step });
|
|
249
|
+
let userFnToRun = __classPrivateFieldGet(this, _InngestFunction_fn, "f");
|
|
250
|
+
/**
|
|
251
|
+
* If the incoming event is an Inngest function failure event, we also want
|
|
252
|
+
* to pass some extra data to the function to act as shortcuts to the event
|
|
253
|
+
* payload.
|
|
254
|
+
*/
|
|
255
|
+
if (isFailureHandler) {
|
|
256
|
+
/**
|
|
257
|
+
* The user could have created a function that intentionally listens for
|
|
258
|
+
* these events. In this case, we may want to use the original handler.
|
|
259
|
+
*
|
|
260
|
+
* We only use the onFailure handler if
|
|
261
|
+
*/
|
|
262
|
+
if (!__classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f")) {
|
|
263
|
+
// TODO PrettyError
|
|
264
|
+
throw new Error(`Function "${this.name}" received a failure event to handle, but no failure handler was defined.`);
|
|
265
|
+
}
|
|
266
|
+
userFnToRun = __classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f");
|
|
267
|
+
const eventData = zod_1.z
|
|
268
|
+
.object({ error: types_1.failureEventErrorSchema })
|
|
269
|
+
.parse((_a = fnArg.event) === null || _a === void 0 ? void 0 : _a.data);
|
|
270
|
+
fnArg = Object.assign(Object.assign({}, fnArg), { error: (0, errors_1.deserializeError)(eventData.error) });
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* If the user has passed functions they wish to use in their step, add them
|
|
274
|
+
* here.
|
|
275
|
+
*
|
|
276
|
+
* We simply place a thin `tools.run()` wrapper around the function and
|
|
277
|
+
* nothing else.
|
|
278
|
+
*/
|
|
279
|
+
if (this.opts.fns) {
|
|
280
|
+
fnArg.fns = Object.entries(this.opts.fns).reduce((acc, [key, fn]) => {
|
|
281
|
+
if (typeof fn !== "function") {
|
|
282
|
+
return acc;
|
|
283
|
+
}
|
|
284
|
+
return Object.assign(Object.assign({}, acc), {
|
|
285
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
286
|
+
[key]: (...args) => step.run(key, () => fn(...args)) });
|
|
287
|
+
}, {});
|
|
288
|
+
}
|
|
289
|
+
const inputMutations = await ((_b = hookStack.transformInput) === null || _b === void 0 ? void 0 : _b.call(hookStack, {
|
|
290
|
+
ctx: Object.assign({}, fnArg),
|
|
291
|
+
steps: opStack,
|
|
292
|
+
fn: this,
|
|
293
|
+
}));
|
|
294
|
+
if (inputMutations === null || inputMutations === void 0 ? void 0 : inputMutations.ctx) {
|
|
295
|
+
fnArg = inputMutations === null || inputMutations === void 0 ? void 0 : inputMutations.ctx;
|
|
296
|
+
}
|
|
297
|
+
if (inputMutations === null || inputMutations === void 0 ? void 0 : inputMutations.steps) {
|
|
298
|
+
opStack = inputMutations === null || inputMutations === void 0 ? void 0 : inputMutations.steps;
|
|
299
|
+
}
|
|
300
|
+
await ((_c = hookStack.beforeMemoization) === null || _c === void 0 ? void 0 : _c.call(hookStack));
|
|
301
|
+
if (opStack.length === 0 && !requestedRunStep) {
|
|
302
|
+
await ((_d = hookStack.afterMemoization) === null || _d === void 0 ? void 0 : _d.call(hookStack));
|
|
303
|
+
await ((_e = hookStack.beforeExecution) === null || _e === void 0 ? void 0 : _e.call(hookStack));
|
|
304
|
+
}
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises, no-async-promise-executor
|
|
306
|
+
const userFnPromise = new Promise(async (resolve, reject) => {
|
|
307
|
+
try {
|
|
308
|
+
resolve(await userFnToRun(fnArg));
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
// logger.error(err);
|
|
312
|
+
reject(err);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
let pos = -1;
|
|
316
|
+
do {
|
|
317
|
+
if (pos >= 0) {
|
|
318
|
+
if (!requestedRunStep && pos == opStack.length - 1) {
|
|
319
|
+
await ((_f = hookStack.afterMemoization) === null || _f === void 0 ? void 0 : _f.call(hookStack));
|
|
320
|
+
await ((_g = hookStack.beforeExecution) === null || _g === void 0 ? void 0 : _g.call(hookStack));
|
|
321
|
+
}
|
|
322
|
+
state.tickOps = {};
|
|
323
|
+
const incomingOp = opStack[pos];
|
|
324
|
+
state.currentOp = state.allFoundOps[incomingOp.id];
|
|
325
|
+
if (!state.currentOp) {
|
|
326
|
+
/**
|
|
327
|
+
* We're trying to resume the function, but we can't find where to go.
|
|
328
|
+
*
|
|
329
|
+
* This means that either the function has changed or there are async
|
|
330
|
+
* actions in-between steps that we haven't noticed in previous
|
|
331
|
+
* executions.
|
|
332
|
+
*
|
|
333
|
+
* Whichever the case, this is bad and we can't continue in this
|
|
334
|
+
* undefined state.
|
|
335
|
+
*/
|
|
336
|
+
throw new NonRetriableError_1.NonRetriableError((0, errors_1.prettyError)({
|
|
337
|
+
whatHappened: " Your function was stopped from running",
|
|
338
|
+
why: "We couldn't resume your function's state because it may have changed since the run started or there are async actions in-between steps that we haven't noticed in previous executions.",
|
|
339
|
+
consequences: "Continuing to run the function may result in unexpected behaviour, so we've stopped your function to ensure nothing unexpected happened!",
|
|
340
|
+
toFixNow: "Ensure that your function is either entirely step-based or entirely non-step-based, by either wrapping all asynchronous logic in `step.run()` calls or by removing all `step.*()` calls.",
|
|
341
|
+
otherwise: "For more information on why step functions work in this manner, see https://www.inngest.com/docs/functions/multi-step#gotchas",
|
|
342
|
+
stack: true,
|
|
343
|
+
code: errors_1.ErrCode.NON_DETERMINISTIC_FUNCTION,
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
state.currentOp.fulfilled = true;
|
|
347
|
+
if (typeof incomingOp.data !== "undefined") {
|
|
348
|
+
state.currentOp.resolve(incomingOp.data);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
state.currentOp.reject(incomingOp.error);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
await timer.wrap("memoizing-ticks", promises_1.resolveAfterPending);
|
|
355
|
+
state.reset();
|
|
356
|
+
pos++;
|
|
357
|
+
} while (pos < opStack.length);
|
|
358
|
+
memoizingStop();
|
|
359
|
+
await ((_h = hookStack.afterMemoization) === null || _h === void 0 ? void 0 : _h.call(hookStack));
|
|
360
|
+
const discoveredOps = Object.values(state.tickOps).map(tickOpToOutgoing);
|
|
361
|
+
/**
|
|
362
|
+
* We make an optimization here by immediately invoking an op if it's the
|
|
363
|
+
* only one we've discovered. The alternative is to plan the step and then
|
|
364
|
+
* complete it, so we skip at least one entire execution with this.
|
|
365
|
+
*/
|
|
366
|
+
const runStep = requestedRunStep || getEarlyExecRunStep(discoveredOps);
|
|
367
|
+
if (runStep) {
|
|
368
|
+
const userFnOp = state.allFoundOps[runStep];
|
|
369
|
+
const userFnToRun = userFnOp === null || userFnOp === void 0 ? void 0 : userFnOp.fn;
|
|
370
|
+
if (!userFnToRun) {
|
|
371
|
+
// TODO PrettyError
|
|
372
|
+
throw new Error(`Bad stack; executor requesting to run unknown step "${runStep}"`);
|
|
373
|
+
}
|
|
374
|
+
const outgoingUserFnOp = Object.assign(Object.assign({}, tickOpToOutgoing(userFnOp)), { op: types_1.StepOpCode.RunStep });
|
|
375
|
+
await ((_j = hookStack.beforeExecution) === null || _j === void 0 ? void 0 : _j.call(hookStack));
|
|
376
|
+
const runningStepStop = timer.start("running-step");
|
|
377
|
+
state.executingStep = true;
|
|
378
|
+
const result = await new Promise((resolve) => {
|
|
379
|
+
return resolve(userFnToRun());
|
|
380
|
+
})
|
|
381
|
+
.finally(() => {
|
|
382
|
+
state.executingStep = false;
|
|
383
|
+
runningStepStop();
|
|
384
|
+
})
|
|
385
|
+
.catch(async (err) => {
|
|
386
|
+
return await createFinalError(err, outgoingUserFnOp);
|
|
387
|
+
})
|
|
388
|
+
.then(async (data) => {
|
|
389
|
+
var _a;
|
|
390
|
+
await ((_a = hookStack.afterExecution) === null || _a === void 0 ? void 0 : _a.call(hookStack));
|
|
391
|
+
return await applyHookToOutput(hookStack.transformOutput, {
|
|
392
|
+
result: { data: typeof data === "undefined" ? null : data },
|
|
393
|
+
step: outgoingUserFnOp,
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
return ["run", Object.assign(Object.assign({}, outgoingUserFnOp), result)];
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Now we're here, we've memoised any function state and we know that this
|
|
400
|
+
* request was a discovery call to find out next steps.
|
|
401
|
+
*
|
|
402
|
+
* We've already given the user's function a lot of chance to register any
|
|
403
|
+
* more ops, so we can assume that this list of discovered ops is final.
|
|
404
|
+
*
|
|
405
|
+
* With that in mind, if this list is empty AND we haven't previously used
|
|
406
|
+
* any step tools, we can assume that the user's function is not one that'll
|
|
407
|
+
* be using step tooling, so we'll just wait for it to complete and return
|
|
408
|
+
* the result.
|
|
409
|
+
*
|
|
410
|
+
* An empty list while also using step tooling is a valid state when the end
|
|
411
|
+
* of a chain of promises is reached, so we MUST also check if step tooling
|
|
412
|
+
* has previously been used.
|
|
413
|
+
*/
|
|
414
|
+
if (!discoveredOps.length) {
|
|
415
|
+
const fnRet = await Promise.race([
|
|
416
|
+
userFnPromise.then((data) => ({ type: "complete", data })),
|
|
417
|
+
(0, promises_1.resolveNextTick)().then(() => ({ type: "incomplete" })),
|
|
418
|
+
]);
|
|
419
|
+
if (fnRet.type === "complete") {
|
|
420
|
+
await ((_k = hookStack.afterExecution) === null || _k === void 0 ? void 0 : _k.call(hookStack));
|
|
421
|
+
/**
|
|
422
|
+
* The function has returned a value, so we should return this to
|
|
423
|
+
* Inngest. Doing this will cause the function to be marked as
|
|
424
|
+
* complete, so we should only do this if we're sure that all
|
|
425
|
+
* registered ops have been resolved.
|
|
426
|
+
*/
|
|
427
|
+
const allOpsFulfilled = Object.values(state.allFoundOps).every((op) => {
|
|
428
|
+
return op.fulfilled;
|
|
429
|
+
});
|
|
430
|
+
if (allOpsFulfilled) {
|
|
431
|
+
const result = await applyHookToOutput(hookStack.transformOutput, {
|
|
432
|
+
result: { data: fnRet.data },
|
|
433
|
+
});
|
|
434
|
+
return ["complete", result.data];
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* If we're here, it means that the user's function has returned a
|
|
438
|
+
* value but not all ops have been resolved. This might be intentional
|
|
439
|
+
* if they are purposefully pushing work to the background, but also
|
|
440
|
+
* might be unintentional and a bug in the user's code where they
|
|
441
|
+
* expected an order to be maintained.
|
|
442
|
+
*
|
|
443
|
+
* To be safe, we'll show a warning here to tell users that this might
|
|
444
|
+
* be unintentional, but otherwise carry on as normal.
|
|
445
|
+
*/
|
|
446
|
+
// TODO PrettyError
|
|
447
|
+
console.warn(`Warning: Your "${this.name}" function has returned a value, but not all ops have been resolved, i.e. you have used step tooling without \`await\`. This may be intentional, but if you expect your ops to be resolved in order, you should \`await\` them. If you are knowingly leaving ops unresolved using \`.catch()\` or \`void\`, you can ignore this warning.`);
|
|
448
|
+
}
|
|
449
|
+
else if (!state.hasUsedTools) {
|
|
450
|
+
/**
|
|
451
|
+
* If we're here, it means that the user's function has not returned
|
|
452
|
+
* a value, but also has not used step tooling. This is a valid
|
|
453
|
+
* state, indicating that the function is a single-action async
|
|
454
|
+
* function.
|
|
455
|
+
*
|
|
456
|
+
* We should wait for the result and return it.
|
|
457
|
+
*
|
|
458
|
+
* A caveat here is that the user could use step tooling later on,
|
|
459
|
+
* resulting in a mix of step and non-step logic. This is not something
|
|
460
|
+
* we want to support without an opt-in from the user, so we should
|
|
461
|
+
* throw if this is the case.
|
|
462
|
+
*/
|
|
463
|
+
state.nonStepFnDetected = true;
|
|
464
|
+
const data = await userFnPromise;
|
|
465
|
+
await ((_l = hookStack.afterExecution) === null || _l === void 0 ? void 0 : _l.call(hookStack));
|
|
466
|
+
const { data: result } = await applyHookToOutput(hookStack.transformOutput, {
|
|
467
|
+
result: { data },
|
|
468
|
+
});
|
|
469
|
+
return ["complete", result];
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
/**
|
|
473
|
+
* If we're here, the user's function has not returned a value, has not
|
|
474
|
+
* reported any new ops, but has also previously used step tools and
|
|
475
|
+
* successfully memoized state.
|
|
476
|
+
*
|
|
477
|
+
* This indicates that the user has mixed step and non-step logic, which
|
|
478
|
+
* is not something we want to support without an opt-in from the user.
|
|
479
|
+
*
|
|
480
|
+
* We should throw here to let the user know that this is not supported.
|
|
481
|
+
*
|
|
482
|
+
* We need to be careful, though; it's a valid state for a chain of
|
|
483
|
+
* promises to return no further actions, so we should only throw if
|
|
484
|
+
* this state is reached and there are no other pending steps.
|
|
485
|
+
*/
|
|
486
|
+
const hasOpsPending = Object.values(state.allFoundOps).some((op) => {
|
|
487
|
+
return op.fulfilled === false;
|
|
488
|
+
});
|
|
489
|
+
if (!hasOpsPending) {
|
|
490
|
+
throw new NonRetriableError_1.NonRetriableError((0, errors_1.functionStoppedRunningErr)(errors_1.ErrCode.ASYNC_DETECTED_AFTER_MEMOIZATION));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
await ((_m = hookStack.afterExecution) === null || _m === void 0 ? void 0 : _m.call(hookStack));
|
|
495
|
+
return ["discovery", discoveredOps];
|
|
496
|
+
}
|
|
497
|
+
catch (err) {
|
|
498
|
+
throw await createFinalError(err);
|
|
499
|
+
}
|
|
500
|
+
finally {
|
|
501
|
+
await ((_o = hookStack.beforeResponse) === null || _o === void 0 ? void 0 : _o.call(hookStack));
|
|
502
|
+
}
|
|
150
503
|
}
|
|
151
504
|
}
|
|
152
|
-
_InngestFunction_client = new WeakMap(), _InngestFunction_instances = new WeakSet(), _InngestFunction_generateId = function _InngestFunction_generateId(prefix) {
|
|
505
|
+
_InngestFunction_fn = new WeakMap(), _InngestFunction_onFailureFn = new WeakMap(), _InngestFunction_client = new WeakMap(), _InngestFunction_instances = new WeakSet(), _InngestFunction_generateId = function _InngestFunction_generateId(prefix) {
|
|
153
506
|
return (0, strings_1.slugify)([prefix || "", this.opts.name].join("-"));
|
|
154
507
|
};
|
|
155
508
|
InngestFunction.stepId = "step";
|
|
156
509
|
InngestFunction.failureSuffix = "-failure";
|
|
157
510
|
exports.InngestFunction = InngestFunction;
|
|
511
|
+
const tickOpToOutgoing = (op) => {
|
|
512
|
+
return {
|
|
513
|
+
op: op.op,
|
|
514
|
+
id: op.id,
|
|
515
|
+
name: op.name,
|
|
516
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
517
|
+
opts: op.opts,
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Given the list of outgoing ops, decide if we can execute an op early and
|
|
522
|
+
* return the ID of the step to run if we can.
|
|
523
|
+
*/
|
|
524
|
+
const getEarlyExecRunStep = (ops) => {
|
|
525
|
+
if (ops.length !== 1)
|
|
526
|
+
return;
|
|
527
|
+
const op = ops[0];
|
|
528
|
+
if (op &&
|
|
529
|
+
op.op === types_1.StepOpCode.StepPlanned &&
|
|
530
|
+
typeof op.opts === "undefined") {
|
|
531
|
+
return op.id;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const createExecutionState = () => {
|
|
535
|
+
const state = {
|
|
536
|
+
allFoundOps: {},
|
|
537
|
+
tickOps: {},
|
|
538
|
+
tickOpHashes: {},
|
|
539
|
+
currentOp: undefined,
|
|
540
|
+
hasUsedTools: false,
|
|
541
|
+
reset: () => {
|
|
542
|
+
state.tickOpHashes = {};
|
|
543
|
+
state.allFoundOps = Object.assign(Object.assign({}, state.allFoundOps), state.tickOps);
|
|
544
|
+
},
|
|
545
|
+
nonStepFnDetected: false,
|
|
546
|
+
executingStep: false,
|
|
547
|
+
};
|
|
548
|
+
return state;
|
|
549
|
+
};
|
|
550
|
+
exports.createExecutionState = createExecutionState;
|
|
551
|
+
const applyHookToOutput = async (outputHook, arg) => {
|
|
552
|
+
const hookOutput = await (outputHook === null || outputHook === void 0 ? void 0 : outputHook(arg));
|
|
553
|
+
return Object.assign(Object.assign({}, arg.result), hookOutput === null || hookOutput === void 0 ? void 0 : hookOutput.result);
|
|
554
|
+
};
|
|
158
555
|
//# sourceMappingURL=InngestFunction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestFunction.js","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA8D;AAC9D,gDAAsD;AAUtD,yDAG4B;AAM5B;;;;;;;;GAQG;AACH,MAAa,eAAe;IAqB1B;;;;;;OAMG;IACH,YACE,MAAsB;IAEtB;;OAEG;IACH,IAAU,EACV,OAAgB,EAChB,EAAiD;;QAlB1C,0CAAwB;QAoB/B,uBAAA,IAAI,2BAAW,MAAM,MAAA,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAEvC,IAAI,CAAC,UAAU,GAAG,uBAAA,IAAI,+BAAQ,CAAC,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AI,EAAE,EAAE,CAAC,CAAC;YAEpD,MAAM,CAAC,IAAI,iCACN,WAAW,KACd,EAAE;gBACF,IAAI,EACJ,QAAQ,EAAE;oBACR;wBACE,KAAK,EAAE,uBAAc,CAAC,cAAc;wBACpC,UAAU,EAAE,8BAA8B,IAAI,GAAG;qBAClD;iBACF,EACD,KAAK,EAAE;oBACL,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;wBACxB,EAAE,EAAE,eAAe,CAAC,MAAM;wBAC1B,IAAI,EAAE,eAAe,CAAC,MAAM;wBAC5B,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,GAAG,EAAE,cAAc,CAAC,IAAI;yBACzB;wBACD,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;qBACzB;iBACF,IACD,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,eAAe,CACrB,OAAuD;QAEvD,OAAO,IAAI,mCAAgB,iBACzB,MAAM,EAAE,uBAAA,IAAI,+BAAQ,EACpB,EAAE,EAAE,IAAI,IACL,OAAO,EACV,CAAC;IACL,CAAC;;wJAKW,MAAe;IACzB,OAAO,IAAA,iBAAO,EAAC,CAAC,MAAM,IAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAxKM,sBAAM,GAAG,MAAM,AAAT,CAAU;AAChB,6BAAa,GAAG,UAAU,AAAb,CAAc;AAZvB,0CAAe"}
|
|
1
|
+
{"version":3,"file":"InngestFunction.js","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAwB;AAExB,8CAA8D;AAC9D,8CAO2B;AAC3B,kDAA2E;AAC3E,gDAAsD;AACtD,oCAgBkB;AAElB,2DAI6B;AAC7B,yDAAkE;AAClE,2DAAwD;AAExD;;;;;;;;GAQG;AACH,MAAa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,GAAmB;QAC5B,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,SAAS;QACpB,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,GAAG,EAAE;YACV,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC;YACxB,KAAK,CAAC,WAAW,mCAAQ,KAAK,CAAC,WAAW,GAAK,KAAK,CAAC,OAAO,CAAE,CAAC;QACjE,CAAC;QACD,iBAAiB,EAAE,KAAK;QACxB,aAAa,EAAE,KAAK;KACrB,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC7B,UAA2C,EAC3C,GAAgE,EACnB,EAAE;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,GAAG,CAAC,CAAA,CAAC;IAC3C,uCAAY,GAAG,CAAC,MAAM,GAAK,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EAAG;AAClD,CAAC,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { type Simplify } from "type-fest";
|
|
2
2
|
import { type Await, type MaybePromise, type ObjectAssign, type PartialK } from "../helpers/types";
|
|
3
3
|
import { type BaseContext, type ClientOptions, type EventPayload, type IncomingOp, type MiddlewareStack, type OutgoingOp } from "../types";
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
4
|
+
import { type Inngest } from "./Inngest";
|
|
5
|
+
import { type InngestFunction } from "./InngestFunction";
|
|
6
6
|
/**
|
|
7
7
|
* A middleware that can be registered with Inngest to hook into various
|
|
8
8
|
* lifecycles of the SDK and affect input and output of Inngest functionality.
|
|
9
9
|
*
|
|
10
|
+
* TODO Add docs and shortlink.
|
|
11
|
+
*
|
|
10
12
|
* See {@link https://innge.st/middleware}
|
|
11
13
|
*
|
|
12
14
|
* @example
|
|
@@ -16,7 +18,7 @@ import { type AnyInngestFunction } from "./InngestFunction";
|
|
|
16
18
|
* middleware: [
|
|
17
19
|
* new InngestMiddleware({
|
|
18
20
|
* name: "My Middleware",
|
|
19
|
-
*
|
|
21
|
+
* register: () => {
|
|
20
22
|
* // ...
|
|
21
23
|
* }
|
|
22
24
|
* })
|
|
@@ -191,13 +193,17 @@ export type MiddlewareRegisterReturn = {
|
|
|
191
193
|
export type MiddlewareRegisterFn = (ctx: {
|
|
192
194
|
/**
|
|
193
195
|
* The client this middleware is being registered on.
|
|
196
|
+
*
|
|
197
|
+
* TODO This should not use `any`, but the generic type expected.
|
|
194
198
|
*/
|
|
195
|
-
client:
|
|
199
|
+
client: Inngest<any>;
|
|
196
200
|
/**
|
|
197
201
|
* If defined, this middleware has been applied directly to an Inngest
|
|
198
202
|
* function rather than on the client.
|
|
203
|
+
*
|
|
204
|
+
* TODO This should not use `any`, but the generic type expected.
|
|
199
205
|
*/
|
|
200
|
-
fn?:
|
|
206
|
+
fn?: InngestFunction<any, any, any, any>;
|
|
201
207
|
}) => MaybePromise<MiddlewareRegisterReturn>;
|
|
202
208
|
/**
|
|
203
209
|
* A blank, no-op hook that passes nothing and expects nothing in return.
|
|
@@ -219,11 +225,13 @@ type MiddlewareRunArgs = Readonly<{
|
|
|
219
225
|
/**
|
|
220
226
|
* The step data that will be passed to the function.
|
|
221
227
|
*/
|
|
222
|
-
steps: Readonly<IncomingOp
|
|
228
|
+
steps: Readonly<Omit<IncomingOp, "id">>[];
|
|
223
229
|
/**
|
|
224
230
|
* The function that is being executed.
|
|
231
|
+
*
|
|
232
|
+
* TODO This should not use `any`, but the generic type expected.
|
|
225
233
|
*/
|
|
226
|
-
fn:
|
|
234
|
+
fn: InngestFunction<any, any, any, any>;
|
|
227
235
|
}>;
|
|
228
236
|
/**
|
|
229
237
|
* The specific arguments sent to the `run` hook when an execution has begun.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestMiddleware.d.ts","sourceRoot":"","sources":["../../src/components/InngestMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"InngestMiddleware.d.ts","sourceRoot":"","sources":["../../src/components/InngestMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,iBAAiB,CAAC,KAAK,SAAS,iBAAiB;IAC5D;;;OAGG;IACH,SAAgB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEpC;;;;;;;;;;;;;;OAcG;IACH,SAAgB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAExB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK;CAIlC;AAED,KAAK,wBAAwB,CAE3B,OAAO,S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F,EACD,QAAQ,CACT,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,CACzC,QAAQ,EACR,WAAW,SAAS,eAAe,IACjC,YAAY,CACd;KACG,CAAC,IAAI,MAAM,WAAW,GAAG,6BAA6B,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACxE,EACD,QAAQ,CACT,CAAC"}
|
|
@@ -6,6 +6,8 @@ const functions_1 = require("../helpers/functions");
|
|
|
6
6
|
* A middleware that can be registered with Inngest to hook into various
|
|
7
7
|
* lifecycles of the SDK and affect input and output of Inngest functionality.
|
|
8
8
|
*
|
|
9
|
+
* TODO Add docs and shortlink.
|
|
10
|
+
*
|
|
9
11
|
* See {@link https://innge.st/middleware}
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
@@ -15,7 +17,7 @@ const functions_1 = require("../helpers/functions");
|
|
|
15
17
|
* middleware: [
|
|
16
18
|
* new InngestMiddleware({
|
|
17
19
|
* name: "My Middleware",
|
|
18
|
-
*
|
|
20
|
+
* register: () => {
|
|
19
21
|
* // ...
|
|
20
22
|
* }
|
|
21
23
|
* })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestMiddleware.js","sourceRoot":"","sources":["../../src/components/InngestMiddleware.ts"],"names":[],"mappings":";;;AACA,oDAA0D;AAkB1D
|
|
1
|
+
{"version":3,"file":"InngestMiddleware.js","sourceRoot":"","sources":["../../src/components/InngestMiddleware.ts"],"names":[],"mappings":";;;AACA,oDAA0D;AAkB1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,iBAAiB;IAwB5B,YAAY,EAAE,IAAI,EAAE,IAAI,EAAS;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AA5BD,8CA4BC;AAuCD;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,KAAK;AAO/B;;GAEG;AACH,UAAkC;AAElC;;G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