inngest 0.4.0-beta.5 → 0.4.0-beta.7
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/README.md +13 -0
- package/dist/components/Inngest.d.ts +73 -16
- package/dist/components/Inngest.d.ts.map +1 -1
- package/dist/components/Inngest.js +19 -9
- package/dist/components/Inngest.js.map +1 -1
- package/dist/components/InngestFunction.d.ts +28 -2
- package/dist/components/InngestFunction.d.ts.map +1 -1
- package/dist/components/InngestFunction.js +32 -3
- package/dist/components/InngestFunction.js.map +1 -1
- package/dist/components/InngestStep.d.ts +3 -0
- package/dist/components/InngestStep.d.ts.map +1 -1
- package/dist/components/InngestStep.js +4 -0
- package/dist/components/InngestStep.js.map +1 -1
- package/dist/handlers/default.d.ts +8 -5
- package/dist/handlers/default.d.ts.map +1 -1
- package/dist/handlers/default.js +32 -22
- package/dist/handlers/default.js.map +1 -1
- package/dist/handlers/next.d.ts +6 -0
- package/dist/handlers/next.d.ts.map +1 -1
- package/dist/handlers/next.js +14 -11
- package/dist/handlers/next.js.map +1 -1
- package/dist/handlers/remix.d.ts +9 -0
- package/dist/handlers/remix.d.ts.map +1 -0
- package/dist/handlers/remix.js +81 -0
- package/dist/handlers/remix.js.map +1 -0
- package/dist/helpers/func.d.ts +13 -1
- package/dist/helpers/func.d.ts.map +1 -1
- package/dist/helpers/func.js +54 -5
- package/dist/helpers/func.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +60 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +23 -3
package/README.md
CHANGED
|
@@ -40,3 +40,16 @@ const events = ["+12125551234", "+13135555678"].map(phoneNumber => ({
|
|
|
40
40
|
}});
|
|
41
41
|
await inngest.send(events);
|
|
42
42
|
```
|
|
43
|
+
|
|
44
|
+
## Contributing
|
|
45
|
+
|
|
46
|
+
Clone the repository, then:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
yarn # install dependencies
|
|
50
|
+
yarn dev # build/lint/test
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
We use [Volta](https://volta.sh/) to manage Node/Yarn versions.
|
|
54
|
+
|
|
55
|
+
When making a pull request, make sure to commit the changed `etc/inngest.api.md` file; this is a generated types/docs file that will highlight changes to the exposed API.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import * as InngestT from "../types";
|
|
1
|
+
import { ClientOptions, EventPayload, FunctionOptions, StepFn } from "../types";
|
|
3
2
|
import { InngestFunction } from "./InngestFunction";
|
|
4
3
|
/**
|
|
5
4
|
* A client used to interact with the Inngest API by sending or reacting to
|
|
@@ -8,8 +7,7 @@ import { InngestFunction } from "./InngestFunction";
|
|
|
8
7
|
* To provide event typing, make sure to pass in your generated event types as
|
|
9
8
|
* the first generic.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* ```ts
|
|
13
11
|
* const inngest = new Inngest<Events>("My App", process.env.INNGEST_API_KEY);
|
|
14
12
|
*
|
|
15
13
|
* // or to provide custom events too
|
|
@@ -23,8 +21,11 @@ import { InngestFunction } from "./InngestFunction";
|
|
|
23
21
|
* };
|
|
24
22
|
* }
|
|
25
23
|
* >("My App", process.env.INNGEST_API_KEY);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
26
27
|
*/
|
|
27
|
-
export declare class Inngest<Events extends Record<string,
|
|
28
|
+
export declare class Inngest<Events extends Record<string, EventPayload>> {
|
|
28
29
|
#private;
|
|
29
30
|
/**
|
|
30
31
|
* The name of this instance, most commonly the name of the application it
|
|
@@ -40,13 +41,13 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
40
41
|
*/
|
|
41
42
|
readonly inngestBaseUrl: URL;
|
|
42
43
|
/**
|
|
43
|
-
* The URL of the Inngest Cloud API.
|
|
44
|
+
* The absolute URL of the Inngest Cloud API.
|
|
44
45
|
*/
|
|
45
46
|
private readonly inngestApiUrl;
|
|
46
47
|
/**
|
|
47
48
|
* An Axios instance used for communicating with Inngest Cloud.
|
|
48
49
|
*
|
|
49
|
-
* @link https://npm.im/axios
|
|
50
|
+
* {@link https://npm.im/axios}
|
|
50
51
|
*/
|
|
51
52
|
private readonly client;
|
|
52
53
|
/**
|
|
@@ -56,8 +57,7 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
56
57
|
* To provide event typing, make sure to pass in your generated event types as
|
|
57
58
|
* the first generic.
|
|
58
59
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* ```ts
|
|
61
61
|
* const inngest = new Inngest<Events>("My App", process.env.INNGEST_API_KEY);
|
|
62
62
|
*
|
|
63
63
|
* // or to provide custom events too
|
|
@@ -71,6 +71,7 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
71
71
|
* };
|
|
72
72
|
* }
|
|
73
73
|
* >("My App", process.env.INNGEST_API_KEY);
|
|
74
|
+
* ```
|
|
74
75
|
*/
|
|
75
76
|
constructor(
|
|
76
77
|
/**
|
|
@@ -81,7 +82,7 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
81
82
|
/**
|
|
82
83
|
* Inngest event key, used to send events to Inngest Cloud.
|
|
83
84
|
*/
|
|
84
|
-
eventKey: string, { inngestBaseUrl }?:
|
|
85
|
+
eventKey: string, { inngestBaseUrl }?: ClientOptions);
|
|
85
86
|
/**
|
|
86
87
|
* Send one or many events to Inngest. Takes a known event from this Inngest
|
|
87
88
|
* instance based on the given `name`.
|
|
@@ -93,25 +94,25 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
93
94
|
* generated), make sure to add it when creating your Inngest instance, like
|
|
94
95
|
* so:
|
|
95
96
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
97
|
+
* ```ts
|
|
98
98
|
* const inngest = new Inngest<Events & {
|
|
99
99
|
* "my/event": {
|
|
100
100
|
* name: "my/event";
|
|
101
101
|
* data: { bar: string; };
|
|
102
102
|
* }
|
|
103
103
|
* }>("My App", "API_KEY");
|
|
104
|
+
* ```
|
|
104
105
|
*/
|
|
105
106
|
send<Event extends keyof Events>(name: Event, payload: Omit<Events[Event], "name"> | Omit<Events[Event], "name">[]): Promise<void>;
|
|
106
107
|
/**
|
|
107
108
|
* Given an event to listen to, run the given function when that event is
|
|
108
109
|
* seen.
|
|
109
110
|
*/
|
|
110
|
-
createFunction<Event extends keyof Events, Fn extends
|
|
111
|
+
createFunction<Event extends keyof Events, Name extends string, Fn extends StepFn<Events[Event], Name, "step">>(
|
|
111
112
|
/**
|
|
112
113
|
* The name of this function as it will appear in the Inngst Cloud UI.
|
|
113
114
|
*/
|
|
114
|
-
name:
|
|
115
|
+
name: Name,
|
|
115
116
|
/**
|
|
116
117
|
* The event to listen for.
|
|
117
118
|
*/
|
|
@@ -120,11 +121,15 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
120
121
|
* The function to run when the event is received.
|
|
121
122
|
*/
|
|
122
123
|
fn: Fn): InngestFunction<Events>;
|
|
123
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Given an event to listen to, run the given function when that event is
|
|
126
|
+
* seen.
|
|
127
|
+
*/
|
|
128
|
+
createFunction<Event extends keyof Events, Opts extends FunctionOptions, Fn extends StepFn<Events[Event], Opts extends FunctionOptions ? Opts["name"] : string, "step">>(
|
|
124
129
|
/**
|
|
125
130
|
* Options for this Inngest function - useful for defining a custom ID.
|
|
126
131
|
*/
|
|
127
|
-
opts:
|
|
132
|
+
opts: Opts,
|
|
128
133
|
/**
|
|
129
134
|
* The event to listen for.
|
|
130
135
|
*/
|
|
@@ -133,5 +138,57 @@ export declare class Inngest<Events extends Record<string, InngestT.EventPayload
|
|
|
133
138
|
* The function to run when the event is received.
|
|
134
139
|
*/
|
|
135
140
|
fn: Fn): InngestFunction<Events>;
|
|
141
|
+
/**
|
|
142
|
+
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
143
|
+
*/
|
|
144
|
+
createScheduledFunction<Name extends string>(
|
|
145
|
+
/**
|
|
146
|
+
* The name of this function as it will appear in the Inngest Cloud UI.
|
|
147
|
+
*/
|
|
148
|
+
name: Name,
|
|
149
|
+
/**
|
|
150
|
+
* The cron definition to schedule your function.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
*
|
|
154
|
+
* "0 0 0 1 1 * 1" // At 12:00 AM, on day 1 of the month, only in January, only in 0001
|
|
155
|
+
* "0 0 0 1 1 * 1,2" // At 12:00 AM, on day 1 of the month, only in January, only in 0001 and 0002
|
|
156
|
+
* "0 0 0 1 1 * 1,2,3" // At 12:00 AM, on day 1 of the month, only in January, only in 0001, 0002, and 0003
|
|
157
|
+
* "0 0 0 1 * * 1/4" // At 12:00 AM, on day 1 of the month, every 4 years
|
|
158
|
+
* "0 0 0 * * 0 1-4" // At 12:00 AM, only on Sunday, 0001 through 0004
|
|
159
|
+
* "0 0 0 * * * 2/4" // At 12:00 AM, every 4 years, 0002 through 9999
|
|
160
|
+
* "0 0 * * * * *" // Every hour
|
|
161
|
+
*/
|
|
162
|
+
cron: string,
|
|
163
|
+
/**
|
|
164
|
+
* The function to run.
|
|
165
|
+
*/
|
|
166
|
+
fn: StepFn<null, Name, "step">): InngestFunction<Events>;
|
|
167
|
+
/**
|
|
168
|
+
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
169
|
+
*/
|
|
170
|
+
createScheduledFunction<Opts extends FunctionOptions>(
|
|
171
|
+
/**
|
|
172
|
+
* Options for this Inngest function - useful for defining a custom ID.
|
|
173
|
+
*/
|
|
174
|
+
opts: Opts,
|
|
175
|
+
/**
|
|
176
|
+
* The cron definition to schedule your function.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
*
|
|
180
|
+
* "0 0 0 1 1 * 1" // At 12:00 AM, on day 1 of the month, only in January, only in 0001
|
|
181
|
+
* "0 0 0 1 1 * 1,2" // At 12:00 AM, on day 1 of the month, only in January, only in 0001 and 0002
|
|
182
|
+
* "0 0 0 1 1 * 1,2,3" // At 12:00 AM, on day 1 of the month, only in January, only in 0001, 0002, and 0003
|
|
183
|
+
* "0 0 0 1 * * 1/4" // At 12:00 AM, on day 1 of the month, every 4 years
|
|
184
|
+
* "0 0 0 * * 0 1-4" // At 12:00 AM, only on Sunday, 0001 through 0004
|
|
185
|
+
* "0 0 0 * * * 2/4" // At 12:00 AM, every 4 years, 0002 through 9999
|
|
186
|
+
* "0 0 * * * * *" // Every hour
|
|
187
|
+
*/
|
|
188
|
+
cron: string,
|
|
189
|
+
/**
|
|
190
|
+
* The function to run.
|
|
191
|
+
*/
|
|
192
|
+
fn: StepFn<null, Opts extends FunctionOptions ? Opts["name"] : string, "step">): InngestFunction<Events>;
|
|
136
193
|
}
|
|
137
194
|
//# sourceMappingURL=Inngest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.d.ts","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Inngest.d.ts","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;;IAC9D;;;OAGG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC;;OAEG;IACH,SAAgB,cAAc,EAAE,GAAG,CAAC;IAEpC;;OAE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AS,MAAM;IAChD;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAC7B,eAAe,CAAC,MAAM,CAAC;IAC1B;;OAEG;IACI,uBAAuB,CAAC,IAAI,SAAS,eAAe;IACzD;;OAEG;IACH,IAAI,EAAE,IAAI;IAEV;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,EAAE,EAAE,MAAM,CACR,IAAI,EACJ,IAAI,SAAS,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,EACpD,MAAM,CACP,GACA,eAAe,CAAC,MAAM,CAAC;CAuB3B"}
|
|
@@ -21,8 +21,7 @@ const InngestStep_1 = require("./InngestStep");
|
|
|
21
21
|
* To provide event typing, make sure to pass in your generated event types as
|
|
22
22
|
* the first generic.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* ```ts
|
|
26
25
|
* const inngest = new Inngest<Events>("My App", process.env.INNGEST_API_KEY);
|
|
27
26
|
*
|
|
28
27
|
* // or to provide custom events too
|
|
@@ -36,6 +35,9 @@ const InngestStep_1 = require("./InngestStep");
|
|
|
36
35
|
* };
|
|
37
36
|
* }
|
|
38
37
|
* >("My App", process.env.INNGEST_API_KEY);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
39
41
|
*/
|
|
40
42
|
class Inngest {
|
|
41
43
|
/**
|
|
@@ -45,8 +47,7 @@ class Inngest {
|
|
|
45
47
|
* To provide event typing, make sure to pass in your generated event types as
|
|
46
48
|
* the first generic.
|
|
47
49
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* ```ts
|
|
50
51
|
* const inngest = new Inngest<Events>("My App", process.env.INNGEST_API_KEY);
|
|
51
52
|
*
|
|
52
53
|
* // or to provide custom events too
|
|
@@ -60,6 +61,7 @@ class Inngest {
|
|
|
60
61
|
* };
|
|
61
62
|
* }
|
|
62
63
|
* >("My App", process.env.INNGEST_API_KEY);
|
|
64
|
+
* ```
|
|
63
65
|
*/
|
|
64
66
|
constructor(
|
|
65
67
|
/**
|
|
@@ -103,14 +105,14 @@ class Inngest {
|
|
|
103
105
|
* generated), make sure to add it when creating your Inngest instance, like
|
|
104
106
|
* so:
|
|
105
107
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
+
* ```ts
|
|
108
109
|
* const inngest = new Inngest<Events & {
|
|
109
110
|
* "my/event": {
|
|
110
111
|
* name: "my/event";
|
|
111
112
|
* data: { bar: string; };
|
|
112
113
|
* }
|
|
113
114
|
* }>("My App", "API_KEY");
|
|
115
|
+
* ```
|
|
114
116
|
*/
|
|
115
117
|
async send(name, payload) {
|
|
116
118
|
const response = await this.client.post(this.inngestApiUrl.href, Object.assign(Object.assign({}, payload), { name }));
|
|
@@ -119,10 +121,18 @@ class Inngest {
|
|
|
119
121
|
}
|
|
120
122
|
throw __classPrivateFieldGet(this, _Inngest_instances, "m", _Inngest_getResponseError).call(this, response);
|
|
121
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Given an event to listen to, run the given function when that event is
|
|
126
|
+
* seen.
|
|
127
|
+
*/
|
|
122
128
|
createFunction(nameOrOpts, event, fn) {
|
|
123
|
-
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, event, {
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { event: event }, { step: new InngestStep_1.InngestStep(fn) });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
133
|
+
*/
|
|
134
|
+
createScheduledFunction(nameOrOpts, cron, fn) {
|
|
135
|
+
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { cron }, { step: new InngestStep_1.InngestStep(fn) });
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
exports.Inngest = Inngest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4D;AAE5D,wCAAqC;AACrC,uDAAoD;AACpD,+CAA4C;AAE5C
|
|
1
|
+
{"version":3,"file":"Inngest.js","sourceRoot":"","sources":["../../src/components/Inngest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4D;AAE5D,wCAAqC;AACrC,uDAAoD;AACpD,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,OAAO;IA6BlB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH;IACE;;;OAGG;IACH,IAAY;IAEZ;;OAEG;IACH,QAAgB,EAChB,EAAE,cAAc,GAAG,iBAAiB,KAAoB,EAAE;;QAE1D,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;SACzE;QAED,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;SACH;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAExE,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,CAAC;YACV,OAAO,EAAE;gBACP,c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YAAY,GAAG,eAAe,CAAC;IACnC,QAAQ,QAAQ,CAAC,MAAM,EAAE;QACvB,KAAK,GAAG;YACN,YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,8BAA8B,CAAC;YAC9C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,WAAW,CAAC;YAC3B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,qBAAqB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM;QACR,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,YAAY,GAAG,6BAA6B,CAAC;YAC7C,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,yBAAyB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,GAAG,uBAAuB,CAAC;YACvC,MAAM;KACT;IACD,OAAO,IAAI,KAAK,CAAC,sBAAsB,QAAQ,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,8 +1,34 @@
|
|
|
1
|
-
import { EventPayload, FunctionOptions, Steps } from "../types";
|
|
1
|
+
import { EventPayload, FunctionOptions, FunctionTrigger, Steps } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* A stateless Inngest function, wrapping up function configuration and any
|
|
4
|
+
* in-memory steps to run when triggered.
|
|
5
|
+
*
|
|
6
|
+
* This function can be "registered" to create a handler that Inngest can
|
|
7
|
+
* trigger remotely.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
2
11
|
export declare class InngestFunction<Events extends Record<string, EventPayload>> {
|
|
3
12
|
#private;
|
|
4
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A stateless Inngest function, wrapping up function configuration and any
|
|
15
|
+
* in-memory steps to run when triggered.
|
|
16
|
+
*
|
|
17
|
+
* This function can be "registered" to create a handler that Inngest can
|
|
18
|
+
* trigger remotely.
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
/**
|
|
22
|
+
* Options
|
|
23
|
+
*/
|
|
24
|
+
opts: FunctionOptions, trigger: FunctionTrigger<keyof Events>, steps: Steps);
|
|
25
|
+
/**
|
|
26
|
+
* The generated or given ID for this function.
|
|
27
|
+
*/
|
|
5
28
|
get id(): string;
|
|
29
|
+
/**
|
|
30
|
+
* The name of this function as it will appear in the Inngest Cloud UI.
|
|
31
|
+
*/
|
|
6
32
|
get name(): string;
|
|
7
33
|
/**
|
|
8
34
|
* Retrieve the Inngest config for this function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestFunction.d.ts","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"InngestFunction.d.ts","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,eAAe,EACf,eAAe,EACf,KAAK,EACN,MAAM,UAAU,CAAC;AAElB;;;;;;;;GAQG;AACH,qBAAa,eAAe,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;;IAKtE;;;;;;OAMG;;IAED;;OAEG;IACH,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,eAAe,CAAC,MAAM,MAAM,CAAC,EACtC,KAAK,EAAE,KAAK;IAOd;;OAEG;IACH,IAAW,EAAE,WAMZ;IAED;;OAEG;IACH,IAAW,IAAI,WAEd;IAED;;OAEG;IACH,OAAO,CAAC,SAAS;IAmCjB;;OAEG;IACH,OAAO,CAAC,OAAO;CAyBhB"}
|
|
@@ -14,8 +14,28 @@ var _InngestFunction_instances, _InngestFunction_opts, _InngestFunction_trigger,
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.InngestFunction = void 0;
|
|
16
16
|
const consts_1 = require("../helpers/consts");
|
|
17
|
+
/**
|
|
18
|
+
* A stateless Inngest function, wrapping up function configuration and any
|
|
19
|
+
* in-memory steps to run when triggered.
|
|
20
|
+
*
|
|
21
|
+
* This function can be "registered" to create a handler that Inngest can
|
|
22
|
+
* trigger remotely.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
17
26
|
class InngestFunction {
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A stateless Inngest function, wrapping up function configuration and any
|
|
29
|
+
* in-memory steps to run when triggered.
|
|
30
|
+
*
|
|
31
|
+
* This function can be "registered" to create a handler that Inngest can
|
|
32
|
+
* trigger remotely.
|
|
33
|
+
*/
|
|
34
|
+
constructor(
|
|
35
|
+
/**
|
|
36
|
+
* Options
|
|
37
|
+
*/
|
|
38
|
+
opts, trigger, steps) {
|
|
19
39
|
_InngestFunction_instances.add(this);
|
|
20
40
|
_InngestFunction_opts.set(this, void 0);
|
|
21
41
|
_InngestFunction_trigger.set(this, void 0);
|
|
@@ -24,9 +44,18 @@ class InngestFunction {
|
|
|
24
44
|
__classPrivateFieldSet(this, _InngestFunction_trigger, trigger, "f");
|
|
25
45
|
__classPrivateFieldSet(this, _InngestFunction_steps, steps || {}, "f");
|
|
26
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The generated or given ID for this function.
|
|
49
|
+
*/
|
|
27
50
|
get id() {
|
|
28
|
-
|
|
51
|
+
if (!__classPrivateFieldGet(this, _InngestFunction_opts, "f").id) {
|
|
52
|
+
__classPrivateFieldGet(this, _InngestFunction_opts, "f").id = __classPrivateFieldGet(this, _InngestFunction_instances, "m", _InngestFunction_generateId).call(this);
|
|
53
|
+
}
|
|
54
|
+
return __classPrivateFieldGet(this, _InngestFunction_opts, "f").id;
|
|
29
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The name of this function as it will appear in the Inngest Cloud UI.
|
|
58
|
+
*/
|
|
30
59
|
get name() {
|
|
31
60
|
return __classPrivateFieldGet(this, _InngestFunction_opts, "f").name;
|
|
32
61
|
}
|
|
@@ -43,7 +72,7 @@ class InngestFunction {
|
|
|
43
72
|
return {
|
|
44
73
|
id: this.id,
|
|
45
74
|
name: this.name,
|
|
46
|
-
triggers: [
|
|
75
|
+
triggers: [__classPrivateFieldGet(this, _InngestFunction_trigger, "f")],
|
|
47
76
|
steps: Object.keys(__classPrivateFieldGet(this, _InngestFunction_steps, "f")).reduce((acc, stepId) => {
|
|
48
77
|
const url = new URL(baseUrl.href);
|
|
49
78
|
url.searchParams.set(consts_1.fnIdParam, __classPrivateFieldGet(this, _InngestFunction_opts, "f").name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestFunction.js","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8CAA2D;
|
|
1
|
+
{"version":3,"file":"InngestFunction.js","sourceRoot":"","sources":["../../src/components/InngestFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8CAA2D;AAS3D;;;;;;;;GAQG;AACH,MAAa,eAAe;IAK1B;;;;;;OAMG;IACH;IACE;;OAEG;IACH,IAAqB,EACrB,OAAsC,EACtC,KAAY;;QAjBd,wCAAgC;QAChC,2CAAiD;QACjD,yCAAuB;QAiBrB,uBAAA,IAAI,yBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,4BAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,0BAAU,KAAK,IAAI,EAAE,MAAA,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,EAAE;QACX,IAAI,CAAC,uBAAA,IAAI,6BAAM,CAAC,EAAE,EAAE;YAClB,uBAAA,IAAI,6BAAM,CAAC,EAAE,GAAG,uBAAA,IAAI,+DAAY,MAAhB,IAAI,CAAc,CAAC;SACpC;QAED,OAAO,uBAAA,IAAI,6BAAM,CAAC,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG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AAG,GAAG,CAAC;IAEjB,OAAO,uBAAA,IAAI,6BAAM,CAAC,IAAI;SACnB,WAAW,EAAE;SACb,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC;SAChC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;SACvB,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -6,6 +6,9 @@ export declare class InngestStep<Input extends any[], Output> {
|
|
|
6
6
|
constructor(fn: (...args: Input) => Output);
|
|
7
7
|
/**
|
|
8
8
|
* Run this step with the given `data`.
|
|
9
|
+
*
|
|
10
|
+
* Purposefully return a promise so that it's easier to catch further up the
|
|
11
|
+
* stack.
|
|
9
12
|
*/
|
|
10
13
|
private run;
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestStep.d.ts","sourceRoot":"","sources":["../../src/components/InngestStep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,KAAK,SAAS,GAAG,EAAE,EAAE,MAAM;;gBAGtC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM;IAI1C
|
|
1
|
+
{"version":3,"file":"InngestStep.d.ts","sourceRoot":"","sources":["../../src/components/InngestStep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAW,CAAC,KAAK,SAAS,GAAG,EAAE,EAAE,MAAM;;gBAGtC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM;IAI1C;;;;;OAKG;YAEW,GAAG;CAGlB"}
|
|
@@ -23,7 +23,11 @@ class InngestStep {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Run this step with the given `data`.
|
|
26
|
+
*
|
|
27
|
+
* Purposefully return a promise so that it's easier to catch further up the
|
|
28
|
+
* stack.
|
|
26
29
|
*/
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
27
31
|
async run(data) {
|
|
28
32
|
return __classPrivateFieldGet(this, _InngestStep_fn, "f").call(this, data);
|
|
29
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestStep.js","sourceRoot":"","sources":["../../src/components/InngestStep.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,EAA8B;QAF1C,kCAAuC;QAGrC,uBAAA,IAAI,mBAAO,EAAE,MAAA,CAAC;IAChB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"InngestStep.js","sourceRoot":"","sources":["../../src/components/InngestStep.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,EAA8B;QAF1C,kCAAuC;QAGrC,uBAAA,IAAI,mBAAO,EAAE,MAAA,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,4DAA4D;IACpD,KAAK,CAAC,GAAG,CAAC,IAAS;QACzB,OAAO,uBAAA,IAAI,uBAAI,MAAR,IAAI,EAAK,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAjBD,kCAiBC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Inngest } from "../components/Inngest";
|
|
3
2
|
import { InngestFunction } from "../components/InngestFunction";
|
|
4
|
-
import { EventPayload, FunctionConfig, RegisterOptions,
|
|
3
|
+
import { EventPayload, FunctionConfig, RegisterOptions, StepRunResponse } from "../types";
|
|
5
4
|
/**
|
|
6
5
|
* A handler for registering Inngest functions. This type should be used
|
|
7
6
|
* whenever a handler for a new framework is being added to enforce that the
|
|
8
7
|
* registration process is always the same for the user.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
9
10
|
*/
|
|
10
11
|
export declare type RegisterHandler = (
|
|
11
12
|
/**
|
|
@@ -27,7 +28,7 @@ signingKey: string, functions: InngestFunction<any>[], opts?: RegisterOptions) =
|
|
|
27
28
|
* Can either take an `Inngest` instance and a signing key, or can be used to
|
|
28
29
|
* create custom handlers by passing in an `InngestCommHandler`.
|
|
29
30
|
*
|
|
30
|
-
* @
|
|
31
|
+
* @public
|
|
31
32
|
*/
|
|
32
33
|
export declare const register: <Events extends Record<string, EventPayload>>(...args: [nameOrInngest: string | Inngest<Events>, signingKey: string, functions: InngestFunction<Events>[], opts?: RegisterOptions | undefined] | [commHandler: InngestCommHandler]) => any;
|
|
33
34
|
/**
|
|
@@ -46,6 +47,8 @@ export declare const register: <Events extends Record<string, EventPayload>>(...
|
|
|
46
47
|
* platform
|
|
47
48
|
*
|
|
48
49
|
* This needs to also account for the ability to validate signatures etc.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
49
52
|
*/
|
|
50
53
|
export declare class InngestCommHandler {
|
|
51
54
|
name: string;
|
|
@@ -58,7 +61,7 @@ export declare class InngestCommHandler {
|
|
|
58
61
|
/**
|
|
59
62
|
* An Axios instance used for communicating with Inngest Cloud.
|
|
60
63
|
*
|
|
61
|
-
* @link https://npm.im/axios
|
|
64
|
+
* {@link https://npm.im/axios}
|
|
62
65
|
*/
|
|
63
66
|
private readonly client;
|
|
64
67
|
/**
|
|
@@ -67,11 +70,11 @@ export declare class InngestCommHandler {
|
|
|
67
70
|
*/
|
|
68
71
|
private readonly fns;
|
|
69
72
|
constructor(nameOrInngest: string | Inngest<any>, signingKey: string, functions: InngestFunction<any>[], { inngestRegisterUrl }?: RegisterOptions);
|
|
73
|
+
private get hashedSigningKey();
|
|
70
74
|
createHandler(): any;
|
|
71
75
|
protected runStep(functionId: string, stepId: string, data: any): Promise<StepRunResponse>;
|
|
72
76
|
protected configs(url: URL): FunctionConfig[];
|
|
73
77
|
protected register(url: URL): Promise<void>;
|
|
74
|
-
protected pong(url: URL): RegisterPingResponse;
|
|
75
78
|
protected validateSignature(): boolean;
|
|
76
79
|
protected signResponse(): string;
|
|
77
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/handlers/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/handlers/default.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EAEf,eAAe,EAChB,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,oBAAY,eAAe,GAAG;AAC5B;;;GAGG;AACH,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;AAEpC;;;;;GAKG;AACH,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,EACjC,IAAI,CAAC,EAAE,eAAe,KACnB,GAAG,CAAC;AAET;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,4OAoBpB,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,MAAM,CAAa;IACrD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAEtC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4C;gBAG9D,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,EACpC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,EACjC,EAAE,kBAAkB,EAAE,GAAE,eAAoB;IAwC9C,OAAO,KAAK,gBAAgB,GAiB3B;IAEM,aAAa,IAAI,GAAG;cAqDX,OAAO,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,eAAe,CAAC;IAqC3B,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,EAAE;cAI7B,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCjD,SAAS,CAAC,iBAAiB,IAAI,OAAO;IAItC,SAAS,CAAC,YAAY,IAAI,MAAM;CAGjC"}
|
package/dist/handlers/default.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.InngestCommHandler = exports.register = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
9
|
const zod_1 = require("zod");
|
|
9
10
|
const consts_1 = require("../helpers/consts");
|
|
10
11
|
const version_1 = require("../version");
|
|
@@ -15,14 +16,16 @@ const version_1 = require("../version");
|
|
|
15
16
|
* Can either take an `Inngest` instance and a signing key, or can be used to
|
|
16
17
|
* create custom handlers by passing in an `InngestCommHandler`.
|
|
17
18
|
*
|
|
18
|
-
* @
|
|
19
|
+
* @public
|
|
19
20
|
*/
|
|
20
21
|
const register = (...args) => {
|
|
21
22
|
if (args.length === 1) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
22
24
|
return args[0].createHandler();
|
|
23
25
|
}
|
|
24
26
|
const [nameOrInngest, signingKey, fns, opts] = args;
|
|
25
27
|
const handler = new InngestCommHandler(nameOrInngest, signingKey, fns, opts);
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
26
29
|
return handler.createHandler();
|
|
27
30
|
};
|
|
28
31
|
exports.register = register;
|
|
@@ -42,6 +45,8 @@ exports.register = register;
|
|
|
42
45
|
* platform
|
|
43
46
|
*
|
|
44
47
|
* This needs to also account for the ability to validate signatures etc.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
45
50
|
*/
|
|
46
51
|
class InngestCommHandler {
|
|
47
52
|
constructor(nameOrInngest, signingKey, functions, { inngestRegisterUrl } = {}) {
|
|
@@ -71,6 +76,16 @@ class InngestCommHandler {
|
|
|
71
76
|
maxRedirects: 0,
|
|
72
77
|
});
|
|
73
78
|
}
|
|
79
|
+
// hashedSigningKey creates a sha256 checksum of the signing key with the
|
|
80
|
+
// same signing key prefix.
|
|
81
|
+
get hashedSigningKey() {
|
|
82
|
+
var _a;
|
|
83
|
+
const prefix = ((_a = this.signingKey.match(/^signkey-(test|prod)-/)) === null || _a === void 0 ? void 0 : _a.shift()) || "";
|
|
84
|
+
const key = Buffer.from(this.signingKey.replace(/^signkey-(test|prod)-/, ""), "hex");
|
|
85
|
+
// Decode the key from its hex representation into a bytestream
|
|
86
|
+
console.log(prefix, key, `${prefix}${crypto_1.default.createHash("sha256").update(key).digest("hex")}`);
|
|
87
|
+
return `${prefix}${crypto_1.default.createHash("sha256").update(key).digest("hex")}`;
|
|
88
|
+
}
|
|
74
89
|
createHandler() {
|
|
75
90
|
return async (req, res, next) => {
|
|
76
91
|
/**
|
|
@@ -91,14 +106,7 @@ class InngestCommHandler {
|
|
|
91
106
|
// Push config to Inngest.
|
|
92
107
|
await this.register(reqUrl);
|
|
93
108
|
return void res.sendStatus(200);
|
|
94
|
-
case "
|
|
95
|
-
console.log("It was a GET request");
|
|
96
|
-
// Inngest is asking for config; confirm signed and send.
|
|
97
|
-
this.validateSignature(); //TODO
|
|
98
|
-
const pingRes = this.pong(reqUrl);
|
|
99
|
-
this.signResponse(); // TODO
|
|
100
|
-
return void res.json(pingRes);
|
|
101
|
-
case "POST":
|
|
109
|
+
case "POST": {
|
|
102
110
|
console.log("It was a POST request");
|
|
103
111
|
// Inngest is trying to run a step; confirm signed and run.
|
|
104
112
|
const { fnId, stepId } = zod_1.z
|
|
@@ -115,6 +123,7 @@ class InngestCommHandler {
|
|
|
115
123
|
return void res.status(stepRes.status).json(stepRes.error);
|
|
116
124
|
}
|
|
117
125
|
return void res.status(stepRes.status).json(stepRes.body);
|
|
126
|
+
}
|
|
118
127
|
default:
|
|
119
128
|
return void res.sendStatus(405);
|
|
120
129
|
}
|
|
@@ -134,9 +143,15 @@ class InngestCommHandler {
|
|
|
134
143
|
};
|
|
135
144
|
}
|
|
136
145
|
catch (err) {
|
|
146
|
+
if (err instanceof Error) {
|
|
147
|
+
return {
|
|
148
|
+
status: 500,
|
|
149
|
+
error: err.stack || err.message,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
137
152
|
return {
|
|
138
153
|
status: 500,
|
|
139
|
-
error:
|
|
154
|
+
error: `Unknown error: ${JSON.stringify(err)}`,
|
|
140
155
|
};
|
|
141
156
|
}
|
|
142
157
|
}
|
|
@@ -146,18 +161,6 @@ class InngestCommHandler {
|
|
|
146
161
|
async register(url) {
|
|
147
162
|
const body = {
|
|
148
163
|
url: url.href,
|
|
149
|
-
hash: "TODO",
|
|
150
|
-
};
|
|
151
|
-
const config = {
|
|
152
|
-
headers: {
|
|
153
|
-
Authorization: `Bearer ${this.signingKey}`,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
const res = await this.client.post(this.inngestRegisterUrl.href, body, config);
|
|
157
|
-
console.log("hit the register URL", this.inngestRegisterUrl.href, "with:", body, "and", config, "and got back:", res.status, res.data);
|
|
158
|
-
}
|
|
159
|
-
pong(url) {
|
|
160
|
-
return {
|
|
161
164
|
deployType: "ping",
|
|
162
165
|
framework: this.frameworkName,
|
|
163
166
|
appName: this.name,
|
|
@@ -165,6 +168,13 @@ class InngestCommHandler {
|
|
|
165
168
|
sdk: `js:v${version_1.version}`,
|
|
166
169
|
v: "0.1",
|
|
167
170
|
};
|
|
171
|
+
const config = {
|
|
172
|
+
headers: {
|
|
173
|
+
Authorization: `Bearer ${this.hashedSigningKey}`,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
const res = await this.client.post(this.inngestRegisterUrl.href, body, config);
|
|
177
|
+
console.log("hit the register URL", this.inngestRegisterUrl.href, "with:", body, "and", config, "and got back:", res.status, res.data);
|
|
168
178
|
}
|
|
169
179
|
validateSignature() {
|
|
170
180
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/handlers/default.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/handlers/default.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;AACjE,oDAA4B;AAE5B,6BAAwB;AAGxB,8CAAuE;AAQvE,wCAAqC;AA2BrC;;;;;;;;GAQG;AACI,MAAM,QAAQ,GAAG,CACtB,GAAG,IAOkC,EACrC,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,MAAM,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAE7E,+DAA+D;IAC/D,OAAO,OAAO,CAAC,aAAa,EAAE,CAAC;AACjC,CAAC,CAAC;AApBW,QAAA,QAAQ,YAoBnB;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,kBAAkB;IAwB7B,YACE,aAAoC,EACpC,UAAkB,EAClB,SAAiC,EACjC,EAAE,kBAAkB,KAAsB,EAAE;QApB3B,kBAAa,GAAW,SAAS,CAAC;QAUrD;;;WAGG;QACc,QAAG,GAAyC,EAAE,CAAC;QAQ9D,IAAI,CAAC,IA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,EACP,IAAI,EACJ,KAAK,EACL,MAAM,EACN,eAAe,EACf,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,IAAI,CACT,CAAC;IACJ,CAAC;IAES,iBAAiB;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAES,YAAY;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AApOD,gDAoOC"}
|
package/dist/handlers/next.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { RegisterHandler } from "./default";
|
|
2
|
+
/**
|
|
3
|
+
* In Next.js, register any declared functions with Inngest, making them
|
|
4
|
+
* available to be triggered by events.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
2
8
|
export declare const register: RegisterHandler;
|
|
3
9
|
//# sourceMappingURL=next.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/handlers/next.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,eAAe,EAChB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/handlers/next.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,eAAe,EAChB,MAAM,WAAW,CAAC;AAiEnB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,eAStB,CAAC"}
|
package/dist/handlers/next.js
CHANGED
|
@@ -26,25 +26,18 @@ class NextCommHandler extends default_1.InngestCommHandler {
|
|
|
26
26
|
});
|
|
27
27
|
let reqUrl;
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
const scheme = process.env.NODE_ENV === "development" ? "http" : "https";
|
|
30
|
+
reqUrl = new URL(req.url, `${scheme}://${req.headers.host || ""}`);
|
|
30
31
|
}
|
|
31
32
|
catch (err) {
|
|
32
33
|
return void res.status(500).json(err);
|
|
33
34
|
}
|
|
34
35
|
switch (req.method) {
|
|
35
36
|
case "PUT":
|
|
36
|
-
console.log("It was a PUT request");
|
|
37
37
|
// Push config to Inngest.
|
|
38
38
|
await this.register(reqUrl);
|
|
39
39
|
return void res.status(200).end();
|
|
40
|
-
case "
|
|
41
|
-
console.log("It was a GET request");
|
|
42
|
-
// Inngest is asking for config; confirm signed and send.
|
|
43
|
-
this.validateSignature(); //TODO
|
|
44
|
-
const pingRes = this.pong(reqUrl);
|
|
45
|
-
this.signResponse(); // TODO
|
|
46
|
-
return void res.status(200).json(pingRes);
|
|
47
|
-
case "POST":
|
|
40
|
+
case "POST": {
|
|
48
41
|
console.log("It was a POST request");
|
|
49
42
|
// Inngest is trying to run a step; confirm signed and run.
|
|
50
43
|
const { fnId, stepId } = zod_1.z
|
|
@@ -57,13 +50,23 @@ class NextCommHandler extends default_1.InngestCommHandler {
|
|
|
57
50
|
stepId: req.query[consts_1.stepIdParam],
|
|
58
51
|
});
|
|
59
52
|
const stepRes = await this.runStep(fnId, stepId, req.body);
|
|
60
|
-
|
|
53
|
+
if (stepRes.status === 500) {
|
|
54
|
+
return void res.status(stepRes.status).json(stepRes.error);
|
|
55
|
+
}
|
|
56
|
+
return void res.status(stepRes.status).json(stepRes.body);
|
|
57
|
+
}
|
|
61
58
|
default:
|
|
62
59
|
return void res.status(405).end();
|
|
63
60
|
}
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* In Next.js, register any declared functions with Inngest, making them
|
|
66
|
+
* available to be triggered by events.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
67
70
|
const register = (nameOrInngest, signingKey, fns, opts) => {
|
|
68
71
|
return (0, default_1.register)(new NextCommHandler(nameOrInngest, signingKey, fns, opts));
|
|
69
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/handlers/next.ts"],"names":[],"mappings":";;;;;;AACA,8DAAmC;AACnC,6BAAwB;AACxB,8CAAuE;AACvE,uCAImB;AAEnB,MA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1,9 @@
|
|
|
1
|
+
import { RegisterHandler } from "./default";
|
|
2
|
+
/**
|
|
3
|
+
* In Remix, register any declared functions with Inngest, making them available
|
|
4
|
+
* to be triggered by events.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const register: RegisterHandler;
|
|
9
|
+
//# sourceMappingURL=remix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remix.d.ts","sourceRoot":"","sources":["../../src/handlers/remix.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,eAAe,EAChB,MAAM,WAAW,CAAC;AA0EnB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,eAStB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const cross_fetch_1 = require("cross-fetch");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const consts_1 = require("../helpers/consts");
|
|
7
|
+
const default_1 = require("./default");
|
|
8
|
+
/**
|
|
9
|
+
* app/inngest/index.server.ts
|
|
10
|
+
* app/routes/api/inngest.ts
|
|
11
|
+
*/
|
|
12
|
+
class RemixCommHandler extends default_1.InngestCommHandler {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.frameworkName = "remix";
|
|
16
|
+
}
|
|
17
|
+
createHandler() {
|
|
18
|
+
return async ({ request: req, }) => {
|
|
19
|
+
/**
|
|
20
|
+
* Specifically for CORS (browser->site requests), only allow PUT requests
|
|
21
|
+
* from the dashboard.
|
|
22
|
+
*/
|
|
23
|
+
if (req.method === "OPTIONS") {
|
|
24
|
+
return new cross_fetch_1.Response(null, {
|
|
25
|
+
status: 200,
|
|
26
|
+
headers: {
|
|
27
|
+
"Access-Control-Allow-Origin": consts_1.corsOrigin,
|
|
28
|
+
"Access-Control-Allow-Methods": "PUT",
|
|
29
|
+
"Access-Control-Allow-Headers": "Content-Type",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let reqUrl;
|
|
34
|
+
try {
|
|
35
|
+
reqUrl = new URL(req.url, `https://${req.headers.get("host") || ""}`);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return new cross_fetch_1.Response(JSON.stringify(err), {
|
|
39
|
+
status: 500,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
switch (req.method) {
|
|
43
|
+
case "PUT":
|
|
44
|
+
console.log("It was a PUT request");
|
|
45
|
+
// Push config to Inngest.
|
|
46
|
+
await this.register(reqUrl);
|
|
47
|
+
return new cross_fetch_1.Response(null, {
|
|
48
|
+
status: 200,
|
|
49
|
+
});
|
|
50
|
+
case "POST": {
|
|
51
|
+
console.log("It was a POST request");
|
|
52
|
+
// Inngest is trying to run a step; confirm signed and run.
|
|
53
|
+
const { fnId, stepId } = zod_1.z
|
|
54
|
+
.object({
|
|
55
|
+
fnId: zod_1.z.string().min(1),
|
|
56
|
+
stepId: zod_1.z.string().min(1),
|
|
57
|
+
})
|
|
58
|
+
.parse({
|
|
59
|
+
fnId: reqUrl.searchParams.get(consts_1.fnIdParam),
|
|
60
|
+
stepId: reqUrl.searchParams.get(consts_1.stepIdParam),
|
|
61
|
+
});
|
|
62
|
+
const stepRes = await this.runStep(fnId, stepId, req.body);
|
|
63
|
+
return new cross_fetch_1.Response(JSON.stringify(stepRes), { status: 200 });
|
|
64
|
+
}
|
|
65
|
+
default:
|
|
66
|
+
return new cross_fetch_1.Response(null, { status: 405 });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* In Remix, register any declared functions with Inngest, making them available
|
|
73
|
+
* to be triggered by events.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
const register = (nameOrInngest, signingKey, fns, opts) => {
|
|
78
|
+
return (0, default_1.register)(new RemixCommHandler(nameOrInngest, signingKey, fns, opts));
|
|
79
|
+
};
|
|
80
|
+
exports.register = register;
|
|
81
|
+
//# sourceMappingURL=remix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remix.js","sourceRoot":"","sources":["../../src/handlers/remix.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,6BAAwB;AACxB,8CAAuE;AACvE,uCAImB;AAEnB;;;GAGG;AACH,MAAM,gBAAiB,SAAQ,4BAAkB;IAAjD;;QACqB,kBAAa,GAAG,OAAO,CAAC;IAiE7C,CAAC;IA/DiB,aAAa;QAC3B,OAAO,KAAK,EAAE,EACZ,OAAO,EAAE,GAAG,GAGb,EAAqB,EAAE;YACtB;;;eAGG;YACH,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE;gBAC5B,OAAO,IAAI,sBAAQ,CAAC,IAAI,EAAE;oBACxB,MAAM,EAAE,GAAG;oBACX,OAAO,EAAE;wBACP,6BAA6B,EAAE,mBAAU;wBACzC,8BAA8B,EAAE,KAAK;wBACrC,8BAA8B,EAAE,cAAc;qBAC/C;iBACF,CAAC,CAAC;aACJ;YAED,IAAI,MAAW,CAAC;YAEhB,IAAI;gBACF,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;aACvE;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,IAAI,sBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,EAAE,GAAG;iBACZ,CAAC,CAAC;aACJ;YAED,QAAQ,GAAG,CAAC,MAAM,EAAE;gBAClB,KAAK,KAAK;oBACR,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;oBACpC,0BAA0B;oBAC1B,MAAM,IAAI,CAAC,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QAAA,QAAQ,YASnB"}
|
package/dist/helpers/func.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { InngestFunction } from "../components/InngestFunction";
|
|
2
2
|
import { EventPayload, FunctionOptions, StepFn } from "../types";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Given an event to listen to, run the given function when that event is
|
|
5
|
+
* seen.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare const createFunction: <Event_1 extends EventPayload>(nameOrOpts: string | FunctionOptions, event: Event_1 extends EventPayload ? (Event_1 extends infer T ? { [K in keyof T]: K extends "name" ? Event_1[K] : never; } : never)[keyof Event_1] : never, fn: StepFn<Event_1, string, "step">) => InngestFunction<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const createScheduledFunction: (nameOrOpts: string | FunctionOptions, cron: string, fn: StepFn<null, string, "step">) => InngestFunction<any>;
|
|
4
16
|
//# sourceMappingURL=func.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"func.d.ts","sourceRoot":"","sources":["../../src/helpers/func.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"func.d.ts","sourceRoot":"","sources":["../../src/helpers/func.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,6CAKb,MAAM,GAAG,eAAe,uMAenC,gBAAgB,GAAG,CAMrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,eAKtB,MAAM,GAAG,eAAe,QAe9B,MAAM,MAKR,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,KAC/B,gBAAgB,GAAG,CAMrB,CAAC"}
|
package/dist/helpers/func.js
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFunction = void 0;
|
|
3
|
+
exports.createScheduledFunction = exports.createFunction = void 0;
|
|
4
4
|
const InngestFunction_1 = require("../components/InngestFunction");
|
|
5
5
|
const InngestStep_1 = require("../components/InngestStep");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Given an event to listen to, run the given function when that event is
|
|
8
|
+
* seen.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
const createFunction = (
|
|
13
|
+
/**
|
|
14
|
+
* The name or options for this Inngest function - providing options is
|
|
15
|
+
* useful for defining a custom ID.
|
|
16
|
+
*/
|
|
17
|
+
nameOrOpts,
|
|
18
|
+
/**
|
|
19
|
+
* The event to listen for.
|
|
20
|
+
*/
|
|
21
|
+
event,
|
|
22
|
+
/**
|
|
23
|
+
* The function to run when the event is received.
|
|
24
|
+
*/
|
|
25
|
+
fn) => {
|
|
26
|
+
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { event: event }, { step: new InngestStep_1.InngestStep(fn) });
|
|
10
27
|
};
|
|
11
28
|
exports.createFunction = createFunction;
|
|
29
|
+
/**
|
|
30
|
+
* Run the given `fn` at a specified time or on a schedule given by `cron`.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
const createScheduledFunction = (
|
|
35
|
+
/**
|
|
36
|
+
* The name or options for this Inngest function - providing options is
|
|
37
|
+
* useful for defining a custom ID.
|
|
38
|
+
*/
|
|
39
|
+
nameOrOpts,
|
|
40
|
+
/**
|
|
41
|
+
* The cron definition to schedule your function.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* "0 0 0 1 1 * 1" // At 12:00 AM, on day 1 of the month, only in January, only in 0001
|
|
46
|
+
* "0 0 0 1 1 * 1,2" // At 12:00 AM, on day 1 of the month, only in January, only in 0001 and 0002
|
|
47
|
+
* "0 0 0 1 1 * 1,2,3" // At 12:00 AM, on day 1 of the month, only in January, only in 0001, 0002, and 0003
|
|
48
|
+
* "0 0 0 1 * * 1/4" // At 12:00 AM, on day 1 of the month, every 4 years
|
|
49
|
+
* "0 0 0 * * 0 1-4" // At 12:00 AM, only on Sunday, 0001 through 0004
|
|
50
|
+
* "0 0 0 * * * 2/4" // At 12:00 AM, every 4 years, 0002 through 9999
|
|
51
|
+
* "0 0 * * * * *" // Every hour
|
|
52
|
+
*/
|
|
53
|
+
cron,
|
|
54
|
+
/**
|
|
55
|
+
* The function to run.
|
|
56
|
+
*/
|
|
57
|
+
fn) => {
|
|
58
|
+
return new InngestFunction_1.InngestFunction(typeof nameOrOpts === "string" ? { name: nameOrOpts } : nameOrOpts, { cron }, { step: new InngestStep_1.InngestStep(fn) });
|
|
59
|
+
};
|
|
60
|
+
exports.createScheduledFunction = createScheduledFunction;
|
|
12
61
|
//# sourceMappingURL=func.js.map
|
package/dist/helpers/func.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"func.js","sourceRoot":"","sources":["../../src/helpers/func.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAChE,2DAAwD;
|
|
1
|
+
{"version":3,"file":"func.js","sourceRoot":"","sources":["../../src/helpers/func.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAChE,2DAAwD;AAGxD;;;;;GAKG;AACI,MAAM,cAAc,GAAG;AAC5B;;;GAGG;AACH,UAAoC;AAEpC;;GAEG;AACH,KAIS;AAET;;GAEG;AACH,EAAiC,EACX,EAAE;IACxB,OAAO,IAAI,iCAAe,CACxB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAClE,EAAE,KAAK,EAAE,KAAe,EAAE,EAC1B,EAAE,IAAI,EAAE,IAAI,yBAAW,CAAC,EAAE,CAAC,EAAE,CAC9B,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,cAAc,kBA0BzB;AAEF;;;;GAIG;AACI,MAAM,uBAAuB,GAAG;AACrC;;;GAGG;AACH,UAAoC;AAEpC;;;;;;;;;;;;GAYG;AACH,IAAY;AAEZ;;GAEG;AACH,EAAgC,EACV,EAAE;IACxB,OAAO,IAAI,iCAAe,CACxB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAClE,EAAE,IAAI,EAAE,EACR,EAAE,IAAI,EAAE,IAAI,yBAAW,CAAC,EAAE,CAAC,EAAE,CAC9B,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,uBAAuB,2BAgClC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Inngest } from "./components/Inngest";
|
|
2
2
|
export { InngestCommHandler, register, RegisterHandler, } from "./handlers/default";
|
|
3
|
-
export { createFunction } from "./helpers/func";
|
|
4
|
-
export { ClientOptions, FunctionOptions } from "./types";
|
|
3
|
+
export { createFunction, createScheduledFunction } from "./helpers/func";
|
|
4
|
+
export { ClientOptions, EventPayload, FunctionOptions, RegisterOptions, StepFn, } from "./types";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,EACf,MAAM,GACP,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFunction = exports.register = exports.InngestCommHandler = exports.Inngest = void 0;
|
|
3
|
+
exports.createScheduledFunction = exports.createFunction = exports.register = exports.InngestCommHandler = exports.Inngest = void 0;
|
|
4
4
|
var Inngest_1 = require("./components/Inngest");
|
|
5
5
|
Object.defineProperty(exports, "Inngest", { enumerable: true, get: function () { return Inngest_1.Inngest; } });
|
|
6
6
|
var default_1 = require("./handlers/default");
|
|
@@ -8,4 +8,5 @@ Object.defineProperty(exports, "InngestCommHandler", { enumerable: true, get: fu
|
|
|
8
8
|
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return default_1.register; } });
|
|
9
9
|
var func_1 = require("./helpers/func");
|
|
10
10
|
Object.defineProperty(exports, "createFunction", { enumerable: true, get: function () { return func_1.createFunction; } });
|
|
11
|
+
Object.defineProperty(exports, "createScheduledFunction", { enumerable: true, get: function () { return func_1.createScheduledFunction; } });
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAA+C;AAAtC,kGAAA,OAAO,OAAA;AAChB,8CAI4B;AAH1B,6GAAA,kBAAkB,OAAA;AAClB,mGAAA,QAAQ,OAAA;AAGV,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAA+C;AAAtC,kGAAA,OAAO,OAAA;AAChB,8CAI4B;AAH1B,6GAAA,kBAAkB,OAAA;AAClB,mGAAA,QAAQ,OAAA;AAGV,uCAAyE;AAAhE,sGAAA,cAAc,OAAA;AAAE,+GAAA,uBAAuB,OAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,10 +2,25 @@ import { InngestStep } from "./components/InngestStep";
|
|
|
2
2
|
/**
|
|
3
3
|
* The shape of a step function, taking in event, step, and ctx data, and
|
|
4
4
|
* outputting anything.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
5
7
|
*/
|
|
6
8
|
export declare type StepFn<Event, FnId, StepId> = (arg: {
|
|
9
|
+
/**
|
|
10
|
+
* If relevant, the event data present in the payload.
|
|
11
|
+
*/
|
|
7
12
|
event: Event;
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The potential step output from other steps in this function. You cannot
|
|
15
|
+
* reference output from the running step.
|
|
16
|
+
*
|
|
17
|
+
* Implementation here may well vary greatly depending on step function
|
|
18
|
+
* implementation.
|
|
19
|
+
*/
|
|
20
|
+
steps: Record<string, never>;
|
|
21
|
+
/**
|
|
22
|
+
* The "context" of the function.
|
|
23
|
+
*/
|
|
9
24
|
ctx: {
|
|
10
25
|
fn_id: FnId;
|
|
11
26
|
step_id: StepId;
|
|
@@ -15,6 +30,8 @@ export declare type StepFn<Event, FnId, StepId> = (arg: {
|
|
|
15
30
|
* The shape of a single event's payload. It should be extended to enforce
|
|
16
31
|
* adherence to given events and not used as a method of creating them (i.e. as
|
|
17
32
|
* a generic).
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
18
35
|
*/
|
|
19
36
|
export interface EventPayload {
|
|
20
37
|
/**
|
|
@@ -65,6 +82,8 @@ export interface EventPayload {
|
|
|
65
82
|
/**
|
|
66
83
|
* An HTTP-like, standardised response format that allows Inngest to help
|
|
67
84
|
* orchestrate steps and retries.
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
68
87
|
*/
|
|
69
88
|
export interface Response {
|
|
70
89
|
/**
|
|
@@ -80,20 +99,22 @@ export interface Response {
|
|
|
80
99
|
* A `5xx` status indicates a temporary internal error; this will be retried
|
|
81
100
|
* according to the step and function's retry policy (3 times, by default).
|
|
82
101
|
*
|
|
83
|
-
* @link https://www.inngest.com/docs/functions/function-input-and-output#response-format
|
|
84
|
-
* @link https://www.inngest.com/docs/functions/retries
|
|
102
|
+
* {@link https://www.inngest.com/docs/functions/function-input-and-output#response-format}
|
|
103
|
+
* {@link https://www.inngest.com/docs/functions/retries}
|
|
85
104
|
*/
|
|
86
105
|
status: number;
|
|
87
106
|
/**
|
|
88
107
|
* The output of the function - the `body` - can be any arbitrary
|
|
89
108
|
* JSON-compatible data. It is then usable by any future steps.
|
|
90
109
|
*
|
|
91
|
-
* @link https://www.inngest.com/docs/functions/function-input-and-output#response-format
|
|
110
|
+
* {@link https://www.inngest.com/docs/functions/function-input-and-output#response-format}
|
|
92
111
|
*/
|
|
93
112
|
body?: any;
|
|
94
113
|
}
|
|
95
114
|
/**
|
|
96
115
|
* A single step within a function.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
97
118
|
*/
|
|
98
119
|
export declare type Step<Context = any> = (
|
|
99
120
|
/**
|
|
@@ -103,6 +124,8 @@ export declare type Step<Context = any> = (
|
|
|
103
124
|
context: Context) => Promise<Response> | Response;
|
|
104
125
|
/**
|
|
105
126
|
* A set of options for configuring the Inngest client.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
106
129
|
*/
|
|
107
130
|
export interface ClientOptions {
|
|
108
131
|
/**
|
|
@@ -113,6 +136,8 @@ export interface ClientOptions {
|
|
|
113
136
|
}
|
|
114
137
|
/**
|
|
115
138
|
* A set of options for configuring the registration of Inngest functions.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
116
141
|
*/
|
|
117
142
|
export interface RegisterOptions {
|
|
118
143
|
/**
|
|
@@ -123,6 +148,8 @@ export interface RegisterOptions {
|
|
|
123
148
|
}
|
|
124
149
|
/**
|
|
125
150
|
* A set of options for configuring an Inngest function.
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
126
153
|
*/
|
|
127
154
|
export interface FunctionOptions {
|
|
128
155
|
/**
|
|
@@ -152,11 +179,15 @@ export interface FunctionOptions {
|
|
|
152
179
|
}
|
|
153
180
|
/**
|
|
154
181
|
* A shortcut type for a collection of Inngest steps.
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
155
184
|
*/
|
|
156
185
|
export declare type Steps = Record<string, InngestStep<any[], any>>;
|
|
157
186
|
/**
|
|
158
187
|
* Expected responses to be used within an `InngestCommHandler` in order to
|
|
159
188
|
* appropriately respond to Inngest.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
160
191
|
*/
|
|
161
192
|
export declare type StepRunResponse = {
|
|
162
193
|
status: 500;
|
|
@@ -168,8 +199,14 @@ export declare type StepRunResponse = {
|
|
|
168
199
|
/**
|
|
169
200
|
* The response to send to Inngest when pushing function config either directly
|
|
170
201
|
* or when pinged by Inngest Cloud.
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
171
204
|
*/
|
|
172
|
-
export interface
|
|
205
|
+
export interface RegisterRequest {
|
|
206
|
+
/**
|
|
207
|
+
* The API handler's URL to invoke SDK based functions.
|
|
208
|
+
*/
|
|
209
|
+
url: string;
|
|
173
210
|
/**
|
|
174
211
|
* Response version, allowing Inngest to change any top-level field.
|
|
175
212
|
*/
|
|
@@ -198,20 +235,32 @@ export interface RegisterPingResponse {
|
|
|
198
235
|
* The functions available at this particular handler.
|
|
199
236
|
*/
|
|
200
237
|
functions: FunctionConfig[];
|
|
238
|
+
/**
|
|
239
|
+
* The hash of the current commit used to track deploys
|
|
240
|
+
*/
|
|
241
|
+
hash?: string;
|
|
201
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* An individual function trigger.
|
|
245
|
+
*
|
|
246
|
+
* @internal
|
|
247
|
+
*/
|
|
248
|
+
export declare type FunctionTrigger<T = string> = {
|
|
249
|
+
event: T;
|
|
250
|
+
expression?: string;
|
|
251
|
+
} | {
|
|
252
|
+
cron: string;
|
|
253
|
+
};
|
|
202
254
|
/**
|
|
203
255
|
* A block representing an individual function being registered to Inngest
|
|
204
256
|
* Cloud.
|
|
257
|
+
*
|
|
258
|
+
* @internal
|
|
205
259
|
*/
|
|
206
260
|
export interface FunctionConfig {
|
|
207
261
|
name: string;
|
|
208
262
|
id: string;
|
|
209
|
-
triggers:
|
|
210
|
-
event: string;
|
|
211
|
-
expression?: string;
|
|
212
|
-
} | {
|
|
213
|
-
cron: string;
|
|
214
|
-
})[];
|
|
263
|
+
triggers: FunctionTrigger[];
|
|
215
264
|
steps: Record<string, {
|
|
216
265
|
id: string;
|
|
217
266
|
name: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;GAKG;AACH,oBAAY,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,GAAG,EAAE;IAC9C;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;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AE,CAAC;IAC5B,KAAK,EAAE,MAAM,CACX,MAAM,EACN;QACE,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CACF,CAAC;CACH"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.4.0-beta.
|
|
1
|
+
export declare const version = "0.4.0-beta.7";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inngest",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.7",
|
|
4
4
|
"description": "Official SDK for Inngest.com",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"clean": "rm -rf ./dist",
|
|
15
15
|
"prepare": "yarn run build",
|
|
16
|
-
"release": "yarn run np"
|
|
16
|
+
"release": "yarn run np",
|
|
17
|
+
"api-extractor": "api-extractor",
|
|
18
|
+
"dev": "concurrently --names Build,Lint --prefix-colors \"green.inverse,magenta.inverse\" --handle-input \"yarn run dev:build\" \"yarn run dev:lint\"",
|
|
19
|
+
"dev:build": "nodemon -w src -e ts -i version.ts --delay 300ms -x 'yarn run build && yarn run build:check --local'",
|
|
20
|
+
"dev:lint": "nodemon -w src -e ts -i version.ts --delay 300ms -x 'eslint .'",
|
|
21
|
+
"build:api": "api-extractor run --local --verbose",
|
|
22
|
+
"build:check": "api-extractor run --verbose"
|
|
17
23
|
},
|
|
18
24
|
"homepage": "https://github.com/inngest/inngest-js#readme",
|
|
19
25
|
"repository": {
|
|
@@ -38,14 +44,28 @@
|
|
|
38
44
|
"zod": "^3.19.1"
|
|
39
45
|
},
|
|
40
46
|
"devDependencies": {
|
|
47
|
+
"@microsoft/api-extractor": "^7.31.1",
|
|
41
48
|
"@types/express": "^4.17.13",
|
|
42
49
|
"@types/jest": "^27.4.1",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
51
|
+
"@typescript-eslint/parser": "^5.38.0",
|
|
52
|
+
"concurrently": "^7.4.0",
|
|
53
|
+
"cross-fetch": "^3.1.5",
|
|
54
|
+
"eslint": "^8.23.1",
|
|
55
|
+
"eslint-config-prettier": "^8.5.0",
|
|
56
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
43
57
|
"express": "^4.18.1",
|
|
44
58
|
"genversion": "^3.1.1",
|
|
45
59
|
"jest": "27.5.1",
|
|
46
60
|
"next": "^12.3.0",
|
|
61
|
+
"nodemon": "^2.0.20",
|
|
47
62
|
"np": "^7.6.1",
|
|
63
|
+
"prettier": "^2.7.1",
|
|
48
64
|
"ts-jest": "^27.1.4",
|
|
49
|
-
"typescript": "^4.
|
|
65
|
+
"typescript": "^4.8.3"
|
|
66
|
+
},
|
|
67
|
+
"volta": {
|
|
68
|
+
"node": "16.17.0",
|
|
69
|
+
"yarn": "1.22.19"
|
|
50
70
|
}
|
|
51
71
|
}
|