inngest 0.8.8 → 0.9.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.
Files changed (63) hide show
  1. package/cloudflare.d.ts +1 -1
  2. package/cloudflare.d.ts.map +1 -1
  3. package/cloudflare.js +50 -81
  4. package/cloudflare.js.map +1 -1
  5. package/components/Inngest.d.ts.map +1 -1
  6. package/components/Inngest.js +1 -1
  7. package/components/Inngest.js.map +1 -1
  8. package/components/InngestCommHandler.d.ts +380 -0
  9. package/components/InngestCommHandler.d.ts.map +1 -0
  10. package/components/InngestCommHandler.js +451 -0
  11. package/components/InngestCommHandler.js.map +1 -0
  12. package/components/InngestStepTools.d.ts +5 -3
  13. package/components/InngestStepTools.d.ts.map +1 -1
  14. package/components/InngestStepTools.js +17 -5
  15. package/components/InngestStepTools.js.map +1 -1
  16. package/deno/fresh.d.ts +9 -0
  17. package/deno/fresh.d.ts.map +1 -0
  18. package/deno/fresh.js +55 -0
  19. package/deno/fresh.js.map +1 -0
  20. package/express.d.ts +2 -122
  21. package/express.d.ts.map +1 -1
  22. package/express.js +48 -302
  23. package/express.js.map +1 -1
  24. package/helpers/consts.d.ts +2 -1
  25. package/helpers/consts.d.ts.map +1 -1
  26. package/helpers/consts.js +1 -0
  27. package/helpers/consts.js.map +1 -1
  28. package/helpers/devserver.d.ts +5 -5
  29. package/helpers/devserver.d.ts.map +1 -1
  30. package/helpers/devserver.js +1 -1
  31. package/helpers/env.d.ts +2 -6
  32. package/helpers/env.d.ts.map +1 -1
  33. package/helpers/env.js +23 -17
  34. package/helpers/env.js.map +1 -1
  35. package/helpers/types.d.ts +13 -9
  36. package/helpers/types.d.ts.map +1 -1
  37. package/index.d.ts +2 -0
  38. package/index.d.ts.map +1 -1
  39. package/index.js +3 -1
  40. package/index.js.map +1 -1
  41. package/init.js +2 -1
  42. package/init.js.map +1 -1
  43. package/landing.d.ts +1 -1
  44. package/landing.d.ts.map +1 -1
  45. package/landing.js +1 -1
  46. package/landing.js.map +1 -1
  47. package/next.d.ts +1 -1
  48. package/next.d.ts.map +1 -1
  49. package/next.js +49 -69
  50. package/next.js.map +1 -1
  51. package/package.json +11 -9
  52. package/redwood.d.ts +1 -1
  53. package/redwood.d.ts.map +1 -1
  54. package/redwood.js +53 -98
  55. package/redwood.js.map +1 -1
  56. package/remix.d.ts +1 -1
  57. package/remix.d.ts.map +1 -1
  58. package/remix.js +61 -105
  59. package/remix.js.map +1 -1
  60. package/types.d.ts +11 -29
  61. package/types.d.ts.map +1 -1
  62. package/version.d.ts +1 -1
  63. package/version.js +1 -1
package/express.d.ts CHANGED
@@ -1,129 +1,9 @@
1
- import { Inngest } from "./components/Inngest";
2
- import { InngestFunction } from "./components/InngestFunction";
3
- import type { FunctionConfig, RegisterOptions, RegisterRequest, StepRunResponse } from "./types";
4
- /**
5
- * A handler for serving Inngest functions. This type should be used
6
- * whenever a handler for a new framework is being added to enforce that the
7
- * registration process is always the same for the user.
8
- *
9
- * @public
10
- */
11
- export declare type ServeHandler = (
12
- /**
13
- * The name of this app, used to scope and group Inngest functions, or
14
- * the `Inngest` instance used to declare all functions.
15
- */
16
- nameOrInngest: string | Inngest<any>,
17
- /**
18
- * An array of the functions to serve and register with Inngest.
19
- */
20
- functions: InngestFunction<any>[],
21
- /**
22
- * A set of options to further configure the registration of Inngest
23
- * functions.
24
- */
25
- opts?: RegisterOptions) => any;
1
+ import { ServeHandler } from "./components/InngestCommHandler";
26
2
  /**
27
3
  * Serve and register any declared functions with Inngest, making them available
28
4
  * to be triggered by events.
29
5
  *
30
- * Can either take an `Inngest` instance and a signing key, or can be used to
31
- * create custom handlers by passing in an `InngestCommHandler`.
32
- *
33
- * @public
34
- */
35
- export declare const serve: (...args: Parameters<ServeHandler> | [commHandler: InngestCommHandler]) => any;
36
- /**
37
- * TODO Instead of `createHandler`, expose `createRequest` and `handleResponse`
38
- *
39
- * Overriding `createHandler` requires that we always remember crucial steps,
40
- * e.g. validating signatures, handling POST, etc.
41
- *
42
- * We should instead require that new comm handlers override only two functions:
43
- *
44
- * `createRequest()`
45
- * This is the function that is exposed. It must return a valid `HandlerRequest`
46
- *
47
- * `handleResponse()`
48
- * The input is a `StepResponse`, and output can be anything needed for the
49
- * platform
50
- *
51
- * This needs to also account for the ability to validate signatures etc.
52
- *
53
6
  * @public
54
7
  */
55
- export declare class InngestCommHandler {
56
- name: string;
57
- /**
58
- * The URL of the Inngest function registration endpoint.
59
- */
60
- private readonly inngestRegisterUrl;
61
- protected readonly frameworkName: string;
62
- protected signingKey: string | undefined;
63
- /**
64
- * A property that can be set to indicate whether or not we believe we are in
65
- * production mode.
66
- *
67
- * Should be set every time a request is received.
68
- */
69
- protected _isProd: boolean;
70
- private readonly headers;
71
- private readonly fetch;
72
- /**
73
- * Whether we should show the SDK Landing Page.
74
- *
75
- * This purposefully does not take in to account any environment variables, as
76
- * accessing them safely is platform-specific.
77
- */
78
- protected readonly showLandingPage: boolean | undefined;
79
- protected readonly serveHost: string | undefined;
80
- protected readonly servePath: string | undefined;
81
- /**
82
- * A private collection of functions that are being served. This map is used
83
- * to find and register functions when interacting with Inngest Cloud.
84
- */
85
- private readonly fns;
86
- constructor(nameOrInngest: string | Inngest<any>, functions: InngestFunction<any>[], { inngestRegisterUrl, fetch, landingPage, signingKey, serveHost, servePath, }?: RegisterOptions);
87
- private get hashedSigningKey();
88
- createHandler(): any;
89
- protected runStep(functionId: string, stepId: string, data: any): Promise<StepRunResponse>;
90
- protected configs(url: URL): FunctionConfig[];
91
- /**
92
- * Returns an SDK header split in to three parts so that they can be used for
93
- * different purposes.
94
- *
95
- * To use the entire string, run `this.sdkHeader.join("")`.
96
- */
97
- protected get sdkHeader(): [
98
- prefix: string,
99
- version: RegisterRequest["sdk"],
100
- suffix: string
101
- ];
102
- /**
103
- * Return an Inngest serve endpoint URL given a potential `path` and `host`.
104
- *
105
- * Will automatically use the `serveHost` and `servePath` if they have been
106
- * set when registering.
107
- */
108
- protected reqUrl(
109
- /**
110
- * The path of the Inngest register URL to create. Regardless of the value,
111
- * will be overwritten by `servePath` if it has been set.
112
- */
113
- path?: string,
114
- /**
115
- * The host of the Inngest register URL to create. Regardless of the value,
116
- * will be overwritten by `serveHost` if it has been set.
117
- */
118
- host?: string): URL;
119
- protected registerBody(url: URL): RegisterRequest;
120
- protected register(url: URL, devServerHost: string | undefined): Promise<{
121
- status: number;
122
- message: string;
123
- }>;
124
- private get isProd();
125
- protected shouldShowLandingPage(strEnvVar: string | undefined): boolean;
126
- protected validateSignature(): boolean;
127
- protected signResponse(): string;
128
- }
8
+ export declare const serve: ServeHandler;
129
9
  //# sourceMappingURL=express.d.ts.map
package/express.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAC;AAiBjB;;;;;;GAMG;AACH,oBAAY,YAAY,GAAG;AACzB;;;GAGG;AACH,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;AAEpC;;GAEG;AACH,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE;AAEjC;;;GAGG;AACH,IAAI,CAAC,EAAE,eAAe,KACnB,GAAG,CAAC;AAET;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,YACP,WAAW,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,QAYtE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kBAAkB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IAEzC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MA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AG,EAAE,GAAG,GAAG,eAAe;cAgBjC,QAAQ,CACtB,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAiE/C,OAAO,KAAK,MAAM,GAEjB;IAED,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;IAIvE,SAAS,CAAC,iBAAiB,IAAI,OAAO;IAItC,SAAS,CAAC,YAAY,IAAI,MAAM;CAGjC"}
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACb,MAAM,iCAAiC,CAAC;AAIzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,YA6DnB,CAAC"}
package/express.js CHANGED
@@ -1,317 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InngestCommHandler = exports.serve = void 0;
4
- const hash_js_1 = require("hash.js");
5
- const zod_1 = require("zod");
3
+ exports.serve = void 0;
4
+ const InngestCommHandler_1 = require("./components/InngestCommHandler");
6
5
  const consts_1 = require("./helpers/consts");
7
- const devserver_1 = require("./helpers/devserver");
8
- const scalar_1 = require("./helpers/scalar");
9
- const landing_1 = require("./landing");
10
- const version_1 = require("./version");
11
- /**
12
- * A schema for the response from Inngest when registering.
13
- */
14
- const registerResSchema = zod_1.z.object({
15
- status: zod_1.z.number().default(200),
16
- skipped: zod_1.z.boolean().optional().default(false),
17
- error: zod_1.z.string().default("Successfully registered"),
18
- });
6
+ const env_1 = require("./helpers/env");
19
7
  /**
20
8
  * Serve and register any declared functions with Inngest, making them available
21
9
  * to be triggered by events.
22
10
  *
23
- * Can either take an `Inngest` instance and a signing key, or can be used to
24
- * create custom handlers by passing in an `InngestCommHandler`.
25
- *
26
- * @public
27
- */
28
- const serve = (...args) => {
29
- if (args.length === 1) {
30
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
31
- return args[0].createHandler();
32
- }
33
- const [nameOrInngest, fns, opts] = args;
34
- const handler = new InngestCommHandler(nameOrInngest, fns, opts);
35
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
36
- return handler.createHandler();
37
- };
38
- exports.serve = serve;
39
- /**
40
- * TODO Instead of `createHandler`, expose `createRequest` and `handleResponse`
41
- *
42
- * Overriding `createHandler` requires that we always remember crucial steps,
43
- * e.g. validating signatures, handling POST, etc.
44
- *
45
- * We should instead require that new comm handlers override only two functions:
46
- *
47
- * `createRequest()`
48
- * This is the function that is exposed. It must return a valid `HandlerRequest`
49
- *
50
- * `handleResponse()`
51
- * The input is a `StepResponse`, and output can be anything needed for the
52
- * platform
53
- *
54
- * This needs to also account for the ability to validate signatures etc.
55
- *
56
11
  * @public
57
12
  */
58
- class InngestCommHandler {
59
- constructor(nameOrInngest, functions, { inngestRegisterUrl, fetch, landingPage, signingKey, serveHost, servePath, } = {}) {
60
- this.frameworkName = "express";
61
- /**
62
- * A property that can be set to indicate whether or not we believe we are in
63
- * production mode.
64
- *
65
- * Should be set every time a request is received.
66
- */
67
- this._isProd = false;
68
- /**
69
- * A private collection of functions that are being served. This map is used
70
- * to find and register functions when interacting with Inngest Cloud.
71
- */
72
- this.fns = {};
73
- this.name =
74
- typeof nameOrInngest === "string" ? nameOrInngest : nameOrInngest.name;
75
- this.fns = functions.reduce((acc, fn) => {
76
- const id = fn.id(this.name);
77
- if (acc[id]) {
78
- throw new Error(`Duplicate function ID "${id}"; please change a function's name or provide an explicit ID to avoid conflicts.`);
79
- }
80
- return Object.assign(Object.assign({}, acc), { [id]: fn });
81
- }, {});
82
- this.inngestRegisterUrl = new URL(inngestRegisterUrl || "https://api.inngest.com/fn/register");
83
- this.signingKey = signingKey;
84
- this.showLandingPage = landingPage;
85
- this.serveHost = serveHost;
86
- this.servePath = servePath;
87
- this.headers = {
88
- "Content-Type": "application/json",
89
- "User-Agent": `inngest-js:v${version_1.version} (${this.frameworkName})`,
90
- };
91
- this.fetch =
92
- fetch ||
93
- (typeof nameOrInngest === "string"
94
- ? undefined
95
- : nameOrInngest["fetch"]) ||
96
- // eslint-disable-next-line @typescript-eslint/no-var-requires
97
- require("cross-fetch");
98
- }
99
- // hashedSigningKey creates a sha256 checksum of the signing key with the
100
- // same signing key prefix.
101
- get hashedSigningKey() {
102
- var _a;
103
- if (!this.signingKey) {
104
- return "";
105
- }
106
- const prefix = ((_a = this.signingKey.match(/^signkey-(test|prod)-/)) === null || _a === void 0 ? void 0 : _a.shift()) || "";
107
- const key = this.signingKey.replace(/^signkey-(test|prod)-/, "");
108
- // Decode the key from its hex representation into a bytestream
109
- return `${prefix}${(0, hash_js_1.sha256)().update(key, "hex").digest("hex")}`;
110
- }
111
- createHandler() {
112
- return async (req, res) => {
113
- res.setHeader("x-inngest-sdk", this.sdkHeader.join(""));
114
- const hostname = req.get("host") || req.headers["host"];
115
- const protocol = (hostname === null || hostname === void 0 ? void 0 : hostname.includes("://")) ? "" : `${req.protocol}://`;
116
- let reqUrl;
117
- try {
118
- reqUrl = this.reqUrl(req.originalUrl, `${protocol}${hostname || ""}`);
119
- reqUrl.searchParams.delete(consts_1.queryKeys.Introspect);
120
- }
121
- catch (e) {
122
- const message = "Unable to determine your site URL to serve the Inngest handler.";
123
- console.error(message);
124
- return res.status(500).json({ message });
125
- }
126
- if (!this.signingKey && process.env[consts_1.envKeys.SigningKey]) {
127
- this.signingKey = process.env[consts_1.envKeys.SigningKey];
128
- }
129
- this._isProd =
130
- process.env.ENVIRONMENT === "production" ||
131
- process.env.NODE_ENV === "production";
132
- switch (req.method) {
133
- case "GET": {
134
- const showLandingPage = this.shouldShowLandingPage(process.env[consts_1.envKeys.LandingPage]);
135
- if (this._isProd || !showLandingPage)
136
- break;
137
- if (Object.hasOwnProperty.call(req.query, consts_1.queryKeys.Introspect)) {
138
- const introspection = Object.assign(Object.assign({}, this.registerBody(reqUrl)), { devServerURL: (0, devserver_1.devServerUrl)(process.env[consts_1.envKeys.DevServerUrl])
139
- .href, hasSigningKey: Boolean(this.signingKey) });
140
- return void res.status(200).json(introspection);
141
- }
142
- // Grab landing page and serve
143
- res.header("content-type", "text/html; charset=utf-8");
144
- return void res.status(200).send(landing_1.landing);
13
+ const serve = (nameOrInngest, fns, opts) => {
14
+ const handler = new InngestCommHandler_1.InngestCommHandler("express", nameOrInngest, fns, opts, (req, _res) => {
15
+ const hostname = req.get("host") || req.headers["host"];
16
+ const protocol = (hostname === null || hostname === void 0 ? void 0 : hostname.includes("://")) ? "" : `${req.protocol}://`;
17
+ const url = new URL(req.originalUrl, `${protocol}${hostname || ""}`);
18
+ const env = (0, env_1.allProcessEnv)();
19
+ const isProduction = env.ENVIRONMENT === "production" || env.NODE_ENV === "production";
20
+ return {
21
+ run: () => {
22
+ if (req.method === "POST") {
23
+ return {
24
+ fnId: req.query[consts_1.queryKeys.FnId],
25
+ data: req.body,
26
+ env,
27
+ isProduction,
28
+ url,
29
+ };
145
30
  }
146
- case "PUT": {
147
- // Push config to Inngest.
148
- const { status, message } = await this.register(reqUrl, process.env[consts_1.envKeys.DevServerUrl]);
149
- return void res.status(status).json({ message });
31
+ },
32
+ register: () => {
33
+ var _a;
34
+ if (req.method === "PUT") {
35
+ return {
36
+ env,
37
+ url,
38
+ isProduction,
39
+ deployId: (_a = req.query[consts_1.queryKeys.DeployId]) === null || _a === void 0 ? void 0 : _a.toString(),
40
+ };
150
41
  }
151
- case "POST": {
152
- // Inngest is trying to run a step; confirm signed and run.
153
- const { fnId, stepId } = zod_1.z
154
- .object({
155
- fnId: zod_1.z.string().min(1),
156
- stepId: zod_1.z.string().min(1),
157
- })
158
- .parse({
159
- fnId: req.query[consts_1.queryKeys.FnId],
160
- stepId: req.query[consts_1.queryKeys.StepId],
161
- });
162
- const stepRes = await this.runStep(fnId, stepId, req.body);
163
- if (stepRes.status === 500) {
164
- return void res.status(stepRes.status).json(stepRes.error);
165
- }
166
- return void res.status(stepRes.status).json(stepRes.body);
42
+ },
43
+ view: () => {
44
+ if (req.method === "GET") {
45
+ return {
46
+ env,
47
+ url,
48
+ isIntrospection: Object.hasOwnProperty.call(req.query, consts_1.queryKeys.Introspect),
49
+ isProduction,
50
+ };
167
51
  }
168
- }
169
- return void res.sendStatus(405);
52
+ },
170
53
  };
171
- }
172
- async runStep(functionId, stepId, data) {
173
- try {
174
- const fn = this.fns[functionId];
175
- if (!fn) {
176
- throw new Error(`Could not find function with ID "${functionId}"`);
177
- }
178
- const { event, steps } = zod_1.z
179
- .object({
180
- event: zod_1.z.object({}).passthrough(),
181
- steps: zod_1.z.object({}).passthrough().optional().nullable(),
182
- })
183
- .parse(data);
184
- const ret = await fn["runFn"]({ event }, steps || {});
185
- const isOp = ret[0];
186
- if (isOp) {
187
- return {
188
- status: 206,
189
- body: ret[1],
190
- };
191
- }
192
- return {
193
- status: 200,
194
- body: ret[1],
195
- };
196
- }
197
- catch (err) {
198
- if (err instanceof Error) {
199
- return {
200
- status: 500,
201
- error: err.stack || err.message,
202
- };
203
- }
204
- return {
205
- status: 500,
206
- error: `Unknown error: ${JSON.stringify(err)}`,
207
- };
208
- }
209
- }
210
- configs(url) {
211
- return Object.values(this.fns).map((fn) => fn["getConfig"](url, this.name));
212
- }
213
- /**
214
- * Returns an SDK header split in to three parts so that they can be used for
215
- * different purposes.
216
- *
217
- * To use the entire string, run `this.sdkHeader.join("")`.
218
- */
219
- get sdkHeader() {
220
- return ["inngest-", `js:v${version_1.version}`, ` (${this.frameworkName})`];
221
- }
222
- /**
223
- * Return an Inngest serve endpoint URL given a potential `path` and `host`.
224
- *
225
- * Will automatically use the `serveHost` and `servePath` if they have been
226
- * set when registering.
227
- */
228
- reqUrl(
229
- /**
230
- * The path of the Inngest register URL to create. Regardless of the value,
231
- * will be overwritten by `servePath` if it has been set.
232
- */
233
- path,
234
- /**
235
- * The host of the Inngest register URL to create. Regardless of the value,
236
- * will be overwritten by `serveHost` if it has been set.
237
- */
238
- host) {
239
- return new URL(this.servePath || (path === null || path === void 0 ? void 0 : path.trim()) || "", this.serveHost || (host === null || host === void 0 ? void 0 : host.trim()) || "");
240
- }
241
- registerBody(url) {
242
- const body = {
243
- url: url.href,
244
- deployType: "ping",
245
- framework: this.frameworkName,
246
- appName: this.name,
247
- functions: this.configs(url),
248
- sdk: this.sdkHeader[1],
249
- v: "0.1",
250
- };
251
- // Calculate the checksum of the body... without the checksum itself being included.
252
- body.hash = (0, hash_js_1.sha256)().update(JSON.stringify(body)).digest("hex");
253
- return body;
254
- }
255
- async register(url, devServerHost) {
256
- const body = this.registerBody(url);
257
- let res;
258
- // Whenever we register, we check to see if the dev server is up. This
259
- // is a noop and returns false in production.
260
- let registerURL = this.inngestRegisterUrl;
261
- if (!this.isProd) {
262
- const hasDevServer = await (0, devserver_1.devServerAvailable)(devServerHost, this.fetch);
263
- if (hasDevServer) {
264
- registerURL = (0, devserver_1.devServerUrl)(devServerHost, "/fn/register");
265
- }
266
- }
267
- try {
268
- res = await this.fetch(registerURL.href, {
269
- method: "POST",
270
- body: JSON.stringify(body),
271
- headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${this.hashedSigningKey}` }),
272
- redirect: "follow",
273
- });
54
+ }, (actionRes, _req, res) => {
55
+ for (const [name, value] of Object.entries(actionRes.headers)) {
56
+ res.setHeader(name, value);
274
57
  }
275
- catch (err) {
276
- console.error(err);
277
- return {
278
- status: 500,
279
- message: `Failed to register${err instanceof Error ? `; ${err.message}` : ""}`,
280
- };
281
- }
282
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
283
- let data = {};
284
- try {
285
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
286
- data = await res.json();
287
- }
288
- catch (err) {
289
- console.warn("Couldn't unpack register response:", err);
290
- }
291
- const { status, error, skipped } = registerResSchema.parse(data);
292
- // The dev server polls this endpoint to register functions every few
293
- // seconds, but we only want to log that we've registered functions if
294
- // the function definitions change. Therefore, we compare the body sent
295
- // during registration with the body of the current functions and refuse
296
- // to register if the functions are the same.
297
- if (!skipped) {
298
- console.log("registered inngest functions:", res.status, res.statusText, data);
299
- }
300
- return { status, message: error };
301
- }
302
- get isProd() {
303
- return this._isProd;
304
- }
305
- shouldShowLandingPage(strEnvVar) {
306
- var _a, _b;
307
- return (_b = (_a = this.showLandingPage) !== null && _a !== void 0 ? _a : (0, scalar_1.strBoolean)(strEnvVar)) !== null && _b !== void 0 ? _b : true;
308
- }
309
- validateSignature() {
310
- return true;
311
- }
312
- signResponse() {
313
- return "";
314
- }
315
- }
316
- exports.InngestCommHandler = InngestCommHandler;
58
+ return res.status(actionRes.status).send(actionRes.body);
59
+ });
60
+ return handler.createHandler();
61
+ };
62
+ exports.serve = serve;
317
63
  //# sourceMappingURL=express.js.map
package/express.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":";;;AACA,qCAAiC;AACjC,6BAAwB;AAGxB,6CAAsD;AACtD,mDAAuE;AACvE,6CAA8C;AAC9C,uCAAoC;AAQpC,uCAAoC;AAEpC;;GAEG;AACH,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAC/B,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC9C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC;CACrD,CAAC,CAAC;AAiCH;;;;;;;;GAQG;AACI,MAAM,KAAK,GAAG,CACnB,GAAG,IAAkE,EACrE,EAAE;IACF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,+DAA+D;QAC/D,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;KAChC;IAED,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GAAG,EAAE;;gBACb,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,EAAE;oBACxB,OAAO;wBACL,GAAG;wBACH,GAAG;wBACH,YAAY;wBACZ,QAAQ,EAAE,MAAA,GAAG,CAAC,KAAK,CAAC,kBAAS,CAAC,QAAQ,CAAC,0CAAE,QAAQ,EAAE;qBACpD,CAAC;iBACH;YACH,CAAC;YACD,IAAI,EAAE,GAAG,EAAE;gBACT,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,EAAE;oBACxB,OAAO;wBACL,GAAG;wBACH,GAAG;wBACH,eAAe,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,CACzC,GAAG,CAAC,KAAK,EACT,kBAAS,CAAC,UAAU,CACrB;wBACD,YAAY;qBACb,CAAC;iBACH;YACH,CAAC;SACF,CAAC;IACJ,CAAC,EACD,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACvB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;YAC7D,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC5B;QAED,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC,CAAC;AA7DW,QAAA,KAAK,SA6DhB"}
@@ -1,7 +1,8 @@
1
1
  export declare enum queryKeys {
2
2
  FnId = "fnId",
3
3
  StepId = "stepId",
4
- Introspect = "introspect"
4
+ Introspect = "introspect",
5
+ DeployId = "deployId"
5
6
  }
6
7
  export declare enum envKeys {
7
8
  SigningKey = "INNGEST_SIGNING_KEY",
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/helpers/consts.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,oBAAY,OAAO;IACjB,UAAU,wBAAwB;IAClC,QAAQ,sBAAsB;IAC9B,WAAW,yBAAyB;IACpC,YAAY,0BAA0B;CACvC;AAED,oBAAY,WAAW;IACrB,UAAU,aAAa;IACvB,YAAY,eAAe;IAC3B,aAAa,YAAY;CAC1B;AAED,eAAO,MAAM,oBAAoB,2BAA2B,CAAC"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/helpers/consts.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,QAAQ,aAAa;CACtB;AAED,oBAAY,OAAO;IACjB,UAAU,wBAAwB;IAClC,QAAQ,sBAAsB;IAC9B,WAAW,yBAAyB;IACpC,YAAY,0BAA0B;CACvC;AAED,oBAAY,WAAW;IACrB,UAAU,aAAa;IACvB,YAAY,eAAe;IAC3B,aAAa,YAAY;CAC1B;AAED,eAAO,MAAM,oBAAoB,2BAA2B,CAAC"}
package/helpers/consts.js CHANGED
@@ -6,6 +6,7 @@ var queryKeys;
6
6
  queryKeys["FnId"] = "fnId";
7
7
  queryKeys["StepId"] = "stepId";
8
8
  queryKeys["Introspect"] = "introspect";
9
+ queryKeys["DeployId"] = "deployId";
9
10
  })(queryKeys = exports.queryKeys || (exports.queryKeys = {}));
10
11
  var envKeys;
11
12
  (function (envKeys) {
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/helpers/consts.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,sCAAyB,CAAA;AAC3B,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AAED,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,6CAAkC,CAAA;IAClC,yCAA8B,CAAA;IAC9B,+CAAoC,CAAA;IACpC,iDAAsC,CAAA;AACxC,CAAC,EALW,OAAO,GAAP,eAAO,KAAP,eAAO,QAKlB;AAED,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAEY,QAAA,oBAAoB,GAAG,wBAAwB,CAAC"}
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/helpers/consts.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,sCAAyB,CAAA;IACzB,kCAAqB,CAAA;AACvB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB;AAED,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,6CAAkC,CAAA;IAClC,yCAA8B,CAAA;IAC9B,+CAAoC,CAAA;IACpC,iDAAsC,CAAA;AACxC,CAAC,EALW,OAAO,GAAP,eAAO,KAAP,eAAO,QAKlB;AAED,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAEY,QAAA,oBAAoB,GAAG,wBAAwB,CAAC"}
@@ -4,7 +4,7 @@ import type { FunctionConfig } from "../types";
4
4
  * to fall in to the self-referencing `const fetch: typeof fetch = ...` which
5
5
  * fails.
6
6
  */
7
- declare type FetchT = typeof fetch;
7
+ type FetchT = typeof fetch;
8
8
  /**
9
9
  * Attempts to contact the dev server, returning a boolean indicating whether or
10
10
  * not it was successful.
@@ -18,11 +18,11 @@ export declare const devServerAvailable: (host: string | undefined, fetch: Fetch
18
18
  * Because Cloudflare/V8 platforms don't allow process.env, you are expected
19
19
  * to pass in the host from the dev server env key:
20
20
  *
21
- * @example devServerUrl(process.env[envKeys.DevServerUrl], "/your-path")
21
+ * @example devServerUrl(processEnv(envKeys.DevServerUrl), "/your-path")
22
22
  * @example devServerUrl("http://localhost:8288/", "/your-path")
23
23
  */
24
24
  export declare const devServerUrl: (host?: string, pathname?: string) => URL;
25
- export declare type InfoResponse = {
25
+ export type InfoResponse = {
26
26
  version: string;
27
27
  startOpts: {
28
28
  sdkURLs: string[];
@@ -35,14 +35,14 @@ export declare type InfoResponse = {
35
35
  functions: FunctionConfig[];
36
36
  handlers: SDKHandler[];
37
37
  };
38
- declare type WorkspaceResponse = {
38
+ type WorkspaceResponse = {
39
39
  signingKey: string;
40
40
  eventKeys: Array<{
41
41
  name: string;
42
42
  key: string;
43
43
  }>;
44
44
  };
45
- declare type SDKHandler = {
45
+ type SDKHandler = {
46
46
  functionIDs: Array<string>;
47
47
  createdAt: string;
48
48
  updatedAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"devserver.d.ts","sourceRoot":"","sources":["../../src/helpers/devserver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;GAIG;AACH,aAAK,MAAM,GAAG,OAAO,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,oCAUtB,MAAM,KACZ,QAAQ,OAAO,CASjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,UACjB,MAAM,wBAEX,GAEF,CAAC;AAGF,oBAAY,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IAEF,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE;QACV,IAAI,EAAE,iBAAiB,CAAC;QACxB,IAAI,EAAE,iBAAiB,CAAC;KACzB,CAAC;IAEF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AC;IAEF,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;CACJ,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,GAAG,EAAE;QACH,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC"}
@@ -35,7 +35,7 @@ exports.devServerAvailable = devServerAvailable;
35
35
  * Because Cloudflare/V8 platforms don't allow process.env, you are expected
36
36
  * to pass in the host from the dev server env key:
37
37
  *
38
- * @example devServerUrl(process.env[envKeys.DevServerUrl], "/your-path")
38
+ * @example devServerUrl(processEnv(envKeys.DevServerUrl), "/your-path")
39
39
  * @example devServerUrl("http://localhost:8288/", "/your-path")
40
40
  */
41
41
  const devServerUrl = (host = consts_1.defaultDevServerHost, pathname = "") => {
package/helpers/env.d.ts CHANGED
@@ -8,10 +8,6 @@
8
8
  */
9
9
  export declare const devServerHost: () => string | undefined;
10
10
  export declare const isProd: () => boolean;
11
- /**
12
- * TODO Refactor this to `processEnv(var: string): string | undefined`, which
13
- * would mean we can drop `process.env` from everywhere in the codebase other
14
- * than this function.
15
- */
16
- export declare const hasProcessEnv: () => boolean;
11
+ export declare const processEnv: (key: string) => string | undefined;
12
+ export declare const allProcessEnv: () => Record<string, string | undefined>;
17
13
  //# sourceMappingURL=env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/helpers/env.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,SAkBzC,CAAC;AAEF,eAAO,MAAM,MAAM,QAAO,OAMzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAO,OAEhC,CAAC"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/helpers/env.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,SAgBzC,CAAC;AAEF,eAAO,MAAM,MAAM,QAAO,OAQzB,CAAC;AAMF,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAAM,GAAG,SAEjD,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,OAAO,MAAM,EAAE,MAAM,GAAG,SAAS,CAOjE,CAAC"}