effect-inngest 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +457 -0
  3. package/dist/Client.d.ts +167 -0
  4. package/dist/Client.js +144 -0
  5. package/dist/Events.d.ts +110 -0
  6. package/dist/Events.js +93 -0
  7. package/dist/Function.d.ts +384 -0
  8. package/dist/Function.js +104 -0
  9. package/dist/Group.d.ts +152 -0
  10. package/dist/Group.js +164 -0
  11. package/dist/HttpApi.d.ts +75 -0
  12. package/dist/HttpApi.js +47 -0
  13. package/dist/_virtual/rolldown_runtime.js +18 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.js +8 -0
  16. package/dist/internal/constants.js +15 -0
  17. package/dist/internal/driver.d.ts +5 -0
  18. package/dist/internal/driver.js +117 -0
  19. package/dist/internal/errors.d.ts +56 -0
  20. package/dist/internal/errors.js +61 -0
  21. package/dist/internal/handler.d.ts +20 -0
  22. package/dist/internal/handler.js +145 -0
  23. package/dist/internal/helpers.js +44 -0
  24. package/dist/internal/interrupts.d.ts +2 -0
  25. package/dist/internal/interrupts.js +45 -0
  26. package/dist/internal/memo.js +56 -0
  27. package/dist/internal/protocol.d.ts +1 -0
  28. package/dist/internal/protocol.js +191 -0
  29. package/dist/internal/signature.d.ts +18 -0
  30. package/dist/internal/signature.js +97 -0
  31. package/dist/internal/step.d.ts +59 -0
  32. package/dist/internal/step.js +183 -0
  33. package/package.json +121 -0
  34. package/src/Client.ts +279 -0
  35. package/src/Events.ts +87 -0
  36. package/src/Function.ts +493 -0
  37. package/src/Group.ts +314 -0
  38. package/src/HttpApi.ts +82 -0
  39. package/src/index.ts +171 -0
  40. package/src/internal/constants.ts +11 -0
  41. package/src/internal/driver.ts +194 -0
  42. package/src/internal/errors.ts +130 -0
  43. package/src/internal/handler.ts +222 -0
  44. package/src/internal/helpers.ts +58 -0
  45. package/src/internal/interrupts.ts +62 -0
  46. package/src/internal/memo.ts +73 -0
  47. package/src/internal/protocol.ts +218 -0
  48. package/src/internal/signature.ts +158 -0
  49. package/src/internal/step.ts +377 -0
@@ -0,0 +1,384 @@
1
+ import { Duration, Schema } from "effect";
2
+
3
+ //#region src/Function.d.ts
4
+ declare namespace Function_d_exports {
5
+ export { CronTrigger, EventTrigger, FunctionOptions, InngestFunction, Trigger, TriggerInput, TypeId, make };
6
+ }
7
+ /**
8
+ * @since 0.1.0
9
+ * @category type ids
10
+ */
11
+ declare const TypeId: unique symbol;
12
+ /**
13
+ * @since 0.1.0
14
+ * @category type ids
15
+ */
16
+ type TypeId = typeof TypeId;
17
+ type EventSchema = Schema.Schema.Any & {
18
+ readonly _tag: string;
19
+ };
20
+ /**
21
+ * An event-based trigger configuration.
22
+ *
23
+ * @since 0.1.0
24
+ * @category triggers
25
+ */
26
+ interface EventTrigger<E extends EventSchema = EventSchema> {
27
+ readonly event: E;
28
+ readonly if?: string;
29
+ }
30
+ /**
31
+ * A cron-based trigger configuration.
32
+ *
33
+ * @since 0.1.0
34
+ * @category triggers
35
+ */
36
+ interface CronTrigger {
37
+ readonly cron: string;
38
+ }
39
+ /**
40
+ * A trigger configuration for a function.
41
+ *
42
+ * @since 0.1.0
43
+ * @category triggers
44
+ */
45
+ type Trigger<E extends EventSchema = EventSchema> = EventTrigger<E> | CronTrigger;
46
+ /**
47
+ * @since 0.1.0
48
+ * @category triggers
49
+ */
50
+ type TriggerInput<E extends EventSchema = EventSchema> = Trigger<E> | ReadonlyArray<Trigger<E>>;
51
+ interface ConcurrencyOption {
52
+ /**
53
+ * The concurrency limit for this option, adding a limit on how many concurrent
54
+ * steps can execute at once.
55
+ */
56
+ readonly limit: number;
57
+ /**
58
+ * An optional concurrency key, as an expression using the common expression language
59
+ * (CEL). The result of this expression is used to create new concurrency groups, or
60
+ * sub-queues, for each function run.
61
+ *
62
+ * The event is passed into this expression as "event".
63
+ *
64
+ * Examples:
65
+ * - `event.data.user_id`: this evaluates to the user_id in the event.data object.
66
+ * - `event.data.user_id + "-" + event.data.account_id`: creates a new group per user/account
67
+ * - `"ai"`: references a custom string
68
+ */
69
+ readonly key?: string;
70
+ /**
71
+ * An optional scope for the concurrency group. By default, concurrency limits are
72
+ * scoped to functions - one function's concurrency limits do not impact other functions.
73
+ *
74
+ * Changing this "scope" allows concurrency limits to work across environments (eg. production
75
+ * vs branch environments) or across your account (global).
76
+ */
77
+ readonly scope?: "fn" | "env" | "account";
78
+ }
79
+ interface RateLimitOption {
80
+ /**
81
+ * An optional key to use for rate limiting, similar to idempotency.
82
+ */
83
+ readonly key?: string;
84
+ /**
85
+ * The number of times to allow the function to run per the given `period`.
86
+ */
87
+ readonly limit: number;
88
+ /**
89
+ * The period of time to allow the function to run `limit` times.
90
+ */
91
+ readonly period: Duration.DurationInput;
92
+ }
93
+ interface ThrottleOption {
94
+ /**
95
+ * An optional expression which returns a throttling key for controlling throttling.
96
+ * Every unique key is its own throttle limit. Event data may be used within this
97
+ * expression, eg "event.data.user_id".
98
+ */
99
+ readonly key?: string;
100
+ /**
101
+ * The total number of runs allowed to start within the given `period`. The limit is
102
+ * applied evenly over the period.
103
+ */
104
+ readonly limit: number;
105
+ /**
106
+ * The period of time for the rate limit. Run starts are evenly spaced through
107
+ * the given period. The minimum granularity is 1 second.
108
+ */
109
+ readonly period: Duration.DurationInput;
110
+ /**
111
+ * The number of runs allowed to start in the given window in a single burst.
112
+ * A burst > 1 bypasses smoothing for the burst and allows many runs to start
113
+ * at once, if desired. Defaults to 1, which disables bursting.
114
+ */
115
+ readonly burst?: number;
116
+ }
117
+ interface DebounceOption {
118
+ /**
119
+ * An optional key to use for debouncing.
120
+ */
121
+ readonly key?: string;
122
+ /**
123
+ * The period of time to delay after receiving the last trigger to run the function.
124
+ */
125
+ readonly period: Duration.DurationInput;
126
+ /**
127
+ * The maximum time that a debounce can be extended before running.
128
+ * If events are continually received within the given period, a function
129
+ * will always run after the given timeout period.
130
+ */
131
+ readonly timeout?: Duration.DurationInput;
132
+ }
133
+ interface BatchEventsOption {
134
+ /**
135
+ * The maximum number of events to be consumed in one batch.
136
+ */
137
+ readonly maxSize: number;
138
+ /**
139
+ * How long to wait before invoking the function with a list of events.
140
+ * If timeout is reached, the function will be invoked with a batch
141
+ * even if it's not filled up to `maxSize`.
142
+ */
143
+ readonly timeout: Duration.DurationInput;
144
+ /**
145
+ * An optional key to use for batching.
146
+ */
147
+ readonly key?: string;
148
+ /**
149
+ * An optional boolean expression to determine an event's eligibility for batching.
150
+ */
151
+ readonly if?: string;
152
+ }
153
+ interface PriorityOption {
154
+ /**
155
+ * An expression to use to determine the priority of a function run. The
156
+ * expression can return a number between `-600` and `600`, where `600`
157
+ * declares that this run should be executed before any others enqueued in
158
+ * the last 600 seconds (10 minutes), and `-600` declares that this run
159
+ * should be executed after any others enqueued in the last 600 seconds.
160
+ */
161
+ readonly run?: string;
162
+ }
163
+ interface TimeoutsOption {
164
+ /**
165
+ * Start represents the timeout for starting a function. If the time
166
+ * between scheduling and starting a function exceeds this value, the
167
+ * function will be cancelled.
168
+ *
169
+ * This is, essentially, the amount of time that a function sits in the
170
+ * queue before starting.
171
+ */
172
+ readonly start?: Duration.DurationInput;
173
+ /**
174
+ * Finish represents the time between a function starting and the function
175
+ * finishing. If a function takes longer than this time to finish, the
176
+ * function is marked as cancelled.
177
+ */
178
+ readonly finish?: Duration.DurationInput;
179
+ }
180
+ interface SingletonOption {
181
+ /**
182
+ * An optional key expression used to scope singleton execution.
183
+ * Each unique key has its own singleton lock. Event data can be referenced,
184
+ * e.g. "event.data.user_id".
185
+ */
186
+ readonly key?: string;
187
+ /**
188
+ * Determines how to handle new runs when one is already active for the same key.
189
+ * - `"skip"` skips the new run.
190
+ * - `"cancel"` cancels the existing run and starts the new one.
191
+ */
192
+ readonly mode: "skip" | "cancel";
193
+ }
194
+ interface CancellationOption {
195
+ /**
196
+ * The name of the event that should cancel the function run.
197
+ */
198
+ readonly event: string;
199
+ /**
200
+ * The expression that must evaluate to true in order to cancel the function run. There
201
+ * are two variables available in this expression:
202
+ * - event, referencing the original function's event trigger
203
+ * - async, referencing the new cancel event.
204
+ */
205
+ readonly if?: string;
206
+ /**
207
+ * An optional timeout that the cancel is valid for. If this isn't
208
+ * specified, cancellation triggers are valid for up to a year or until the
209
+ * function ends.
210
+ */
211
+ readonly timeout?: Duration.DurationInput;
212
+ }
213
+ type Retries = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
214
+ /**
215
+ * @since 0.1.0
216
+ * @category models
217
+ */
218
+ interface FunctionOptions {
219
+ /**
220
+ * A name for the function as it will appear in the Inngest Cloud UI.
221
+ */
222
+ readonly name?: string;
223
+ /**
224
+ * A description of the function.
225
+ */
226
+ readonly description?: string;
227
+ /**
228
+ * Specifies the maximum number of retries for all steps across this function.
229
+ * Can be a number from `0` to `20`. Defaults to `3`.
230
+ */
231
+ readonly retries?: Retries;
232
+ /**
233
+ * Concurrency specifies a limit on the total number of concurrent steps that
234
+ * can occur across all runs of the function. A value of 0 (or undefined) means
235
+ * use the maximum available concurrency.
236
+ *
237
+ * Specifying just a number means specifying only the concurrency limit. A
238
+ * maximum of two concurrency options can be specified.
239
+ */
240
+ readonly concurrency?: number | ConcurrencyOption | readonly [ConcurrencyOption, ConcurrencyOption];
241
+ /**
242
+ * Rate limit function runs, only running them a given number of times (limit) per
243
+ * period. Note that rate limit is a lossy, hard limit. Once the limit is hit,
244
+ * new runs will be skipped.
245
+ */
246
+ readonly rateLimit?: RateLimitOption;
247
+ /**
248
+ * Throttles function runs, only running them a given number of times (limit) per
249
+ * period. Once the limit is hit, new runs will be enqueued and will start when there's
250
+ * capacity.
251
+ */
252
+ readonly throttle?: ThrottleOption;
253
+ /**
254
+ * Debounce delays functions for the `period` specified.
255
+ */
256
+ readonly debounce?: DebounceOption;
257
+ /**
258
+ * Allow the specification of an idempotency key using event data.
259
+ */
260
+ readonly idempotency?: string;
261
+ /**
262
+ * Configure how the priority of a function run is decided.
263
+ */
264
+ readonly priority?: PriorityOption;
265
+ /**
266
+ * Ensures that only one run of the function is active at a time for a given key.
267
+ */
268
+ readonly singleton?: SingletonOption;
269
+ /**
270
+ * Configuration for cancelling a function run based on incoming events.
271
+ */
272
+ readonly cancelOn?: ReadonlyArray<CancellationOption>;
273
+ /**
274
+ * Configure timeouts for the function.
275
+ */
276
+ readonly timeouts?: TimeoutsOption;
277
+ /**
278
+ * Batch events configuration.
279
+ */
280
+ readonly batchEvents?: BatchEventsOption;
281
+ }
282
+ interface RegistrationConfig {
283
+ readonly appId: string;
284
+ readonly url: string;
285
+ }
286
+ interface FunctionRegistration {
287
+ readonly id: string;
288
+ readonly name: string;
289
+ readonly triggers: ReadonlyArray<{
290
+ event?: string;
291
+ cron?: string;
292
+ expression?: string;
293
+ }>;
294
+ readonly steps: {
295
+ readonly step: {
296
+ readonly id: string;
297
+ readonly name: string;
298
+ readonly runtime: {
299
+ readonly type: "http";
300
+ readonly url: string;
301
+ };
302
+ readonly retries?: {
303
+ readonly attempts: number;
304
+ };
305
+ };
306
+ };
307
+ readonly cancel?: ReadonlyArray<{
308
+ event: string;
309
+ if?: string;
310
+ timeout?: string;
311
+ }>;
312
+ readonly timeouts?: {
313
+ start?: string;
314
+ finish?: string;
315
+ };
316
+ }
317
+ /**
318
+ * An Inngest function definition.
319
+ *
320
+ * @since 0.1.0
321
+ * @category models
322
+ */
323
+ interface InngestFunction<Tag extends string, Triggers extends Trigger, Success extends Schema.Schema.Any, Options extends FunctionOptions = FunctionOptions> {
324
+ readonly [TypeId]: TypeId;
325
+ readonly _tag: Tag;
326
+ readonly key: string;
327
+ readonly triggers: ReadonlyArray<Triggers>;
328
+ readonly success: Success;
329
+ readonly options: Options;
330
+ readonly toRegistration: (config: RegistrationConfig) => FunctionRegistration;
331
+ }
332
+ /**
333
+ * @since 0.1.0
334
+ * @category models
335
+ */
336
+ declare namespace InngestFunction {
337
+ type Any = InngestFunction<string, Trigger, Schema.Schema.Any, FunctionOptions>;
338
+ type Tag<F> = F extends InngestFunction<infer T, any, any, any> ? T : never;
339
+ type Triggers<F> = F extends InngestFunction<any, infer T, any, any> ? T : never;
340
+ type Events<F> = F extends InngestFunction<any, infer T, any, any> ? (T extends EventTrigger<infer E> ? E : never) : never;
341
+ type EventType<F> = F extends InngestFunction<any, infer T, any, any> ? T extends EventTrigger<infer E> ? Schema.Schema.Type<E> : never : never;
342
+ type Success<F> = F extends InngestFunction<any, any, infer S, any> ? Schema.Schema.Type<S> : never;
343
+ type Options<F> = F extends InngestFunction<any, any, any, infer O> ? O : never;
344
+ }
345
+ type NormalizeTriggers<T extends TriggerInput> = T extends ReadonlyArray<Trigger> ? T[number] : T;
346
+ /**
347
+ * @since 0.1.0
348
+ * @category constructors
349
+ * @example
350
+ * ```ts
351
+ * // Event trigger
352
+ * const Fn1 = InngestFunction.make("Hello", {
353
+ * trigger: { event: HelloEvent },
354
+ * success: Schema.Void,
355
+ * })
356
+ *
357
+ * // Event trigger with CEL filter
358
+ * const Fn2 = InngestFunction.make("Hello", {
359
+ * trigger: { event: HelloEvent, if: "event.data.name != ''" },
360
+ * success: Schema.Void,
361
+ * })
362
+ *
363
+ * // Cron trigger
364
+ * const Fn3 = InngestFunction.make("Scheduled", {
365
+ * trigger: { cron: "0 * * * *" },
366
+ * success: Schema.Void,
367
+ * })
368
+ *
369
+ * // Multiple triggers
370
+ * const Fn4 = InngestFunction.make("Multi", {
371
+ * trigger: [
372
+ * { event: HelloEvent },
373
+ * { cron: "0 0 * * *" },
374
+ * ],
375
+ * success: Schema.Void,
376
+ * })
377
+ * ```
378
+ */
379
+ declare function make<const Tag extends string, T extends TriggerInput, S extends Schema.Schema.Any, const O extends FunctionOptions = {}>(tag: Tag, options: {
380
+ readonly trigger: T;
381
+ readonly success: S;
382
+ } & O): InngestFunction<Tag, NormalizeTriggers<T>, S, O>;
383
+ //#endregion
384
+ export { CronTrigger, EventTrigger, FunctionOptions, Function_d_exports, InngestFunction, Trigger, TriggerInput, TypeId, make };
@@ -0,0 +1,104 @@
1
+ import { __exportAll } from "./_virtual/rolldown_runtime.js";
2
+ import { timeStr } from "./internal/helpers.js";
3
+ import { Array, Duration, Predicate, Schema } from "effect";
4
+
5
+ //#region src/Function.ts
6
+ /**
7
+ * @since 0.1.0
8
+ */
9
+ var Function_exports = /* @__PURE__ */ __exportAll({
10
+ TypeId: () => TypeId,
11
+ make: () => make
12
+ });
13
+ /**
14
+ * @since 0.1.0
15
+ * @category type ids
16
+ */
17
+ const TypeId = Symbol.for("effect-inngest/Function");
18
+ const isEventTrigger = (t) => Predicate.hasProperty(t, "event");
19
+ const Proto = {
20
+ [TypeId]: TypeId,
21
+ toRegistration(config) {
22
+ const triggers = [];
23
+ for (const t of this.triggers) if (isEventTrigger(t)) triggers.push({
24
+ event: t.event._tag,
25
+ expression: t.if
26
+ });
27
+ else triggers.push({ cron: t.cron });
28
+ const opts = this.options;
29
+ const cancel = opts.cancelOn?.map((c) => ({
30
+ event: c.event,
31
+ if: c.if,
32
+ timeout: c.timeout ? timeStr(c.timeout) : void 0
33
+ }));
34
+ const timeouts = opts.timeouts?.start || opts.timeouts?.finish ? {
35
+ start: opts.timeouts.start ? timeStr(opts.timeouts.start) : void 0,
36
+ finish: opts.timeouts.finish ? timeStr(opts.timeouts.finish) : void 0
37
+ } : void 0;
38
+ const fnId = `${config.appId}-${this._tag}`;
39
+ const stepUrl = new URL(config.url);
40
+ stepUrl.searchParams.set("fnId", fnId);
41
+ stepUrl.searchParams.set("stepId", "step");
42
+ return {
43
+ id: fnId,
44
+ name: opts.name ?? this._tag,
45
+ triggers,
46
+ steps: { step: {
47
+ id: "step",
48
+ name: "step",
49
+ runtime: {
50
+ type: "http",
51
+ url: stepUrl.href
52
+ },
53
+ retries: { attempts: opts.retries ?? 3 }
54
+ } },
55
+ cancel: cancel && cancel.length > 0 ? cancel : void 0,
56
+ timeouts
57
+ };
58
+ }
59
+ };
60
+ /**
61
+ * @since 0.1.0
62
+ * @category constructors
63
+ * @example
64
+ * ```ts
65
+ * // Event trigger
66
+ * const Fn1 = InngestFunction.make("Hello", {
67
+ * trigger: { event: HelloEvent },
68
+ * success: Schema.Void,
69
+ * })
70
+ *
71
+ * // Event trigger with CEL filter
72
+ * const Fn2 = InngestFunction.make("Hello", {
73
+ * trigger: { event: HelloEvent, if: "event.data.name != ''" },
74
+ * success: Schema.Void,
75
+ * })
76
+ *
77
+ * // Cron trigger
78
+ * const Fn3 = InngestFunction.make("Scheduled", {
79
+ * trigger: { cron: "0 * * * *" },
80
+ * success: Schema.Void,
81
+ * })
82
+ *
83
+ * // Multiple triggers
84
+ * const Fn4 = InngestFunction.make("Multi", {
85
+ * trigger: [
86
+ * { event: HelloEvent },
87
+ * { cron: "0 0 * * *" },
88
+ * ],
89
+ * success: Schema.Void,
90
+ * })
91
+ * ```
92
+ */
93
+ function make(tag, options) {
94
+ const fn = Object.create(Proto);
95
+ fn._tag = tag;
96
+ fn.key = `effect-inngest/Function/${tag}`;
97
+ fn.triggers = Array.ensure(options.trigger);
98
+ fn.success = options.success;
99
+ fn.options = options;
100
+ return fn;
101
+ }
102
+
103
+ //#endregion
104
+ export { Function_exports, TypeId, make };
@@ -0,0 +1,152 @@
1
+ import { InngestClient } from "./Client.js";
2
+ import { InngestFunction } from "./Function.js";
3
+ import { HandlerContext } from "./internal/step.js";
4
+ import * as HttpApp from "@effect/platform/HttpApp";
5
+ import * as HttpClient from "@effect/platform/HttpClient";
6
+ import * as Context from "effect/Context";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Layer from "effect/Layer";
9
+
10
+ //#region src/Group.d.ts
11
+ declare namespace Group_d_exports {
12
+ export { Handler, HandlerContext, HandlerFn, HandlerFrom, HandlerRequirements, HandlersFrom, HandlersRequirements, InngestGroup, ToHandler, TypeId, make, toHttpApp, toWebHandler };
13
+ }
14
+ /**
15
+ * @since 0.1.0
16
+ * @category type ids
17
+ */
18
+ declare const TypeId: unique symbol;
19
+ /**
20
+ * @since 0.1.0
21
+ * @category type ids
22
+ */
23
+ type TypeId = typeof TypeId;
24
+ /**
25
+ * @since 0.1.0
26
+ * @category models
27
+ */
28
+ type HandlerFn<F extends InngestFunction.Any> = (context: HandlerContext<F>) => Effect.Effect<InngestFunction.Success<F>, unknown, unknown>;
29
+ /**
30
+ * @since 0.1.0
31
+ * @category models
32
+ */
33
+ type HandlersFrom<Fns extends InngestFunction.Any> = { readonly [F in Fns as InngestFunction.Tag<F>]: HandlerFn<F> };
34
+ /**
35
+ * @since 0.1.0
36
+ * @category models
37
+ */
38
+ type HandlerFrom<Fns extends InngestFunction.Any, Tag extends InngestFunction.Tag<Fns>> = Extract<Fns, {
39
+ readonly _tag: Tag;
40
+ }> extends infer Current ? Current extends InngestFunction.Any ? HandlerFn<Current> : never : never;
41
+ /**
42
+ * @since 0.1.0
43
+ * @category models
44
+ */
45
+ type HandlersRequirements<H> = H extends Record<string, (...args: ReadonlyArray<unknown>) => Effect.Effect<unknown, unknown, infer R>> ? R : never;
46
+ /**
47
+ * @since 0.1.0
48
+ * @category models
49
+ */
50
+ type HandlerRequirements<Handler> = Handler extends ((...args: ReadonlyArray<unknown>) => Effect.Effect<unknown, unknown, infer R>) ? R : never;
51
+ /**
52
+ * A nominal type representing a registered handler for a specific function tag.
53
+ * @since 0.1.0
54
+ * @category models
55
+ */
56
+ interface Handler<Tag extends string> {
57
+ readonly _: unique symbol;
58
+ readonly tag: Tag;
59
+ readonly handler: (context: unknown) => Effect.Effect<unknown, unknown, unknown>;
60
+ readonly context: Context.Context<never>;
61
+ }
62
+ /**
63
+ * Maps a function to its Handler type.
64
+ * @since 0.1.0
65
+ * @category models
66
+ */
67
+ type ToHandler<F extends InngestFunction.Any> = F extends InngestFunction<infer _Tag, infer _Triggers, infer _Success> ? Handler<_Tag> : never;
68
+ /**
69
+ * @since 0.1.0
70
+ * @category models
71
+ */
72
+ interface InngestGroup<Fns extends InngestFunction.Any> {
73
+ readonly [TypeId]: TypeId;
74
+ readonly functions: ReadonlyMap<string, Fns>;
75
+ /**
76
+ * Implement all handlers for the functions in this group.
77
+ */
78
+ readonly toLayer: <H extends HandlersFrom<Fns>>(handlers: H) => Layer.Layer<ToHandler<Fns>, never, HandlersRequirements<H>>;
79
+ /**
80
+ * Implement a single handler from the group.
81
+ */
82
+ readonly toLayerHandler: <Tag extends InngestFunction.Tag<Fns>, H extends HandlerFrom<Fns, Tag>>(tag: Tag, handler: H) => Layer.Layer<Handler<Tag>, never, HandlerRequirements<H>>;
83
+ }
84
+ /**
85
+ * @since 0.1.0
86
+ * @category models
87
+ */
88
+ declare namespace InngestGroup {
89
+ type Any = InngestGroup<InngestFunction.Any>;
90
+ type Functions<G> = G extends InngestGroup<infer Fns> ? Fns : never;
91
+ type FunctionTags<G> = G extends InngestGroup<infer Fns> ? InngestFunction.Tag<Fns> : never;
92
+ type Handlers<G> = G extends InngestGroup<infer Fns> ? HandlersFrom<Fns> : never;
93
+ }
94
+ /**
95
+ * @since 0.1.0
96
+ * @category constructors
97
+ */
98
+ declare const make: <Fns extends ReadonlyArray<InngestFunction.Any>>(...fns: Fns) => InngestGroup<Fns[number]>;
99
+ /**
100
+ * Build an HttpApp from an InngestGroup.
101
+ *
102
+ * @since 0.1.0
103
+ * @category http
104
+ * @example
105
+ * ```ts
106
+ * import { Effect, Layer } from "effect"
107
+ * import { HttpServer } from "@effect/platform"
108
+ * import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
109
+ * import { InngestGroup, InngestClient } from "effect-inngest"
110
+ *
111
+ * InngestGroup.toHttpApp(MyGroup).pipe(
112
+ * Effect.flatMap((app) => HttpServer.serve(app)),
113
+ * Effect.provide(InngestClient.layer({ id: "my-app" })),
114
+ * Effect.provide(NodeHttpServer.layer({ port: 3000 })),
115
+ * NodeRuntime.runMain,
116
+ * )
117
+ * ```
118
+ */
119
+ declare const toHttpApp: (group: InngestGroup.Any) => HttpApp.Default<never, InngestClient | HttpClient.HttpClient>;
120
+ /**
121
+ * Create a standalone web handler from an InngestGroup.
122
+ *
123
+ * @since 0.1.0
124
+ * @category http
125
+ * @example
126
+ * ```ts
127
+ * import { InngestGroup, InngestClient } from "effect-inngest"
128
+ * import { HttpClient } from "@effect/platform"
129
+ * import { FetchHttpClient } from "@effect/platform"
130
+ *
131
+ * const { handler, dispose } = InngestGroup.toWebHandler(MyGroup, {
132
+ * layer: InngestClient.layer({ id: "my-app" }).pipe(
133
+ * Layer.provide(FetchHttpClient.layer),
134
+ * ),
135
+ * })
136
+ *
137
+ * // Use with any web framework
138
+ * Bun.serve({ fetch: handler, port: 3000 })
139
+ *
140
+ * // Call dispose() on shutdown
141
+ * process.on("SIGTERM", dispose)
142
+ * ```
143
+ */
144
+ declare const toWebHandler: <R, E>(group: InngestGroup.Any, options: {
145
+ readonly layer: Layer.Layer<InngestClient | HttpClient.HttpClient | R, E, never>;
146
+ readonly memoMap?: Layer.MemoMap;
147
+ }) => {
148
+ readonly handler: (request: Request) => Promise<Response>;
149
+ readonly dispose: () => Promise<void>;
150
+ };
151
+ //#endregion
152
+ export { Group_d_exports, Handler, type HandlerContext, HandlerFn, HandlerFrom, HandlerRequirements, HandlersFrom, HandlersRequirements, InngestGroup, ToHandler, TypeId, make, toHttpApp, toWebHandler };