inngest 1.4.1 → 1.5.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.
- package/CHANGELOG.md +7 -0
- package/edge.d.ts +19 -0
- package/edge.d.ts.map +1 -0
- package/edge.js +71 -0
- package/edge.js.map +1 -0
- package/lambda.d.ts +28 -0
- package/lambda.d.ts.map +1 -0
- package/lambda.js +112 -0
- package/lambda.js.map +1 -0
- package/landing.d.ts +1 -1
- package/landing.js +1 -1
- package/package.json +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
package/edge.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ServeHandler } from "./components/InngestCommHandler";
|
|
2
|
+
/**
|
|
3
|
+
* In an edge runtime, serve and register any declared functions with Inngest,
|
|
4
|
+
* making them available to be triggered by events.
|
|
5
|
+
*
|
|
6
|
+
* The edge runtime is a generic term for any serverless runtime that supports
|
|
7
|
+
* only standard Web APIs such as `fetch`, `Request`, and `Response`, such as
|
|
8
|
+
* Cloudflare Workers, Vercel Edge Functions, and AWS Lambda@Edge.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { serve } from "inngest/edge";
|
|
13
|
+
* import fns from "~/inngest";
|
|
14
|
+
*
|
|
15
|
+
* export const handler = serve("My Edge App", fns);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const serve: ServeHandler;
|
|
19
|
+
//# sourceMappingURL=edge.d.ts.map
|
package/edge.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,iCAAiC,CAAC;AAIzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,KAAK,EAAE,YA2DnB,CAAC"}
|
package/edge.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serve = void 0;
|
|
4
|
+
const InngestCommHandler_1 = require("./components/InngestCommHandler");
|
|
5
|
+
const consts_1 = require("./helpers/consts");
|
|
6
|
+
const env_1 = require("./helpers/env");
|
|
7
|
+
/**
|
|
8
|
+
* In an edge runtime, serve and register any declared functions with Inngest,
|
|
9
|
+
* making them available to be triggered by events.
|
|
10
|
+
*
|
|
11
|
+
* The edge runtime is a generic term for any serverless runtime that supports
|
|
12
|
+
* only standard Web APIs such as `fetch`, `Request`, and `Response`, such as
|
|
13
|
+
* Cloudflare Workers, Vercel Edge Functions, and AWS Lambda@Edge.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { serve } from "inngest/edge";
|
|
18
|
+
* import fns from "~/inngest";
|
|
19
|
+
*
|
|
20
|
+
* export const handler = serve("My Edge App", fns);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const serve = (nameOrInngest, fns, opts) => {
|
|
24
|
+
const handler = new InngestCommHandler_1.InngestCommHandler("edge", nameOrInngest, fns, Object.assign({ fetch: fetch.bind(globalThis) }, opts), (req) => {
|
|
25
|
+
const env = (0, env_1.allProcessEnv)();
|
|
26
|
+
const url = new URL(req.url, `https://${req.headers.get("host") || ""}`);
|
|
27
|
+
const isProduction = env.VERCEL_ENV === "production" ||
|
|
28
|
+
env.CONTEXT === "production" ||
|
|
29
|
+
env.ENVIRONMENT === "production";
|
|
30
|
+
return {
|
|
31
|
+
register: () => {
|
|
32
|
+
if (req.method === "PUT") {
|
|
33
|
+
return {
|
|
34
|
+
env,
|
|
35
|
+
isProduction,
|
|
36
|
+
url,
|
|
37
|
+
deployId: url.searchParams.get(consts_1.queryKeys.DeployId),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
run: async () => {
|
|
42
|
+
if (req.method === "POST") {
|
|
43
|
+
return {
|
|
44
|
+
data: (await req.json()),
|
|
45
|
+
env,
|
|
46
|
+
fnId: url.searchParams.get(consts_1.queryKeys.FnId),
|
|
47
|
+
isProduction,
|
|
48
|
+
url,
|
|
49
|
+
stepId: url.searchParams.get(consts_1.queryKeys.StepId),
|
|
50
|
+
signature: req.headers.get(consts_1.headerKeys.Signature),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
view: () => {
|
|
55
|
+
if (req.method === "GET") {
|
|
56
|
+
return {
|
|
57
|
+
env,
|
|
58
|
+
isIntrospection: url.searchParams.has(consts_1.queryKeys.Introspect),
|
|
59
|
+
isProduction,
|
|
60
|
+
url,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}, ({ body, status, headers }) => {
|
|
66
|
+
return new Response(body, { status, headers });
|
|
67
|
+
});
|
|
68
|
+
return handler.createHandler();
|
|
69
|
+
};
|
|
70
|
+
exports.serve = serve;
|
|
71
|
+
//# sourceMappingURL=edge.js.map
|
package/edge.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":";;;AAAA,wEAGyC;AACzC,6CAAyD;AACzD,uCAA8C;AAE9C;;;;;;;;;;;;;;;GAeG;AACI,MAAM,KAAK,GAAiB,CAAC,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAI,uCAAkB,CACpC,MAAM,EACN,aAAa,EACb,GAAG,kBAED,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAC1B,IAAI,GAET,CAAC,GAAY,EAAE,EAAE;QACf,MAAM,GAAG,GAAG,IAAA,mBAAa,GAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,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,EAAE,OAAO,EAAE,EAAY,EAAE;QACtC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC,CAAC;AA3DW,QAAA,KAAK,SA2DhB"}
|
package/lambda.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ServeHandler } from "./components/InngestCommHandler";
|
|
2
|
+
/**
|
|
3
|
+
* With AWS Lambda, serve and register any declared functions with Inngest,
|
|
4
|
+
* making them available to be triggered by events.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Inngest } from "inngest";
|
|
10
|
+
* import { serve } from "inngest/lambda";
|
|
11
|
+
*
|
|
12
|
+
* const inngest = new Inngest({ name: "My Lambda App" });
|
|
13
|
+
*
|
|
14
|
+
* const fn = inngest.createFunction(
|
|
15
|
+
* { name: "Hello World" },
|
|
16
|
+
* { event: "test/hello.world" },
|
|
17
|
+
* async ({ event }) => {
|
|
18
|
+
* return "Hello World";
|
|
19
|
+
* }
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* export const handler = serve(inngest, [fn]);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare const serve: ServeHandler;
|
|
28
|
+
//# sourceMappingURL=lambda.d.ts.map
|
package/lambda.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../src/lambda.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,YAAY,EACb,MAAM,iCAAiC,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,KAAK,EAAE,YAqGnB,CAAC"}
|
package/lambda.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serve = void 0;
|
|
4
|
+
const InngestCommHandler_1 = require("./components/InngestCommHandler");
|
|
5
|
+
const consts_1 = require("./helpers/consts");
|
|
6
|
+
const env_1 = require("./helpers/env");
|
|
7
|
+
/**
|
|
8
|
+
* With AWS Lambda, serve and register any declared functions with Inngest,
|
|
9
|
+
* making them available to be triggered by events.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Inngest } from "inngest";
|
|
15
|
+
* import { serve } from "inngest/lambda";
|
|
16
|
+
*
|
|
17
|
+
* const inngest = new Inngest({ name: "My Lambda App" });
|
|
18
|
+
*
|
|
19
|
+
* const fn = inngest.createFunction(
|
|
20
|
+
* { name: "Hello World" },
|
|
21
|
+
* { event: "test/hello.world" },
|
|
22
|
+
* async ({ event }) => {
|
|
23
|
+
* return "Hello World";
|
|
24
|
+
* }
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* export const handler = serve(inngest, [fn]);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
const serve = (nameOrInngest, fns, opts) => {
|
|
33
|
+
const handler = new InngestCommHandler_1.InngestCommHandler("aws-lambda", nameOrInngest, fns, Object.assign({}, opts), (event, _context) => {
|
|
34
|
+
var _a;
|
|
35
|
+
/**
|
|
36
|
+
* Try to handle multiple incoming event types, as Lambda can have many
|
|
37
|
+
* triggers.
|
|
38
|
+
*
|
|
39
|
+
* This still doesn't handle all cases, but it's a start.
|
|
40
|
+
*/
|
|
41
|
+
const eventIsV2 = ((ev) => {
|
|
42
|
+
return ev.version === "2.0";
|
|
43
|
+
})(event);
|
|
44
|
+
const method = eventIsV2
|
|
45
|
+
? event.requestContext.http.method
|
|
46
|
+
: event.httpMethod;
|
|
47
|
+
const path = eventIsV2 ? event.requestContext.http.path : event.path;
|
|
48
|
+
const env = (0, env_1.allProcessEnv)();
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
const proto = event.headers["x-forwarded-proto"] || "https";
|
|
52
|
+
url = new URL(path, `${proto}://${event.headers.host || ""}`);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
throw new Error("Could not parse URL from `event.headers.host`");
|
|
56
|
+
}
|
|
57
|
+
const isProduction = env.CONTEXT === "production" ||
|
|
58
|
+
env.ENVIRONMENT === "production" ||
|
|
59
|
+
((_a = env.NODE_ENV) === null || _a === void 0 ? void 0 : _a.startsWith("prod")) ||
|
|
60
|
+
false;
|
|
61
|
+
return {
|
|
62
|
+
register: () => {
|
|
63
|
+
var _a;
|
|
64
|
+
if (method === "PUT") {
|
|
65
|
+
return {
|
|
66
|
+
env,
|
|
67
|
+
isProduction,
|
|
68
|
+
url,
|
|
69
|
+
deployId: (_a = event.queryStringParameters) === null || _a === void 0 ? void 0 : _a[consts_1.queryKeys.DeployId],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
run: () => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
if (method === "POST") {
|
|
76
|
+
return {
|
|
77
|
+
data: JSON.parse(event.body
|
|
78
|
+
? event.isBase64Encoded
|
|
79
|
+
? Buffer.from(event.body, "base64").toString()
|
|
80
|
+
: event.body
|
|
81
|
+
: "{}"),
|
|
82
|
+
env,
|
|
83
|
+
fnId: (_a = event.queryStringParameters) === null || _a === void 0 ? void 0 : _a[consts_1.queryKeys.FnId],
|
|
84
|
+
isProduction,
|
|
85
|
+
url,
|
|
86
|
+
stepId: (_b = event.queryStringParameters) === null || _b === void 0 ? void 0 : _b[consts_1.queryKeys.StepId],
|
|
87
|
+
signature: event.headers[consts_1.headerKeys.Signature],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
view: () => {
|
|
92
|
+
if (method === "GET") {
|
|
93
|
+
return {
|
|
94
|
+
env,
|
|
95
|
+
isIntrospection: Object.hasOwnProperty.call(event.queryStringParameters || {}, consts_1.queryKeys.Introspect),
|
|
96
|
+
isProduction,
|
|
97
|
+
url,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}, ({ body, status, headers }, _req) => {
|
|
103
|
+
return Promise.resolve({
|
|
104
|
+
body,
|
|
105
|
+
statusCode: status,
|
|
106
|
+
headers,
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
return handler.createHandler();
|
|
110
|
+
};
|
|
111
|
+
exports.serve = serve;
|
|
112
|
+
//# sourceMappingURL=lambda.js.map
|
package/lambda.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda.js","sourceRoot":"","sources":["../src/lambda.ts"],"names":[],"mappings":";;;AAMA,wEAGyC;AACzC,6CAAyD;AACzD,uCAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,KAAK,GAAiB,CAAC,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAI,uCAAkB,CACpC,YAAY,EACZ,aAAa,EACb,GAAG,oBACE,IAAI,GACT,CAAC,KAA+C,EAAE,QAAiB,EAAE,EAAE;;QACrE;;;;;WAKG;QACH,MAAM,SAAS,GAAG,CAAC,CACjB,EAA4C,EACd,EAAE;YAChC,OAAQ,EAA6B,CAAC,OAAO,KAAK,KAAK,CAAC;QAC1D,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEV,MAAM,MAAM,GAAG,SAAS;YACtB,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM;YAClC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;QACrB,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAA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