inngest 4.3.0 → 4.4.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 (134) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/api/schema.d.cts +2 -2
  3. package/api/schema.d.cts.map +1 -1
  4. package/api/schema.d.ts +2 -2
  5. package/api/schema.d.ts.map +1 -1
  6. package/components/DeferredFunction.cjs +66 -0
  7. package/components/DeferredFunction.cjs.map +1 -0
  8. package/components/DeferredFunction.d.cts +99 -0
  9. package/components/DeferredFunction.d.cts.map +1 -0
  10. package/components/DeferredFunction.d.ts +99 -0
  11. package/components/DeferredFunction.d.ts.map +1 -0
  12. package/components/DeferredFunction.js +65 -0
  13. package/components/DeferredFunction.js.map +1 -0
  14. package/components/Inngest.cjs +5 -2
  15. package/components/Inngest.cjs.map +1 -1
  16. package/components/Inngest.d.cts +4 -3
  17. package/components/Inngest.d.cts.map +1 -1
  18. package/components/Inngest.d.ts +4 -3
  19. package/components/Inngest.d.ts.map +1 -1
  20. package/components/Inngest.js +5 -2
  21. package/components/Inngest.js.map +1 -1
  22. package/components/InngestCommHandler.cjs +28 -23
  23. package/components/InngestCommHandler.cjs.map +1 -1
  24. package/components/InngestCommHandler.d.cts +9 -4
  25. package/components/InngestCommHandler.d.cts.map +1 -1
  26. package/components/InngestCommHandler.d.ts +9 -4
  27. package/components/InngestCommHandler.d.ts.map +1 -1
  28. package/components/InngestCommHandler.js +28 -23
  29. package/components/InngestCommHandler.js.map +1 -1
  30. package/components/InngestFunction.cjs +27 -19
  31. package/components/InngestFunction.cjs.map +1 -1
  32. package/components/InngestFunction.d.cts +6 -1
  33. package/components/InngestFunction.d.cts.map +1 -1
  34. package/components/InngestFunction.d.ts +6 -1
  35. package/components/InngestFunction.d.ts.map +1 -1
  36. package/components/InngestFunction.js +27 -19
  37. package/components/InngestFunction.js.map +1 -1
  38. package/components/InngestGroupTools.cjs +1 -1
  39. package/components/InngestGroupTools.cjs.map +1 -1
  40. package/components/InngestGroupTools.js +1 -1
  41. package/components/InngestGroupTools.js.map +1 -1
  42. package/components/connect/config.cjs +2 -0
  43. package/components/connect/config.cjs.map +1 -1
  44. package/components/connect/config.js +2 -0
  45. package/components/connect/config.js.map +1 -1
  46. package/components/execution/InngestExecution.cjs.map +1 -1
  47. package/components/execution/InngestExecution.d.cts +19 -2
  48. package/components/execution/InngestExecution.d.cts.map +1 -1
  49. package/components/execution/InngestExecution.d.ts +19 -2
  50. package/components/execution/InngestExecution.d.ts.map +1 -1
  51. package/components/execution/InngestExecution.js.map +1 -1
  52. package/components/execution/engine.cjs +232 -27
  53. package/components/execution/engine.cjs.map +1 -1
  54. package/components/execution/engine.d.cts +14 -0
  55. package/components/execution/engine.d.cts.map +1 -1
  56. package/components/execution/engine.d.ts +14 -0
  57. package/components/execution/engine.d.ts.map +1 -1
  58. package/components/execution/engine.js +232 -27
  59. package/components/execution/engine.js.map +1 -1
  60. package/components/execution/lazyOps.cjs +64 -0
  61. package/components/execution/lazyOps.cjs.map +1 -0
  62. package/components/execution/lazyOps.d.cts +42 -0
  63. package/components/execution/lazyOps.d.cts.map +1 -0
  64. package/components/execution/lazyOps.d.ts +42 -0
  65. package/components/execution/lazyOps.d.ts.map +1 -0
  66. package/components/execution/lazyOps.js +63 -0
  67. package/components/execution/lazyOps.js.map +1 -0
  68. package/components/execution/otel/middleware.d.cts +6 -3
  69. package/components/execution/otel/middleware.d.cts.map +1 -1
  70. package/components/execution/otel/middleware.d.ts +6 -3
  71. package/components/execution/otel/middleware.d.ts.map +1 -1
  72. package/components/middleware/middleware.cjs.map +1 -1
  73. package/components/middleware/middleware.d.cts +1 -1
  74. package/components/middleware/middleware.d.cts.map +1 -1
  75. package/components/middleware/middleware.d.ts +1 -1
  76. package/components/middleware/middleware.d.ts.map +1 -1
  77. package/components/middleware/middleware.js.map +1 -1
  78. package/components/middleware/utils.cjs +1 -0
  79. package/components/middleware/utils.cjs.map +1 -1
  80. package/components/middleware/utils.js +1 -0
  81. package/components/middleware/utils.js.map +1 -1
  82. package/components/realtime/types.d.cts +4 -4
  83. package/components/realtime/types.d.cts.map +1 -1
  84. package/components/realtime/types.d.ts +4 -4
  85. package/components/realtime/types.d.ts.map +1 -1
  86. package/components/triggers/typeHelpers.cjs.map +1 -1
  87. package/components/triggers/typeHelpers.d.cts +11 -0
  88. package/components/triggers/typeHelpers.d.cts.map +1 -1
  89. package/components/triggers/typeHelpers.d.ts +11 -0
  90. package/components/triggers/typeHelpers.d.ts.map +1 -1
  91. package/components/triggers/typeHelpers.js.map +1 -1
  92. package/experimental.cjs +3 -0
  93. package/experimental.d.cts +2 -1
  94. package/experimental.d.ts +2 -1
  95. package/experimental.js +2 -1
  96. package/helpers/consts.cjs +6 -0
  97. package/helpers/consts.cjs.map +1 -1
  98. package/helpers/consts.d.cts +6 -0
  99. package/helpers/consts.d.cts.map +1 -1
  100. package/helpers/consts.d.ts +6 -0
  101. package/helpers/consts.d.ts.map +1 -1
  102. package/helpers/consts.js +6 -0
  103. package/helpers/consts.js.map +1 -1
  104. package/helpers/functions.cjs +1 -0
  105. package/helpers/functions.cjs.map +1 -1
  106. package/helpers/functions.js +1 -0
  107. package/helpers/functions.js.map +1 -1
  108. package/helpers/marker.cjs +21 -0
  109. package/helpers/marker.cjs.map +1 -0
  110. package/helpers/marker.d.cts +12 -0
  111. package/helpers/marker.d.cts.map +1 -0
  112. package/helpers/marker.d.ts +12 -0
  113. package/helpers/marker.d.ts.map +1 -0
  114. package/helpers/marker.js +19 -0
  115. package/helpers/marker.js.map +1 -0
  116. package/package.json +2 -2
  117. package/proto/src/components/connect/protobuf/connect.cjs +11 -2
  118. package/proto/src/components/connect/protobuf/connect.cjs.map +1 -1
  119. package/proto/src/components/connect/protobuf/connect.js +11 -2
  120. package/proto/src/components/connect/protobuf/connect.js.map +1 -1
  121. package/types.cjs +2 -0
  122. package/types.cjs.map +1 -1
  123. package/types.d.cts +52 -18
  124. package/types.d.cts.map +1 -1
  125. package/types.d.ts +52 -18
  126. package/types.d.ts.map +1 -1
  127. package/types.js +2 -0
  128. package/types.js.map +1 -1
  129. package/version.cjs +1 -1
  130. package/version.cjs.map +1 -1
  131. package/version.d.cts +1 -1
  132. package/version.d.ts +1 -1
  133. package/version.js +1 -1
  134. package/version.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # inngest
2
2
 
3
+ ## 4.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1508](https://github.com/inngest/inngest-js/pull/1508) [`4771b424`](https://github.com/inngest/inngest-js/commit/4771b42402f9e2f435417b65f4e5a38e54e398af) Thanks [@amh4r](https://github.com/amh4r)! - Add experimental support for deferred functions
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1512](https://github.com/inngest/inngest-js/pull/1512) [`be675a3d`](https://github.com/inngest/inngest-js/commit/be675a3d3c2a39b415ded8db5e2626e22b941760) Thanks [@amh4r](https://github.com/amh4r)! - Fix waitForSignal not in middleware StepType union
12
+
13
+ - [#1513](https://github.com/inngest/inngest-js/pull/1513) [`cbad05c3`](https://github.com/inngest/inngest-js/commit/cbad05c3052de84defe36797c23eb0da295022fb) Thanks [@jakobevangelista](https://github.com/jakobevangelista)! - Standardize variant naming to `variant` instead of `variant_selected`
14
+
15
+ - [#1516](https://github.com/inngest/inngest-js/pull/1516) [`1bca44a8`](https://github.com/inngest/inngest-js/commit/1bca44a8293d6d44e93266fbe3e8dd4dc7e0fa73) Thanks [@BrunoScheufler](https://github.com/BrunoScheufler)! - - Add Request ID & Job ID to context and logs
16
+
3
17
  ## 4.3.0
4
18
 
5
19
  ### Minor Changes
package/api/schema.d.cts CHANGED
@@ -6,11 +6,11 @@ declare const errorSchema: z.ZodObject<{
6
6
  error: z.ZodString;
7
7
  status: z.ZodNumber;
8
8
  }, "strip", z.ZodTypeAny, {
9
- error: string;
10
9
  status: number;
11
- }, {
12
10
  error: string;
11
+ }, {
13
12
  status: number;
13
+ error: string;
14
14
  }>;
15
15
  type ErrorResponse = z.infer<typeof errorSchema>;
16
16
  declare const stepSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/api/schema.ts"],"sourcesContent":[],"mappings":";;;;cAGa,aAAW,CAAA,CAAA;;EAAX,MAAA,aAGX;CAAA,EAAA,OAAA,cAAA,EAAA;;;;OAHsB,EAAA,MAAA;EAAA,MAAA,EAAA,MAAA;AAIxB,CAAA,CAAA;AAAyB,KAAb,aAAA,GAAgB,CAAA,CAAE,KAAL,CAAA,OAAkB,WAAlB,CAAA;AAAkB,cAE9B,UAF8B,EAEpB,CAAA,CAAA,UAFoB,CAEpB,CAAA,CAAA,SAFoB,CAEpB,CAAA,CAAA,SAFoB,EAEpB,CAAA,CAAA,QAFoB,CAAA,CAEpB,CAAA,CAAA,QAFoB,CAAA,CAEpB,CAAA,CAAA,QAFoB,CAAA,CAEpB,CAAA,CAAA,SAFoB,CAAA;MAAf,cAAE,cAAA,aAAA,CAAA,MAAA,CAAA,CAAA,CAAA;EAAK,IAAA,cAAA,SAAA,EAAA,GAAA,EAAA,GAAA,CAAA;AAEnC,CAAA,EAAA,QAAa,cAuCC,EAAA;EAAA,IAAA,EAAA,MAAA;MAvCS,CAAA,EAAA,GAAA;;;;;;;WAAA,cAAA,EAAA;;;;;;;;;;;;;;;;;;MAAA;;;IAAA,KAAA,CAAA,EAAA,OAAA;;MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;CAAA,CAAA,CAAA,CAAA,aAAA,CAAA;EAyCX,IAAA,cAAa,cAAA,aAAA,CAAA,OAAA,CAAA,CAAA,CAAA;EAAA,KAAA,cAAA,SAAA,EAAA,GAAA,EAAA,GAAA,CAAA;WAAkB,cAAA,EAAA;MAAf,EAAE,OAAA;EAAK,KAAA,CAAA,EAAA,GAAA;AAEnC,CAAA,EAAA;EAEC,IAAA,CAAA,E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;;;;;;WAAA,cAAA,EAAA;;;;;;;;;;;;;;;;;;MAAA;;;IAAA,KAAA,CAAA,EAAA,OAAA;;MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;CAAA,CAAA,CAAA,CAAA,aAAA,CAAA;EAyCX,IAAA,cAAa,cAAA,aAAA,CAAA,OAAA,CAAA,CAAA,CAAA;EAAA,KAAA,cAAA,SAAA,EAAA,GAAA,EAAA,GAAA,CAAA;WAAkB,cAAA,EAAA;MAAf,EAAE,OAAA;EAAK,KAAA,CAAA,EAAA,GAAA;AAEnC,CAAA,EAAA;EAEC,IAAA,CAAA,EAAA,OAAA,GAAA,SAAA;OAFuB,CAAA,EAAA,GAAA;kBAAA,SAAA,EAAA;MAAA,EAAA,MAAA;MAAA,EAAA,GAAA;OAAA,CAAA,CAAA,CAAA,CAAA;AAAA,KAFZ,aAAA,GAAgB,CAAA,CAAE,KAEN,CAAA,OAFmB,UAEnB,CAAA;AAAA,cAAX,WAAW,EAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA,GAAA,CAAA,EAAA,MAAA,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAA,MAAA,CAAA;AAAA,KAGZ,aAAA,GAAgB,CAAA,CAAE,KAHN,CAAA,OAGmB,WAHnB,CAAA"}
package/api/schema.d.ts CHANGED
@@ -6,11 +6,11 @@ declare const errorSchema: z.ZodObject<{
6
6
  error: z.ZodString;
7
7
  status: z.ZodNumber;
8
8
  }, "strip", z.ZodTypeAny, {
9
- error: string;
10
9
  status: number;
11
- }, {
12
10
  error: string;
11
+ }, {
13
12
  status: number;
13
+ error: string;
14
14
  }>;
15
15
  type ErrorResponse = z.infer<typeof errorSchema>;
16
16
  declare const stepSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[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,SAAA;CAAA,CAAA,CAAA,CAAA,aAAA,CAAA;EAyCX,IAAA,cAAa,cAAA,aAAA,CAAA,OAAA,CAAA,CAAA,CAAA;EAAA,KAAA,cAAA,SAAA,EAAA,GAAA,EAAA,GAAA,CAAA;WAAkB,cAAA,EAAA;MAAf,EAAE,OAAA;EAAK,KAAA,CAAA,EAAA,GAAA;AAEnC,CAAA,EAAA;EAEC,IAAA,CAAA,EAAA,OAAA,GAAA,SAAA;OAFuB,CAAA,EAAA,GAAA;kBAAA,SAAA,EAAA;MAAA,EAAA,MAAA;MAAA,EAAA,GAAA;OAAA,CAAA,CAAA,CAAA,CAAA;AAAA,KAFZ,aAAA,GAAgB,CAAA,CAAE,KAEN,CAAA,OAFmB,UAEnB,CAAA;AAAA,cAAX,WAAW,EAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,MAAA,CAAA,EAAA,YAAA,CAAA,GAAA,CAAA,EAAA,MAAA,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAA,MAAA,CAAA;AAAA,KAGZ,aAAA,GAAgB,CAAA,CAAE,KAHN,CAAA,OAGmB,WAHnB,CAAA"}
@@ -0,0 +1,66 @@
1
+ const require_consts = require('../helpers/consts.cjs');
2
+ const require_marker = require('../helpers/marker.cjs');
3
+ const require_InngestFunction = require('./InngestFunction.cjs');
4
+
5
+ //#region src/components/DeferredFunction.ts
6
+ const idDenyRegex = /['\\\n\r]/;
7
+ /**
8
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
9
+ * a major version bump.
10
+ *
11
+ * A defer (companion) function created via `createDefer(...)`. Real
12
+ * `InngestFunction` at runtime, but with the trigger pinned to
13
+ * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and
14
+ * `onFailure` disallowed, and the schema carried as a typed instance
15
+ * property so callers of `defer(id, { function, data })` can extract it.
16
+ *
17
+ * Identify a defer function at runtime via `isDeferredFunction(value)` from
18
+ * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across
19
+ * duplicate SDK copies in the same process.
20
+ *
21
+ * @public
22
+ */
23
+ var DeferredFunction = class extends require_InngestFunction.InngestFunction {
24
+ schema;
25
+ [require_marker.markerKey] = { kind: "deferredFunction" };
26
+ constructor(client, opts, handler, schema) {
27
+ if (idDenyRegex.test(opts.id)) throw new Error(`invalid id "${opts.id}"; must match ${idDenyRegex.source}`);
28
+ super(client, {
29
+ ...opts,
30
+ triggers: []
31
+ }, handler);
32
+ this.schema = schema;
33
+ }
34
+ getConfigTriggers(fnId) {
35
+ return [{
36
+ event: require_consts.internalEvents.DeferredSchedule,
37
+ expression: `event.data._inngest.fn_slug == '${fnId}'`
38
+ }];
39
+ }
40
+ };
41
+ /**
42
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
43
+ * a major version bump.
44
+ *
45
+ * Create a typed defer function. One `createDefer` call = one Inngest
46
+ * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,
47
+ * { function, data })` get the data type inferred from the schema.
48
+ *
49
+ * Mirrors `inngest.createFunction(opts, handler)`, with three differences:
50
+ * the client is the first positional arg, `triggers` is not accepted (the
51
+ * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`
52
+ * describes the payload that callers will send via `defer(id, { function,
53
+ * data })`.
54
+ *
55
+ * Pass the result to `serve()` alongside regular functions so the SDK
56
+ * registers it.
57
+ */
58
+ function createDefer(client, options, handler) {
59
+ const { schema, ...rest } = options;
60
+ return new DeferredFunction(client, rest, handler, schema);
61
+ }
62
+
63
+ //#endregion
64
+ exports.DeferredFunction = DeferredFunction;
65
+ exports.createDefer = createDefer;
66
+ //# sourceMappingURL=DeferredFunction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeferredFunction.cjs","names":["InngestFunction","markerKey","internalEvents"],"sources":["../../src/components/DeferredFunction.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { internalEvents } from \"../helpers/consts.ts\";\nimport { type Marker, markerKey } from \"../helpers/marker.ts\";\nimport type {\n ApplyAllMiddlewareCtxExtensions,\n ApplyAllMiddlewareStepExtensions,\n BaseContext,\n FunctionConfig,\n Handler,\n} from \"../types.ts\";\nimport type {\n builtInMiddleware,\n ClientOptionsFromInngest,\n Inngest,\n} from \"./Inngest.ts\";\nimport { InngestFunction } from \"./InngestFunction.ts\";\nimport type { createStepTools } from \"./InngestStepTools.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\n\nconst idDenyRegex = /['\\\\\\n\\r]/;\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * A defer (companion) function created via `createDefer(...)`. Real\n * `InngestFunction` at runtime, but with the trigger pinned to\n * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and\n * `onFailure` disallowed, and the schema carried as a typed instance\n * property so callers of `defer(id, { function, data })` can extract it.\n *\n * Identify a defer function at runtime via `isDeferredFunction(value)` from\n * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across\n * duplicate SDK copies in the same process.\n *\n * @public\n */\nexport class DeferredFunction<\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n> extends InngestFunction<\n InngestFunction.Options<[], never>,\n Handler.Any,\n never,\n Inngest.Any,\n []\n> {\n readonly schema: TSchema;\n readonly [markerKey]: Marker = { kind: \"deferredFunction\" };\n\n constructor(\n client: Inngest.Any,\n opts: DeferredFunction.Options,\n handler: Handler.Any,\n schema: TSchema,\n ) {\n // The id is interpolated into a CEL trigger expression\n // (`event.data._inngest.fn_slug == '${fnId}'`). Reject characters that\n // would break the single-quoted string literal.\n if (idDenyRegex.test(opts.id)) {\n throw new Error(\n `invalid id \"${opts.id}\"; must match ${idDenyRegex.source}`,\n );\n }\n super(\n client,\n { ...opts, triggers: [] } as InngestFunction.Options<[], never>,\n handler,\n );\n this.schema = schema;\n }\n\n protected override getConfigTriggers(\n fnId: string,\n ): FunctionConfig[\"triggers\"] {\n return [\n {\n event: internalEvents.DeferredSchedule,\n expression: `event.data._inngest.fn_slug == '${fnId}'`,\n },\n ];\n }\n}\n\n/**\n * @public\n */\nexport namespace DeferredFunction {\n /**\n * Matches any `DeferredFunction` regardless of its schema. Use as the\n * constraint for the `function` argument of `defer()`.\n */\n // biome-ignore lint/suspicious/noExplicitAny: widest schema constraint for inference\n export type Any = DeferredFunction<StandardSchemaV1<any> | undefined>;\n\n /**\n * The user-facing options accepted by `createDefer(client, opts, handler)`.\n * Mirrors `InngestFunction.Options` minus `triggers` (implicit), `onFailure`\n * (not yet supported), and `batchEvents` (each `defer(...)` is its own run).\n */\n export type Options = Omit<\n InngestFunction.Options<[], never>,\n \"triggers\" | \"onFailure\" | \"batchEvents\"\n >;\n}\n\n/**\n * The `event` shape a defer handler receives. With a schema, `data`\n * narrows to its inferred type; without one, it falls back to\n * `Record<string, any>`.\n */\ntype DeferEvent<TSchema> = {\n name: internalEvents.DeferredSchedule;\n data: TSchema extends StandardSchemaV1<\n infer D extends Record<string, unknown>\n >\n ? D\n : // biome-ignore lint/suspicious/noExplicitAny: no schema = any\n Record<string, any>;\n};\n\n/**\n * Base ctx shape for a defer handler: the standard function context\n * (`runId`, `attempt`, `group`, `step` with middleware step extensions)\n * with `event`/`events` pinned to `inngest/deferred.schedule` and the\n * schema-typed payload.\n */\ntype BaseDeferCtx<\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined,\n TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined,\n> = Omit<BaseContext<TClient>, \"event\" | \"events\" | \"step\"> & {\n event: DeferEvent<TSchema>;\n events: [DeferEvent<TSchema>];\n step: ReturnType<typeof createStepTools<TClient, TFnMiddleware>> &\n ApplyAllMiddlewareStepExtensions<\n ClientOptionsFromInngest<TClient>[\"middleware\"]\n > &\n ApplyAllMiddlewareStepExtensions<TFnMiddleware>;\n};\n\n/**\n * Input type for `createDefer`. Same shape as `DeferredFunction.Options`\n * plus `schema` (the StandardSchema describing `event.data` that flows\n * to caller `defer(id, { function, data })` call sites) and `middleware`.\n */\nexport type CreateDeferInput<\n TFnMiddleware extends Middleware.Class[] | undefined,\n TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined,\n> = DeferredFunction.Options & {\n schema?: TSchema;\n middleware?: TFnMiddleware;\n};\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * Create a typed defer function. One `createDefer` call = one Inngest\n * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,\n * { function, data })` get the data type inferred from the schema.\n *\n * Mirrors `inngest.createFunction(opts, handler)`, with three differences:\n * the client is the first positional arg, `triggers` is not accepted (the\n * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`\n * describes the payload that callers will send via `defer(id, { function,\n * data })`.\n *\n * Pass the result to `serve()` alongside regular functions so the SDK\n * registers it.\n */\nexport function createDefer<\n TClient extends Inngest.Any,\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n const TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n THandler extends Handler.Any = (\n ctx: BaseDeferCtx<TClient, TFnMiddleware, TSchema> &\n ApplyAllMiddlewareCtxExtensions<\n [...ReturnType<typeof builtInMiddleware>]\n > &\n ApplyAllMiddlewareCtxExtensions<\n ClientOptionsFromInngest<TClient>[\"middleware\"]\n > &\n ApplyAllMiddlewareCtxExtensions<TFnMiddleware>,\n ) => unknown,\n>(\n client: TClient,\n options: CreateDeferInput<TFnMiddleware, TSchema>,\n handler: THandler,\n): DeferredFunction<TSchema> {\n const { schema, ...rest } = options;\n return new DeferredFunction<TSchema>(\n client,\n rest,\n handler as Handler.Any,\n schema as TSchema,\n );\n}\n"],"mappings":";;;;;AAmBA,MAAM,cAAc;;;;;;;;;;;;;;;;;AAkBpB,IAAa,mBAAb,cAIUA,wCAMR;CACA,AAAS;CACT,CAAUC,4BAAqB,EAAE,MAAM,oBAAoB;CAE3D,YACE,QACA,MACA,SACA,QACA;AAIA,MAAI,YAAY,KAAK,KAAK,GAAG,CAC3B,OAAM,IAAI,MACR,eAAe,KAAK,GAAG,gBAAgB,YAAY,SACpD;AAEH,QACE,QACA;GAAE,GAAG;GAAM,UAAU,EAAE;GAAE,EACzB,QACD;AACD,OAAK,SAAS;;CAGhB,AAAmB,kBACjB,MAC4B;AAC5B,SAAO,CACL;GACE,OAAOC,8BAAe;GACtB,YAAY,mCAAmC,KAAK;GACrD,CACF;;;;;;;;;;;;;;;;;;;;AA2FL,SAAgB,YAiBd,QACA,SACA,SAC2B;CAC3B,MAAM,EAAE,QAAQ,GAAG,SAAS;AAC5B,QAAO,IAAI,iBACT,QACA,MACA,SACA,OACD"}
@@ -0,0 +1,99 @@
1
+ import { internalEvents } from "../helpers/consts.cjs";
2
+ import { Marker, markerKey } from "../helpers/marker.cjs";
3
+ import { Middleware } from "./middleware/middleware.cjs";
4
+ import { createStepTools } from "./InngestStepTools.cjs";
5
+ import { InngestFunction } from "./InngestFunction.cjs";
6
+ import { ApplyAllMiddlewareCtxExtensions, ApplyAllMiddlewareStepExtensions, BaseContext, FunctionConfig, Handler } from "../types.cjs";
7
+ import { ClientOptionsFromInngest, Inngest, builtInMiddleware } from "./Inngest.cjs";
8
+ import { StandardSchemaV1 } from "@standard-schema/spec";
9
+
10
+ //#region src/components/DeferredFunction.d.ts
11
+
12
+ /**
13
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
14
+ * a major version bump.
15
+ *
16
+ * A defer (companion) function created via `createDefer(...)`. Real
17
+ * `InngestFunction` at runtime, but with the trigger pinned to
18
+ * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and
19
+ * `onFailure` disallowed, and the schema carried as a typed instance
20
+ * property so callers of `defer(id, { function, data })` can extract it.
21
+ *
22
+ * Identify a defer function at runtime via `isDeferredFunction(value)` from
23
+ * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across
24
+ * duplicate SDK copies in the same process.
25
+ *
26
+ * @public
27
+ */
28
+ declare class DeferredFunction<TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined> extends InngestFunction<InngestFunction.Options<[], never>, Handler.Any, never, Inngest.Any, []> {
29
+ readonly schema: TSchema;
30
+ readonly [markerKey]: Marker;
31
+ constructor(client: Inngest.Any, opts: DeferredFunction.Options, handler: Handler.Any, schema: TSchema);
32
+ protected getConfigTriggers(fnId: string): FunctionConfig["triggers"];
33
+ }
34
+ /**
35
+ * @public
36
+ */
37
+ declare namespace DeferredFunction {
38
+ /**
39
+ * Matches any `DeferredFunction` regardless of its schema. Use as the
40
+ * constraint for the `function` argument of `defer()`.
41
+ */
42
+ type Any = DeferredFunction<StandardSchemaV1<any> | undefined>;
43
+ /**
44
+ * The user-facing options accepted by `createDefer(client, opts, handler)`.
45
+ * Mirrors `InngestFunction.Options` minus `triggers` (implicit), `onFailure`
46
+ * (not yet supported), and `batchEvents` (each `defer(...)` is its own run).
47
+ */
48
+ type Options = Omit<InngestFunction.Options<[], never>, "triggers" | "onFailure" | "batchEvents">;
49
+ }
50
+ /**
51
+ * The `event` shape a defer handler receives. With a schema, `data`
52
+ * narrows to its inferred type; without one, it falls back to
53
+ * `Record<string, any>`.
54
+ */
55
+ type DeferEvent<TSchema> = {
56
+ name: internalEvents.DeferredSchedule;
57
+ data: TSchema extends StandardSchemaV1<infer D extends Record<string, unknown>> ? D : Record<string, any>;
58
+ };
59
+ /**
60
+ * Base ctx shape for a defer handler: the standard function context
61
+ * (`runId`, `attempt`, `group`, `step` with middleware step extensions)
62
+ * with `event`/`events` pinned to `inngest/deferred.schedule` and the
63
+ * schema-typed payload.
64
+ */
65
+ type BaseDeferCtx<TClient extends Inngest.Any, TFnMiddleware extends Middleware.Class[] | undefined, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined> = Omit<BaseContext<TClient>, "event" | "events" | "step"> & {
66
+ event: DeferEvent<TSchema>;
67
+ events: [DeferEvent<TSchema>];
68
+ step: ReturnType<typeof createStepTools<TClient, TFnMiddleware>> & ApplyAllMiddlewareStepExtensions<ClientOptionsFromInngest<TClient>["middleware"]> & ApplyAllMiddlewareStepExtensions<TFnMiddleware>;
69
+ };
70
+ /**
71
+ * Input type for `createDefer`. Same shape as `DeferredFunction.Options`
72
+ * plus `schema` (the StandardSchema describing `event.data` that flows
73
+ * to caller `defer(id, { function, data })` call sites) and `middleware`.
74
+ */
75
+ type CreateDeferInput<TFnMiddleware extends Middleware.Class[] | undefined, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined> = DeferredFunction.Options & {
76
+ schema?: TSchema;
77
+ middleware?: TFnMiddleware;
78
+ };
79
+ /**
80
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
81
+ * a major version bump.
82
+ *
83
+ * Create a typed defer function. One `createDefer` call = one Inngest
84
+ * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,
85
+ * { function, data })` get the data type inferred from the schema.
86
+ *
87
+ * Mirrors `inngest.createFunction(opts, handler)`, with three differences:
88
+ * the client is the first positional arg, `triggers` is not accepted (the
89
+ * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`
90
+ * describes the payload that callers will send via `defer(id, { function,
91
+ * data })`.
92
+ *
93
+ * Pass the result to `serve()` alongside regular functions so the SDK
94
+ * registers it.
95
+ */
96
+ declare function createDefer<TClient extends Inngest.Any, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined, const TFnMiddleware extends Middleware.Class[] | undefined = undefined, THandler extends Handler.Any = (ctx: BaseDeferCtx<TClient, TFnMiddleware, TSchema> & ApplyAllMiddlewareCtxExtensions<[...ReturnType<typeof builtInMiddleware>]> & ApplyAllMiddlewareCtxExtensions<ClientOptionsFromInngest<TClient>["middleware"]> & ApplyAllMiddlewareCtxExtensions<TFnMiddleware>) => unknown>(client: TClient, options: CreateDeferInput<TFnMiddleware, TSchema>, handler: THandler): DeferredFunction<TSchema>;
97
+ //#endregion
98
+ export { DeferredFunction, createDefer };
99
+ //# sourceMappingURL=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AQpB,CAAA,KANJ,+BAOsB,CANpB,wBAMoB,CANK,OAML,CAAA,CAAA,YAAA,CAAA,CAAA,GAJtB,+BAIsB,CAJU,aAIV,CAAA,EAAA,GAAA,OAAA,CAAA,CAAA,MAAA,EADlB,OACkB,EAAA,OAAA,EAAjB,gBAAiB,CAAA,aAAA,EAAe,OAAf,CAAA,EAAA,OAAA,EACjB,QADiB,CAAA,EAEzB,gBAFyB,CAER,OAFQ,CAAA"}
@@ -0,0 +1,99 @@
1
+ import { internalEvents } from "../helpers/consts.js";
2
+ import { Marker, markerKey } from "../helpers/marker.js";
3
+ import { Middleware } from "./middleware/middleware.js";
4
+ import { createStepTools } from "./InngestStepTools.js";
5
+ import { InngestFunction } from "./InngestFunction.js";
6
+ import { ApplyAllMiddlewareCtxExtensions, ApplyAllMiddlewareStepExtensions, BaseContext, FunctionConfig, Handler } from "../types.js";
7
+ import { ClientOptionsFromInngest, Inngest, builtInMiddleware } from "./Inngest.js";
8
+ import { StandardSchemaV1 } from "@standard-schema/spec";
9
+
10
+ //#region src/components/DeferredFunction.d.ts
11
+
12
+ /**
13
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
14
+ * a major version bump.
15
+ *
16
+ * A defer (companion) function created via `createDefer(...)`. Real
17
+ * `InngestFunction` at runtime, but with the trigger pinned to
18
+ * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and
19
+ * `onFailure` disallowed, and the schema carried as a typed instance
20
+ * property so callers of `defer(id, { function, data })` can extract it.
21
+ *
22
+ * Identify a defer function at runtime via `isDeferredFunction(value)` from
23
+ * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across
24
+ * duplicate SDK copies in the same process.
25
+ *
26
+ * @public
27
+ */
28
+ declare class DeferredFunction<TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined> extends InngestFunction<InngestFunction.Options<[], never>, Handler.Any, never, Inngest.Any, []> {
29
+ readonly schema: TSchema;
30
+ readonly [markerKey]: Marker;
31
+ constructor(client: Inngest.Any, opts: DeferredFunction.Options, handler: Handler.Any, schema: TSchema);
32
+ protected getConfigTriggers(fnId: string): FunctionConfig["triggers"];
33
+ }
34
+ /**
35
+ * @public
36
+ */
37
+ declare namespace DeferredFunction {
38
+ /**
39
+ * Matches any `DeferredFunction` regardless of its schema. Use as the
40
+ * constraint for the `function` argument of `defer()`.
41
+ */
42
+ type Any = DeferredFunction<StandardSchemaV1<any> | undefined>;
43
+ /**
44
+ * The user-facing options accepted by `createDefer(client, opts, handler)`.
45
+ * Mirrors `InngestFunction.Options` minus `triggers` (implicit), `onFailure`
46
+ * (not yet supported), and `batchEvents` (each `defer(...)` is its own run).
47
+ */
48
+ type Options = Omit<InngestFunction.Options<[], never>, "triggers" | "onFailure" | "batchEvents">;
49
+ }
50
+ /**
51
+ * The `event` shape a defer handler receives. With a schema, `data`
52
+ * narrows to its inferred type; without one, it falls back to
53
+ * `Record<string, any>`.
54
+ */
55
+ type DeferEvent<TSchema> = {
56
+ name: internalEvents.DeferredSchedule;
57
+ data: TSchema extends StandardSchemaV1<infer D extends Record<string, unknown>> ? D : Record<string, any>;
58
+ };
59
+ /**
60
+ * Base ctx shape for a defer handler: the standard function context
61
+ * (`runId`, `attempt`, `group`, `step` with middleware step extensions)
62
+ * with `event`/`events` pinned to `inngest/deferred.schedule` and the
63
+ * schema-typed payload.
64
+ */
65
+ type BaseDeferCtx<TClient extends Inngest.Any, TFnMiddleware extends Middleware.Class[] | undefined, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined> = Omit<BaseContext<TClient>, "event" | "events" | "step"> & {
66
+ event: DeferEvent<TSchema>;
67
+ events: [DeferEvent<TSchema>];
68
+ step: ReturnType<typeof createStepTools<TClient, TFnMiddleware>> & ApplyAllMiddlewareStepExtensions<ClientOptionsFromInngest<TClient>["middleware"]> & ApplyAllMiddlewareStepExtensions<TFnMiddleware>;
69
+ };
70
+ /**
71
+ * Input type for `createDefer`. Same shape as `DeferredFunction.Options`
72
+ * plus `schema` (the StandardSchema describing `event.data` that flows
73
+ * to caller `defer(id, { function, data })` call sites) and `middleware`.
74
+ */
75
+ type CreateDeferInput<TFnMiddleware extends Middleware.Class[] | undefined, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined> = DeferredFunction.Options & {
76
+ schema?: TSchema;
77
+ middleware?: TFnMiddleware;
78
+ };
79
+ /**
80
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
81
+ * a major version bump.
82
+ *
83
+ * Create a typed defer function. One `createDefer` call = one Inngest
84
+ * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,
85
+ * { function, data })` get the data type inferred from the schema.
86
+ *
87
+ * Mirrors `inngest.createFunction(opts, handler)`, with three differences:
88
+ * the client is the first positional arg, `triggers` is not accepted (the
89
+ * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`
90
+ * describes the payload that callers will send via `defer(id, { function,
91
+ * data })`.
92
+ *
93
+ * Pass the result to `serve()` alongside regular functions so the SDK
94
+ * registers it.
95
+ */
96
+ declare function createDefer<TClient extends Inngest.Any, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined, const TFnMiddleware extends Middleware.Class[] | undefined = undefined, THandler extends Handler.Any = (ctx: BaseDeferCtx<TClient, TFnMiddleware, TSchema> & ApplyAllMiddlewareCtxExtensions<[...ReturnType<typeof builtInMiddleware>]> & ApplyAllMiddlewareCtxExtensions<ClientOptionsFromInngest<TClient>["middleware"]> & ApplyAllMiddlewareCtxExtensions<TFnMiddleware>) => unknown>(client: TClient, options: CreateDeferInput<TFnMiddleware, TSchema>, handler: THandler): DeferredFunction<TSchema>;
97
+ //#endregion
98
+ export { DeferredFunction, createDefer };
99
+ //# sourceMappingURL=DeferredFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeferredFunction.d.ts","names":[],"sources":["../../src/components/DeferredFunction.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAqCA;;;;;;;;;;;;;;AAsCK,cAtCQ,gBAsCR,CAAA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AiB,CAAA,aAAA,EAAe,OAAf,CAAA,EAAA,OAAA,EACjB,QADiB,CAAA,EAEzB,gBAFyB,CAER,OAFQ,CAAA"}
@@ -0,0 +1,65 @@
1
+ import { internalEvents } from "../helpers/consts.js";
2
+ import { markerKey } from "../helpers/marker.js";
3
+ import { InngestFunction } from "./InngestFunction.js";
4
+
5
+ //#region src/components/DeferredFunction.ts
6
+ const idDenyRegex = /['\\\n\r]/;
7
+ /**
8
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
9
+ * a major version bump.
10
+ *
11
+ * A defer (companion) function created via `createDefer(...)`. Real
12
+ * `InngestFunction` at runtime, but with the trigger pinned to
13
+ * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and
14
+ * `onFailure` disallowed, and the schema carried as a typed instance
15
+ * property so callers of `defer(id, { function, data })` can extract it.
16
+ *
17
+ * Identify a defer function at runtime via `isDeferredFunction(value)` from
18
+ * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across
19
+ * duplicate SDK copies in the same process.
20
+ *
21
+ * @public
22
+ */
23
+ var DeferredFunction = class extends InngestFunction {
24
+ schema;
25
+ [markerKey] = { kind: "deferredFunction" };
26
+ constructor(client, opts, handler, schema) {
27
+ if (idDenyRegex.test(opts.id)) throw new Error(`invalid id "${opts.id}"; must match ${idDenyRegex.source}`);
28
+ super(client, {
29
+ ...opts,
30
+ triggers: []
31
+ }, handler);
32
+ this.schema = schema;
33
+ }
34
+ getConfigTriggers(fnId) {
35
+ return [{
36
+ event: internalEvents.DeferredSchedule,
37
+ expression: `event.data._inngest.fn_slug == '${fnId}'`
38
+ }];
39
+ }
40
+ };
41
+ /**
42
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
43
+ * a major version bump.
44
+ *
45
+ * Create a typed defer function. One `createDefer` call = one Inngest
46
+ * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,
47
+ * { function, data })` get the data type inferred from the schema.
48
+ *
49
+ * Mirrors `inngest.createFunction(opts, handler)`, with three differences:
50
+ * the client is the first positional arg, `triggers` is not accepted (the
51
+ * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`
52
+ * describes the payload that callers will send via `defer(id, { function,
53
+ * data })`.
54
+ *
55
+ * Pass the result to `serve()` alongside regular functions so the SDK
56
+ * registers it.
57
+ */
58
+ function createDefer(client, options, handler) {
59
+ const { schema, ...rest } = options;
60
+ return new DeferredFunction(client, rest, handler, schema);
61
+ }
62
+
63
+ //#endregion
64
+ export { DeferredFunction, createDefer };
65
+ //# sourceMappingURL=DeferredFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeferredFunction.js","names":[],"sources":["../../src/components/DeferredFunction.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { internalEvents } from \"../helpers/consts.ts\";\nimport { type Marker, markerKey } from \"../helpers/marker.ts\";\nimport type {\n ApplyAllMiddlewareCtxExtensions,\n ApplyAllMiddlewareStepExtensions,\n BaseContext,\n FunctionConfig,\n Handler,\n} from \"../types.ts\";\nimport type {\n builtInMiddleware,\n ClientOptionsFromInngest,\n Inngest,\n} from \"./Inngest.ts\";\nimport { InngestFunction } from \"./InngestFunction.ts\";\nimport type { createStepTools } from \"./InngestStepTools.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\n\nconst idDenyRegex = /['\\\\\\n\\r]/;\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * A defer (companion) function created via `createDefer(...)`. Real\n * `InngestFunction` at runtime, but with the trigger pinned to\n * `inngest/deferred.schedule` (see `getConfigTriggers`), `triggers` and\n * `onFailure` disallowed, and the schema carried as a typed instance\n * property so callers of `defer(id, { function, data })` can extract it.\n *\n * Identify a defer function at runtime via `isDeferredFunction(value)` from\n * `helpers/marker.ts`. Prefer that over `instanceof`, which fails across\n * duplicate SDK copies in the same process.\n *\n * @public\n */\nexport class DeferredFunction<\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n> extends InngestFunction<\n InngestFunction.Options<[], never>,\n Handler.Any,\n never,\n Inngest.Any,\n []\n> {\n readonly schema: TSchema;\n readonly [markerKey]: Marker = { kind: \"deferredFunction\" };\n\n constructor(\n client: Inngest.Any,\n opts: DeferredFunction.Options,\n handler: Handler.Any,\n schema: TSchema,\n ) {\n // The id is interpolated into a CEL trigger expression\n // (`event.data._inngest.fn_slug == '${fnId}'`). Reject characters that\n // would break the single-quoted string literal.\n if (idDenyRegex.test(opts.id)) {\n throw new Error(\n `invalid id \"${opts.id}\"; must match ${idDenyRegex.source}`,\n );\n }\n super(\n client,\n { ...opts, triggers: [] } as InngestFunction.Options<[], never>,\n handler,\n );\n this.schema = schema;\n }\n\n protected override getConfigTriggers(\n fnId: string,\n ): FunctionConfig[\"triggers\"] {\n return [\n {\n event: internalEvents.DeferredSchedule,\n expression: `event.data._inngest.fn_slug == '${fnId}'`,\n },\n ];\n }\n}\n\n/**\n * @public\n */\nexport namespace DeferredFunction {\n /**\n * Matches any `DeferredFunction` regardless of its schema. Use as the\n * constraint for the `function` argument of `defer()`.\n */\n // biome-ignore lint/suspicious/noExplicitAny: widest schema constraint for inference\n export type Any = DeferredFunction<StandardSchemaV1<any> | undefined>;\n\n /**\n * The user-facing options accepted by `createDefer(client, opts, handler)`.\n * Mirrors `InngestFunction.Options` minus `triggers` (implicit), `onFailure`\n * (not yet supported), and `batchEvents` (each `defer(...)` is its own run).\n */\n export type Options = Omit<\n InngestFunction.Options<[], never>,\n \"triggers\" | \"onFailure\" | \"batchEvents\"\n >;\n}\n\n/**\n * The `event` shape a defer handler receives. With a schema, `data`\n * narrows to its inferred type; without one, it falls back to\n * `Record<string, any>`.\n */\ntype DeferEvent<TSchema> = {\n name: internalEvents.DeferredSchedule;\n data: TSchema extends StandardSchemaV1<\n infer D extends Record<string, unknown>\n >\n ? D\n : // biome-ignore lint/suspicious/noExplicitAny: no schema = any\n Record<string, any>;\n};\n\n/**\n * Base ctx shape for a defer handler: the standard function context\n * (`runId`, `attempt`, `group`, `step` with middleware step extensions)\n * with `event`/`events` pinned to `inngest/deferred.schedule` and the\n * schema-typed payload.\n */\ntype BaseDeferCtx<\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined,\n TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined,\n> = Omit<BaseContext<TClient>, \"event\" | \"events\" | \"step\"> & {\n event: DeferEvent<TSchema>;\n events: [DeferEvent<TSchema>];\n step: ReturnType<typeof createStepTools<TClient, TFnMiddleware>> &\n ApplyAllMiddlewareStepExtensions<\n ClientOptionsFromInngest<TClient>[\"middleware\"]\n > &\n ApplyAllMiddlewareStepExtensions<TFnMiddleware>;\n};\n\n/**\n * Input type for `createDefer`. Same shape as `DeferredFunction.Options`\n * plus `schema` (the StandardSchema describing `event.data` that flows\n * to caller `defer(id, { function, data })` call sites) and `middleware`.\n */\nexport type CreateDeferInput<\n TFnMiddleware extends Middleware.Class[] | undefined,\n TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined,\n> = DeferredFunction.Options & {\n schema?: TSchema;\n middleware?: TFnMiddleware;\n};\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * Create a typed defer function. One `createDefer` call = one Inngest\n * function. Returns a `DeferredFunction<TSchema>` so callers of `defer(id,\n * { function, data })` get the data type inferred from the schema.\n *\n * Mirrors `inngest.createFunction(opts, handler)`, with three differences:\n * the client is the first positional arg, `triggers` is not accepted (the\n * SDK emits an implicit `inngest/deferred.schedule` trigger), and `schema`\n * describes the payload that callers will send via `defer(id, { function,\n * data })`.\n *\n * Pass the result to `serve()` alongside regular functions so the SDK\n * registers it.\n */\nexport function createDefer<\n TClient extends Inngest.Any,\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n const TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n THandler extends Handler.Any = (\n ctx: BaseDeferCtx<TClient, TFnMiddleware, TSchema> &\n ApplyAllMiddlewareCtxExtensions<\n [...ReturnType<typeof builtInMiddleware>]\n > &\n ApplyAllMiddlewareCtxExtensions<\n ClientOptionsFromInngest<TClient>[\"middleware\"]\n > &\n ApplyAllMiddlewareCtxExtensions<TFnMiddleware>,\n ) => unknown,\n>(\n client: TClient,\n options: CreateDeferInput<TFnMiddleware, TSchema>,\n handler: THandler,\n): DeferredFunction<TSchema> {\n const { schema, ...rest } = options;\n return new DeferredFunction<TSchema>(\n client,\n rest,\n handler as Handler.Any,\n schema as TSchema,\n );\n}\n"],"mappings":";;;;;AAmBA,MAAM,cAAc;;;;;;;;;;;;;;;;;AAkBpB,IAAa,mBAAb,cAIU,gBAMR;CACA,AAAS;CACT,CAAU,aAAqB,EAAE,MAAM,oBAAoB;CAE3D,YACE,QACA,MACA,SACA,QACA;AAIA,MAAI,YAAY,KAAK,KAAK,GAAG,CAC3B,OAAM,IAAI,MACR,eAAe,KAAK,GAAG,gBAAgB,YAAY,SACpD;AAEH,QACE,QACA;GAAE,GAAG;GAAM,UAAU,EAAE;GAAE,EACzB,QACD;AACD,OAAK,SAAS;;CAGhB,AAAmB,kBACjB,MAC4B;AAC5B,SAAO,CACL;GACE,OAAO,eAAe;GACtB,YAAY,mCAAmC,KAAK;GACrD,CACF;;;;;;;;;;;;;;;;;;;;AA2FL,SAAgB,YAiBd,QACA,SACA,SAC2B;CAC3B,MAAM,EAAE,QAAQ,GAAG,SAAS;AAC5B,QAAO,IAAI,iBACT,QACA,MACA,SACA,OACD"}
@@ -576,10 +576,13 @@ function builtInMiddleware(baseLogger) {
576
576
  transformFunctionInput(arg) {
577
577
  let logger = baseLogger;
578
578
  if ("child" in logger) try {
579
- logger = logger.child({
579
+ const childMetadata = {
580
580
  runID: arg.ctx.runId,
581
581
  eventName: arg.ctx.event.name
582
- });
582
+ };
583
+ if (typeof arg.ctx.requestId !== "undefined") childMetadata.requestId = arg.ctx.requestId;
584
+ if (typeof arg.ctx.jobId !== "undefined") childMetadata.jobId = arg.ctx.jobId;
585
+ logger = logger.child(childMetadata);
583
586
  } catch (err) {
584
587
  logger.error({ err }, "failed to create \"childLogger\" with error");
585
588
  }