Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inngest

Package Overview
Dependencies
Maintainers
2
Versions
564
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inngest - npm Package Compare versions

Comparing version 1.4.0-concurrency.0 to 1.4.0

5

CHANGELOG.md
# inngest
## 1.4.0-concurrency.0
## 1.4.0
### Minor Changes
- fd8df7a: Add ability to control the concurrency of a specific function via the `concurrency` option when creating an Inngest function
- ebb8740: Add ability to control the concurrency of a specific function via the `concurrency` option when creating an Inngest function
- e61cf0f: Add `cancelOn` option when creating a function, allowing you cancel execution of a function based on incoming events.

@@ -9,0 +10,0 @@ ## 1.3.5

40

components/Inngest.d.ts
import type { PartialK, SendEventPayload, SingleOrArray } from "../helpers/types";
import type { ClientOptions, EventPayload, FunctionOptions, Handler, TriggerOptions } from "../types";
import type { ClientOptions, EventNameFromTrigger, EventPayload, FunctionOptions, Handler, ShimmedFns, TriggerOptions } from "../types";
import { InngestFunction } from "./InngestFunction";

@@ -143,6 +143,38 @@ 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.";

send<Payload extends SendEventPayload<Events>>(payload: Payload): Promise<void>;
createFunction<Trigger extends TriggerOptions<keyof Events & string>, NameOrOpts extends string | FunctionOptions>(nameOrOpts: NameOrOpts, trigger: Trigger, fn: Handler<Events, Trigger extends string ? Trigger : Trigger extends {
event: string;
} ? Trigger["event"] : string, NameOrOpts extends FunctionOptions ? NameOrOpts : never>): InngestFunction<Events>;
createFunction<TFns extends Record<string, any>, TTrigger extends TriggerOptions<keyof Events & string>, TShimmedFns extends Record<string, (...args: any[]) => any> = ShimmedFns<TFns>, TTriggerName extends keyof Events & string = EventNameFromTrigger<Events, TTrigger>>(nameOrOpts: string | (Omit<FunctionOptions<Events, TTriggerName>, "fns" | "onFailure"> & {
/**
* Pass in an object of functions that will be wrapped in Inngest
* tooling and passes to your handler. This wrapping ensures that each
* function is automatically separated and retried.
*
* @example
*
* Both examples behave the same; it's preference as to which you
* prefer.
*
* ```ts
* import { userDb } from "./db";
*
* // Specify `fns` and be able to use them in your Inngest function
* inngest.createFunction(
* { name: "Create user from PR", fns: { ...userDb } },
* { event: "github/pull_request" },
* async ({ fns: { createUser } }) => {
* await createUser("Alice");
* }
* );
*
* // Or always use `run()` to run inline steps and use them directly
* inngest.createFunction(
* { name: "Create user from PR" },
* { event: "github/pull_request" },
* async ({ step: { run } }) => {
* await run("createUser", () => userDb.createUser("Alice"));
* }
* );
* ```
*/
fns?: TFns;
}), trigger: TTrigger, handler: Handler<Events, TTriggerName, TShimmedFns>): InngestFunction<Events, any, any>;
}
//# sourceMappingURL=Inngest.d.ts.map

@@ -174,4 +174,5 @@ "use strict";

}
createFunction(nameOrOpts, trigger, fn) {
return new InngestFunction_1.InngestFunction(this, typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, typeof trigger === "string" ? { event: trigger } : trigger, fn);
createFunction(nameOrOpts, trigger, handler) {
const opts = typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts;
return new InngestFunction_1.InngestFunction(this, opts, typeof trigger === "string" ? { event: trigger } : trigger, handler);
}

@@ -178,0 +179,0 @@ }

@@ -41,3 +41,3 @@ import { ServerTiming } from "../helpers/ServerTiming";

*/
functions: InngestFunction<any>[],
functions: InngestFunction<any, any, any>[],
/**

@@ -203,3 +203,3 @@ * A set of options to further configure the registration of Inngest

*/
functions: InngestFunction<any>[], { inngestRegisterUrl, fetch, landingPage, logLevel, signingKey, serveHost, servePath, }: RegisterOptions | undefined,
functions: InngestFunction<any, any, any>[], { inngestRegisterUrl, fetch, landingPage, logLevel, signingKey, serveHost, servePath, }: RegisterOptions | undefined,
/**

@@ -206,0 +206,0 @@ * The `handler` is the function your framework requires to handle a

@@ -164,7 +164,12 @@ "use strict";

this.fns = functions.reduce((acc, fn) => {
const id = fn.id(this.name);
if (acc[id]) {
throw new Error(`Duplicate function ID "${id}"; please change a function's name or provide an explicit ID to avoid conflicts.`);
}
return Object.assign(Object.assign({}, acc), { [id]: fn });
const configs = fn["getConfig"](new URL("https://example.com"), this.name);
const fns = configs.reduce((acc, { id }, index) => {
return Object.assign(Object.assign({}, acc), { [id]: { fn, onFailure: Boolean(index) } });
}, {});
configs.forEach(({ id }) => {
if (acc[id]) {
throw new Error(`Duplicate function ID "${id}"; please change a function's name or provide an explicit ID to avoid conflicts.`);
}
});
return Object.assign(Object.assign({}, acc), fns);
}, {});

@@ -382,3 +387,3 @@ this.inngestRegisterUrl = new URL(inngestRegisterUrl || "https://api.inngest.com/fn/register");

})) !== null && _b !== void 0 ? _b : [];
const ret = await fn["runFn"]({ event }, opStack,
const ret = await fn.fn["runFn"]({ event }, opStack,
/**

@@ -389,3 +394,3 @@ * TODO The executor is sending `"step"` as the step ID when it is not

*/
stepId === "step" ? null : stepId || null, timer);
stepId === "step" ? null : stepId || null, timer, fn.onFailure);
if (ret[0] === "complete") {

@@ -439,3 +444,3 @@ return {

configs(url) {
return Object.values(this.fns).map((fn) => fn["getConfig"](url, this.name));
return Object.values(this.fns).reduce((acc, fn) => [...acc, ...fn.fn["getConfig"](url, this.name)], []);
}

@@ -442,0 +447,0 @@ /**

@@ -1,2 +0,2 @@

import { EventPayload, FunctionOptions, FunctionTrigger } from "../types";
import { EventNameFromTrigger, EventPayload, FunctionOptions, FunctionTrigger } from "../types";
import { Inngest } from "./Inngest";

@@ -12,5 +12,6 @@ /**

*/
export declare class InngestFunction<Events extends Record<string, EventPayload>> {
export declare class InngestFunction<Events extends Record<string, EventPayload>, Trigger extends FunctionTrigger<keyof Events & string>, Opts extends FunctionOptions<Events, EventNameFromTrigger<Events, Trigger>>> {
#private;
static stepId: string;
static failureSuffix: string;
/**

@@ -27,3 +28,3 @@ * A stateless Inngest function, wrapping up function configuration and any

*/
opts: FunctionOptions, trigger: FunctionTrigger<keyof Events>, fn: (...args: any[]) => any);
opts: Opts, trigger: Trigger, fn: (...args: any[]) => any);
/**

@@ -30,0 +31,0 @@ * The generated or given ID for this function.

@@ -24,3 +24,3 @@ "use strict";

};
var _InngestFunction_instances, _InngestFunction_opts, _InngestFunction_trigger, _InngestFunction_fn, _InngestFunction_client, _InngestFunction_generateId;
var _InngestFunction_instances, _InngestFunction_opts, _InngestFunction_trigger, _InngestFunction_fn, _InngestFunction_onFailureFn, _InngestFunction_client, _InngestFunction_generateId;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -60,2 +60,3 @@ exports.InngestFunction = void 0;

_InngestFunction_fn.set(this, void 0);
_InngestFunction_onFailureFn.set(this, void 0);
_InngestFunction_client.set(this, void 0);

@@ -66,2 +67,3 @@ __classPrivateFieldSet(this, _InngestFunction_client, client, "f");

__classPrivateFieldSet(this, _InngestFunction_fn, fn, "f");
__classPrivateFieldSet(this, _InngestFunction_onFailureFn, __classPrivateFieldGet(this, _InngestFunction_opts, "f").onFailure, "f");
}

@@ -72,6 +74,3 @@ /**

id(prefix) {
if (!__classPrivateFieldGet(this, _InngestFunction_opts, "f").id) {
__classPrivateFieldGet(this, _InngestFunction_opts, "f").id = __classPrivateFieldGet(this, _InngestFunction_instances, "m", _InngestFunction_generateId).call(this, prefix);
}
return __classPrivateFieldGet(this, _InngestFunction_opts, "f").id;
return __classPrivateFieldGet(this, _InngestFunction_opts, "f").id || __classPrivateFieldGet(this, _InngestFunction_instances, "m", _InngestFunction_generateId).call(this, prefix);
}

@@ -98,3 +97,3 @@ /**

stepUrl.searchParams.set(consts_1.queryKeys.StepId, InngestFunction.stepId);
const _a = __classPrivateFieldGet(this, _InngestFunction_opts, "f"), { retries: attempts, fns: _ } = _a, opts = __rest(_a, ["retries", "fns"]);
const _a = __classPrivateFieldGet(this, _InngestFunction_opts, "f"), { retries: attempts, cancelOn, fns: _ } = _a, opts = __rest(_a, ["retries", "cancelOn", "fns"]);
/**

@@ -105,3 +104,3 @@ * Convert retries into the format required when defining function

const retries = typeof attempts === "undefined" ? undefined : { attempts };
return Object.assign(Object.assign({}, opts), { id: fnId, name: this.name, triggers: [__classPrivateFieldGet(this, _InngestFunction_trigger, "f")], steps: {
const fn = Object.assign(Object.assign({}, opts), { id: fnId, name: this.name, triggers: [__classPrivateFieldGet(this, _InngestFunction_trigger, "f")], steps: {
[InngestFunction.stepId]: {

@@ -117,2 +116,45 @@ id: InngestFunction.stepId,

} });
if (cancelOn) {
fn.cancel = cancelOn.map(({ event, timeout, if: ifStr, match }) => {
const ret = {
event,
};
if (timeout) {
ret.timeout = (0, strings_1.timeStr)(timeout);
}
if (match) {
ret.if = `event.${match} == async.${match}`;
}
else if (ifStr) {
ret.if = ifStr;
}
return ret;
}, []);
}
const config = [fn];
if (__classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f")) {
const failureOpts = Object.assign({}, opts);
const id = `${fn.id}${InngestFunction.failureSuffix}`;
const name = `${fn.name} (failure)`;
const failureStepUrl = new URL(stepUrl.href);
failureStepUrl.searchParams.set(consts_1.queryKeys.FnId, id);
config.push(Object.assign(Object.assign({}, failureOpts), { id,
name, triggers: [
{
event: consts_1.internalEvents.FunctionFailed,
expression: `async.data.function_id == '${fnId}'`,
},
], steps: {
[InngestFunction.stepId]: {
id: InngestFunction.stepId,
name: InngestFunction.stepId,
runtime: {
type: "http",
url: failureStepUrl.href,
},
retries: { attempts: 1 },
},
} }));
}
return config;
}

@@ -154,3 +196,7 @@ /**

*/
runStep, timer) {
runStep, timer,
/**
* TODO Ugly boolean option; wrap this.
*/
isFailureHandler) {
const memoizingStop = timer.start("memoizing");

@@ -168,3 +214,22 @@ /**

const fnArg = Object.assign(Object.assign({}, data), { tools, step: tools });
let userFnToRun = __classPrivateFieldGet(this, _InngestFunction_fn, "f");
/**
* If the incoming event is an Inngest function failure event, we also want
* to pass some extra data to the function to act as shortcuts to the event
* payload.
*/
if (isFailureHandler) {
/**
* The user could have created a function that intentionally listens for
* these events. In this case, we may want to use the original handler.
*
* We only use the onFailure handler if
*/
if (!__classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f")) {
throw new Error(`Function "${this.name}" received a failure event to handle, but no failure handler was defined.`);
}
userFnToRun = __classPrivateFieldGet(this, _InngestFunction_onFailureFn, "f");
fnArg.err = fnArg.event.data.error;
}
/**
* If the user has passed functions they wish to use in their step, add them

@@ -189,3 +254,3 @@ * here.

try {
resolve(await __classPrivateFieldGet(this, _InngestFunction_fn, "f").call(this, fnArg));
resolve(await userFnToRun(fnArg));
}

@@ -326,6 +391,7 @@ catch (err) {

exports.InngestFunction = InngestFunction;
_InngestFunction_opts = new WeakMap(), _InngestFunction_trigger = new WeakMap(), _InngestFunction_fn = new WeakMap(), _InngestFunction_client = new WeakMap(), _InngestFunction_instances = new WeakSet(), _InngestFunction_generateId = function _InngestFunction_generateId(prefix) {
_InngestFunction_opts = new WeakMap(), _InngestFunction_trigger = new WeakMap(), _InngestFunction_fn = new WeakMap(), _InngestFunction_onFailureFn = new WeakMap(), _InngestFunction_client = new WeakMap(), _InngestFunction_instances = new WeakSet(), _InngestFunction_generateId = function _InngestFunction_generateId(prefix) {
return (0, strings_1.slugify)([prefix || "", __classPrivateFieldGet(this, _InngestFunction_opts, "f").name].join("-"));
};
InngestFunction.stepId = "step";
InngestFunction.failureSuffix = "-failure";
const tickOpToOutgoing = (op) => {

@@ -332,0 +398,0 @@ return {

@@ -41,2 +41,15 @@ /**

export declare const defaultDevServerHost = "http://127.0.0.1:8288/";
/**
* Events that Inngest may send internally that can be used to trigger
* functions.
*
* @public
*/
export declare enum internalEvents {
/**
* A function has failed after exhausting all available retries. This event
* will contain the original event and the error that caused the failure.
*/
FunctionFailed = "inngest/function.failed"
}
//# sourceMappingURL=consts.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultDevServerHost = exports.headerKeys = exports.prodEnvKeys = exports.envKeys = exports.queryKeys = void 0;
exports.internalEvents = exports.defaultDevServerHost = exports.headerKeys = exports.prodEnvKeys = exports.envKeys = exports.queryKeys = void 0;
/**

@@ -48,2 +48,16 @@ * Keys for accessing query parameters included in requests from Inngest to run

exports.defaultDevServerHost = "http://127.0.0.1:8288/";
/**
* Events that Inngest may send internally that can be used to trigger
* functions.
*
* @public
*/
var internalEvents;
(function (internalEvents) {
/**
* A function has failed after exhausting all available retries. This event
* will contain the original event and the error that caused the failure.
*/
internalEvents["FunctionFailed"] = "inngest/function.failed";
})(internalEvents = exports.internalEvents || (exports.internalEvents = {}));
//# sourceMappingURL=consts.js.map

@@ -0,1 +1,2 @@

import { TimeStr } from "../types";
/**

@@ -12,3 +13,3 @@ * Returns a slugified string used ot generate consistent IDs.

*/
export declare const timeStr: (input: string | number | Date, now?: Date) => string;
export declare const timeStr: (input: string | number | Date, now?: Date) => TimeStr;
//# sourceMappingURL=strings.d.ts.map

@@ -5,4 +5,4 @@ export { Inngest } from "./components/Inngest";

export { NonRetriableError } from "./components/NonRetriableError";
export { headerKeys, queryKeys } from "./helpers/consts";
export type { ClientOptions, EventPayload, FunctionOptions, LogLevel, RegisterOptions, TimeStr, } from "./types";
export { headerKeys, internalEvents, queryKeys } from "./helpers/consts";
export type { ClientOptions, EventNameFromTrigger, EventPayload, FailureEventArgs, FailureEventPayload, FunctionOptions, LogLevel, RegisterOptions, TimeStr, } from "./types";
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.queryKeys = exports.headerKeys = exports.NonRetriableError = exports.InngestCommHandler = exports.Inngest = void 0;
exports.queryKeys = exports.internalEvents = exports.headerKeys = exports.NonRetriableError = exports.InngestCommHandler = exports.Inngest = void 0;
var Inngest_1 = require("./components/Inngest");

@@ -12,3 +12,4 @@ Object.defineProperty(exports, "Inngest", { enumerable: true, get: function () { return Inngest_1.Inngest; } });

Object.defineProperty(exports, "headerKeys", { enumerable: true, get: function () { return consts_1.headerKeys; } });
Object.defineProperty(exports, "internalEvents", { enumerable: true, get: function () { return consts_1.internalEvents; } });
Object.defineProperty(exports, "queryKeys", { enumerable: true, get: function () { return consts_1.queryKeys; } });
//# sourceMappingURL=index.js.map
{
"name": "inngest",
"version": "1.4.0-concurrency.0",
"version": "1.4.0",
"description": "Official SDK for Inngest.com",

@@ -67,3 +67,2 @@ "main": "./index.js",

"@actions/exec": "^1.1.1",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",

@@ -70,0 +69,0 @@ "@inngest/eslint-plugin": "./rules",

import { z } from "zod";
import type { createStepTools } from "./components/InngestStepTools";
import type { KeysNotOfType, StrictUnion } from "./helpers/types";
import { internalEvents } from "./helpers/consts";
import type { KeysNotOfType, ObjectPaths, StrictUnion } from "./helpers/types";
/**
* Arguments for a single-step function.
* The payload for an internal Inngest event that is sent when a function fails.
*
* @public
*/
export type EventData<Event> = Event extends never ? Record<string, never> : {
/**
* The event data present in the payload.
*/
event: Event;
export type FailureEventPayload<P extends EventPayload = EventPayload> = {
name: `${internalEvents.FunctionFailed}`;
data: {
function_id: string;
run_id: string;
error: {
message: string;
stack?: string;
cause?: string;
status?: number;
};
event: P;
};
};
/**
* Arguments for a multi-step function, extending the single-step args and
* including step function tooling.
* Context arguments specific to a failure event.
*
* @public
*/
export type HandlerArgs<Events extends Record<string, EventPayload>, Event extends keyof Events, Opts extends FunctionOptions> = EventData<Events[Event]> & {
export type FailureEventArgs<P extends EventPayload = EventPayload> = {
/**
* @deprecated Use `step` instead.
* The event data present in the payload.
*/
tools: ReturnType<typeof createStepTools<Events, Event>>[0];
step: ReturnType<typeof createStepTools<Events, Event>>[0];
} & (Opts["fns"] extends Record<string, any> ? {
event: FailureEventPayload<P>;
/**
* Any `fns` passed when creating your Inngest function will be
* available here and can be used as normal.
*
* Every call to one of these functions will become a new retryable
* step.
*
* @example
*
* Both examples behave the same; it's preference as to which you
* prefer.
*
* ```ts
* import { userDb } from "./db";
*
* // Specify `fns` and be able to use them in your Inngest function
* inngest.createFunction(
* { name: "Create user from PR", fns: { ...userDb } },
* { event: "github/pull_request" },
* async ({ tools: { run }, fns: { createUser } }) => {
* await createUser("Alice");
* }
* );
*
* // Or always use `run()` to run inline steps and use them directly
* inngest.createFunction(
* { name: "Create user from PR" },
* { event: "github/pull_request" },
* async ({ tools: { run } }) => {
* await run("createUser", () => userDb.createUser("Alice"));
* }
* );
* ```
* The final error that caused this function to exhaust all retries.
*/
fns: {
[K in keyof Omit<Opts["fns"], KeysNotOfType<Opts["fns"], (...args: any[]) => any>>]: (...args: Parameters<Opts["fns"][K]>) => Promise<Awaited<ReturnType<Opts["fns"][K]>>>;
};
} : Record<string, never>);
err: FailureEventPayload<P>["data"]["error"];
};
/**

@@ -156,12 +129,73 @@ * Unique codes for the different types of operation that can be sent to Inngest

export type TimeStr = `${`${number}w` | ""}${`${number}d` | ""}${`${number}h` | ""}${`${number}m` | ""}${`${number}s` | ""}`;
export type BaseContext<TEvents extends Record<string, EventPayload>, TTrigger extends keyof TEvents & string, TShimmedFns extends Record<string, (...args: any[]) => any>> = {
/**
* The event data present in the payload.
*/
event: TEvents[TTrigger];
/**
* @deprecated Use `step` instead.
*/
tools: ReturnType<typeof createStepTools<TEvents, TTrigger>>[0];
step: ReturnType<typeof createStepTools<TEvents, TTrigger>>[0];
/**
* Any `fns` passed when creating your Inngest function will be
* available here and can be used as normal.
*
* Every call to one of these functions will become a new retryable
* step.
*
* @example
*
* Both examples behave the same; it's preference as to which you
* prefer.
*
* ```ts
* import { userDb } from "./db";
*
* // Specify `fns` and be able to use them in your Inngest function
* inngest.createFunction(
* { name: "Create user from PR", fns: { ...userDb } },
* { event: "github/pull_request" },
* async ({ tools: { run }, fns: { createUser } }) => {
* await createUser("Alice");
* }
* );
*
* // Or always use `run()` to run inline steps and use them directly
* inngest.createFunction(
* { name: "Create user from PR" },
* { event: "github/pull_request" },
* async ({ tools: { run } }) => {
* await run("createUser", () => userDb.createUser("Alice"));
* }
* );
* ```
*/
fns: TShimmedFns;
};
/**
* The shape of a multi-step function, taking in event, step, ctx, and tools.
* Given a set of generic objects, extract any top-level functions and
* appropriately shim their types.
*/
export type ShimmedFns<Fns extends Record<string, any>> = Fns extends Record<string, any> ? {
[K in keyof Omit<Fns, KeysNotOfType<Fns, (...args: any[]) => any>>]: (...args: Parameters<Fns[K]>) => Promise<Awaited<ReturnType<Fns[K]>>>;
} : Record<string, never>;
/**
* Builds a context object for an Inngest handler, optionally overriding some
* keys.
*/
export type Context<TEvents extends Record<string, EventPayload>, TTrigger extends keyof TEvents & string, TShimmedFns extends Record<string, (...args: any[]) => any>, TOverrides extends Record<string, any> = Record<never, never>> = Omit<BaseContext<TEvents, TTrigger, TShimmedFns>, keyof TOverrides> & TOverrides;
/**
* The shape of a Inngest function, taking in event, step, ctx, and step
* tooling.
*
* Multi-step functions are not expected to return any data themselves, as all
* logic is expected to be placed within steps.
*
* @public
*/
export type Handler<Events extends Record<string, EventPayload>, Event extends keyof Events, Opts extends FunctionOptions> = (arg: HandlerArgs<Events, Event, Opts>) => any | Promise<any>;
export type Handler<TEvents extends Record<string, EventPayload>, TTrigger extends keyof TEvents & string, TShimmedFns extends Record<string, (...args: any[]) => any>, TOverrides extends Record<string, any> = Record<never, never>> = (
/**
* The context argument provides access to all data and tooling available to
* the function.
*/
ctx: Context<TEvents, TTrigger, TShimmedFns, TOverrides>) => any;
/**
* The shape of a single event's payload. It should be extended to enforce

@@ -238,3 +272,3 @@ * adherence to given events and not used as a method of creating them (i.e. as

*/
export type Step<Context = any> = (
export type Step<TContext = any> = (
/**

@@ -244,3 +278,3 @@ * The context for this step, including the triggering event and any previous

*/
context: Context) => Promise<Response> | Response;
context: TContext) => Promise<Response> | Response;
/**

@@ -373,2 +407,5 @@ * A set of options for configuring the Inngest client.

}
/**
* A user-friendly method of specifying a trigger for an Inngest function.
*/
export type TriggerOptions<T extends string> = T | StrictUnion<{

@@ -384,3 +421,3 @@ event: T;

*/
export interface FunctionOptions {
export interface FunctionOptions<Events extends Record<string, EventPayload>, Event extends keyof Events & string> {
/**

@@ -441,2 +478,3 @@ * An optional unique ID used to identify the function. This is used

};
cancelOn?: Cancellation<Events, Event>[];
/**

@@ -448,4 +486,68 @@ * Specifies the maximum number of retries for all steps across this function.

retries?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
onFailure?: (...args: any[]) => any;
}
/**
* Configuration for cancelling a function run based on an incoming event.
*
* @public
*/
export type Cancellation<Events extends Record<string, EventPayload>, TriggeringEvent extends keyof Events & string> = {
[K in keyof Events]: {
/**
* The name of the event that should cancel the function run.
*/
event: K & string;
/**
* The expression that must evaluate to true in order to cancel the function run. There
* are two variables available in this expression:
* - event, referencing the original function's event trigger
* - async, referencing the new cancel event.
*
* @example
*
* Ensures the cancel event's data.user_id field matches the triggering event's data.user_id
* field:
*
* ```ts
* "async.data.user_id == event.data.user_id"
* ```
*/
if?: string;
/**
* If provided, the step function will wait for the incoming event to match
* particular criteria. If the event does not match, it will be ignored and
* the step function will wait for another event.
*
* It must be a string of a dot-notation field name within both events to
* compare, e.g. `"data.id"` or `"user.email"`.
*
* ```
* // Wait for an event where the `user.email` field matches
* match: "user.email"
* ```
*
* All of these are helpers for the `if` option, which allows you to specify
* a custom condition to check. This can be useful if you need to compare
* multiple fields or use a more complex condition.
*
* See the Inngest expressions docs for more information.
*
* {@link https://www.inngest.com/docs/functions/expressions}
*/
match?: ObjectPaths<Events[TriggeringEvent]> & ObjectPaths<Events[K]>;
/**
* An optional timeout that the cancel is valid for. If this isn't
* specified, cancellation triggers are valid for up to a year or until the
* function ends.
*
* The time to wait can be specified using a `number` of milliseconds, an
* `ms`-compatible time string like `"1 hour"`, `"30 mins"`, or `"2.5d"`, or
* a `Date` object.
*
* {@link https://npm.im/ms}
*/
timeout?: number | string | Date;
};
}[keyof Events];
/**
* Expected responses to be used within an `InngestCommHandler` in order to

@@ -567,2 +669,7 @@ * appropriately respond to Inngest.

};
cancel?: {
event: string;
if?: string;
timeout?: TimeStr;
}[];
}

@@ -583,2 +690,11 @@ export interface DevServerInfo {

}
/**
* Given a set of events and a user-friendly trigger paramter, returns the name
* of the event that the user intends to listen to.
*
* @public
*/
export type EventNameFromTrigger<Events extends Record<string, EventPayload>, T extends TriggerOptions<keyof Events & string>> = T extends string ? T : T extends {
event: string;
} ? T["event"] : string;
//# sourceMappingURL=types.d.ts.map

@@ -1,2 +0,2 @@

export declare const version = "1.4.0-concurrency.0";
export declare const version = "1.4.0";
//# sourceMappingURL=version.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

// Generated by genversion.
exports.version = "1.4.0-concurrency.0";
exports.version = "1.4.0";
//# sourceMappingURL=version.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc