inngest 2.7.1 → 3.0.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 +52 -0
- package/api/api.js +4 -4
- package/api/schema.d.ts +54 -6
- package/api/schema.d.ts.map +1 -1
- package/api/schema.js +17 -7
- package/api/schema.js.map +1 -1
- package/cloudflare.d.ts +6 -3
- package/cloudflare.d.ts.map +1 -1
- package/cloudflare.js +19 -41
- package/cloudflare.js.map +1 -1
- package/components/EventSchemas.d.ts +1 -12
- package/components/EventSchemas.d.ts.map +1 -1
- package/components/EventSchemas.js.map +1 -1
- package/components/Inngest.d.ts +44 -57
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js +91 -59
- package/components/Inngest.js.map +1 -1
- package/components/InngestCommHandler.d.ts +156 -198
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +311 -305
- package/components/InngestCommHandler.js.map +1 -1
- package/components/InngestFunction.d.ts +9 -82
- package/components/InngestFunction.d.ts.map +1 -1
- package/components/InngestFunction.js +21 -413
- package/components/InngestFunction.js.map +1 -1
- package/components/InngestMiddleware.d.ts +37 -26
- package/components/InngestMiddleware.d.ts.map +1 -1
- package/components/InngestMiddleware.js +1 -3
- package/components/InngestMiddleware.js.map +1 -1
- package/components/InngestStepTools.d.ts +69 -37
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +34 -95
- package/components/InngestStepTools.js.map +1 -1
- package/components/NonRetriableError.d.ts.map +1 -1
- package/components/NonRetriableError.js +1 -0
- package/components/NonRetriableError.js.map +1 -1
- package/components/RetryAfterError.d.ts +38 -0
- package/components/RetryAfterError.d.ts.map +1 -0
- package/components/RetryAfterError.js +42 -0
- package/components/RetryAfterError.js.map +1 -0
- package/components/execution/InngestExecution.d.ts +72 -0
- package/components/execution/InngestExecution.d.ts.map +1 -0
- package/components/execution/InngestExecution.js +23 -0
- package/components/execution/InngestExecution.js.map +1 -0
- package/components/execution/v0.d.ts +114 -0
- package/components/execution/v0.d.ts.map +1 -0
- package/components/execution/v0.js +394 -0
- package/components/execution/v0.js.map +1 -0
- package/components/execution/v1.d.ts +88 -0
- package/components/execution/v1.d.ts.map +1 -0
- package/components/execution/v1.js +673 -0
- package/components/execution/v1.js.map +1 -0
- package/deno/fresh.d.ts +3 -3
- package/deno/fresh.d.ts.map +1 -1
- package/deno/fresh.js +17 -38
- package/deno/fresh.js.map +1 -1
- package/digitalocean.d.ts +5 -5
- package/digitalocean.d.ts.map +1 -1
- package/digitalocean.js +14 -46
- package/digitalocean.js.map +1 -1
- package/edge.d.ts +5 -5
- package/edge.d.ts.map +1 -1
- package/edge.js +16 -38
- package/edge.js.map +1 -1
- package/express.d.ts +7 -3
- package/express.d.ts.map +1 -1
- package/express.js +38 -45
- package/express.js.map +1 -1
- package/fastify.d.ts +8 -3
- package/fastify.d.ts.map +1 -1
- package/fastify.js +37 -47
- package/fastify.js.map +1 -1
- package/h3.d.ts +4 -3
- package/h3.d.ts.map +1 -1
- package/h3.js +18 -45
- package/h3.js.map +1 -1
- package/helpers/ServerTiming.d.ts.map +1 -1
- package/helpers/ServerTiming.js +2 -1
- package/helpers/ServerTiming.js.map +1 -1
- package/helpers/consts.d.ts +23 -9
- package/helpers/consts.d.ts.map +1 -1
- package/helpers/consts.js +31 -13
- package/helpers/consts.js.map +1 -1
- package/helpers/devserver.d.ts +0 -34
- package/helpers/devserver.d.ts.map +1 -1
- package/helpers/devserver.js.map +1 -1
- package/helpers/env.d.ts +14 -6
- package/helpers/env.d.ts.map +1 -1
- package/helpers/env.js +4 -4
- package/helpers/env.js.map +1 -1
- package/helpers/errors.d.ts +37 -2
- package/helpers/errors.d.ts.map +1 -1
- package/helpers/errors.js +66 -15
- package/helpers/errors.js.map +1 -1
- package/helpers/functions.d.ts +52 -5
- package/helpers/functions.d.ts.map +1 -1
- package/helpers/functions.js +121 -22
- package/helpers/functions.js.map +1 -1
- package/helpers/promises.d.ts +45 -0
- package/helpers/promises.d.ts.map +1 -1
- package/helpers/promises.js +69 -1
- package/helpers/promises.js.map +1 -1
- package/helpers/strings.d.ts +6 -1
- package/helpers/strings.d.ts.map +1 -1
- package/helpers/strings.js +7 -2
- package/helpers/strings.js.map +1 -1
- package/helpers/types.d.ts +5 -17
- package/helpers/types.d.ts.map +1 -1
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/lambda.d.ts +10 -8
- package/lambda.d.ts.map +1 -1
- package/lambda.js +48 -72
- package/lambda.js.map +1 -1
- package/next.d.ts +11 -5
- package/next.d.ts.map +1 -1
- package/next.js +84 -103
- package/next.js.map +1 -1
- package/nuxt.d.ts +3 -3
- package/nuxt.d.ts.map +1 -1
- package/nuxt.js +5 -6
- package/nuxt.js.map +1 -1
- package/package.json +5 -4
- package/redwood.d.ts +4 -3
- package/redwood.d.ts.map +1 -1
- package/redwood.js +22 -48
- package/redwood.js.map +1 -1
- package/remix.d.ts +7 -5
- package/remix.d.ts.map +1 -1
- package/remix.js +15 -36
- package/remix.js.map +1 -1
- package/types.d.ts +150 -218
- package/types.d.ts.map +1 -1
- package/types.js +38 -45
- package/types.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/helpers/scalar.d.ts +0 -8
- package/helpers/scalar.d.ts.map +0 -1
- package/helpers/scalar.js +0 -19
- package/helpers/scalar.js.map +0 -1
|
@@ -1,61 +1,90 @@
|
|
|
1
1
|
import { ServerTiming } from "../helpers/ServerTiming";
|
|
2
|
+
import { type Env } from "../helpers/env";
|
|
2
3
|
import { type MaybePromise } from "../helpers/types";
|
|
3
|
-
import { type FunctionConfig, type LogLevel, type RegisterOptions, type RegisterRequest
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
4
|
+
import { type FunctionConfig, type LogLevel, type RegisterOptions, type RegisterRequest } from "../types";
|
|
5
|
+
import { type AnyInngest } from "./Inngest";
|
|
6
|
+
import { type AnyInngestFunction } from "./InngestFunction";
|
|
7
|
+
import { ExecutionVersion, type ExecutionResult } from "./execution/InngestExecution";
|
|
6
8
|
/**
|
|
7
|
-
* A
|
|
8
|
-
*
|
|
9
|
-
* registration process is always the same for the user.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* // my-custom-handler.ts
|
|
14
|
-
* import { InngestCommHandler, ServeHandler } from "inngest";
|
|
15
|
-
*
|
|
16
|
-
* export const serve: ServeHandler = (nameOrInngest, fns, opts) => {
|
|
17
|
-
* const handler = new InngestCommHandler(
|
|
18
|
-
* "my-custom-handler",
|
|
19
|
-
* nameOrInngest,
|
|
20
|
-
* fns,
|
|
21
|
-
* opts,
|
|
22
|
-
* () => { ... },
|
|
23
|
-
* () => { ... }
|
|
24
|
-
* );
|
|
25
|
-
*
|
|
26
|
-
* return handler.createHandler();
|
|
27
|
-
* };
|
|
28
|
-
* ```
|
|
9
|
+
* A set of options that can be passed to a serve handler, intended to be used
|
|
10
|
+
* by internal and custom serve handlers to provide a consistent interface.
|
|
29
11
|
*
|
|
30
12
|
* @public
|
|
31
13
|
*/
|
|
32
|
-
export
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
14
|
+
export interface ServeHandlerOptions extends RegisterOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The `Inngest` instance used to declare all functions.
|
|
17
|
+
*/
|
|
18
|
+
client: AnyInngest;
|
|
19
|
+
/**
|
|
20
|
+
* An array of the functions to serve and register with Inngest.
|
|
21
|
+
*/
|
|
22
|
+
functions: readonly AnyInngestFunction[];
|
|
23
|
+
}
|
|
24
|
+
export interface InternalServeHandlerOptions extends ServeHandlerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Can be used to override the framework name given to a particular serve
|
|
27
|
+
* handler.
|
|
28
|
+
*/
|
|
29
|
+
frameworkName?: string;
|
|
30
|
+
}
|
|
31
|
+
interface InngestCommHandlerOptions<Input extends any[] = any[], Output = any, StreamOutput = any> extends RegisterOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The name of the framework this handler is designed for. Should be
|
|
34
|
+
* lowercase, alphanumeric characters inclusive of `-` and `/`.
|
|
35
|
+
*
|
|
36
|
+
* This should never be defined by the user; a {@link ServeHandler} should
|
|
37
|
+
* abstract this.
|
|
38
|
+
*/
|
|
39
|
+
frameworkName: string;
|
|
40
|
+
/**
|
|
41
|
+
* The name of this serve handler, e.g. `"My App"`. It's recommended that this
|
|
42
|
+
* value represents the overarching app/service that this set of functions is
|
|
43
|
+
* being served from.
|
|
44
|
+
*
|
|
45
|
+
* This can also be an `Inngest` client, in which case the name given when
|
|
46
|
+
* instantiating the client is used. This is useful if you're sending and
|
|
47
|
+
* receiving events from the same service, as you can reuse a single
|
|
48
|
+
* definition of Inngest.
|
|
49
|
+
*/
|
|
50
|
+
client: AnyInngest;
|
|
51
|
+
/**
|
|
52
|
+
* An array of the functions to serve and register with Inngest.
|
|
53
|
+
*/
|
|
54
|
+
functions: readonly AnyInngestFunction[];
|
|
55
|
+
/**
|
|
56
|
+
* The `handler` is the function your framework requires to handle a
|
|
57
|
+
* request. For example, this is most commonly a function that is given a
|
|
58
|
+
* `Request` and must return a `Response`.
|
|
59
|
+
*
|
|
60
|
+
* The handler must map out any incoming parameters, then return a
|
|
61
|
+
* strictly-typed object to assess what kind of request is being made,
|
|
62
|
+
* collecting any relevant data as we go.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```
|
|
66
|
+
* return {
|
|
67
|
+
* register: () => { ... },
|
|
68
|
+
* run: () => { ... },
|
|
69
|
+
* view: () => { ... }
|
|
70
|
+
* };
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Every key must be specified and must be a function that either returns
|
|
74
|
+
* a strictly-typed payload or `undefined` if the request is not for that
|
|
75
|
+
* purpose.
|
|
76
|
+
*
|
|
77
|
+
* This gives handlers freedom to choose how their platform of choice will
|
|
78
|
+
* trigger differing actions, whilst also ensuring all required information
|
|
79
|
+
* is given for each request type.
|
|
80
|
+
*
|
|
81
|
+
* See any existing handler for a full example.
|
|
82
|
+
*
|
|
83
|
+
* This should never be defined by the user; a {@link ServeHandler} should
|
|
84
|
+
* abstract this.
|
|
85
|
+
*/
|
|
86
|
+
handler: Handler<Input, Output, StreamOutput>;
|
|
87
|
+
}
|
|
59
88
|
/**
|
|
60
89
|
* `InngestCommHandler` is a class for handling incoming requests from Inngest (or
|
|
61
90
|
* Inngest's tooling such as the dev server or CLI) and taking appropriate
|
|
@@ -91,30 +120,24 @@ opts?: RegisterOptions
|
|
|
91
120
|
*
|
|
92
121
|
* @public
|
|
93
122
|
*/
|
|
94
|
-
export declare class InngestCommHandler<
|
|
123
|
+
export declare class InngestCommHandler<Input extends any[] = any[], Output = any, StreamOutput = any> {
|
|
95
124
|
/**
|
|
96
|
-
* The
|
|
125
|
+
* The ID of this serve handler, e.g. `"my-app"`. It's recommended that this
|
|
97
126
|
* value represents the overarching app/service that this set of functions is
|
|
98
127
|
* being served from.
|
|
99
128
|
*/
|
|
100
|
-
readonly
|
|
129
|
+
readonly id: string;
|
|
101
130
|
/**
|
|
102
131
|
* The handler specified during instantiation of the class.
|
|
103
132
|
*/
|
|
104
|
-
readonly handler:
|
|
105
|
-
/**
|
|
106
|
-
* The response transformer specified during instantiation of the class.
|
|
107
|
-
*/
|
|
108
|
-
readonly transformRes: TResTransform;
|
|
109
|
-
readonly streamTransformRes: TStreamTransform | undefined;
|
|
133
|
+
readonly handler: Handler;
|
|
110
134
|
/**
|
|
111
135
|
* The URL of the Inngest function registration endpoint.
|
|
112
136
|
*/
|
|
113
137
|
private readonly inngestRegisterUrl;
|
|
114
138
|
/**
|
|
115
139
|
* The name of the framework this handler is designed for. Should be
|
|
116
|
-
* lowercase, alphanumeric characters inclusive of `-` and `/`.
|
|
117
|
-
* never be defined by the user; a {@link ServeHandler} should abstract this.
|
|
140
|
+
* lowercase, alphanumeric characters inclusive of `-` and `/`.
|
|
118
141
|
*/
|
|
119
142
|
protected readonly frameworkName: string;
|
|
120
143
|
/**
|
|
@@ -188,106 +211,9 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
188
211
|
* to find and register functions when interacting with Inngest Cloud.
|
|
189
212
|
*/
|
|
190
213
|
private readonly fns;
|
|
214
|
+
private env;
|
|
191
215
|
private allowExpiredSignatures;
|
|
192
|
-
constructor(
|
|
193
|
-
/**
|
|
194
|
-
* The name of the framework this handler is designed for. Should be
|
|
195
|
-
* lowercase, alphanumeric characters inclusive of `-` and `/`.
|
|
196
|
-
*
|
|
197
|
-
* This should never be defined by the user; a {@link ServeHandler} should
|
|
198
|
-
* abstract this.
|
|
199
|
-
*/
|
|
200
|
-
frameworkName: string,
|
|
201
|
-
/**
|
|
202
|
-
* The name of this serve handler, e.g. `"My App"`. It's recommended that this
|
|
203
|
-
* value represents the overarching app/service that this set of functions is
|
|
204
|
-
* being served from.
|
|
205
|
-
*
|
|
206
|
-
* This can also be an `Inngest` client, in which case the name given when
|
|
207
|
-
* instantiating the client is used. This is useful if you're sending and
|
|
208
|
-
* receiving events from the same service, as you can reuse a single
|
|
209
|
-
* definition of Inngest.
|
|
210
|
-
*/
|
|
211
|
-
client: Inngest<any>,
|
|
212
|
-
/**
|
|
213
|
-
* An array of the functions to serve and register with Inngest.
|
|
214
|
-
*/
|
|
215
|
-
functions: InngestFunction<any, any, any, any>[], options: RegisterOptions | undefined,
|
|
216
|
-
/**
|
|
217
|
-
* The `handler` is the function your framework requires to handle a
|
|
218
|
-
* request. For example, this is most commonly a function that is given a
|
|
219
|
-
* `Request` and must return a `Response`.
|
|
220
|
-
*
|
|
221
|
-
* The handler must map out any incoming parameters, then return a
|
|
222
|
-
* strictly-typed object to assess what kind of request is being made,
|
|
223
|
-
* collecting any relevant data as we go.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* ```
|
|
227
|
-
* return {
|
|
228
|
-
* register: () => { ... },
|
|
229
|
-
* run: () => { ... },
|
|
230
|
-
* view: () => { ... }
|
|
231
|
-
* };
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* Every key must be specified and must be a function that either returns
|
|
235
|
-
* a strictly-typed payload or `undefined` if the request is not for that
|
|
236
|
-
* purpose.
|
|
237
|
-
*
|
|
238
|
-
* This gives handlers freedom to choose how their platform of choice will
|
|
239
|
-
* trigger differing actions, whilst also ensuring all required information
|
|
240
|
-
* is given for each request type.
|
|
241
|
-
*
|
|
242
|
-
* See any existing handler for a full example.
|
|
243
|
-
*
|
|
244
|
-
* This should never be defined by the user; a {@link ServeHandler} should
|
|
245
|
-
* abstract this.
|
|
246
|
-
*/
|
|
247
|
-
handler: H,
|
|
248
|
-
/**
|
|
249
|
-
* The `transformRes` function receives the output of the Inngest SDK and
|
|
250
|
-
* can decide how to package up that information to appropriately return the
|
|
251
|
-
* information to Inngest.
|
|
252
|
-
*
|
|
253
|
-
* Mostly, this is taking the given parameters and returning a new
|
|
254
|
-
* `Response`.
|
|
255
|
-
*
|
|
256
|
-
* The function is passed an {@link ActionResponse} (an object containing a
|
|
257
|
-
* `status` code, a `headers` object, and a stringified `body`), as well as
|
|
258
|
-
* every parameter passed to the given `handler` function. This ensures you
|
|
259
|
-
* can appropriately handle the response, including use of any required
|
|
260
|
-
* parameters such as `res` in Express-/Connect-like frameworks.
|
|
261
|
-
*
|
|
262
|
-
* This should never be defined by the user; a {@link ServeHandler} should
|
|
263
|
-
* abstract this.
|
|
264
|
-
*/
|
|
265
|
-
transformRes: TResTransform,
|
|
266
|
-
/**
|
|
267
|
-
* The `streamTransformRes` function, if defined, declares that this handler
|
|
268
|
-
* supports streaming responses back to Inngest. This is useful for
|
|
269
|
-
* functions that are expected to take a long time, as edge streaming can
|
|
270
|
-
* often circumvent restrictive request timeouts and other limitations.
|
|
271
|
-
*
|
|
272
|
-
* If your handler does not support streaming, do not define this function.
|
|
273
|
-
*
|
|
274
|
-
* It receives the output of the Inngest SDK and can decide how to package
|
|
275
|
-
* up that information to appropriately return the information in a stream
|
|
276
|
-
* to Inngest.
|
|
277
|
-
*
|
|
278
|
-
* Mostly, this is taking the given parameters and returning a new
|
|
279
|
-
* `Response`.
|
|
280
|
-
*
|
|
281
|
-
* The function is passed an {@link ActionResponse} (an object containing a
|
|
282
|
-
* `status` code, a `headers` object, and `body`, a `ReadableStream`), as
|
|
283
|
-
* well as every parameter passed to the given `handler` function. This
|
|
284
|
-
* ensures you can appropriately handle the response, including use of any
|
|
285
|
-
* required parameters such as `res` in Express-/Connect-like frameworks.
|
|
286
|
-
*
|
|
287
|
-
* This should never be defined by the user; a {@link ServeHandler} should
|
|
288
|
-
* abstract this.
|
|
289
|
-
*/
|
|
290
|
-
streamTransformRes?: TStreamTransform);
|
|
216
|
+
constructor(options: InngestCommHandlerOptions<Input, Output, StreamOutput>);
|
|
291
217
|
private get hashedSigningKey();
|
|
292
218
|
/**
|
|
293
219
|
* `createHandler` should be used to return a type-equivalent version of the
|
|
@@ -312,7 +238,7 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
312
238
|
* };
|
|
313
239
|
* ```
|
|
314
240
|
*/
|
|
315
|
-
createHandler(): (...args:
|
|
241
|
+
createHandler(): (...args: Input) => Promise<Awaited<Output>>;
|
|
316
242
|
/**
|
|
317
243
|
* Given a set of functions to check if an action is available from the
|
|
318
244
|
* instance's handler, enact any action that is found.
|
|
@@ -325,7 +251,10 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
325
251
|
* found (e.g. env vars, options, etc).
|
|
326
252
|
*/
|
|
327
253
|
private handleAction;
|
|
328
|
-
protected runStep(functionId: string, stepId: string | null, data: unknown, timer: ServerTiming):
|
|
254
|
+
protected runStep(functionId: string, stepId: string | null, data: unknown, timer: ServerTiming): {
|
|
255
|
+
version: ExecutionVersion;
|
|
256
|
+
result: Promise<ExecutionResult>;
|
|
257
|
+
};
|
|
329
258
|
protected configs(url: URL): FunctionConfig[];
|
|
330
259
|
/**
|
|
331
260
|
* Return an Inngest serve endpoint URL given a potential `path` and `host`.
|
|
@@ -335,7 +264,7 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
335
264
|
*/
|
|
336
265
|
protected reqUrl(url: URL): URL;
|
|
337
266
|
protected registerBody(url: URL): RegisterRequest;
|
|
338
|
-
protected register(url: URL,
|
|
267
|
+
protected register(url: URL, deployId: string | undefined | null, getHeaders: () => Record<string, string>): Promise<{
|
|
339
268
|
status: number;
|
|
340
269
|
message: string;
|
|
341
270
|
modified: boolean;
|
|
@@ -347,7 +276,7 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
347
276
|
* are otherwise difficult to access during initialization.
|
|
348
277
|
*/
|
|
349
278
|
private upsertKeysFromEnv;
|
|
350
|
-
protected validateSignature(sig: string | undefined, body:
|
|
279
|
+
protected validateSignature(sig: string | undefined, body: unknown): void;
|
|
351
280
|
protected signResponse(): string;
|
|
352
281
|
/**
|
|
353
282
|
* Log to stdout/stderr if the log level is set to include the given level.
|
|
@@ -363,16 +292,57 @@ export declare class InngestCommHandler<H extends Handler, TResTransform extends
|
|
|
363
292
|
* The broad definition of a handler passed when instantiating an
|
|
364
293
|
* {@link InngestCommHandler} instance.
|
|
365
294
|
*/
|
|
366
|
-
type Handler = (...args:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
295
|
+
export type Handler<Input extends any[] = any[], Output = any, StreamOutput = any> = (...args: Input) => HandlerResponse<Output, StreamOutput>;
|
|
296
|
+
export type HandlerResponse<Output = any, StreamOutput = any> = {
|
|
297
|
+
body: () => MaybePromise<any>;
|
|
298
|
+
env?: () => MaybePromise<Env>;
|
|
299
|
+
headers: (key: string) => MaybePromise<string | null | undefined>;
|
|
300
|
+
/**
|
|
301
|
+
* Whether the current environment is production. This is used to determine
|
|
302
|
+
* some functionality like whether to connect to the dev server or whether to
|
|
303
|
+
* show debug logging.
|
|
304
|
+
*
|
|
305
|
+
* If this is not provided--or is provided and returns `undefined`--we'll try
|
|
306
|
+
* to automatically detect whether we're in production by checking various
|
|
307
|
+
* environment variables.
|
|
308
|
+
*/
|
|
309
|
+
isProduction?: () => MaybePromise<boolean | undefined>;
|
|
310
|
+
method: () => MaybePromise<string>;
|
|
311
|
+
queryString?: (key: string, url: URL) => MaybePromise<string | null | undefined>;
|
|
312
|
+
url: () => MaybePromise<URL>;
|
|
313
|
+
/**
|
|
314
|
+
* The `transformResponse` function receives the output of the Inngest SDK and
|
|
315
|
+
* can decide how to package up that information to appropriately return the
|
|
316
|
+
* information to Inngest.
|
|
317
|
+
*
|
|
318
|
+
* Mostly, this is taking the given parameters and returning a new `Response`.
|
|
319
|
+
*
|
|
320
|
+
* The function is passed an {@link ActionResponse}, an object containing a
|
|
321
|
+
* `status` code, a `headers` object, and a stringified `body`. This ensures
|
|
322
|
+
* you can appropriately handle the response, including use of any required
|
|
323
|
+
* parameters such as `res` in Express-/Connect-like frameworks.
|
|
324
|
+
*/
|
|
325
|
+
transformResponse: (res: ActionResponse<string>) => Output;
|
|
326
|
+
/**
|
|
327
|
+
* The `transformStreamingResponse` function, if defined, declares that this
|
|
328
|
+
* handler supports streaming responses back to Inngest. This is useful for
|
|
329
|
+
* functions that are expected to take a long time, as edge streaming can
|
|
330
|
+
* often circumvent restrictive request timeouts and other limitations.
|
|
331
|
+
*
|
|
332
|
+
* If your handler does not support streaming, do not define this function.
|
|
333
|
+
*
|
|
334
|
+
* It receives the output of the Inngest SDK and can decide how to package
|
|
335
|
+
* up that information to appropriately return the information in a stream
|
|
336
|
+
* to Inngest.
|
|
337
|
+
*
|
|
338
|
+
* Mostly, this is taking the given parameters and returning a new `Response`.
|
|
339
|
+
*
|
|
340
|
+
* The function is passed an {@link ActionResponse}, an object containing a
|
|
341
|
+
* `status` code, a `headers` object, and `body`, a `ReadableStream`. This
|
|
342
|
+
* ensures you can appropriately handle the response, including use of any
|
|
343
|
+
* required parameters such as `res` in Express-/Connect-like frameworks.
|
|
344
|
+
*/
|
|
345
|
+
transformStreamingResponse?: (res: ActionResponse<ReadableStream>) => StreamOutput;
|
|
376
346
|
};
|
|
377
347
|
/**
|
|
378
348
|
* The response from the Inngest SDK before it is transformed in to a
|
|
@@ -391,28 +361,16 @@ export interface ActionResponse<TBody extends string | ReadableStream = string>
|
|
|
391
361
|
* A stringified body to return.
|
|
392
362
|
*/
|
|
393
363
|
body: TBody;
|
|
364
|
+
/**
|
|
365
|
+
* The version of the execution engine that was used to run this action.
|
|
366
|
+
*
|
|
367
|
+
* If the action didn't use the execution engine (for example, a GET request
|
|
368
|
+
* as a health check), this will be `undefined`.
|
|
369
|
+
*
|
|
370
|
+
* If the version should be entirely omitted from the response (for example,
|
|
371
|
+
* when sending preliminary headers when streaming), this will be `null`.
|
|
372
|
+
*/
|
|
373
|
+
version: ExecutionVersion | null | undefined;
|
|
394
374
|
}
|
|
395
|
-
/**
|
|
396
|
-
* A set of actions the SDK is aware of, including any payloads they require
|
|
397
|
-
* when requesting them.
|
|
398
|
-
*/
|
|
399
|
-
type HandlerAction = {
|
|
400
|
-
action: "error";
|
|
401
|
-
data: Record<string, string>;
|
|
402
|
-
} | {
|
|
403
|
-
action: "view";
|
|
404
|
-
isIntrospection: boolean;
|
|
405
|
-
} | {
|
|
406
|
-
action: "register";
|
|
407
|
-
deployId?: null | string;
|
|
408
|
-
} | {
|
|
409
|
-
action: "run";
|
|
410
|
-
fnId: string;
|
|
411
|
-
stepId: string | null;
|
|
412
|
-
data: Record<string, unknown>;
|
|
413
|
-
signature: string | undefined;
|
|
414
|
-
} | {
|
|
415
|
-
action: "bad-method";
|
|
416
|
-
};
|
|
417
375
|
export {};
|
|
418
376
|
//# sourceMappingURL=InngestCommHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestCommHandler.d.ts","sourceRoot":"","sources":["../../src/components/InngestCommHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InngestCommHandler.d.ts","sourceRoot":"","sources":["../../src/components/InngestCommHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAUvD,OAAO,EAQL,KAAK,GAAG,EACT,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAGL,KAAK,cAAc,EAEnB,KAAK,QAAQ,EAEb,KAAK,eAAe,EACpB,KAAK,eAAe,EAErB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAEhB,KAAK,eAAe,EAIrB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,yBAAyB,CAEjC,KAAK,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAE3B,MAAM,GAAG,GAAG,EAEZ,YAAY,GAAG,GAAG,CAClB,SAAQ,eAAe;IACvB;;;;;;OAMG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