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 0.7.1-beta.1 to 0.7.1

38

components/InngestStepTools.d.ts
import type { ObjectPaths } from "../helpers/types";
import { EventPayload, HashedOp, OpStack, TimeStr } from "../types";
import { EventPayload, HashedOp, OpStack } from "../types";
/**

@@ -35,7 +35,7 @@ * A unique class used to interrupt the flow of a step. It is intended to be

*/
waitForEvent: <IncomingEvent extends keyof Events, Opts extends (WaitForEventOpts<Events[TriggeringEvent], Events[IncomingEvent]> & {
waitForEvent: <IncomingEvent extends EventPayload | keyof Events>(event: IncomingEvent extends keyof Events ? IncomingEvent : IncomingEvent extends EventPayload ? IncomingEvent["name"] : never, opts: ((IncomingEvent extends keyof Events ? WaitForEventOpts<Events[TriggeringEvent], Events[IncomingEvent]> : IncomingEvent extends EventPayload ? WaitForEventOpts<Events[TriggeringEvent], IncomingEvent> : never) & {
if?: undefined;
}) | (WaitForEventOpts<Events[TriggeringEvent], Events[IncomingEvent]> & {
}) | ((IncomingEvent extends keyof Events ? WaitForEventOpts<Events[TriggeringEvent], Events[IncomingEvent]> : IncomingEvent extends EventPayload ? WaitForEventOpts<Events[TriggeringEvent], IncomingEvent> : never) & {
match?: undefined;
})>(event: IncomingEvent, opts?: Opts | undefined) => Opts["timeout"] extends string ? Opts["timeout"] extends "" ? Events[IncomingEvent] : Events[IncomingEvent] | null : Events[IncomingEvent];
})) => IncomingEvent extends keyof Events ? Events[IncomingEvent] | null : IncomingEvent | null;
/**

@@ -55,8 +55,12 @@ * Use this tool to run business logic. Each call to `run` will be retried

/**
* Wait a specified amount of time before continuing, in the format of a
* time string like `"1h30m"` or `"1d"`.
* Wait a specified amount of time before continuing.
*
* The time to wait can be specified using a `number` of milliseconds or an
* `ms`-compatible time string like `"1 hour"`, `"30 mins"`, or `"2.5d"`.
*
* {@link https://npm.im/ms}
*
* To wait until a particular date, use `sleepUntil` instead.
*/
sleep: (time: Exclude<TimeStr, "">) => void;
sleep: (time: number | string) => void;
/**

@@ -77,18 +81,12 @@ * Wait until a particular date before continuing by passing a `Date`.

/**
* If provided, the step function will wait for the event for a maximum of
* this time, at which point the event will be returned as `null` instead of
* any event data.
* The step function will wait for the event for a maximum of this time, at
* which point the event will be returned as `null` instead of any event data.
*
* The time to wait can be specified using a string in the format of
* `[number][unit]`, e.g. `50ms` for 50 milliseconds, `1s` for 1 second, `2m`
* for 2 minutes, `3h` for 3 hours, `4d` for 4 days, and `5w` for 5 weeks.
* These can also be combined, e.g. `1h30m` for 1 hour and 30 minutes.
* 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.
*
* Alternatively, the timeout can be provided as a `Date`, in which case the
* SDK will calculate the time to wait for you.
*
* If this is not specified or is blank (an empty string `""`), the step will
* wait for the event indefinitely.
* {@link https://npm.im/ms}
*/
timeout?: TimeStr | Date;
timeout: number | string | Date;
/**

@@ -95,0 +93,0 @@ * If provided, the step function will wait for the incoming event to match

@@ -191,9 +191,5 @@ "use strict";

opts) => {
const matchOpts = {};
if (opts === null || opts === void 0 ? void 0 : opts.timeout) {
matchOpts.ttl =
typeof opts.timeout === "string"
? opts.timeout
: (0, strings_1.dateToTimeStr)(opts.timeout);
}
const matchOpts = {
ttl: (0, strings_1.timeStr)(opts.timeout),
};
if (opts === null || opts === void 0 ? void 0 : opts.match) {

@@ -232,5 +228,9 @@ matchOpts.match = `event.${opts.match} == async.${opts.match}`;

/**
* Wait a specified amount of time before continuing, in the format of a
* time string like `"1h30m"` or `"1d"`.
* Wait a specified amount of time before continuing.
*
* The time to wait can be specified using a `number` of milliseconds or an
* `ms`-compatible time string like `"1 hour"`, `"30 mins"`, or `"2.5d"`.
*
* {@link https://npm.im/ms}
*
* To wait until a particular date, use `sleepUntil` instead.

@@ -245,3 +245,3 @@ */

op: types_1.StepOpCode.Sleep,
name: time,
name: (0, strings_1.timeStr)(time),
};

@@ -261,3 +261,3 @@ }),

op: types_1.StepOpCode.Sleep,
name: (0, strings_1.dateToTimeStr)(time),
name: (0, strings_1.timeStr)(time),
};

@@ -264,0 +264,0 @@ }),

@@ -177,3 +177,2 @@ "use strict";

.parse(data);
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const ret = await fn["runFn"]({ event }, steps || {});

@@ -180,0 +179,0 @@ const isOp = ret[0];

@@ -26,3 +26,3 @@ import { InngestFunction } from "../components/InngestFunction";

*/
export declare const createStepFunction: <Events extends Record<string, EventPayload>, Event_1 extends keyof Events>(nameOrOpts: string | FunctionOptions, event: EventName<Events[Event_1]>, fn: MultiStepFn<Events, Event_1, string, "step">) => InngestFunction<any>;
export declare const createStepFunction: <T extends EventPayload>(nameOrOpts: string | FunctionOptions, event: EventName<T>, fn: MultiStepFn<Record<T["name"], T>, T["name"], string, "step">) => InngestFunction<any>;
//# sourceMappingURL=func.d.ts.map

@@ -6,4 +6,4 @@ /**

/**
* Convert a given `date` to a sleep-compatible time string (e.g. `"1d"` or
* `"2h3010s"`).
* Convert a given `Date`, `number`, or `ms`-compatible `string` to a
* Inngest sleep-compatible time string (e.g. `"1d"` or `"2h3010s"`).
*

@@ -13,3 +13,3 @@ * Can optionally provide a `now` date to use as the base for the calculation,

*/
export declare const dateToTimeStr: (date: Date, now?: Date) => string;
export declare const timeStr: (input: string | number | Date, now?: Date) => string;
//# sourceMappingURL=strings.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dateToTimeStr = exports.slugify = void 0;
exports.timeStr = exports.slugify = void 0;
const ms_1 = __importDefault(require("ms"));
/**

@@ -34,7 +38,6 @@ * Returns a slugified string used ot generate consistent IDs.

["s", second],
["ms", millisecond],
];
/**
* Convert a given `date` to a sleep-compatible time string (e.g. `"1d"` or
* `"2h3010s"`).
* Convert a given `Date`, `number`, or `ms`-compatible `string` to a
* Inngest sleep-compatible time string (e.g. `"1d"` or `"2h3010s"`).
*

@@ -44,7 +47,7 @@ * Can optionally provide a `now` date to use as the base for the calculation,

*/
const dateToTimeStr = (
const timeStr = (
/**
* The future date to use to convert to a time string.
*/
date,
input,
/**

@@ -54,2 +57,9 @@ * Optionally provide a date to use as the base for the calculation.

now = new Date()) => {
let date = input;
if (typeof date === "string" || typeof date === "number") {
const numTimeout = typeof date === "string" ? (0, ms_1.default)(date) : date;
date = new Date(Date.now() + numTimeout);
}
now.setMilliseconds(0);
date.setMilliseconds(0);
const isValidDate = !isNaN(date.getTime());

@@ -59,11 +69,2 @@ if (!isValidDate) {

}
/**
* TODO In this eventuality, should we smartly skip the sleep?
*
* We'd have to return two ops to Inngest, this being skipped and the
* next.
*/
if (date <= now) {
throw new Error("Cannot sleep until a time in the past");
}
const timeNum = date.getTime() - now.getTime();

@@ -79,3 +80,3 @@ const [, timeStr] = periods.reduce(([num, str], [suffix, period]) => {

};
exports.dateToTimeStr = dateToTimeStr;
exports.timeStr = timeStr;
//# sourceMappingURL=strings.js.map
export { Inngest } from "./components/Inngest";
export { createFunction, createScheduledFunction } from "./helpers/func";
export { createFunction, createScheduledFunction, createStepFunction, } from "./helpers/func";
export type { ClientOptions, EventPayload, FunctionOptions, MultiStepFn, MultiStepFnArgs, RegisterOptions, SingleStepFn, SingleStepFnArgs, TimeStr, } from "./types";
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createScheduledFunction = exports.createFunction = exports.Inngest = void 0;
exports.createStepFunction = exports.createScheduledFunction = exports.createFunction = exports.Inngest = void 0;
var Inngest_1 = require("./components/Inngest");

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

Object.defineProperty(exports, "createScheduledFunction", { enumerable: true, get: function () { return func_1.createScheduledFunction; } });
Object.defineProperty(exports, "createStepFunction", { enumerable: true, get: function () { return func_1.createStepFunction; } });
//# sourceMappingURL=index.js.map
{
"name": "inngest",
"version": "0.7.1-beta.1",
"version": "0.7.1",
"description": "Official SDK for Inngest.com",

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

"hash.js": "^1.1.7",
"ms": "^2.1.3",
"sigmund": "^1.0.1",

@@ -66,2 +67,3 @@ "zod": "^3.19.1"

"@types/jest": "^27.4.1",
"@types/ms": "^0.7.31",
"@types/sha.js": "^2.4.0",

@@ -68,0 +70,0 @@ "@types/sigmund": "^1.0.0",

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

export declare const version = "0.7.1-beta.1";
export declare const version = "0.7.1";
//# sourceMappingURL=version.d.ts.map

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

// Generated by genversion.
exports.version = "0.7.1-beta.1";
exports.version = "0.7.1";
//# 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 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

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