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

inngest

Package Overview
Dependencies
Maintainers
2
Versions
556
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.3.0 to 0.4.0-beta.1

dist/components/Inngest.d.ts

125

dist/index.d.ts

@@ -1,122 +0,5 @@

/**
* An HTTP-like, standardised response format that allows Inngest to help
* orchestrate steps and retries.
*/
export interface InngestResponse {
/**
* A step response must contain an HTTP status code.
*
* A `2xx` response indicates success; this is not a failure and no retry is
* necessary.
*
* A `4xx` response indicates a bad request; this step will not be retried as
* it is deemed irrecoverable. Examples of this might be an event with
* insufficient data or concerning a user that no longer exists.
*
* A `5xx` status indicates a temporary internal error; this will be retried
* according to the step and function's retry policy (3 times, by default).
*
* @link https://www.inngest.com/docs/functions/function-input-and-output#response-format
* @link https://www.inngest.com/docs/functions/retries
*/
status: number;
/**
* The output of the function - the `body` - can be any arbitrary
* JSON-compatible data. It is then usable by any future steps.
*
* @link https://www.inngest.com/docs/functions/function-input-and-output#response-format
*/
body?: any;
}
/**
* A single step within a function.
*/
export declare type InngestStep<Context = any> = (
/**
* The context for this step, including the triggering event and any previous
* step output.
*/
context: Context) => Promise<InngestResponse> | InngestResponse;
/**
* The event payload structure for sending data to Inngest
*/
export interface EventPayload {
/**
* A unique identifier for the event
*/
name: string;
/**
* Any data pertinent to the event
*/
data: {
[key: string]: any;
};
/**
* Any user data associated with the event
* All fields ending in "_id" will be used to attribute the event to a particular user
*/
user?: {
/**
* Your user's unique id in your system
*/
external_id?: string;
/**
* Your user's email address
*/
email?: string;
/**
* Your user's phone number
*/
phone?: string;
[key: string]: any;
};
/**
* A specific event schema version
* (optional)
*/
v?: string;
/**
* An integer representing the milliseconds since the unix epoch at which this event occurred.
* Defaults to the current time.
* (optional)
*/
ts?: number;
}
/**
* A set of options for configuring the Inngest client
*/
export interface InngestClientOptions {
/**
* The base Inngest Source API URL to append the Source API Key to.
* Defaults to https://inn.gs/e/
*/
inngestApiUrl?: string;
}
/**
* A client for the Inngest Source API
*/
declare class Inngest {
/**
* Inngest Source API Key
*/
private apiKey;
/**
* Full URL for the Inngest Source API
*/
private inngestApiUrl;
/**
* Axios configuration for sending events to Inngest
*/
private axiosConfig;
/**
* @param apiKey - An API Key for the Inngest Source API
*/
constructor(apiKey: string, { inngestApiUrl }?: InngestClientOptions);
private getResponseError;
/**
* Send event(s) to Inngest
*/
send(payload: EventPayload | EventPayload[]): Promise<boolean>;
}
export { Inngest };
export { Inngest } from "./components/Inngest";
export { InngestCommHandler, register, RegisterHandler, } from "./handlers/default";
export { createFunction } from "./helpers/func";
export { ClientOptions, FunctionOptions } from "./types";
//# sourceMappingURL=index.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.Inngest = void 0;
const axios_1 = __importDefault(require("axios"));
const url_1 = require("url");
/**
* A client for the Inngest Source API
*/
class Inngest {
/**
* @param apiKey - An API Key for the Inngest Source API
*/
constructor(apiKey, { inngestApiUrl = "https://inn.gs/e/" } = {}) {
this.apiKey = apiKey;
this.inngestApiUrl = new url_1.URL(this.apiKey, inngestApiUrl).toString();
this.axiosConfig = {
timeout: 0,
headers: {
"Content-Type": "application/json",
"User-Agent": "InngestJS 0.1.0",
},
validateStatus: () => true,
maxRedirects: 0,
};
}
getResponseError(response) {
let errorMessage = "Unknown error";
switch (response.status) {
case 401:
errorMessage = "API Key Not Found";
break;
case 400:
errorMessage = "Cannot process event payload";
break;
case 403:
errorMessage = "Forbidden";
break;
case 404:
errorMessage = "API Key not found";
break;
case 406:
errorMessage = `${JSON.stringify(response.data)}`;
break;
case 409:
case 412:
errorMessage = "Event transformation failed";
break;
case 413:
errorMessage = "Event payload too large";
break;
case 500:
errorMessage = "Internal server error";
break;
}
return new Error(`Inngest API Error: ${response.status} ${errorMessage}`);
}
/**
* Send event(s) to Inngest
*/
async send(payload) {
const response = await axios_1.default.post(this.inngestApiUrl, payload, this.axiosConfig);
if (response.status >= 200 && response.status < 300) {
return true;
}
throw this.getResponseError(response);
}
}
exports.Inngest = Inngest;
exports.createFunction = exports.register = exports.InngestCommHandler = exports.Inngest = void 0;
var Inngest_1 = require("./components/Inngest");
Object.defineProperty(exports, "Inngest", { enumerable: true, get: function () { return Inngest_1.Inngest; } });
var default_1 = require("./handlers/default");
Object.defineProperty(exports, "InngestCommHandler", { enumerable: true, get: function () { return default_1.InngestCommHandler; } });
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return default_1.register; } });
var func_1 = require("./helpers/func");
Object.defineProperty(exports, "createFunction", { enumerable: true, get: function () { return func_1.createFunction; } });
//# sourceMappingURL=index.js.map
{
"name": "inngest",
"version": "0.3.0",
"version": "0.4.0-beta.1",
"description": "Official SDK for Inngest.com",

@@ -10,10 +10,8 @@ "main": "./dist/index.js",

},
"bin": {
"inngest-init": "./dist/init.js"
},
"scripts": {
"prebuild": "genversion --semi --double --es6 ./src/version.ts",
"build": "yarn run clean && tsc",
"test": "jest",
"clean": "rm -rf ./dist",
"prepare": "yarn run test && yarn run build",
"prepare": "yarn run build",
"release": "yarn run np"

@@ -42,7 +40,11 @@ },

"dependencies": {
"axios": "^0.27.2"
"axios": "^0.27.2",
"zod": "^3.19.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"genversion": "^3.1.1",
"jest": "27.5.1",
"next": "^12.3.0",
"np": "^7.6.1",

@@ -49,0 +51,0 @@ "ts-jest": "^27.1.4",

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