inngest 0.8.9 → 0.8.10
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.
- package/cloudflare.d.ts +1 -1
- package/cloudflare.d.ts.map +1 -1
- package/cloudflare.js +50 -81
- package/cloudflare.js.map +1 -1
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js +1 -1
- package/components/Inngest.js.map +1 -1
- package/components/InngestCommHandler.d.ts +380 -0
- package/components/InngestCommHandler.d.ts.map +1 -0
- package/components/InngestCommHandler.js +474 -0
- package/components/InngestCommHandler.js.map +1 -0
- package/components/InngestStepTools.d.ts +5 -3
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +17 -5
- package/components/InngestStepTools.js.map +1 -1
- package/components/NonRetriableError.d.ts +26 -0
- package/components/NonRetriableError.d.ts.map +1 -0
- package/components/NonRetriableError.js +21 -0
- package/components/NonRetriableError.js.map +1 -0
- package/deno/fresh.d.ts +9 -0
- package/deno/fresh.d.ts.map +1 -0
- package/deno/fresh.js +55 -0
- package/deno/fresh.js.map +1 -0
- package/digitalocean.d.ts +15 -0
- package/digitalocean.d.ts.map +1 -0
- package/digitalocean.js +72 -0
- package/digitalocean.js.map +1 -0
- package/express.d.ts +2 -122
- package/express.d.ts.map +1 -1
- package/express.js +48 -302
- package/express.js.map +1 -1
- package/helpers/consts.d.ts +2 -1
- package/helpers/consts.d.ts.map +1 -1
- package/helpers/consts.js +1 -0
- package/helpers/consts.js.map +1 -1
- package/helpers/devserver.d.ts +5 -5
- package/helpers/devserver.d.ts.map +1 -1
- package/helpers/devserver.js +1 -1
- package/helpers/env.d.ts +2 -6
- package/helpers/env.d.ts.map +1 -1
- package/helpers/env.js +23 -17
- package/helpers/env.js.map +1 -1
- package/helpers/types.d.ts +13 -9
- package/helpers/types.d.ts.map +1 -1
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/init.js +2 -1
- package/init.js.map +1 -1
- package/landing.d.ts +1 -1
- package/landing.d.ts.map +1 -1
- package/landing.js +1 -1
- package/landing.js.map +1 -1
- package/next.d.ts +1 -1
- package/next.d.ts.map +1 -1
- package/next.js +49 -69
- package/next.js.map +1 -1
- package/package.json +11 -9
- package/redwood.d.ts +1 -1
- package/redwood.d.ts.map +1 -1
- package/redwood.js +53 -98
- package/redwood.js.map +1 -1
- package/remix.d.ts +1 -1
- package/remix.d.ts.map +1 -1
- package/remix.js +61 -105
- package/remix.js.map +1 -1
- package/types.d.ts +13 -10
- package/types.d.ts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/cloudflare.d.ts
CHANGED
package/cloudflare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,iCAAiC,CAAC;AAGzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,YAoEnB,CAAC"}
|
package/cloudflare.js
CHANGED
|
@@ -1,87 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serve = void 0;
|
|
4
|
-
const
|
|
5
|
-
const express_1 = require("./express");
|
|
4
|
+
const InngestCommHandler_1 = require("./components/InngestCommHandler");
|
|
6
5
|
const consts_1 = require("./helpers/consts");
|
|
7
|
-
const devserver_1 = require("./helpers/devserver");
|
|
8
|
-
const landing_1 = require("./landing");
|
|
9
|
-
class CloudflareCommHandler extends express_1.InngestCommHandler {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.frameworkName = "cloudflare-pages";
|
|
13
|
-
}
|
|
14
|
-
createHandler() {
|
|
15
|
-
return async ({ request: req, env, }) => {
|
|
16
|
-
const headers = { "x-inngest-sdk": this.sdkHeader.join("") };
|
|
17
|
-
let reqUrl;
|
|
18
|
-
let isIntrospection;
|
|
19
|
-
try {
|
|
20
|
-
reqUrl = this.reqUrl(req.url, `https://${req.headers.get("host") || ""}`);
|
|
21
|
-
isIntrospection = reqUrl.searchParams.has(consts_1.queryKeys.Introspect);
|
|
22
|
-
reqUrl.searchParams.delete(consts_1.queryKeys.Introspect);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
return new Response(JSON.stringify(err), {
|
|
26
|
-
status: 500,
|
|
27
|
-
headers,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (!this.signingKey && env[consts_1.envKeys.SigningKey]) {
|
|
31
|
-
this.signingKey = env[consts_1.envKeys.SigningKey];
|
|
32
|
-
}
|
|
33
|
-
this._isProd = env.CF_PAGES === "1" || env.ENVIRONMENT === "production";
|
|
34
|
-
switch (req.method) {
|
|
35
|
-
case "GET": {
|
|
36
|
-
const showLandingPage = this.shouldShowLandingPage(env[consts_1.envKeys.LandingPage]);
|
|
37
|
-
if (this._isProd || !showLandingPage)
|
|
38
|
-
break;
|
|
39
|
-
if (isIntrospection) {
|
|
40
|
-
const introspection = Object.assign(Object.assign({}, this.registerBody(reqUrl)), { devServerURL: (0, devserver_1.devServerUrl)(env[consts_1.envKeys.DevServerUrl]).href, hasSigningKey: Boolean(this.signingKey) });
|
|
41
|
-
return new Response(JSON.stringify(introspection), {
|
|
42
|
-
status: 200,
|
|
43
|
-
headers,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Grab landing page and serve
|
|
47
|
-
return new Response(landing_1.landing, {
|
|
48
|
-
status: 200,
|
|
49
|
-
headers: Object.assign(Object.assign({}, headers), { "content-type": "text/html; charset=utf-8" }),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
case "PUT": {
|
|
53
|
-
// Push config to Inngest.
|
|
54
|
-
const { status, message } = await this.register(reqUrl, env[consts_1.envKeys.DevServerUrl]);
|
|
55
|
-
return new Response(JSON.stringify({ message }), { status, headers });
|
|
56
|
-
}
|
|
57
|
-
case "POST": {
|
|
58
|
-
// Inngest is trying to run a step; confirm signed and run.
|
|
59
|
-
const { fnId, stepId } = zod_1.z
|
|
60
|
-
.object({
|
|
61
|
-
fnId: zod_1.z.string().min(1),
|
|
62
|
-
stepId: zod_1.z.string().min(1),
|
|
63
|
-
})
|
|
64
|
-
.parse({
|
|
65
|
-
fnId: reqUrl.searchParams.get(consts_1.queryKeys.FnId),
|
|
66
|
-
stepId: reqUrl.searchParams.get(consts_1.queryKeys.StepId),
|
|
67
|
-
});
|
|
68
|
-
const stepRes = await this.runStep(fnId, stepId, await req.json());
|
|
69
|
-
if (stepRes.status === 500) {
|
|
70
|
-
return new Response(JSON.stringify(stepRes.error), {
|
|
71
|
-
status: stepRes.status,
|
|
72
|
-
headers,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return new Response(JSON.stringify(stepRes.body), {
|
|
76
|
-
status: stepRes.status,
|
|
77
|
-
headers,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return new Response(null, { status: 405, headers });
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
6
|
/**
|
|
86
7
|
* In Cloudflare, serve and register any declared functions with Inngest, making
|
|
87
8
|
* them available to be triggered by events.
|
|
@@ -89,7 +10,55 @@ class CloudflareCommHandler extends express_1.InngestCommHandler {
|
|
|
89
10
|
* @public
|
|
90
11
|
*/
|
|
91
12
|
const serve = (nameOrInngest, fns, opts) => {
|
|
92
|
-
|
|
13
|
+
const handler = new InngestCommHandler_1.InngestCommHandler("cloudflare-pages", nameOrInngest, fns, Object.assign({
|
|
14
|
+
/**
|
|
15
|
+
* Assume that we want to override the `fetch` implementation with the one
|
|
16
|
+
* globally available in the Cloudflare env. Specifying it here will
|
|
17
|
+
* ensure we avoid trying to load a Node-compatible version later.
|
|
18
|
+
*/
|
|
19
|
+
fetch: fetch.bind(globalThis) }, opts), ({ request: req, env, }) => {
|
|
20
|
+
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`);
|
|
21
|
+
const isProduction = env.CF_PAGES === "1" || env.ENVIRONMENT === "production";
|
|
22
|
+
return {
|
|
23
|
+
view: () => {
|
|
24
|
+
if (req.method === "GET") {
|
|
25
|
+
return {
|
|
26
|
+
url,
|
|
27
|
+
env,
|
|
28
|
+
isIntrospection: url.searchParams.has(consts_1.queryKeys.Introspect),
|
|
29
|
+
isProduction,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
register: () => {
|
|
34
|
+
if (req.method === "PUT") {
|
|
35
|
+
return {
|
|
36
|
+
env,
|
|
37
|
+
url,
|
|
38
|
+
isProduction,
|
|
39
|
+
deployId: url.searchParams.get(consts_1.queryKeys.DeployId),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
run: async () => {
|
|
44
|
+
if (req.method === "POST") {
|
|
45
|
+
return {
|
|
46
|
+
fnId: url.searchParams.get(consts_1.queryKeys.FnId),
|
|
47
|
+
data: (await req.json()),
|
|
48
|
+
env,
|
|
49
|
+
isProduction,
|
|
50
|
+
url,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}, ({ body, status, headers }) => {
|
|
56
|
+
return new Response(body, {
|
|
57
|
+
status,
|
|
58
|
+
headers,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
return handler.createHandler();
|
|
93
62
|
};
|
|
94
63
|
exports.serve = serve;
|
|
95
64
|
//# sourceMappingURL=cloudflare.js.map
|
package/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":";;;AAAA,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AAI;IAEV;;OAEG;IACH,KAAK,EAAE,KAAK;IAEZ;;OAEG;IACH,EAAE,EAAE,EAAE,GACL,eAAe,CAAC,MAAM,CAAC;IAC1B;;;OAGG;IACI,cAAc,CACnB,KAAK,SAAS,MAAM,MAAM,EAC1B,IAAI,SAAS,eAAe,EAC5B,EAAE,SAAS,YAAY,CACrB,MAAM,CAAC,KAAK,CAAC,EACb,IAAI,SAAS,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,EACpD,MAAM,CACP;IAED;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;OAEG;IACH,KAAK,EAAE,KAAK;IAEZ;;OAEG;IACH,EAAE,EAAE,EAAE,GACL,eAAe,CAAC,MAAM,CAAC;IAyB1B;;OAEG;IACI,uBAAuB,CAAC,IAAI,SAAS,MAAM;IAChD;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,EAAE,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GACnC,eAAe,CAAC,MAAM,CAAC;IAC1B;;OAEG;IACI,uBAAuB,CAAC,IAAI,SAAS,eAAe;IACzD;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,EAAE,EAAE,YAAY,CACd,IAAI,EACJ,IAAI,SAAS,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,EACpD,MAAM,CACP,GACA,eAAe,CAAC,MAAM,CAAC;CAuB3B"}
|
package/components/Inngest.js
CHANGED
|
@@ -78,7 +78,7 @@ class Inngest {
|
|
|
78
78
|
}
|
|
79
79
|
this.name = name;
|
|
80
80
|
this.inngestBaseUrl = new URL(inngestBaseUrl);
|
|
81
|
-
this.setEventKey(eventKey || (
|
|
81
|
+
this.setEventKey(eventKey || (0, env_1.processEnv)(consts_1.envKeys.EventKey) || "");
|
|
82
82
|
if (!this.eventKey) {
|
|
83
83
|
console.warn(exports.eventKeyWarning);
|
|
84
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA4C;AAC5C,oDAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,8CAA4C;AAC5C,oDAAwE;AACxE,wCAAmE;AAcnE,wCAAqC;AACrC,uDAAoD;AAOvC,QAAA,eAAe,GAC1B,2NAA2N,CAAC;AAEjN,QAAA,aAAa,GACxB,0KAA0K,CAAC;AAE7K;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,OAAO;IA0BlB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,cAAc,GAAG,iBAAiB,EAClC,KAAK,GACS;;QA/ChB;;WAEG;QACK,aAAQ,GAAG,EAAE,CAAC;QAOtB;;WAEG;QACK,kBAAa,GAAQ,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAmC5E,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;SACzE;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,IAAA,gBAAU,EAAC,gBAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC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,CAAC"}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import type { MaybePromise } from "../helpers/types";
|
|
2
|
+
import type { FunctionConfig, RegisterOptions, RegisterRequest, StepRunResponse } from "../types";
|
|
3
|
+
import type { Inngest } from "./Inngest";
|
|
4
|
+
import type { InngestFunction } from "./InngestFunction";
|
|
5
|
+
/**
|
|
6
|
+
* A handler for serving Inngest functions. This type should be used
|
|
7
|
+
* whenever a handler for a new framework is being added to enforce that the
|
|
8
|
+
* registration process is always the same for the user.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* // my-custom-handler.ts
|
|
13
|
+
* import { InngestCommHandler, ServeHandler } from "inngest";
|
|
14
|
+
*
|
|
15
|
+
* export const serve: ServeHandler = (nameOrInngest, fns, opts) => {
|
|
16
|
+
* const handler = new InngestCommHandler(
|
|
17
|
+
* "my-custom-handler",
|
|
18
|
+
* nameOrInngest,
|
|
19
|
+
* fns,
|
|
20
|
+
* opts,
|
|
21
|
+
* () => { ... },
|
|
22
|
+
* () => { ... }
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* return handler.createHandler();
|
|
26
|
+
* };
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export type ServeHandler = (
|
|
32
|
+
/**
|
|
33
|
+
* The name of this app, used to scope and group Inngest functions, or
|
|
34
|
+
* the `Inngest` instance used to declare all functions.
|
|
35
|
+
*/
|
|
36
|
+
nameOrInngest: string | Inngest<any>,
|
|
37
|
+
/**
|
|
38
|
+
* An array of the functions to serve and register with Inngest.
|
|
39
|
+
*/
|
|
40
|
+
functions: InngestFunction<any>[],
|
|
41
|
+
/**
|
|
42
|
+
* A set of options to further configure the registration of Inngest
|
|
43
|
+
* functions.
|
|
44
|
+
*/
|
|
45
|
+
opts?: RegisterOptions) => any;
|
|
46
|
+
/**
|
|
47
|
+
* `InngestCommHandler` is a class for handling incoming requests from Inngest (or
|
|
48
|
+
* Inngest's tooling such as the dev server or CLI) and taking appropriate
|
|
49
|
+
* action for any served functions.
|
|
50
|
+
*
|
|
51
|
+
* All handlers (Next.js, RedwoodJS, Remix, Deno Fresh, etc) are created using
|
|
52
|
+
* this class; the exposed `serve` function will - most commonly - create an
|
|
53
|
+
* instance of `InngestCommHandler` and then return `instance.createHandler()`.
|
|
54
|
+
*
|
|
55
|
+
* Two critical parameters required are the `handler` and the `transformRes`
|
|
56
|
+
* function. See individual parameter details for more information, or see the
|
|
57
|
+
* source code for an existing handler, e.g.
|
|
58
|
+
* {@link https://github.com/inngest/inngest-js/blob/main/src/next.ts}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```
|
|
62
|
+
* // my-custom-handler.ts
|
|
63
|
+
* import { InngestCommHandler, ServeHandler } from "inngest";
|
|
64
|
+
*
|
|
65
|
+
* export const serve: ServeHandler = (nameOrInngest, fns, opts) => {
|
|
66
|
+
* const handler = new InngestCommHandler(
|
|
67
|
+
* "my-custom-handler",
|
|
68
|
+
* nameOrInngest,
|
|
69
|
+
* fns,
|
|
70
|
+
* opts,
|
|
71
|
+
* () => { ... },
|
|
72
|
+
* () => { ... }
|
|
73
|
+
* );
|
|
74
|
+
*
|
|
75
|
+
* return handler.createHandler();
|
|
76
|
+
* };
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare class InngestCommHandler<H extends Handler, TransformedRes> {
|
|
82
|
+
/**
|
|
83
|
+
* The name of this serve handler, e.g. `"My App"`. It's recommended that this
|
|
84
|
+
* value represents the overarching app/service that this set of functions is
|
|
85
|
+
* being served from.
|
|
86
|
+
*/
|
|
87
|
+
readonly name: string;
|
|
88
|
+
/**
|
|
89
|
+
* The handler specified during instantiation of the class.
|
|
90
|
+
*/
|
|
91
|
+
readonly handler: H;
|
|
92
|
+
/**
|
|
93
|
+
* The response transformer specified during instantiation of the class.
|
|
94
|
+
*/
|
|
95
|
+
readonly transformRes: (res: ActionResponse, ...args: Parameters<H>) => TransformedRes;
|
|
96
|
+
/**
|
|
97
|
+
* The URL of the Inngest function registration endpoint.
|
|
98
|
+
*/
|
|
99
|
+
private readonly inngestRegisterUrl;
|
|
100
|
+
/**
|
|
101
|
+
* The name of the framework this handler is designed for. Should be
|
|
102
|
+
* lowercase, alphanumeric characters inclusive of `-` and `/`. This should
|
|
103
|
+
* never be defined by the user; a {@link ServeHandler} should abstract this.
|
|
104
|
+
*/
|
|
105
|
+
protected readonly frameworkName: string;
|
|
106
|
+
/**
|
|
107
|
+
* The signing key used to validate requests from Inngest. This is
|
|
108
|
+
* intentionally mutatble so that we can pick up the signing key from the
|
|
109
|
+
* environment during execution if needed.
|
|
110
|
+
*/
|
|
111
|
+
protected signingKey: string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* A property that can be set to indicate whether or not we believe we are in
|
|
114
|
+
* production mode.
|
|
115
|
+
*
|
|
116
|
+
* Should be set every time a request is received.
|
|
117
|
+
*/
|
|
118
|
+
protected _isProd: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* A set of headers sent back with every request. Usually includes generic
|
|
121
|
+
* functionality such as `"Content-Type"`, alongside informational headers
|
|
122
|
+
* such as Inngest SDK version.
|
|
123
|
+
*/
|
|
124
|
+
private readonly headers;
|
|
125
|
+
/**
|
|
126
|
+
* The localized `fetch` implementation used by this handler.
|
|
127
|
+
*/
|
|
128
|
+
private readonly fetch;
|
|
129
|
+
/**
|
|
130
|
+
* Whether we should show the SDK Landing Page.
|
|
131
|
+
*
|
|
132
|
+
* This purposefully does not take in to account any environment variables, as
|
|
133
|
+
* accessing them safely is platform-specific.
|
|
134
|
+
*/
|
|
135
|
+
protected readonly showLandingPage: boolean | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The host used to access the Inngest serve endpoint, e.g.:
|
|
138
|
+
*
|
|
139
|
+
* "https://myapp.com"
|
|
140
|
+
*
|
|
141
|
+
* By default, the library will try to infer this using request details such
|
|
142
|
+
* as the "Host" header and request path, but sometimes this isn't possible
|
|
143
|
+
* (e.g. when running in a more controlled environments such as AWS Lambda or
|
|
144
|
+
* when dealing with proxies/rediects).
|
|
145
|
+
*
|
|
146
|
+
* Provide the custom hostname here to ensure that the path is reported
|
|
147
|
+
* correctly when registering functions with Inngest.
|
|
148
|
+
*
|
|
149
|
+
* To also provide a custom path, use `servePath`.
|
|
150
|
+
*/
|
|
151
|
+
protected readonly serveHost: string | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* The path to the Inngest serve endpoint. e.g.:
|
|
154
|
+
*
|
|
155
|
+
* "/some/long/path/to/inngest/endpoint"
|
|
156
|
+
*
|
|
157
|
+
* By default, the library will try to infer this using request details such
|
|
158
|
+
* as the "Host" header and request path, but sometimes this isn't possible
|
|
159
|
+
* (e.g. when running in a more controlled environments such as AWS Lambda or
|
|
160
|
+
* when dealing with proxies/rediects).
|
|
161
|
+
*
|
|
162
|
+
* Provide the custom path (excluding the hostname) here to ensure that the
|
|
163
|
+
* path is reported correctly when registering functions with Inngest.
|
|
164
|
+
*
|
|
165
|
+
* To also provide a custom hostname, use `serveHost`.
|
|
166
|
+
*/
|
|
167
|
+
protected readonly servePath: string | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* A private collection of functions that are being served. This map is used
|
|
170
|
+
* to find and register functions when interacting with Inngest Cloud.
|
|
171
|
+
*/
|
|
172
|
+
private readonly fns;
|
|
173
|
+
constructor(
|
|
174
|
+
/**
|
|
175
|
+
* The name of the framework this handler is designed for. Should be
|
|
176
|
+
* lowercase, alphanumeric characters inclusive of `-` and `/`.
|
|
177
|
+
*
|
|
178
|
+
* This should never be defined by the user; a {@link ServeHandler} should
|
|
179
|
+
* abstract this.
|
|
180
|
+
*/
|
|
181
|
+
frameworkName: string,
|
|
182
|
+
/**
|
|
183
|
+
* The name of this serve handler, e.g. `"My App"`. It's recommended that this
|
|
184
|
+
* value represents the overarching app/service that this set of functions is
|
|
185
|
+
* being served from.
|
|
186
|
+
*
|
|
187
|
+
* This can also be an `Inngest` client, in which case the name given when
|
|
188
|
+
* instantiating the client is used. This is useful if you're sending and
|
|
189
|
+
* receiving events from the same service, as you can reuse a single
|
|
190
|
+
* definition of Inngest.
|
|
191
|
+
*/
|
|
192
|
+
appNameOrInngest: string | Inngest<any>,
|
|
193
|
+
/**
|
|
194
|
+
* An array of the functions to serve and register with Inngest.
|
|
195
|
+
*/
|
|
196
|
+
functions: InngestFunction<any>[], { inngestRegisterUrl, fetch, landingPage, signingKey, serveHost, servePath, }: RegisterOptions | undefined,
|
|
197
|
+
/**
|
|
198
|
+
* The `handler` is the function your framework requires to handle a
|
|
199
|
+
* request. For example, this is most commonly a function that is given a
|
|
200
|
+
* `Request` and must return a `Response`.
|
|
201
|
+
*
|
|
202
|
+
* The handler must map out any incoming parameters, then return a
|
|
203
|
+
* strictly-typed object to assess what kind of request is being made,
|
|
204
|
+
* collecting any relevant data as we go.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```
|
|
208
|
+
* return {
|
|
209
|
+
* register: () => { ... },
|
|
210
|
+
* run: () => { ... },
|
|
211
|
+
* view: () => { ... }
|
|
212
|
+
* };
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* Every key must be specified and must be a function that either returns
|
|
216
|
+
* a strictly-typed payload or `undefined` if the request is not for that
|
|
217
|
+
* purpose.
|
|
218
|
+
*
|
|
219
|
+
* This gives handlers freedom to choose how their platform of choice will
|
|
220
|
+
* trigger differing actions, whilst also ensuring all required information
|
|
221
|
+
* is given for each request type.
|
|
222
|
+
*
|
|
223
|
+
* See any existing handler for a full example.
|
|
224
|
+
*
|
|
225
|
+
* This should never be defined by the user; a {@link ServeHandler} should
|
|
226
|
+
* abstract this.
|
|
227
|
+
*/
|
|
228
|
+
handler: H,
|
|
229
|
+
/**
|
|
230
|
+
* The `transformRes` function receives the output of the Inngest SDK and
|
|
231
|
+
* can decide how to package up that information to appropriately return the
|
|
232
|
+
* information to Inngest.
|
|
233
|
+
*
|
|
234
|
+
* Mostly, this is taking the given parameters and returning a new
|
|
235
|
+
* `Response`.
|
|
236
|
+
*
|
|
237
|
+
* The function is passed an {@link ActionResponse} (an object containing a
|
|
238
|
+
* `status` code, a `headers` object, and a stringified `body`), as well as
|
|
239
|
+
* every parameter passed to the given `handler` function. This ensures you
|
|
240
|
+
* can appropriately handle the response, including use of any required
|
|
241
|
+
* parameters such as `res` in Express-/Connect-like frameworks.
|
|
242
|
+
*
|
|
243
|
+
* This should never be defined by the user; a {@link ServeHandler} should
|
|
244
|
+
* abstract this.
|
|
245
|
+
*/
|
|
246
|
+
transformRes: (actionRes: ActionResponse, ...args: Parameters<H>) => TransformedRes);
|
|
247
|
+
private get hashedSigningKey();
|
|
248
|
+
/**
|
|
249
|
+
* `createHandler` should be used to return a type-equivalent version of the
|
|
250
|
+
* `handler` specified during instantiation.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```
|
|
254
|
+
* // my-custom-handler.ts
|
|
255
|
+
* import { InngestCommHandler, ServeHandler } from "inngest";
|
|
256
|
+
*
|
|
257
|
+
* export const serve: ServeHandler = (nameOrInngest, fns, opts) => {
|
|
258
|
+
* const handler = new InngestCommHandler(
|
|
259
|
+
* "my-custom-handler",
|
|
260
|
+
* nameOrInngest,
|
|
261
|
+
* fns,
|
|
262
|
+
* opts,
|
|
263
|
+
* () => { ... },
|
|
264
|
+
* () => { ... }
|
|
265
|
+
* );
|
|
266
|
+
*
|
|
267
|
+
* return handler.createHandler();
|
|
268
|
+
* };
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
createHandler(): (...args: Parameters<H>) => Promise<TransformedRes>;
|
|
272
|
+
/**
|
|
273
|
+
* Given a set of functions to check if an action is available from the
|
|
274
|
+
* instance's handler, enact any action that is found.
|
|
275
|
+
*
|
|
276
|
+
* This method can fetch varying payloads of data, but ultimately is the place
|
|
277
|
+
* where _decisions_ are made regarding functionality.
|
|
278
|
+
*
|
|
279
|
+
* For example, if we find that we should be viewing the UI, this function
|
|
280
|
+
* will decide whether the UI should be visible based on the payload it has
|
|
281
|
+
* found (e.g. env vars, options, etc).
|
|
282
|
+
*/
|
|
283
|
+
private handleAction;
|
|
284
|
+
protected runStep(functionId: string, stepId: string, data: any): Promise<StepRunResponse>;
|
|
285
|
+
protected configs(url: URL): FunctionConfig[];
|
|
286
|
+
/**
|
|
287
|
+
* Returns an SDK header split in to three parts so that they can be used for
|
|
288
|
+
* different purposes.
|
|
289
|
+
*
|
|
290
|
+
* To use the entire string, run `this.sdkHeader.join("")`.
|
|
291
|
+
*/
|
|
292
|
+
protected get sdkHeader(): [
|
|
293
|
+
prefix: string,
|
|
294
|
+
version: RegisterRequest["sdk"],
|
|
295
|
+
suffix: string
|
|
296
|
+
];
|
|
297
|
+
/**
|
|
298
|
+
* Return an Inngest serve endpoint URL given a potential `path` and `host`.
|
|
299
|
+
*
|
|
300
|
+
* Will automatically use the `serveHost` and `servePath` if they have been
|
|
301
|
+
* set when registering.
|
|
302
|
+
*/
|
|
303
|
+
protected reqUrl(url: URL): URL;
|
|
304
|
+
protected registerBody(url: URL): RegisterRequest;
|
|
305
|
+
protected register(url: URL, devServerHost: string | undefined, deployId?: string | undefined | null): Promise<{
|
|
306
|
+
status: number;
|
|
307
|
+
message: string;
|
|
308
|
+
}>;
|
|
309
|
+
private get isProd();
|
|
310
|
+
private upsertSigningKeyFromEnv;
|
|
311
|
+
protected shouldShowLandingPage(strEnvVar: string | undefined): boolean;
|
|
312
|
+
protected validateSignature(): boolean;
|
|
313
|
+
protected signResponse(): string;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The broad definition of a handler passed when instantiating an
|
|
317
|
+
* {@link InngestCommHandler} instance.
|
|
318
|
+
*/
|
|
319
|
+
type Handler = (...args: any[]) => {
|
|
320
|
+
[K in Extract<HandlerAction, {
|
|
321
|
+
action: "run" | "register" | "view";
|
|
322
|
+
}>["action"]]: () => MaybePromise<Omit<Extract<HandlerAction, {
|
|
323
|
+
action: K;
|
|
324
|
+
}>, "action"> | undefined>;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* The response from the Inngest SDK before it is transformed in to a
|
|
328
|
+
* framework-compatible response by an {@link InngestCommHandler} instance.
|
|
329
|
+
*/
|
|
330
|
+
export interface ActionResponse {
|
|
331
|
+
/**
|
|
332
|
+
* The HTTP status code to return.
|
|
333
|
+
*/
|
|
334
|
+
status: number;
|
|
335
|
+
/**
|
|
336
|
+
* The headers to return in the response.
|
|
337
|
+
*/
|
|
338
|
+
headers: Record<string, string>;
|
|
339
|
+
/**
|
|
340
|
+
* A stringified body to return.
|
|
341
|
+
*/
|
|
342
|
+
body: string;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A set of actions the SDK is aware of, including any payloads they require
|
|
346
|
+
* when requesting them.
|
|
347
|
+
*/
|
|
348
|
+
type HandlerAction = {
|
|
349
|
+
action: "error";
|
|
350
|
+
data: Record<string, string>;
|
|
351
|
+
env: Record<string, string | undefined>;
|
|
352
|
+
isProduction: boolean;
|
|
353
|
+
url: URL;
|
|
354
|
+
} | {
|
|
355
|
+
action: "view";
|
|
356
|
+
env: Record<string, string | undefined>;
|
|
357
|
+
url: URL;
|
|
358
|
+
isIntrospection: boolean;
|
|
359
|
+
isProduction: boolean;
|
|
360
|
+
} | {
|
|
361
|
+
action: "register";
|
|
362
|
+
env: Record<string, string | undefined>;
|
|
363
|
+
url: URL;
|
|
364
|
+
isProduction: boolean;
|
|
365
|
+
deployId?: null | string;
|
|
366
|
+
} | {
|
|
367
|
+
action: "run";
|
|
368
|
+
fnId: string;
|
|
369
|
+
data: Record<string, any>;
|
|
370
|
+
env: Record<string, string | undefined>;
|
|
371
|
+
isProduction: boolean;
|
|
372
|
+
url: URL;
|
|
373
|
+
} | {
|
|
374
|
+
action: "bad-method";
|
|
375
|
+
env: Record<string, string | undefined>;
|
|
376
|
+
isProduction: boolean;
|
|
377
|
+
url: URL;
|
|
378
|
+
};
|
|
379
|
+
export {};
|
|
380
|
+
//# sourceMappingURL=InngestCommHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InngestCommHandler.d.ts","sourceRoot":"","sources":["../../src/components/InngestCommHandler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EACV,cAAc,EAEd,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,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;AAgBT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,kBAAkB,CAAC,CAAC,SAAS,OAAO,EAAE,cAAc;IAC/D;;;;OAIG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAgB,OAAO,EAAE,CAAC,CAAC;IAE3B;;OAEG;IACH,SAAgB,YAAY,EAAE,CAC5B,GAAG,EAAE,cAAc,EACnB,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KACnB,cAAc,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IAEzC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAEzC;;;;OAIG;IACH,SAAS,CAAC,UAAU,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