Comparing version 1.6.1 to 1.7.0
# inngest | ||
## 1.7.0 | ||
### Minor Changes | ||
- c999896: INN-1029 Add `env` option to `Inngest` client to explicitly push to a particular Inngest env | ||
### Patch Changes | ||
- 131727a: Adjust README to have a slightly clearer intro | ||
- c999896: INN-1186 Send `x-inngest-platform` and `x-inngest-framework` headers during registration | ||
- 0728308: Expose run ID to function executions for user-managed logging and tracing | ||
- 3ac579f: Warn users when some functions appear undefined when serving | ||
- eb1ea34: Allow signing keys with multiple prefixes, as required for branch environment support | ||
## 1.6.1 | ||
@@ -4,0 +18,0 @@ |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "cloudflare-pages"; | ||
/** | ||
@@ -3,0 +4,0 @@ * In Cloudflare, serve and register any declared functions with Inngest, making |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
exports.name = "cloudflare-pages"; | ||
/** | ||
@@ -13,3 +14,3 @@ * In Cloudflare, serve and register any declared functions with Inngest, making | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("cloudflare-pages", nameOrInngest, fns, Object.assign({ | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, Object.assign({ | ||
/** | ||
@@ -16,0 +17,0 @@ * Assume that we want to override the `fetch` implementation with the one |
@@ -75,3 +75,3 @@ import type { PartialK, SendEventPayload, SingleOrArray } from "../helpers/types"; | ||
*/ | ||
constructor({ name, eventKey, inngestBaseUrl, fetch, }: ClientOptions); | ||
constructor({ name, eventKey, inngestBaseUrl, fetch, env, }: ClientOptions); | ||
/** | ||
@@ -78,0 +78,0 @@ * Given a potential fetch function, return the fetch function to use based on |
@@ -13,3 +13,2 @@ "use strict"; | ||
const env_1 = require("../helpers/env"); | ||
const version_1 = require("../version"); | ||
const InngestFunction_1 = require("./InngestFunction"); | ||
@@ -67,3 +66,3 @@ exports.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."; | ||
*/ | ||
constructor({ name, eventKey, inngestBaseUrl = "https://inn.gs/", fetch, }) { | ||
constructor({ name, eventKey, inngestBaseUrl = "https://inn.gs/", fetch, env, }) { | ||
_Inngest_instances.add(this); | ||
@@ -87,6 +86,5 @@ /** | ||
} | ||
this.headers = { | ||
"Content-Type": "application/json", | ||
"User-Agent": `InngestJS v${version_1.version}`, | ||
}; | ||
this.headers = (0, env_1.inngestHeaders)({ | ||
inngestEnv: env, | ||
}); | ||
this.fetch = Inngest.parseFetch(fetch); | ||
@@ -93,0 +91,0 @@ } |
@@ -133,8 +133,2 @@ import { ServerTiming } from "../helpers/ServerTiming"; | ||
/** | ||
* A set of headers sent back with every request. Usually includes generic | ||
* functionality such as `"Content-Type"`, alongside informational headers | ||
* such as Inngest SDK version. | ||
*/ | ||
private readonly headers; | ||
/** | ||
* The localized `fetch` implementation used by this handler. | ||
@@ -311,13 +305,2 @@ */ | ||
/** | ||
* Returns an SDK header split in to three parts so that they can be used for | ||
* different purposes. | ||
* | ||
* To use the entire string, run `this.sdkHeader.join("")`. | ||
*/ | ||
protected get sdkHeader(): [ | ||
prefix: string, | ||
version: RegisterRequest["sdk"], | ||
suffix: string | ||
]; | ||
/** | ||
* Return an Inngest serve endpoint URL given a potential `path` and `host`. | ||
@@ -330,3 +313,3 @@ * | ||
protected registerBody(url: URL): RegisterRequest; | ||
protected register(url: URL, devServerHost: string | undefined, deployId?: string | undefined | null): Promise<{ | ||
protected register(url: URL, devServerHost: string | undefined, deployId: string | undefined | null, getHeaders: () => Record<string, string>): Promise<{ | ||
status: number; | ||
@@ -333,0 +316,0 @@ message: string; |
@@ -167,3 +167,7 @@ "use strict"; | ||
(_a = arguments["3"]) === null || _a === void 0 ? void 0 : _a.__testingAllowExpiredSignatures); | ||
this.rawFns = functions; | ||
// Ensure we filter any undefined functions in case of missing imports. | ||
this.rawFns = functions.filter(Boolean); | ||
if (this.rawFns.length !== functions.length) { | ||
console.warn(`Some functions passed to serve() are undefined and misconfigured. Please check your imports.`); | ||
} | ||
this.fns = this.rawFns.reduce((acc, fn) => { | ||
@@ -187,6 +191,2 @@ const configs = fn["getConfig"](new URL("https://example.com"), this.name); | ||
this.logLevel = logLevel; | ||
this.headers = { | ||
"Content-Type": "application/json", | ||
"User-Agent": `inngest-js:v${version_1.version} (${this.frameworkName})`, | ||
}; | ||
this.fetch = | ||
@@ -207,4 +207,4 @@ fetch || | ||
} | ||
const prefix = ((_a = this.signingKey.match(/^signkey-(test|prod)-/)) === null || _a === void 0 ? void 0 : _a.shift()) || ""; | ||
const key = this.signingKey.replace(/^signkey-(test|prod)-/, ""); | ||
const prefix = ((_a = this.signingKey.match(/^signkey-[\w]+-/)) === null || _a === void 0 ? void 0 : _a.shift()) || ""; | ||
const key = this.signingKey.replace(/^signkey-[\w]+-/, ""); | ||
// Decode the key from its hex representation into a bytestream | ||
@@ -262,7 +262,7 @@ return `${prefix}${(0, hash_js_1.sha256)().update(key, "hex").digest("hex")}`; | ||
var _a, _b; | ||
const getHeaders = () => ({ | ||
[consts_1.headerKeys.SdkVersion]: this.sdkHeader.join(""), | ||
"Server-Timing": timer.getHeader(), | ||
}); | ||
const env = (_a = actions.env) !== null && _a !== void 0 ? _a : (0, env_1.allProcessEnv)(); | ||
const getHeaders = () => (Object.assign(Object.assign({}, (0, env_1.inngestHeaders)({ | ||
env: env, | ||
framework: this.frameworkName, | ||
})), { "Server-Timing": timer.getHeader() })); | ||
this._isProd = (_b = actions.isProduction) !== null && _b !== void 0 ? _b : (0, env_1.isProd)(env); | ||
@@ -317,3 +317,3 @@ try { | ||
this.upsertSigningKeyFromEnv(env); | ||
const { status, message } = await this.register(this.reqUrl(actions.url), (0, strings_1.stringifyUnknown)(env[consts_1.envKeys.DevServerUrl]), registerRes.deployId); | ||
const { status, message } = await this.register(this.reqUrl(actions.url), (0, strings_1.stringifyUnknown)(env[consts_1.envKeys.DevServerUrl]), registerRes.deployId, getHeaders); | ||
return { | ||
@@ -368,2 +368,3 @@ status, | ||
.object({ | ||
run_id: zod_1.z.string(), | ||
stack: zod_1.z | ||
@@ -398,3 +399,3 @@ .object({ | ||
})) !== null && _b !== void 0 ? _b : []; | ||
const ret = await fn.fn["runFn"]({ event }, opStack, | ||
const ret = await fn.fn["runFn"]({ event, runId: ctx === null || ctx === void 0 ? void 0 : ctx.run_id }, opStack, | ||
/** | ||
@@ -457,11 +458,2 @@ * TODO The executor is sending `"step"` as the step ID when it is not | ||
/** | ||
* Returns an SDK header split in to three parts so that they can be used for | ||
* different purposes. | ||
* | ||
* To use the entire string, run `this.sdkHeader.join("")`. | ||
*/ | ||
get sdkHeader() { | ||
return ["inngest-", `js:v${version_1.version}`, ` (${this.frameworkName})`]; | ||
} | ||
/** | ||
* Return an Inngest serve endpoint URL given a potential `path` and `host`. | ||
@@ -491,3 +483,3 @@ * | ||
functions: this.configs(url), | ||
sdk: this.sdkHeader[1], | ||
sdk: `js:v${version_1.version}`, | ||
v: "0.1", | ||
@@ -499,3 +491,3 @@ }; | ||
} | ||
async register(url, devServerHost, deployId) { | ||
async register(url, devServerHost, deployId, getHeaders) { | ||
const body = this.registerBody(url); | ||
@@ -519,3 +511,3 @@ let res; | ||
body: JSON.stringify(body), | ||
headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${this.hashedSigningKey}` }), | ||
headers: Object.assign(Object.assign({}, getHeaders()), { Authorization: `Bearer ${this.hashedSigningKey}` }), | ||
redirect: "follow", | ||
@@ -522,0 +514,0 @@ }); |
import { ServeHandler } from "../components/InngestCommHandler"; | ||
export declare const name = "deno/fresh"; | ||
/** | ||
@@ -3,0 +4,0 @@ * With Deno's Fresh framework, serve and register any declared functions with |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("../components/InngestCommHandler"); | ||
const consts_1 = require("../helpers/consts"); | ||
exports.name = "deno/fresh"; | ||
/** | ||
@@ -13,3 +14,3 @@ * With Deno's Fresh framework, serve and register any declared functions with | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("deno/fresh", nameOrInngest, fns, opts, (req, env) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, (req, env) => { | ||
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`); | ||
@@ -16,0 +17,0 @@ return { |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "edge"; | ||
/** | ||
@@ -3,0 +4,0 @@ * In an edge runtime, serve and register any declared functions with Inngest, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
exports.name = "edge"; | ||
/** | ||
@@ -23,3 +24,3 @@ * In an edge runtime, serve and register any declared functions with Inngest, | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("edge", nameOrInngest, fns, Object.assign({ fetch: fetch.bind(globalThis) }, opts), (req) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, Object.assign({ fetch: fetch.bind(globalThis) }, opts), (req) => { | ||
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`); | ||
@@ -26,0 +27,0 @@ return { |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "express"; | ||
/** | ||
@@ -3,0 +4,0 @@ * Serve and register any declared functions with Inngest, making them available |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
exports.name = "express"; | ||
/** | ||
@@ -13,3 +14,3 @@ * Serve and register any declared functions with Inngest, making them available | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("express", nameOrInngest, fns, opts, (req, _res) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, (req, _res) => { | ||
const hostname = req.get("host") || req.headers["host"]; | ||
@@ -16,0 +17,0 @@ const protocol = (hostname === null || hostname === void 0 ? void 0 : hostname.includes("://")) ? "" : `${req.protocol}://`; |
@@ -20,3 +20,59 @@ /** | ||
LandingPage = "INNGEST_LANDING_PAGE", | ||
DevServerUrl = "INNGEST_DEVSERVER_URL" | ||
DevServerUrl = "INNGEST_DEVSERVER_URL", | ||
Environment = "INNGEST_ENV", | ||
BranchName = "BRANCH_NAME", | ||
/** | ||
* The git branch of the commit the deployment was triggered by. Example: | ||
* `improve-about-page`. | ||
* | ||
* {@link https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#system-environment-variables} | ||
*/ | ||
VercelBranch = "VERCEL_GIT_COMMIT_REF", | ||
/** | ||
* Expected to be `"1"` if defined. | ||
*/ | ||
IsVercel = "VERCEL", | ||
/** | ||
* The branch name of the current deployment. May only be accessible at build | ||
* time, but included here just in case. | ||
* | ||
* {@link https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables} | ||
*/ | ||
CloudflarePagesBranch = "CF_PAGES_BRANCH", | ||
/** | ||
* Expected to be `"1"` if defined. | ||
*/ | ||
IsCloudflarePages = "CF_PAGES", | ||
/** | ||
* The branch name of the deployment from Git to Netlify, if available. | ||
* | ||
* {@link https://docs.netlify.com/configure-builds/environment-variables/#git-metadata} | ||
*/ | ||
NetlifyBranch = "BRANCH", | ||
/** | ||
* Expected to be `"true"` if defined. | ||
*/ | ||
IsNetlify = "NETLIFY", | ||
/** | ||
* The Git branch for a service or deploy. | ||
* | ||
* {@link https://render.com/docs/environment-variables#all-services} | ||
*/ | ||
RenderBranch = "RENDER_GIT_BRANCH", | ||
/** | ||
* Expected to be `"true"` if defined. | ||
*/ | ||
IsRender = "RENDER", | ||
/** | ||
* The branch that triggered the deployment. Example: `main` | ||
* | ||
* {@link https://docs.railway.app/develop/variables#railway-provided-variables} | ||
*/ | ||
RailwayBranch = "RAILWAY_GIT_BRANCH", | ||
/** | ||
* The railway environment for the deployment. Example: `production` | ||
* | ||
* {@link https://docs.railway.app/develop/variables#railway-provided-variables} | ||
*/ | ||
RailwayEnvironment = "RAILWAY_ENVIRONMENT" | ||
} | ||
@@ -39,3 +95,6 @@ export declare enum prodEnvKeys { | ||
Signature = "x-inngest-signature", | ||
SdkVersion = "x-inngest-sdk" | ||
SdkVersion = "x-inngest-sdk", | ||
Environment = "x-inngest-env", | ||
Platform = "x-inngest-platform", | ||
Framework = "x-inngest-framework" | ||
} | ||
@@ -42,0 +101,0 @@ export declare const defaultDevServerHost = "http://127.0.0.1:8288/"; |
@@ -26,2 +26,58 @@ "use strict"; | ||
envKeys["DevServerUrl"] = "INNGEST_DEVSERVER_URL"; | ||
envKeys["Environment"] = "INNGEST_ENV"; | ||
envKeys["BranchName"] = "BRANCH_NAME"; | ||
/** | ||
* The git branch of the commit the deployment was triggered by. Example: | ||
* `improve-about-page`. | ||
* | ||
* {@link https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#system-environment-variables} | ||
*/ | ||
envKeys["VercelBranch"] = "VERCEL_GIT_COMMIT_REF"; | ||
/** | ||
* Expected to be `"1"` if defined. | ||
*/ | ||
envKeys["IsVercel"] = "VERCEL"; | ||
/** | ||
* The branch name of the current deployment. May only be accessible at build | ||
* time, but included here just in case. | ||
* | ||
* {@link https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables} | ||
*/ | ||
envKeys["CloudflarePagesBranch"] = "CF_PAGES_BRANCH"; | ||
/** | ||
* Expected to be `"1"` if defined. | ||
*/ | ||
envKeys["IsCloudflarePages"] = "CF_PAGES"; | ||
/** | ||
* The branch name of the deployment from Git to Netlify, if available. | ||
* | ||
* {@link https://docs.netlify.com/configure-builds/environment-variables/#git-metadata} | ||
*/ | ||
envKeys["NetlifyBranch"] = "BRANCH"; | ||
/** | ||
* Expected to be `"true"` if defined. | ||
*/ | ||
envKeys["IsNetlify"] = "NETLIFY"; | ||
/** | ||
* The Git branch for a service or deploy. | ||
* | ||
* {@link https://render.com/docs/environment-variables#all-services} | ||
*/ | ||
envKeys["RenderBranch"] = "RENDER_GIT_BRANCH"; | ||
/** | ||
* Expected to be `"true"` if defined. | ||
*/ | ||
envKeys["IsRender"] = "RENDER"; | ||
/** | ||
* The branch that triggered the deployment. Example: `main` | ||
* | ||
* {@link https://docs.railway.app/develop/variables#railway-provided-variables} | ||
*/ | ||
envKeys["RailwayBranch"] = "RAILWAY_GIT_BRANCH"; | ||
/** | ||
* The railway environment for the deployment. Example: `production` | ||
* | ||
* {@link https://docs.railway.app/develop/variables#railway-provided-variables} | ||
*/ | ||
envKeys["RailwayEnvironment"] = "RAILWAY_ENVIRONMENT"; | ||
})(envKeys = exports.envKeys || (exports.envKeys = {})); | ||
@@ -47,2 +103,5 @@ var prodEnvKeys; | ||
headerKeys["SdkVersion"] = "x-inngest-sdk"; | ||
headerKeys["Environment"] = "x-inngest-env"; | ||
headerKeys["Platform"] = "x-inngest-platform"; | ||
headerKeys["Framework"] = "x-inngest-framework"; | ||
})(headerKeys = exports.headerKeys || (exports.headerKeys = {})); | ||
@@ -49,0 +108,0 @@ exports.defaultDevServerHost = "http://127.0.0.1:8288/"; |
@@ -15,4 +15,44 @@ /** | ||
export declare const isProd: (env?: Record<string, unknown>) => boolean; | ||
/** | ||
* getEnvironmentName returns the suspected branch name for this environment by | ||
* searching through a set of common environment variables. | ||
* | ||
* This could be used to determine if we're on a branch deploy or not, though it | ||
* should be noted that we don't know if this is the default branch or not. | ||
*/ | ||
export declare const getEnvironmentName: (env?: Record<string, string | undefined>) => string | undefined; | ||
export declare const processEnv: (key: string) => string | undefined; | ||
/** | ||
* allProcessEnv returns the current process environment variables, or an empty | ||
* object if they cannot be read, making sure we support environments other than | ||
* Node such as Deno, too. | ||
* | ||
* Using this ensures we don't dangerously access `process.env` in environments | ||
* where it may not be defined, such as Deno or the browser. | ||
*/ | ||
export declare const allProcessEnv: () => Record<string, string | undefined>; | ||
/** | ||
* Generate a standardised set of headers based on input and environment | ||
* variables. | ||
* | ||
* | ||
*/ | ||
export declare const inngestHeaders: (opts?: { | ||
/** | ||
* The environment variables to use instead of `process.env` or any other | ||
* default source. Useful for platforms where environment variables are passed | ||
* in alongside requests. | ||
*/ | ||
env?: Record<string, string | undefined>; | ||
/** | ||
* The framework name to use in the `X-Inngest-Framework` header. This is not | ||
* always available, hence being optional. | ||
*/ | ||
framework?: string; | ||
/** | ||
* The environment name to use in the `X-Inngest-Env` header. This is likely | ||
* to be representative of the target preview environment. | ||
*/ | ||
inngestEnv?: string; | ||
}) => Record<string, string>; | ||
//# sourceMappingURL=env.d.ts.map |
@@ -7,3 +7,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.allProcessEnv = exports.processEnv = exports.isProd = exports.devServerHost = void 0; | ||
exports.inngestHeaders = exports.allProcessEnv = exports.processEnv = exports.getEnvironmentName = exports.isProd = exports.devServerHost = void 0; | ||
const version_1 = require("../version"); | ||
const consts_1 = require("./consts"); | ||
@@ -63,2 +64,23 @@ const strings_1 = require("./strings"); | ||
exports.isProd = isProd; | ||
/** | ||
* getEnvironmentName returns the suspected branch name for this environment by | ||
* searching through a set of common environment variables. | ||
* | ||
* This could be used to determine if we're on a branch deploy or not, though it | ||
* should be noted that we don't know if this is the default branch or not. | ||
*/ | ||
const getEnvironmentName = (env = (0, exports.allProcessEnv)()) => { | ||
/** | ||
* Order is important; more than one of these env vars may be set, so ensure | ||
* that we check the most specific, most reliable env vars first. | ||
*/ | ||
return (env[consts_1.envKeys.Environment] || | ||
env[consts_1.envKeys.BranchName] || | ||
env[consts_1.envKeys.VercelBranch] || | ||
env[consts_1.envKeys.NetlifyBranch] || | ||
env[consts_1.envKeys.CloudflarePagesBranch] || | ||
env[consts_1.envKeys.RenderBranch] || | ||
env[consts_1.envKeys.RailwayBranch]); | ||
}; | ||
exports.getEnvironmentName = getEnvironmentName; | ||
const processEnv = (key) => { | ||
@@ -68,2 +90,10 @@ return (0, exports.allProcessEnv)()[key]; | ||
exports.processEnv = processEnv; | ||
/** | ||
* allProcessEnv returns the current process environment variables, or an empty | ||
* object if they cannot be read, making sure we support environments other than | ||
* Node such as Deno, too. | ||
* | ||
* Using this ensures we don't dangerously access `process.env` in environments | ||
* where it may not be defined, such as Deno or the browser. | ||
*/ | ||
const allProcessEnv = () => { | ||
@@ -86,2 +116,42 @@ try { | ||
exports.allProcessEnv = allProcessEnv; | ||
/** | ||
* Generate a standardised set of headers based on input and environment | ||
* variables. | ||
* | ||
* | ||
*/ | ||
const inngestHeaders = (opts) => { | ||
const sdkVersion = `inngest-js:v${version_1.version}`; | ||
const headers = { | ||
"Content-Type": "application/json", | ||
"User-Agent": sdkVersion, | ||
[consts_1.headerKeys.SdkVersion]: sdkVersion, | ||
}; | ||
if (opts === null || opts === void 0 ? void 0 : opts.framework) { | ||
headers[consts_1.headerKeys.Framework] = opts.framework; | ||
} | ||
const env = (opts === null || opts === void 0 ? void 0 : opts.env) || (0, exports.allProcessEnv)(); | ||
const inngestEnv = (opts === null || opts === void 0 ? void 0 : opts.inngestEnv) || (0, exports.getEnvironmentName)(env); | ||
if (inngestEnv) { | ||
headers[consts_1.headerKeys.Environment] = inngestEnv; | ||
} | ||
const platform = getPlatformName(env); | ||
if (platform) { | ||
headers[consts_1.headerKeys.Platform] = platform; | ||
} | ||
return headers; | ||
}; | ||
exports.inngestHeaders = inngestHeaders; | ||
const getPlatformName = (env) => { | ||
const platformChecks = { | ||
vercel: (env) => env[consts_1.envKeys.IsVercel] === "1", | ||
netlify: (env) => env[consts_1.envKeys.IsNetlify] === "true", | ||
"cloudflare-pages": (env) => env[consts_1.envKeys.IsCloudflarePages] === "1", | ||
render: (env) => env[consts_1.envKeys.IsRender] === "true", | ||
railway: (env) => Boolean(env[consts_1.envKeys.RailwayEnvironment]), | ||
}; | ||
return Object.keys(platformChecks).find((key) => { | ||
return platformChecks[key](env); | ||
}); | ||
}; | ||
//# sourceMappingURL=env.js.map |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "aws-lambda"; | ||
/** | ||
@@ -3,0 +4,0 @@ * With AWS Lambda, serve and register any declared functions with Inngest, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
exports.name = "aws-lambda"; | ||
/** | ||
@@ -32,3 +33,3 @@ * With AWS Lambda, serve and register any declared functions with Inngest, | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("aws-lambda", nameOrInngest, fns, Object.assign({}, opts), (event, _context) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, Object.assign({}, opts), (event, _context) => { | ||
/** | ||
@@ -35,0 +36,0 @@ * Try to handle multiple incoming event types, as Lambda can have many |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "nextjs"; | ||
/** | ||
@@ -3,0 +4,0 @@ * In Next.js, serve and register any declared functions with Inngest, making |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
const env_1 = require("./helpers/env"); | ||
exports.name = "nextjs"; | ||
/** | ||
@@ -14,3 +15,3 @@ * In Next.js, serve and register any declared functions with Inngest, making | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("nextjs", nameOrInngest, fns, opts, (req, _res) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, (req, _res) => { | ||
const scheme = (0, env_1.processEnv)("NODE_ENV") === "development" ? "http" : "https"; | ||
@@ -17,0 +18,0 @@ const url = new URL(req.url, `${scheme}://${req.headers.host || ""}`); |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "nuxt"; | ||
/** | ||
@@ -3,0 +4,0 @@ * In Nuxt 3, serve and register any declared functions with Inngest, making |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const h3_1 = require("h3"); | ||
@@ -8,2 +8,3 @@ const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const env_1 = require("./helpers/env"); | ||
exports.name = "nuxt"; | ||
/** | ||
@@ -16,3 +17,3 @@ * In Nuxt 3, serve and register any declared functions with Inngest, making | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("nuxt", nameOrInngest, fns, opts, (event) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, (event) => { | ||
const host = String((0, h3_1.getHeader)(event, "host")); | ||
@@ -19,0 +20,0 @@ const protocol = (0, env_1.processEnv)("NODE_ENV") === "development" ? "http" : "https"; |
{ | ||
"name": "inngest", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Official SDK for Inngest.com", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -14,4 +14,5 @@ <div align="center"> | ||
<a href="http://www.typescriptlang.org/"><img src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg" /></a> | ||
<a href="http://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TS-%3E%3D4.7-blue" /></a> | ||
<a href="https://www.npmjs.com/package/inngest"><img src="https://img.shields.io/npm/v/inngest" /></a> | ||
<br/> | ||
<a href="https://discord.gg/EuesV2ZSnX"><img src="https://img.shields.io/discord/842170679536517141?label=discord" /></a> | ||
@@ -25,10 +26,10 @@ <a href="https://twitter.com/inngest"><img src="https://img.shields.io/twitter/follow/inngest?style=social" /></a> | ||
Inngest allows you to: | ||
On _any_ serverless platform ([Next.js](https://www.inngest.com/docs/sdk/serve#framework-next-js), [Deno Deploy](https://www.inngest.com/docs/sdk/serve#framework-fresh-deno), [RedwoodJS](https://www.inngest.com/docs/sdk/serve#framework-redwood), [AWS Lambda](https://www.inngest.com/docs/sdk/serve#framework-aws-lambda), and [anything else](https://www.inngest.com/docs/sdk/serve#custom-frameworks)) and with no extra infrastructure: | ||
- 👉 Write <b>background jobs</b> in any framework, on any platform <br /> | ||
- 👉 Create <b>scheduled & cron jobs</b> for any serverless platform <br /> | ||
- 👉 Build <b>serverless queues</b> without configuring infra <br /> | ||
- 👉 Write complex <b>step functions</b> anywhere <br /> | ||
- 👉 Build <b>serverless event-driven systems</b> <br /> | ||
- 👉 Reliably respond to webhooks, with retries & payloads stored for history <br /> | ||
- ⚡ Write <b>background jobs</b> | ||
- 🕐 Create <b>scheduled & cron jobs</b> | ||
- ♻️ Build <b>serverless queues</b> | ||
- 🪜 Write complex <b>step functions</b> | ||
- 🚘 Build <b>serverless event-driven systems</b> | ||
- 🪝 Reliably respond to webhooks, with retries & payloads stored for history | ||
@@ -35,0 +36,0 @@ 👋 _Have a question or feature request? [Join our Discord](https://www.inngest.com/discord)!_ |
@@ -7,2 +7,3 @@ import { ServeHandler } from "./components/InngestCommHandler"; | ||
} | ||
export declare const name = "redwoodjs"; | ||
/** | ||
@@ -9,0 +10,0 @@ * In Redwood.js, serve and register any declared functions with Inngest, making |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
const env_1 = require("./helpers/env"); | ||
exports.name = "redwoodjs"; | ||
/** | ||
@@ -14,3 +15,3 @@ * In Redwood.js, serve and register any declared functions with Inngest, making | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("redwoodjs", nameOrInngest, fns, opts, (event, _context) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, (event, _context) => { | ||
const scheme = (0, env_1.processEnv)("NODE_ENV") === "development" ? "http" : "https"; | ||
@@ -17,0 +18,0 @@ const url = new URL(event.path, `${scheme}://${event.headers.host || ""}`); |
import { ServeHandler } from "./components/InngestCommHandler"; | ||
export declare const name = "remix"; | ||
/** | ||
@@ -3,0 +4,0 @@ * In Remix, serve and register any declared functions with Inngest, making them |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serve = void 0; | ||
exports.serve = exports.name = void 0; | ||
const InngestCommHandler_1 = require("./components/InngestCommHandler"); | ||
const consts_1 = require("./helpers/consts"); | ||
exports.name = "remix"; | ||
/** | ||
@@ -29,3 +30,3 @@ * In Remix, serve and register any declared functions with Inngest, making them | ||
const serve = (nameOrInngest, fns, opts) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler("remix", nameOrInngest, fns, opts, ({ request: req }) => { | ||
const handler = new InngestCommHandler_1.InngestCommHandler(exports.name, nameOrInngest, fns, opts, ({ request: req }) => { | ||
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`); | ||
@@ -32,0 +33,0 @@ return { |
@@ -136,2 +136,6 @@ import { z } from "zod"; | ||
/** | ||
* The run ID for the current function execution | ||
*/ | ||
runId: string; | ||
/** | ||
* @deprecated Use `step` instead. | ||
@@ -311,2 +315,10 @@ */ | ||
fetch?: typeof fetch; | ||
/** | ||
* The Inngest environment to send events to. Defaults to whichever | ||
* environment this client's event key is associated with. | ||
* | ||
* It's likely you never need to change this unless you're trying to sync | ||
* multiple systems together using branch names. | ||
*/ | ||
env?: string; | ||
} | ||
@@ -313,0 +325,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.6.1"; | ||
export declare const version = "1.7.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Generated by genversion. | ||
exports.version = "1.6.1"; | ||
exports.version = "1.7.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 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
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
585982
6069
163