inngest 4.2.6 → 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 (175) hide show
  1. package/CHANGELOG.md +24 -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 +11 -4
  17. package/components/Inngest.d.cts.map +1 -1
  18. package/components/Inngest.d.ts +11 -4
  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/InngestStepTools.cjs +3 -7
  43. package/components/InngestStepTools.cjs.map +1 -1
  44. package/components/InngestStepTools.d.cts +10 -7
  45. package/components/InngestStepTools.d.cts.map +1 -1
  46. package/components/InngestStepTools.d.ts +10 -7
  47. package/components/InngestStepTools.d.ts.map +1 -1
  48. package/components/InngestStepTools.js +3 -7
  49. package/components/InngestStepTools.js.map +1 -1
  50. package/components/connect/config.cjs +2 -0
  51. package/components/connect/config.cjs.map +1 -1
  52. package/components/connect/config.js +2 -0
  53. package/components/connect/config.js.map +1 -1
  54. package/components/connect/strategies/core/connection.cjs +91 -11
  55. package/components/connect/strategies/core/connection.cjs.map +1 -1
  56. package/components/connect/strategies/core/connection.js +91 -11
  57. package/components/connect/strategies/core/connection.js.map +1 -1
  58. package/components/connect/strategies/core/heartbeat.cjs +2 -1
  59. package/components/connect/strategies/core/heartbeat.cjs.map +1 -1
  60. package/components/connect/strategies/core/heartbeat.js +2 -1
  61. package/components/connect/strategies/core/heartbeat.js.map +1 -1
  62. package/components/connect/strategies/core/requestProcessor.cjs +27 -4
  63. package/components/connect/strategies/core/requestProcessor.cjs.map +1 -1
  64. package/components/connect/strategies/core/requestProcessor.js +27 -4
  65. package/components/connect/strategies/core/requestProcessor.js.map +1 -1
  66. package/components/connect/strategies/core/types.cjs +21 -0
  67. package/components/connect/strategies/core/types.cjs.map +1 -0
  68. package/components/connect/strategies/core/types.js +20 -0
  69. package/components/connect/strategies/core/types.js.map +1 -0
  70. package/components/connect/types.cjs.map +1 -1
  71. package/components/connect/types.d.cts +18 -0
  72. package/components/connect/types.d.cts.map +1 -1
  73. package/components/connect/types.d.ts +18 -0
  74. package/components/connect/types.d.ts.map +1 -1
  75. package/components/connect/types.js.map +1 -1
  76. package/components/execution/InngestExecution.cjs.map +1 -1
  77. package/components/execution/InngestExecution.d.cts +19 -2
  78. package/components/execution/InngestExecution.d.cts.map +1 -1
  79. package/components/execution/InngestExecution.d.ts +19 -2
  80. package/components/execution/InngestExecution.d.ts.map +1 -1
  81. package/components/execution/InngestExecution.js.map +1 -1
  82. package/components/execution/engine.cjs +233 -28
  83. package/components/execution/engine.cjs.map +1 -1
  84. package/components/execution/engine.d.cts +14 -0
  85. package/components/execution/engine.d.cts.map +1 -1
  86. package/components/execution/engine.d.ts +14 -0
  87. package/components/execution/engine.d.ts.map +1 -1
  88. package/components/execution/engine.js +233 -28
  89. package/components/execution/engine.js.map +1 -1
  90. package/components/execution/lazyOps.cjs +64 -0
  91. package/components/execution/lazyOps.cjs.map +1 -0
  92. package/components/execution/lazyOps.d.cts +42 -0
  93. package/components/execution/lazyOps.d.cts.map +1 -0
  94. package/components/execution/lazyOps.d.ts +42 -0
  95. package/components/execution/lazyOps.d.ts.map +1 -0
  96. package/components/execution/lazyOps.js +63 -0
  97. package/components/execution/lazyOps.js.map +1 -0
  98. package/components/execution/otel/middleware.d.cts +14 -5
  99. package/components/execution/otel/middleware.d.cts.map +1 -1
  100. package/components/execution/otel/middleware.d.ts +14 -5
  101. package/components/execution/otel/middleware.d.ts.map +1 -1
  102. package/components/middleware/manager.cjs +1 -1
  103. package/components/middleware/manager.cjs.map +1 -1
  104. package/components/middleware/manager.js +2 -2
  105. package/components/middleware/manager.js.map +1 -1
  106. package/components/middleware/middleware.cjs.map +1 -1
  107. package/components/middleware/middleware.d.cts +1 -1
  108. package/components/middleware/middleware.d.cts.map +1 -1
  109. package/components/middleware/middleware.d.ts +1 -1
  110. package/components/middleware/middleware.d.ts.map +1 -1
  111. package/components/middleware/middleware.js.map +1 -1
  112. package/components/middleware/utils.cjs +5 -3
  113. package/components/middleware/utils.cjs.map +1 -1
  114. package/components/middleware/utils.js +5 -3
  115. package/components/middleware/utils.js.map +1 -1
  116. package/components/triggers/typeHelpers.cjs.map +1 -1
  117. package/components/triggers/typeHelpers.d.cts +11 -0
  118. package/components/triggers/typeHelpers.d.cts.map +1 -1
  119. package/components/triggers/typeHelpers.d.ts +11 -0
  120. package/components/triggers/typeHelpers.d.ts.map +1 -1
  121. package/components/triggers/typeHelpers.js.map +1 -1
  122. package/experimental.cjs +3 -0
  123. package/experimental.d.cts +2 -1
  124. package/experimental.d.ts +2 -1
  125. package/experimental.js +2 -1
  126. package/helpers/consts.cjs +6 -0
  127. package/helpers/consts.cjs.map +1 -1
  128. package/helpers/consts.d.cts +6 -0
  129. package/helpers/consts.d.cts.map +1 -1
  130. package/helpers/consts.d.ts +6 -0
  131. package/helpers/consts.d.ts.map +1 -1
  132. package/helpers/consts.js +6 -0
  133. package/helpers/consts.js.map +1 -1
  134. package/helpers/functions.cjs +1 -0
  135. package/helpers/functions.cjs.map +1 -1
  136. package/helpers/functions.js +1 -0
  137. package/helpers/functions.js.map +1 -1
  138. package/helpers/marker.cjs +21 -0
  139. package/helpers/marker.cjs.map +1 -0
  140. package/helpers/marker.d.cts +12 -0
  141. package/helpers/marker.d.cts.map +1 -0
  142. package/helpers/marker.d.ts +12 -0
  143. package/helpers/marker.d.ts.map +1 -0
  144. package/helpers/marker.js +19 -0
  145. package/helpers/marker.js.map +1 -0
  146. package/helpers/strings.cjs +10 -4
  147. package/helpers/strings.cjs.map +1 -1
  148. package/helpers/strings.d.cts.map +1 -1
  149. package/helpers/strings.d.ts.map +1 -1
  150. package/helpers/strings.js +10 -4
  151. package/helpers/strings.js.map +1 -1
  152. package/helpers/temporal.cjs +2 -0
  153. package/helpers/temporal.d.ts +3 -0
  154. package/helpers/temporal.d.ts.map +1 -1
  155. package/helpers/temporal.js +1 -1
  156. package/package.json +2 -2
  157. package/proto/src/components/connect/protobuf/connect.cjs +11 -2
  158. package/proto/src/components/connect/protobuf/connect.cjs.map +1 -1
  159. package/proto/src/components/connect/protobuf/connect.js +11 -2
  160. package/proto/src/components/connect/protobuf/connect.js.map +1 -1
  161. package/react.d.cts.map +1 -1
  162. package/types.cjs +2 -0
  163. package/types.cjs.map +1 -1
  164. package/types.d.cts +43 -8
  165. package/types.d.cts.map +1 -1
  166. package/types.d.ts +43 -8
  167. package/types.d.ts.map +1 -1
  168. package/types.js +2 -0
  169. package/types.js.map +1 -1
  170. package/version.cjs +1 -1
  171. package/version.cjs.map +1 -1
  172. package/version.d.cts +1 -1
  173. package/version.d.ts +1 -1
  174. package/version.js +1 -1
  175. package/version.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.cjs","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":["import type { Jsonify } from \"../../helpers/jsonify.ts\";\nimport type { MaybePromise } from \"../../helpers/types.ts\";\nimport type {\n Context,\n EventPayload,\n JsonError,\n SendEventBaseOutput,\n StepOptions,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type { createStepTools } from \"../InngestStepTools.ts\";\nimport type { OpenStringUnion } from \"./types.ts\";\n\n/**\n * Namespace containing middleware-related types and base class.\n */\nexport namespace Middleware {\n /**\n * Base interface for output transformers. Extend this and override `Out` to\n * create custom transformers. This is necessary because TypeScript doesn't\n * support higher-kinded types.\n *\n * @example\n * ```ts\n * interface BooleanToStringTransform extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends boolean ? string : this[\"In\"];\n * }\n * ```\n */\n export type StaticTransform = {\n In: unknown;\n Out: unknown;\n };\n\n /**\n * Default transform. Applies the same transform as `JSON.stringify`.\n */\n export interface DefaultStaticTransform extends StaticTransform {\n Out: Jsonify<this[\"In\"]>;\n }\n\n /**\n * The step tools available to middleware for extending step functionality.\n * This is the same type as `step` in the function handler context.\n */\n export type StepTools = ReturnType<typeof createStepTools<Inngest.Any>>;\n\n /**\n * The argument passed to `transformSendEvent`.\n */\n export type TransformSendEventArgs = {\n events: EventPayload<Record<string, unknown>>[];\n readonly fn: DeepReadonly<InngestFunction.Any> | null;\n };\n\n /**\n * The argument passed to `transformStepInput`.\n */\n export type TransformStepInputArgs = {\n readonly fn: DeepReadonly<InngestFunction.Any>;\n readonly stepInfo: Readonly<\n Pick<StepInfo, \"hashedId\" | \"memoized\" | \"stepType\">\n >;\n stepOptions: StepOptions;\n input: unknown[];\n };\n\n /** The argument passed to `wrapStepHandler`. */\n export type WrapStepHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * A single memoized step entry received in `transformFunctionInput`.\n */\n type MemoizedStep =\n | { type: \"data\"; data: unknown }\n | { type: \"error\"; error: JsonError }\n | { type: \"input\"; input: unknown };\n\n /**\n * Memoized step state keyed by hashed step ID.\n */\n type MemoizedSteps = Record<string, MemoizedStep>;\n\n /**\n * The argument passed to `transformFunctionInput`.\n */\n export type TransformFunctionInputArgs = {\n ctx: Context.Any;\n readonly fn: DeepReadonly<InngestFunction.Any>;\n steps: MemoizedSteps;\n };\n\n /**\n * The argument passed to the static `onRegister` hook.\n */\n export type OnRegisterArgs = Readonly<{\n client: Inngest.Any;\n fn: InngestFunction.Any | null;\n }>;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n */\n export type Request = {\n body: () => Promise<unknown>;\n headers: Readonly<Record<string, string>>;\n method: string;\n url: URL;\n };\n\n /** The argument passed to `wrapFunctionHandler`. */\n export type WrapFunctionHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n }>;\n\n /** The argument passed to `wrapRequest`. */\n export type WrapRequestArgs = DeepReadonly<{\n fn: InngestFunction.Any | null;\n next: () => Promise<Response>;\n requestArgs: readonly unknown[];\n requestInfo: Request;\n runId: string;\n }>;\n\n /** The argument passed to `wrapSendEvent`. */\n export type WrapSendEventArgs = DeepReadonly<{\n events: EventPayload<Record<string, unknown>>[];\n fn: InngestFunction.Any | null;\n next: () => Promise<SendEventBaseOutput>;\n }>;\n\n /** The argument passed to `wrapStep`. */\n export type WrapStepArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The shape of the HTTP response returned by the middleware chain.\n * This is what `next()` resolves with inside `wrapRequest`.\n */\n export type Response = {\n body: string;\n headers: Record<string, string>;\n status: number;\n };\n\n /**\n * The argument passed to `onMemoizationEnd`.\n */\n export type OnMemoizationEndArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onStepStart`.\n */\n export type OnStepStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepError`.\n */\n export type OnStepErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the step, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the step will be\n * retried.\n */\n isFinalAttempt: boolean;\n\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepComplete`.\n */\n export type OnStepCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onRunStart`.\n */\n export type OnRunStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onRunComplete`.\n */\n export type OnRunCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n }>;\n\n /**\n * The argument passed to `onRunError`.\n */\n export type OnRunErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the function, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the function will\n * be retried.\n */\n isFinalAttempt: boolean;\n }>;\n\n /**\n * The type of step. This union may be extended in the future, and will not be\n * considered a breaking change.\n */\n export type StepType = OpenStringUnion<\n | \"ai.infer\"\n | \"ai.wrap\"\n | \"fetch\"\n | \"group.experiment\"\n | \"invoke\"\n | \"realtime.publish\"\n | \"run\"\n | \"sendEvent\"\n | \"sleep\"\n | \"waitForEvent\"\n >;\n\n export type StepInfo = {\n /**\n * Unique ID for the step. This is a hash of the user-defined step ID,\n * including the implicit index if the user-defined ID is not unique.\n */\n hashedId: string;\n\n /**\n * The arguments passed to the step function, if any. For `step.run()`,\n * these are the arguments after the id and handler function.\n */\n input?: unknown[];\n\n /**\n * Whether the step result is being retrieved from memoized state (true)\n * or being executed fresh (false).\n */\n memoized: boolean;\n\n /**\n * Based on the first argument passed to the `step` method.\n */\n options: StepOptions;\n\n stepType: StepType;\n };\n\n /**\n * Base class for creating middleware. Extend this class to create custom\n * middleware with hooks for step execution.\n */\n // @privateRemark\n // Methods are nullish instead of noops as a performance optimization. This is\n // primarily because of `wrapStep`. Each defined `wrapStep` method adds 1 more\n // promise to the chain for each step. This chain runs every time the step\n // completes/errors (even when memoized).\n export abstract class BaseMiddleware {\n readonly client: Inngest.Any;\n\n /**\n * Used to identify the middleware instance in logs. Uniqueness is not\n * required, though using multiple middleware with the same ID in the same\n * app may cause confusion when debugging.\n */\n abstract readonly id: string;\n\n /**\n * Declare this to statically specify how function return types are\n * transformed. By default, the function return type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare functionOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare functionOutputTransform: DefaultStaticTransform;\n\n /**\n * Declare this to statically specify how step output types are transformed.\n * By default, the step output type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare stepOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare stepOutputTransform: DefaultStaticTransform;\n\n constructor({ client }: { client: Inngest.Any }) {\n this.client = client;\n }\n\n /**\n * Called when the middleware class is added to an Inngest client or Inngest\n * function. Use this for one-time setup that needs a reference to the\n * client instance (e.g. registering processors, setting feature flags).\n *\n * Do not mutate arguments.\n */\n static onRegister?(args: Middleware.OnRegisterArgs): void;\n\n /**\n * Called 1 time per request, after memoization completes.\n *\n * If all memoized steps have been resolved/rejected, then this hook calls.\n * This is at the top of the function handler when there are 0 memoized\n * steps.\n *\n * If a new step is found before resolving/rejecting all memoized steps,\n * then this calls.\n *\n * Do not mutate arguments.\n */\n onMemoizationEnd?(arg: Middleware.OnMemoizationEndArgs): MaybePromise<void>;\n\n /**\n * Called when the run completes successfully. Does NOT call when the run\n * errors: `onRunError` calls instead.\n *\n * Do not mutate arguments.\n */\n onRunComplete?(arg: Middleware.OnRunCompleteArgs): MaybePromise<void>;\n\n /**\n * Called when the function throws an error.\n *\n * Do not mutate arguments.\n */\n onRunError?(arg: Middleware.OnRunErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per run on the very first request (0 memoized steps,\n * attempt 0). Does NOT call on subsequent requests where steps are being\n * replayed.\n *\n * Do not mutate arguments.\n */\n onRunStart?(arg: Middleware.OnRunStartArgs): MaybePromise<void>;\n\n /**\n * Called when a step successfully completes. Only called for `step.run`\n * and `step.sendEvent`. Never called for memoized step outputs. Does NOT\n * call when the step errors: `onStepError` calls instead.\n *\n * Do not mutate arguments.\n */\n onStepComplete?(arg: Middleware.OnStepCompleteArgs): MaybePromise<void>;\n\n /**\n * Called each time a step errors. Only called for `step.run` and\n * `step.sendEvent`. Never called for memoized errors.\n *\n * Do not mutate arguments.\n */\n onStepError?(arg: Middleware.OnStepErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per step before running its handler. Only called for\n * `step.run` and `step.sendEvent`.\n *\n * Do not mutate arguments.\n */\n onStepStart?(arg: Middleware.OnStepStartArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per request (likely multiple times per run). Return the\n * (potentially modified) arg object.\n *\n * Use cases:\n * - Dependency injection.\n * - Deserialize events before passing it to the function handler.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because `wrapFunctionHandler` can't be used for the\n // transformation's static type inference. For example, if the user added\n // `ctx.db` in `wrapFunctionHandler` then the static types wouldn't show\n // `ctx.db` in the function handler.\n transformFunctionInput?(\n arg: Middleware.TransformFunctionInputArgs,\n ): MaybePromise<Middleware.TransformFunctionInputArgs>;\n\n /**\n * Called when sending events. This is either `step.sendEvent` or\n * `client.send`. Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Serialize event data before sending it to the Inngest Server.\n *\n * Do not mutate arguments.\n */\n transformSendEvent?(\n arg: Middleware.TransformSendEventArgs,\n ): MaybePromise<Middleware.TransformSendEventArgs>;\n\n /**\n * Called 1 time per step per request (likely multiple times per step).\n * Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Modify step options (e.g. the step ID).\n * - Modify step input args.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // Step input transformation could happen in `wrapStep`, but we chose not to\n // for the following reasons:\n // 1. `wrapStep` may have a negative performance impact under certain\n // workloads.\n // 2. `wrapStep` is a little more complicated to use.\n // 3. Since `transformFunctionInput` must exist, having this hook\n // establishes a consistent pattern for input transformation.\n transformStepInput?(\n arg: TransformStepInputArgs,\n ): MaybePromise<TransformStepInputArgs>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - AsyncLocalStorage context.\n * - Function-level output/error transformation.\n * - Prepend/append steps around the function handler.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * **Important:** `next()` only resolves when the function completes. On\n * requests where a fresh step is discovered, control flow is interrupted\n * and `next()` never resolves.\n */\n wrapFunctionHandler?(args: WrapFunctionHandlerArgs): Promise<unknown>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - Custom auth.\n * - Expose request data to the Inngest function handler.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapRequest?(args: WrapRequestArgs): Promise<Response>;\n\n /**\n * Called each time events are sent (either `client.send` or\n * `step.sendEvent`).\n *\n * Use cases:\n * - Backup events (e.g. blob store) when they fail to send.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapSendEvent?(args: WrapSendEventArgs): Promise<SendEventBaseOutput>;\n\n /**\n * Called 1 time per step per request. Called for all step kinds. Depending\n * on your use case, you may want `wrapStepHandler` instead.\n *\n * Use cases:\n * - Deserialize step output before returning it to the function handler.\n * - Handle step failure errors (after exhausting retries).\n * - Prepend/append steps around a step.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * NOTE: `next()` only resolves when the step completes/fails. On requests\n * where a fresh step is discovered, control flow is interrupted and\n * `next()` never resolves.\n */\n wrapStep?(args: WrapStepArgs): Promise<unknown>;\n\n /**\n * Called 1 time per step attempt. Wraps the step's handler. Only called for\n * `step.run` and `step.sendEvent`. Use this to modify the handler's\n * returned output or thrown error before it's sent to the Inngest Server.\n *\n * Use cases:\n * - Serialize step output before sending it to the Inngest Server.\n * - Handle step attempt errors (before exhausting retries).\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because of checkpointing. For serialization middleware\n // to work with checkpointing, we need to both:\n // 1. Serialize the step output before sending it to the Inngest Server.\n // 2. Deserialize the step output before returning it to the function handler.\n //\n // We initially solved this by calling `wrapStep` twice per step per\n // request. But this breaks the \"prepend with step\" logic since we'd\n // encounter the prepended step twice; this caused us to run the prepended\n // step twice.\n //\n // Now that we have `wrapStepHandler`, it can be responsible for\n // serialization and `wrapStep` can be responsible for deserialization.\n wrapStepHandler?(args: WrapStepHandlerArgs): Promise<unknown>;\n }\n\n /**\n * A no-arg constructor for a BaseMiddleware subclass. Used in client and\n * function options so that fresh instances are created per-request.\n */\n export type Class = (new (args: {\n client: Inngest.Any;\n }) => BaseMiddleware) & {\n // Static methods aren't captured by `new () => ...`, so we repeat it here.\n onRegister?(arg: OnRegisterArgs): void;\n };\n}\n\ntype DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : // Do not make functions readonly, since that leads to weird stuff like not\n // being able to call `.catch()` on the returned promise.\n T extends Function\n ? T\n : // Do not recurse into these types. If that happens, then the resulting\n // type will not be compatible with the original type\n T extends Date | RegExp | Error | Map<unknown, unknown> | Set<unknown>\n ? Readonly<T>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"],"mappings":";;;;CAgSS,MAAe,eAAe;EACnC,AAAS;EAqDT,YAAY,EAAE,UAAmC;AAC/C,QAAK,SAAS"}
1
+ {"version":3,"file":"middleware.cjs","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":["import type { Jsonify } from \"../../helpers/jsonify.ts\";\nimport type { MaybePromise } from \"../../helpers/types.ts\";\nimport type {\n Context,\n EventPayload,\n JsonError,\n SendEventBaseOutput,\n StepOptions,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type { createStepTools } from \"../InngestStepTools.ts\";\nimport type { OpenStringUnion } from \"./types.ts\";\n\n/**\n * Namespace containing middleware-related types and base class.\n */\nexport namespace Middleware {\n /**\n * Base interface for output transformers. Extend this and override `Out` to\n * create custom transformers. This is necessary because TypeScript doesn't\n * support higher-kinded types.\n *\n * @example\n * ```ts\n * interface BooleanToStringTransform extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends boolean ? string : this[\"In\"];\n * }\n * ```\n */\n export type StaticTransform = {\n In: unknown;\n Out: unknown;\n };\n\n /**\n * Default transform. Applies the same transform as `JSON.stringify`.\n */\n export interface DefaultStaticTransform extends StaticTransform {\n Out: Jsonify<this[\"In\"]>;\n }\n\n /**\n * The step tools available to middleware for extending step functionality.\n * This is the same type as `step` in the function handler context.\n */\n export type StepTools = ReturnType<typeof createStepTools<Inngest.Any>>;\n\n /**\n * The argument passed to `transformSendEvent`.\n */\n export type TransformSendEventArgs = {\n events: EventPayload<Record<string, unknown>>[];\n readonly fn: DeepReadonly<InngestFunction.Any> | null;\n };\n\n /**\n * The argument passed to `transformStepInput`.\n */\n export type TransformStepInputArgs = {\n readonly fn: DeepReadonly<InngestFunction.Any>;\n readonly stepInfo: Readonly<\n Pick<StepInfo, \"hashedId\" | \"memoized\" | \"stepType\">\n >;\n stepOptions: StepOptions;\n input: unknown[];\n };\n\n /** The argument passed to `wrapStepHandler`. */\n export type WrapStepHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * A single memoized step entry received in `transformFunctionInput`.\n */\n type MemoizedStep =\n | { type: \"data\"; data: unknown }\n | { type: \"error\"; error: JsonError }\n | { type: \"input\"; input: unknown };\n\n /**\n * Memoized step state keyed by hashed step ID.\n */\n type MemoizedSteps = Record<string, MemoizedStep>;\n\n /**\n * The argument passed to `transformFunctionInput`.\n */\n export type TransformFunctionInputArgs = {\n ctx: Context.Any;\n readonly fn: DeepReadonly<InngestFunction.Any>;\n steps: MemoizedSteps;\n };\n\n /**\n * The argument passed to the static `onRegister` hook.\n */\n export type OnRegisterArgs = Readonly<{\n client: Inngest.Any;\n fn: InngestFunction.Any | null;\n }>;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n */\n export type Request = {\n body: () => Promise<unknown>;\n headers: Readonly<Record<string, string>>;\n method: string;\n url: URL;\n };\n\n /** The argument passed to `wrapFunctionHandler`. */\n export type WrapFunctionHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n }>;\n\n /** The argument passed to `wrapRequest`. */\n export type WrapRequestArgs = DeepReadonly<{\n fn: InngestFunction.Any | null;\n next: () => Promise<Response>;\n requestArgs: readonly unknown[];\n requestInfo: Request;\n runId: string;\n }>;\n\n /** The argument passed to `wrapSendEvent`. */\n export type WrapSendEventArgs = DeepReadonly<{\n events: EventPayload<Record<string, unknown>>[];\n fn: InngestFunction.Any | null;\n next: () => Promise<SendEventBaseOutput>;\n }>;\n\n /** The argument passed to `wrapStep`. */\n export type WrapStepArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The shape of the HTTP response returned by the middleware chain.\n * This is what `next()` resolves with inside `wrapRequest`.\n */\n export type Response = {\n body: string;\n headers: Record<string, string>;\n status: number;\n };\n\n /**\n * The argument passed to `onMemoizationEnd`.\n */\n export type OnMemoizationEndArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onStepStart`.\n */\n export type OnStepStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepError`.\n */\n export type OnStepErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the step, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the step will be\n * retried.\n */\n isFinalAttempt: boolean;\n\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepComplete`.\n */\n export type OnStepCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onRunStart`.\n */\n export type OnRunStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onRunComplete`.\n */\n export type OnRunCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n }>;\n\n /**\n * The argument passed to `onRunError`.\n */\n export type OnRunErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the function, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the function will\n * be retried.\n */\n isFinalAttempt: boolean;\n }>;\n\n /**\n * The type of step. This union may be extended in the future, and will not be\n * considered a breaking change.\n */\n export type StepType = OpenStringUnion<\n | \"ai.infer\"\n | \"ai.wrap\"\n | \"fetch\"\n | \"group.experiment\"\n | \"invoke\"\n | \"realtime.publish\"\n | \"run\"\n | \"sendEvent\"\n | \"sleep\"\n | \"waitForEvent\"\n | \"waitForSignal\"\n >;\n\n export type StepInfo = {\n /**\n * Unique ID for the step. This is a hash of the user-defined step ID,\n * including the implicit index if the user-defined ID is not unique.\n */\n hashedId: string;\n\n /**\n * The arguments passed to the step function, if any. For `step.run()`,\n * these are the arguments after the id and handler function.\n */\n input?: unknown[];\n\n /**\n * Whether the step result is being retrieved from memoized state (true)\n * or being executed fresh (false).\n */\n memoized: boolean;\n\n /**\n * Based on the first argument passed to the `step` method.\n */\n options: StepOptions;\n\n stepType: StepType;\n };\n\n /**\n * Base class for creating middleware. Extend this class to create custom\n * middleware with hooks for step execution.\n */\n // @privateRemark\n // Methods are nullish instead of noops as a performance optimization. This is\n // primarily because of `wrapStep`. Each defined `wrapStep` method adds 1 more\n // promise to the chain for each step. This chain runs every time the step\n // completes/errors (even when memoized).\n export abstract class BaseMiddleware {\n readonly client: Inngest.Any;\n\n /**\n * Used to identify the middleware instance in logs. Uniqueness is not\n * required, though using multiple middleware with the same ID in the same\n * app may cause confusion when debugging.\n */\n abstract readonly id: string;\n\n /**\n * Declare this to statically specify how function return types are\n * transformed. By default, the function return type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare functionOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare functionOutputTransform: DefaultStaticTransform;\n\n /**\n * Declare this to statically specify how step output types are transformed.\n * By default, the step output type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare stepOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare stepOutputTransform: DefaultStaticTransform;\n\n constructor({ client }: { client: Inngest.Any }) {\n this.client = client;\n }\n\n /**\n * Called when the middleware class is added to an Inngest client or Inngest\n * function. Use this for one-time setup that needs a reference to the\n * client instance (e.g. registering processors, setting feature flags).\n *\n * Do not mutate arguments.\n */\n static onRegister?(args: Middleware.OnRegisterArgs): void;\n\n /**\n * Called 1 time per request, after memoization completes.\n *\n * If all memoized steps have been resolved/rejected, then this hook calls.\n * This is at the top of the function handler when there are 0 memoized\n * steps.\n *\n * If a new step is found before resolving/rejecting all memoized steps,\n * then this calls.\n *\n * Do not mutate arguments.\n */\n onMemoizationEnd?(arg: Middleware.OnMemoizationEndArgs): MaybePromise<void>;\n\n /**\n * Called when the run completes successfully. Does NOT call when the run\n * errors: `onRunError` calls instead.\n *\n * Do not mutate arguments.\n */\n onRunComplete?(arg: Middleware.OnRunCompleteArgs): MaybePromise<void>;\n\n /**\n * Called when the function throws an error.\n *\n * Do not mutate arguments.\n */\n onRunError?(arg: Middleware.OnRunErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per run on the very first request (0 memoized steps,\n * attempt 0). Does NOT call on subsequent requests where steps are being\n * replayed.\n *\n * Do not mutate arguments.\n */\n onRunStart?(arg: Middleware.OnRunStartArgs): MaybePromise<void>;\n\n /**\n * Called when a step successfully completes. Only called for `step.run`\n * and `step.sendEvent`. Never called for memoized step outputs. Does NOT\n * call when the step errors: `onStepError` calls instead.\n *\n * Do not mutate arguments.\n */\n onStepComplete?(arg: Middleware.OnStepCompleteArgs): MaybePromise<void>;\n\n /**\n * Called each time a step errors. Only called for `step.run` and\n * `step.sendEvent`. Never called for memoized errors.\n *\n * Do not mutate arguments.\n */\n onStepError?(arg: Middleware.OnStepErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per step before running its handler. Only called for\n * `step.run` and `step.sendEvent`.\n *\n * Do not mutate arguments.\n */\n onStepStart?(arg: Middleware.OnStepStartArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per request (likely multiple times per run). Return the\n * (potentially modified) arg object.\n *\n * Use cases:\n * - Dependency injection.\n * - Deserialize events before passing it to the function handler.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because `wrapFunctionHandler` can't be used for the\n // transformation's static type inference. For example, if the user added\n // `ctx.db` in `wrapFunctionHandler` then the static types wouldn't show\n // `ctx.db` in the function handler.\n transformFunctionInput?(\n arg: Middleware.TransformFunctionInputArgs,\n ): MaybePromise<Middleware.TransformFunctionInputArgs>;\n\n /**\n * Called when sending events. This is either `step.sendEvent` or\n * `client.send`. Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Serialize event data before sending it to the Inngest Server.\n *\n * Do not mutate arguments.\n */\n transformSendEvent?(\n arg: Middleware.TransformSendEventArgs,\n ): MaybePromise<Middleware.TransformSendEventArgs>;\n\n /**\n * Called 1 time per step per request (likely multiple times per step).\n * Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Modify step options (e.g. the step ID).\n * - Modify step input args.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // Step input transformation could happen in `wrapStep`, but we chose not to\n // for the following reasons:\n // 1. `wrapStep` may have a negative performance impact under certain\n // workloads.\n // 2. `wrapStep` is a little more complicated to use.\n // 3. Since `transformFunctionInput` must exist, having this hook\n // establishes a consistent pattern for input transformation.\n transformStepInput?(\n arg: TransformStepInputArgs,\n ): MaybePromise<TransformStepInputArgs>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - AsyncLocalStorage context.\n * - Function-level output/error transformation.\n * - Prepend/append steps around the function handler.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * **Important:** `next()` only resolves when the function completes. On\n * requests where a fresh step is discovered, control flow is interrupted\n * and `next()` never resolves.\n */\n wrapFunctionHandler?(args: WrapFunctionHandlerArgs): Promise<unknown>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - Custom auth.\n * - Expose request data to the Inngest function handler.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapRequest?(args: WrapRequestArgs): Promise<Response>;\n\n /**\n * Called each time events are sent (either `client.send` or\n * `step.sendEvent`).\n *\n * Use cases:\n * - Backup events (e.g. blob store) when they fail to send.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapSendEvent?(args: WrapSendEventArgs): Promise<SendEventBaseOutput>;\n\n /**\n * Called 1 time per step per request. Called for all step kinds. Depending\n * on your use case, you may want `wrapStepHandler` instead.\n *\n * Use cases:\n * - Deserialize step output before returning it to the function handler.\n * - Handle step failure errors (after exhausting retries).\n * - Prepend/append steps around a step.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * NOTE: `next()` only resolves when the step completes/fails. On requests\n * where a fresh step is discovered, control flow is interrupted and\n * `next()` never resolves.\n */\n wrapStep?(args: WrapStepArgs): Promise<unknown>;\n\n /**\n * Called 1 time per step attempt. Wraps the step's handler. Only called for\n * `step.run` and `step.sendEvent`. Use this to modify the handler's\n * returned output or thrown error before it's sent to the Inngest Server.\n *\n * Use cases:\n * - Serialize step output before sending it to the Inngest Server.\n * - Handle step attempt errors (before exhausting retries).\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because of checkpointing. For serialization middleware\n // to work with checkpointing, we need to both:\n // 1. Serialize the step output before sending it to the Inngest Server.\n // 2. Deserialize the step output before returning it to the function handler.\n //\n // We initially solved this by calling `wrapStep` twice per step per\n // request. But this breaks the \"prepend with step\" logic since we'd\n // encounter the prepended step twice; this caused us to run the prepended\n // step twice.\n //\n // Now that we have `wrapStepHandler`, it can be responsible for\n // serialization and `wrapStep` can be responsible for deserialization.\n wrapStepHandler?(args: WrapStepHandlerArgs): Promise<unknown>;\n }\n\n /**\n * A no-arg constructor for a BaseMiddleware subclass. Used in client and\n * function options so that fresh instances are created per-request.\n */\n export type Class = (new (args: {\n client: Inngest.Any;\n }) => BaseMiddleware) & {\n // Static methods aren't captured by `new () => ...`, so we repeat it here.\n onRegister?(arg: OnRegisterArgs): void;\n };\n}\n\ntype DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : // Do not make functions readonly, since that leads to weird stuff like not\n // being able to call `.catch()` on the returned promise.\n T extends Function\n ? T\n : // Do not recurse into these types. If that happens, then the resulting\n // type will not be compatible with the original type\n T extends Date | RegExp | Error | Map<unknown, unknown> | Set<unknown>\n ? Readonly<T>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"],"mappings":";;;;CAiSS,MAAe,eAAe;EACnC,AAAS;EAqDT,YAAY,EAAE,UAAmC;AAC/C,QAAK,SAAS"}
@@ -211,7 +211,7 @@ declare namespace Middleware {
211
211
  * The type of step. This union may be extended in the future, and will not be
212
212
  * considered a breaking change.
213
213
  */
214
- export type StepType = OpenStringUnion<"ai.infer" | "ai.wrap" | "fetch" | "group.experiment" | "invoke" | "realtime.publish" | "run" | "sendEvent" | "sleep" | "waitForEvent">;
214
+ export type StepType = OpenStringUnion<"ai.infer" | "ai.wrap" | "fetch" | "group.experiment" | "invoke" | "realtime.publish" | "run" | "sendEvent" | "sleep" | "waitForEvent" | "waitForSignal">;
215
215
  export type StepInfo = {
216
216
  /**
217
217
  * Unique ID for the step. This is a hash of the user-defined step ID,
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.cts","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAiBA;AAA2B,kBAAV,UAAA,CAAU;;;;;;;;;;;;;SA6CrB,KAAA,eAAA,GAAA;IADiB,EAAA,EAAA,OAAA;IAGN,GAAA,EAAA,OAAA;;;;;SAKmB,UAAA,sBAAA,SA/Bc,eA+Bd,CAAA;IAYN,GAAA,EA1CrB,OA0CqB,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA;;;;;;SAcnB,KAAA,SAAA,GAjDe,UAiDf,CAAA,OAjDiC,eAiDjC,CAjDiD,OAAA,CAAQ,GAiDzD,CAAA,CAAA;;;;SAeK,KAAA,sBAAA,GAAA;IACM,MAAA,EA3DV,YA2DU,CA3DG,MA2DH,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAAA;IAAT,SAAA,EAAA,EA1DI,YA0DJ,CA1DiB,eAAA,CAAgB,GA0DjC,CAAA,GAAA,IAAA;;;;;SAM2B,KAAA,sBAAA,GAAA;IAQhC,SAAA,EAAA,EAjES,YAiEO,CAjEM,eAAA,CAAgB,GAiEtB,CAAA;IACA,SAAA,QAAA,EAjED,QAiEC,CAhElB,IAgEkB,CAhEb,QAgEa,EAAA,UAAA,GAAA,UAAA,GAAA,UAAA,CAAA,CAAA;IAAR,WAAA,EA9DC,WA8DD;IAEC,KAAA,EAAA,OAAA,EAAA;;;SAML,KAAA,mBAAA,GAjEwB,YAiExB,CAAA;IACJ,GAAA,EAjEC,OAAA,CAAQ,GAiEO;IACA,EAAA,EAjEhB,eAAA,CAAgB,GAiEA;IAAR,IAAA,EAAA,GAAA,GAhEA,OAgEA,CAAA,OAAA,CAAA;IAHkB,QAAA,EA5DpB,QA4DoB;;;;;OAOL,YAAA,GAAA;IAah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lC,UAAA,CAAW,iBAAiB;;;;;;;;qBAS5B,UAAA,CAAW,iBAAiB;;;;;;;;yBASxB,UAAA,CAAW,qBAAqB;;;;;;;sBAQnC,UAAA,CAAW,kBAAkB;;;;;;;sBAQ7B,UAAA,CAAW,kBAAkB;;;;;;;;;;;iCAkBxC,UAAA,CAAW,6BACf,aAAa,UAAA,CAAW;;;;;;;;;;6BAYpB,UAAA,CAAW,yBACf,aAAa,UAAA,CAAW;;;;;;;;;;;6BAqBpB,yBACJ,aAAa;;;;;;;;;;;;;;;+BAgBW,0BAA0B;;;;;;;;;;;uBAYlC,kBAAkB,QAAQ;;;;;;;;;;;yBAYxB,oBAAoB,QAAQ;;;;;;;;;;;;;;;;oBAiBjC,eAAe;;;;;;;;;;;;2BA0BR,sBAAsB;;;;;;;YAQrC,OAAA,CAAQ;QACZ;qBAEa;;;;KAIhB,kBAAkB,iCACV,aAAa,OAGtB,UAAU,WACR,IAGA,UAAU,OAAO,SAAS,QAAQ,wBAAwB,eACxD,SAAS,KACT,0CACyB,IAAI,aAAa,EAAE,QAC1C"}
@@ -211,7 +211,7 @@ declare namespace Middleware {
211
211
  * The type of step. This union may be extended in the future, and will not be
212
212
  * considered a breaking change.
213
213
  */
214
- export type StepType = OpenStringUnion<"ai.infer" | "ai.wrap" | "fetch" | "group.experiment" | "invoke" | "realtime.publish" | "run" | "sendEvent" | "sleep" | "waitForEvent">;
214
+ export type StepType = OpenStringUnion<"ai.infer" | "ai.wrap" | "fetch" | "group.experiment" | "invoke" | "realtime.publish" | "run" | "sendEvent" | "sleep" | "waitForEvent" | "waitForSignal">;
215
215
  export type StepInfo = {
216
216
  /**
217
217
  * Unique ID for the step. This is a hash of the user-defined step ID,
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAiBA;AAA2B,kBAAV,UAAA,CAAU;;;;;;;;;;;;;SA6CrB,KAAA,eAA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AAa,UAAA,CAAW;;;;;;;;;;;6BAqBpB,yBACJ,aAAa;;;;;;;;;;;;;;;+BAgBW,0BAA0B;;;;;;;;;;;uBAYlC,kBAAkB,QAAQ;;;;;;;;;;;yBAYxB,oBAAoB,QAAQ;;;;;;;;;;;;;;;;oBAiBjC,eAAe;;;;;;;;;;;;2BA0BR,sBAAsB;;;;;;;YAQrC,OAAA,CAAQ;QACZ;qBAEa;;;;KAIhB,kBAAkB,iCACV,aAAa,OAGtB,UAAU,WACR,IAGA,UAAU,OAAO,SAAS,QAAQ,wBAAwB,eACxD,SAAS,KACT,0CACyB,IAAI,aAAa,EAAE,QAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":["import type { Jsonify } from \"../../helpers/jsonify.ts\";\nimport type { MaybePromise } from \"../../helpers/types.ts\";\nimport type {\n Context,\n EventPayload,\n JsonError,\n SendEventBaseOutput,\n StepOptions,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type { createStepTools } from \"../InngestStepTools.ts\";\nimport type { OpenStringUnion } from \"./types.ts\";\n\n/**\n * Namespace containing middleware-related types and base class.\n */\nexport namespace Middleware {\n /**\n * Base interface for output transformers. Extend this and override `Out` to\n * create custom transformers. This is necessary because TypeScript doesn't\n * support higher-kinded types.\n *\n * @example\n * ```ts\n * interface BooleanToStringTransform extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends boolean ? string : this[\"In\"];\n * }\n * ```\n */\n export type StaticTransform = {\n In: unknown;\n Out: unknown;\n };\n\n /**\n * Default transform. Applies the same transform as `JSON.stringify`.\n */\n export interface DefaultStaticTransform extends StaticTransform {\n Out: Jsonify<this[\"In\"]>;\n }\n\n /**\n * The step tools available to middleware for extending step functionality.\n * This is the same type as `step` in the function handler context.\n */\n export type StepTools = ReturnType<typeof createStepTools<Inngest.Any>>;\n\n /**\n * The argument passed to `transformSendEvent`.\n */\n export type TransformSendEventArgs = {\n events: EventPayload<Record<string, unknown>>[];\n readonly fn: DeepReadonly<InngestFunction.Any> | null;\n };\n\n /**\n * The argument passed to `transformStepInput`.\n */\n export type TransformStepInputArgs = {\n readonly fn: DeepReadonly<InngestFunction.Any>;\n readonly stepInfo: Readonly<\n Pick<StepInfo, \"hashedId\" | \"memoized\" | \"stepType\">\n >;\n stepOptions: StepOptions;\n input: unknown[];\n };\n\n /** The argument passed to `wrapStepHandler`. */\n export type WrapStepHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * A single memoized step entry received in `transformFunctionInput`.\n */\n type MemoizedStep =\n | { type: \"data\"; data: unknown }\n | { type: \"error\"; error: JsonError }\n | { type: \"input\"; input: unknown };\n\n /**\n * Memoized step state keyed by hashed step ID.\n */\n type MemoizedSteps = Record<string, MemoizedStep>;\n\n /**\n * The argument passed to `transformFunctionInput`.\n */\n export type TransformFunctionInputArgs = {\n ctx: Context.Any;\n readonly fn: DeepReadonly<InngestFunction.Any>;\n steps: MemoizedSteps;\n };\n\n /**\n * The argument passed to the static `onRegister` hook.\n */\n export type OnRegisterArgs = Readonly<{\n client: Inngest.Any;\n fn: InngestFunction.Any | null;\n }>;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n */\n export type Request = {\n body: () => Promise<unknown>;\n headers: Readonly<Record<string, string>>;\n method: string;\n url: URL;\n };\n\n /** The argument passed to `wrapFunctionHandler`. */\n export type WrapFunctionHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n }>;\n\n /** The argument passed to `wrapRequest`. */\n export type WrapRequestArgs = DeepReadonly<{\n fn: InngestFunction.Any | null;\n next: () => Promise<Response>;\n requestArgs: readonly unknown[];\n requestInfo: Request;\n runId: string;\n }>;\n\n /** The argument passed to `wrapSendEvent`. */\n export type WrapSendEventArgs = DeepReadonly<{\n events: EventPayload<Record<string, unknown>>[];\n fn: InngestFunction.Any | null;\n next: () => Promise<SendEventBaseOutput>;\n }>;\n\n /** The argument passed to `wrapStep`. */\n export type WrapStepArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The shape of the HTTP response returned by the middleware chain.\n * This is what `next()` resolves with inside `wrapRequest`.\n */\n export type Response = {\n body: string;\n headers: Record<string, string>;\n status: number;\n };\n\n /**\n * The argument passed to `onMemoizationEnd`.\n */\n export type OnMemoizationEndArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onStepStart`.\n */\n export type OnStepStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepError`.\n */\n export type OnStepErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the step, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the step will be\n * retried.\n */\n isFinalAttempt: boolean;\n\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepComplete`.\n */\n export type OnStepCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onRunStart`.\n */\n export type OnRunStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onRunComplete`.\n */\n export type OnRunCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n }>;\n\n /**\n * The argument passed to `onRunError`.\n */\n export type OnRunErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the function, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the function will\n * be retried.\n */\n isFinalAttempt: boolean;\n }>;\n\n /**\n * The type of step. This union may be extended in the future, and will not be\n * considered a breaking change.\n */\n export type StepType = OpenStringUnion<\n | \"ai.infer\"\n | \"ai.wrap\"\n | \"fetch\"\n | \"group.experiment\"\n | \"invoke\"\n | \"realtime.publish\"\n | \"run\"\n | \"sendEvent\"\n | \"sleep\"\n | \"waitForEvent\"\n >;\n\n export type StepInfo = {\n /**\n * Unique ID for the step. This is a hash of the user-defined step ID,\n * including the implicit index if the user-defined ID is not unique.\n */\n hashedId: string;\n\n /**\n * The arguments passed to the step function, if any. For `step.run()`,\n * these are the arguments after the id and handler function.\n */\n input?: unknown[];\n\n /**\n * Whether the step result is being retrieved from memoized state (true)\n * or being executed fresh (false).\n */\n memoized: boolean;\n\n /**\n * Based on the first argument passed to the `step` method.\n */\n options: StepOptions;\n\n stepType: StepType;\n };\n\n /**\n * Base class for creating middleware. Extend this class to create custom\n * middleware with hooks for step execution.\n */\n // @privateRemark\n // Methods are nullish instead of noops as a performance optimization. This is\n // primarily because of `wrapStep`. Each defined `wrapStep` method adds 1 more\n // promise to the chain for each step. This chain runs every time the step\n // completes/errors (even when memoized).\n export abstract class BaseMiddleware {\n readonly client: Inngest.Any;\n\n /**\n * Used to identify the middleware instance in logs. Uniqueness is not\n * required, though using multiple middleware with the same ID in the same\n * app may cause confusion when debugging.\n */\n abstract readonly id: string;\n\n /**\n * Declare this to statically specify how function return types are\n * transformed. By default, the function return type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare functionOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare functionOutputTransform: DefaultStaticTransform;\n\n /**\n * Declare this to statically specify how step output types are transformed.\n * By default, the step output type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare stepOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare stepOutputTransform: DefaultStaticTransform;\n\n constructor({ client }: { client: Inngest.Any }) {\n this.client = client;\n }\n\n /**\n * Called when the middleware class is added to an Inngest client or Inngest\n * function. Use this for one-time setup that needs a reference to the\n * client instance (e.g. registering processors, setting feature flags).\n *\n * Do not mutate arguments.\n */\n static onRegister?(args: Middleware.OnRegisterArgs): void;\n\n /**\n * Called 1 time per request, after memoization completes.\n *\n * If all memoized steps have been resolved/rejected, then this hook calls.\n * This is at the top of the function handler when there are 0 memoized\n * steps.\n *\n * If a new step is found before resolving/rejecting all memoized steps,\n * then this calls.\n *\n * Do not mutate arguments.\n */\n onMemoizationEnd?(arg: Middleware.OnMemoizationEndArgs): MaybePromise<void>;\n\n /**\n * Called when the run completes successfully. Does NOT call when the run\n * errors: `onRunError` calls instead.\n *\n * Do not mutate arguments.\n */\n onRunComplete?(arg: Middleware.OnRunCompleteArgs): MaybePromise<void>;\n\n /**\n * Called when the function throws an error.\n *\n * Do not mutate arguments.\n */\n onRunError?(arg: Middleware.OnRunErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per run on the very first request (0 memoized steps,\n * attempt 0). Does NOT call on subsequent requests where steps are being\n * replayed.\n *\n * Do not mutate arguments.\n */\n onRunStart?(arg: Middleware.OnRunStartArgs): MaybePromise<void>;\n\n /**\n * Called when a step successfully completes. Only called for `step.run`\n * and `step.sendEvent`. Never called for memoized step outputs. Does NOT\n * call when the step errors: `onStepError` calls instead.\n *\n * Do not mutate arguments.\n */\n onStepComplete?(arg: Middleware.OnStepCompleteArgs): MaybePromise<void>;\n\n /**\n * Called each time a step errors. Only called for `step.run` and\n * `step.sendEvent`. Never called for memoized errors.\n *\n * Do not mutate arguments.\n */\n onStepError?(arg: Middleware.OnStepErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per step before running its handler. Only called for\n * `step.run` and `step.sendEvent`.\n *\n * Do not mutate arguments.\n */\n onStepStart?(arg: Middleware.OnStepStartArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per request (likely multiple times per run). Return the\n * (potentially modified) arg object.\n *\n * Use cases:\n * - Dependency injection.\n * - Deserialize events before passing it to the function handler.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because `wrapFunctionHandler` can't be used for the\n // transformation's static type inference. For example, if the user added\n // `ctx.db` in `wrapFunctionHandler` then the static types wouldn't show\n // `ctx.db` in the function handler.\n transformFunctionInput?(\n arg: Middleware.TransformFunctionInputArgs,\n ): MaybePromise<Middleware.TransformFunctionInputArgs>;\n\n /**\n * Called when sending events. This is either `step.sendEvent` or\n * `client.send`. Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Serialize event data before sending it to the Inngest Server.\n *\n * Do not mutate arguments.\n */\n transformSendEvent?(\n arg: Middleware.TransformSendEventArgs,\n ): MaybePromise<Middleware.TransformSendEventArgs>;\n\n /**\n * Called 1 time per step per request (likely multiple times per step).\n * Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Modify step options (e.g. the step ID).\n * - Modify step input args.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // Step input transformation could happen in `wrapStep`, but we chose not to\n // for the following reasons:\n // 1. `wrapStep` may have a negative performance impact under certain\n // workloads.\n // 2. `wrapStep` is a little more complicated to use.\n // 3. Since `transformFunctionInput` must exist, having this hook\n // establishes a consistent pattern for input transformation.\n transformStepInput?(\n arg: TransformStepInputArgs,\n ): MaybePromise<TransformStepInputArgs>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - AsyncLocalStorage context.\n * - Function-level output/error transformation.\n * - Prepend/append steps around the function handler.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * **Important:** `next()` only resolves when the function completes. On\n * requests where a fresh step is discovered, control flow is interrupted\n * and `next()` never resolves.\n */\n wrapFunctionHandler?(args: WrapFunctionHandlerArgs): Promise<unknown>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - Custom auth.\n * - Expose request data to the Inngest function handler.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapRequest?(args: WrapRequestArgs): Promise<Response>;\n\n /**\n * Called each time events are sent (either `client.send` or\n * `step.sendEvent`).\n *\n * Use cases:\n * - Backup events (e.g. blob store) when they fail to send.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapSendEvent?(args: WrapSendEventArgs): Promise<SendEventBaseOutput>;\n\n /**\n * Called 1 time per step per request. Called for all step kinds. Depending\n * on your use case, you may want `wrapStepHandler` instead.\n *\n * Use cases:\n * - Deserialize step output before returning it to the function handler.\n * - Handle step failure errors (after exhausting retries).\n * - Prepend/append steps around a step.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * NOTE: `next()` only resolves when the step completes/fails. On requests\n * where a fresh step is discovered, control flow is interrupted and\n * `next()` never resolves.\n */\n wrapStep?(args: WrapStepArgs): Promise<unknown>;\n\n /**\n * Called 1 time per step attempt. Wraps the step's handler. Only called for\n * `step.run` and `step.sendEvent`. Use this to modify the handler's\n * returned output or thrown error before it's sent to the Inngest Server.\n *\n * Use cases:\n * - Serialize step output before sending it to the Inngest Server.\n * - Handle step attempt errors (before exhausting retries).\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because of checkpointing. For serialization middleware\n // to work with checkpointing, we need to both:\n // 1. Serialize the step output before sending it to the Inngest Server.\n // 2. Deserialize the step output before returning it to the function handler.\n //\n // We initially solved this by calling `wrapStep` twice per step per\n // request. But this breaks the \"prepend with step\" logic since we'd\n // encounter the prepended step twice; this caused us to run the prepended\n // step twice.\n //\n // Now that we have `wrapStepHandler`, it can be responsible for\n // serialization and `wrapStep` can be responsible for deserialization.\n wrapStepHandler?(args: WrapStepHandlerArgs): Promise<unknown>;\n }\n\n /**\n * A no-arg constructor for a BaseMiddleware subclass. Used in client and\n * function options so that fresh instances are created per-request.\n */\n export type Class = (new (args: {\n client: Inngest.Any;\n }) => BaseMiddleware) & {\n // Static methods aren't captured by `new () => ...`, so we repeat it here.\n onRegister?(arg: OnRegisterArgs): void;\n };\n}\n\ntype DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : // Do not make functions readonly, since that leads to weird stuff like not\n // being able to call `.catch()` on the returned promise.\n T extends Function\n ? T\n : // Do not recurse into these types. If that happens, then the resulting\n // type will not be compatible with the original type\n T extends Date | RegExp | Error | Map<unknown, unknown> | Set<unknown>\n ? Readonly<T>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"],"mappings":";;;CAgSS,MAAe,eAAe;EACnC,AAAS;EAqDT,YAAY,EAAE,UAAmC;AAC/C,QAAK,SAAS"}
1
+ {"version":3,"file":"middleware.js","names":[],"sources":["../../../src/components/middleware/middleware.ts"],"sourcesContent":["import type { Jsonify } from \"../../helpers/jsonify.ts\";\nimport type { MaybePromise } from \"../../helpers/types.ts\";\nimport type {\n Context,\n EventPayload,\n JsonError,\n SendEventBaseOutput,\n StepOptions,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type { createStepTools } from \"../InngestStepTools.ts\";\nimport type { OpenStringUnion } from \"./types.ts\";\n\n/**\n * Namespace containing middleware-related types and base class.\n */\nexport namespace Middleware {\n /**\n * Base interface for output transformers. Extend this and override `Out` to\n * create custom transformers. This is necessary because TypeScript doesn't\n * support higher-kinded types.\n *\n * @example\n * ```ts\n * interface BooleanToStringTransform extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends boolean ? string : this[\"In\"];\n * }\n * ```\n */\n export type StaticTransform = {\n In: unknown;\n Out: unknown;\n };\n\n /**\n * Default transform. Applies the same transform as `JSON.stringify`.\n */\n export interface DefaultStaticTransform extends StaticTransform {\n Out: Jsonify<this[\"In\"]>;\n }\n\n /**\n * The step tools available to middleware for extending step functionality.\n * This is the same type as `step` in the function handler context.\n */\n export type StepTools = ReturnType<typeof createStepTools<Inngest.Any>>;\n\n /**\n * The argument passed to `transformSendEvent`.\n */\n export type TransformSendEventArgs = {\n events: EventPayload<Record<string, unknown>>[];\n readonly fn: DeepReadonly<InngestFunction.Any> | null;\n };\n\n /**\n * The argument passed to `transformStepInput`.\n */\n export type TransformStepInputArgs = {\n readonly fn: DeepReadonly<InngestFunction.Any>;\n readonly stepInfo: Readonly<\n Pick<StepInfo, \"hashedId\" | \"memoized\" | \"stepType\">\n >;\n stepOptions: StepOptions;\n input: unknown[];\n };\n\n /** The argument passed to `wrapStepHandler`. */\n export type WrapStepHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * A single memoized step entry received in `transformFunctionInput`.\n */\n type MemoizedStep =\n | { type: \"data\"; data: unknown }\n | { type: \"error\"; error: JsonError }\n | { type: \"input\"; input: unknown };\n\n /**\n * Memoized step state keyed by hashed step ID.\n */\n type MemoizedSteps = Record<string, MemoizedStep>;\n\n /**\n * The argument passed to `transformFunctionInput`.\n */\n export type TransformFunctionInputArgs = {\n ctx: Context.Any;\n readonly fn: DeepReadonly<InngestFunction.Any>;\n steps: MemoizedSteps;\n };\n\n /**\n * The argument passed to the static `onRegister` hook.\n */\n export type OnRegisterArgs = Readonly<{\n client: Inngest.Any;\n fn: InngestFunction.Any | null;\n }>;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n */\n export type Request = {\n body: () => Promise<unknown>;\n headers: Readonly<Record<string, string>>;\n method: string;\n url: URL;\n };\n\n /** The argument passed to `wrapFunctionHandler`. */\n export type WrapFunctionHandlerArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n }>;\n\n /** The argument passed to `wrapRequest`. */\n export type WrapRequestArgs = DeepReadonly<{\n fn: InngestFunction.Any | null;\n next: () => Promise<Response>;\n requestArgs: readonly unknown[];\n requestInfo: Request;\n runId: string;\n }>;\n\n /** The argument passed to `wrapSendEvent`. */\n export type WrapSendEventArgs = DeepReadonly<{\n events: EventPayload<Record<string, unknown>>[];\n fn: InngestFunction.Any | null;\n next: () => Promise<SendEventBaseOutput>;\n }>;\n\n /** The argument passed to `wrapStep`. */\n export type WrapStepArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n next: () => Promise<unknown>;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The shape of the HTTP response returned by the middleware chain.\n * This is what `next()` resolves with inside `wrapRequest`.\n */\n export type Response = {\n body: string;\n headers: Record<string, string>;\n status: number;\n };\n\n /**\n * The argument passed to `onMemoizationEnd`.\n */\n export type OnMemoizationEndArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onStepStart`.\n */\n export type OnStepStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepError`.\n */\n export type OnStepErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the step, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the step will be\n * retried.\n */\n isFinalAttempt: boolean;\n\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onStepComplete`.\n */\n export type OnStepCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n stepInfo: StepInfo;\n }>;\n\n /**\n * The argument passed to `onRunStart`.\n */\n export type OnRunStartArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n }>;\n\n /**\n * The argument passed to `onRunComplete`.\n */\n export type OnRunCompleteArgs = DeepReadonly<{\n ctx: Context.Any;\n fn: InngestFunction.Any;\n output: unknown;\n }>;\n\n /**\n * The argument passed to `onRunError`.\n */\n export type OnRunErrorArgs = DeepReadonly<{\n ctx: Context.Any;\n error: Error;\n fn: InngestFunction.Any;\n\n /**\n * Whether this is the final attempt for the function, meaning retries are\n * exhausted or the error is non-retriable. When `false`, the function will\n * be retried.\n */\n isFinalAttempt: boolean;\n }>;\n\n /**\n * The type of step. This union may be extended in the future, and will not be\n * considered a breaking change.\n */\n export type StepType = OpenStringUnion<\n | \"ai.infer\"\n | \"ai.wrap\"\n | \"fetch\"\n | \"group.experiment\"\n | \"invoke\"\n | \"realtime.publish\"\n | \"run\"\n | \"sendEvent\"\n | \"sleep\"\n | \"waitForEvent\"\n | \"waitForSignal\"\n >;\n\n export type StepInfo = {\n /**\n * Unique ID for the step. This is a hash of the user-defined step ID,\n * including the implicit index if the user-defined ID is not unique.\n */\n hashedId: string;\n\n /**\n * The arguments passed to the step function, if any. For `step.run()`,\n * these are the arguments after the id and handler function.\n */\n input?: unknown[];\n\n /**\n * Whether the step result is being retrieved from memoized state (true)\n * or being executed fresh (false).\n */\n memoized: boolean;\n\n /**\n * Based on the first argument passed to the `step` method.\n */\n options: StepOptions;\n\n stepType: StepType;\n };\n\n /**\n * Base class for creating middleware. Extend this class to create custom\n * middleware with hooks for step execution.\n */\n // @privateRemark\n // Methods are nullish instead of noops as a performance optimization. This is\n // primarily because of `wrapStep`. Each defined `wrapStep` method adds 1 more\n // promise to the chain for each step. This chain runs every time the step\n // completes/errors (even when memoized).\n export abstract class BaseMiddleware {\n readonly client: Inngest.Any;\n\n /**\n * Used to identify the middleware instance in logs. Uniqueness is not\n * required, though using multiple middleware with the same ID in the same\n * app may cause confusion when debugging.\n */\n abstract readonly id: string;\n\n /**\n * Declare this to statically specify how function return types are\n * transformed. By default, the function return type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare functionOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare functionOutputTransform: DefaultStaticTransform;\n\n /**\n * Declare this to statically specify how step output types are transformed.\n * By default, the step output type is Jsonified.\n *\n * Must match the same structure as `StaticTransform` to imitate\n * higher-kinded types.\n *\n * @example\n * ```ts\n * interface PreserveDate extends Middleware.StaticTransform {\n * Out: this[\"In\"] extends Date ? Date : Jsonify<this[\"In\"]>;\n * }\n *\n * class MyMiddleware extends Middleware.BaseMiddleware {\n * declare stepOutputTransform: PreserveDate;\n * }\n * ```\n *\n * @default Middleware.DefaultStaticTransform (e.g. Date -> string)\n */\n declare stepOutputTransform: DefaultStaticTransform;\n\n constructor({ client }: { client: Inngest.Any }) {\n this.client = client;\n }\n\n /**\n * Called when the middleware class is added to an Inngest client or Inngest\n * function. Use this for one-time setup that needs a reference to the\n * client instance (e.g. registering processors, setting feature flags).\n *\n * Do not mutate arguments.\n */\n static onRegister?(args: Middleware.OnRegisterArgs): void;\n\n /**\n * Called 1 time per request, after memoization completes.\n *\n * If all memoized steps have been resolved/rejected, then this hook calls.\n * This is at the top of the function handler when there are 0 memoized\n * steps.\n *\n * If a new step is found before resolving/rejecting all memoized steps,\n * then this calls.\n *\n * Do not mutate arguments.\n */\n onMemoizationEnd?(arg: Middleware.OnMemoizationEndArgs): MaybePromise<void>;\n\n /**\n * Called when the run completes successfully. Does NOT call when the run\n * errors: `onRunError` calls instead.\n *\n * Do not mutate arguments.\n */\n onRunComplete?(arg: Middleware.OnRunCompleteArgs): MaybePromise<void>;\n\n /**\n * Called when the function throws an error.\n *\n * Do not mutate arguments.\n */\n onRunError?(arg: Middleware.OnRunErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per run on the very first request (0 memoized steps,\n * attempt 0). Does NOT call on subsequent requests where steps are being\n * replayed.\n *\n * Do not mutate arguments.\n */\n onRunStart?(arg: Middleware.OnRunStartArgs): MaybePromise<void>;\n\n /**\n * Called when a step successfully completes. Only called for `step.run`\n * and `step.sendEvent`. Never called for memoized step outputs. Does NOT\n * call when the step errors: `onStepError` calls instead.\n *\n * Do not mutate arguments.\n */\n onStepComplete?(arg: Middleware.OnStepCompleteArgs): MaybePromise<void>;\n\n /**\n * Called each time a step errors. Only called for `step.run` and\n * `step.sendEvent`. Never called for memoized errors.\n *\n * Do not mutate arguments.\n */\n onStepError?(arg: Middleware.OnStepErrorArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per step before running its handler. Only called for\n * `step.run` and `step.sendEvent`.\n *\n * Do not mutate arguments.\n */\n onStepStart?(arg: Middleware.OnStepStartArgs): MaybePromise<void>;\n\n /**\n * Called 1 time per request (likely multiple times per run). Return the\n * (potentially modified) arg object.\n *\n * Use cases:\n * - Dependency injection.\n * - Deserialize events before passing it to the function handler.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because `wrapFunctionHandler` can't be used for the\n // transformation's static type inference. For example, if the user added\n // `ctx.db` in `wrapFunctionHandler` then the static types wouldn't show\n // `ctx.db` in the function handler.\n transformFunctionInput?(\n arg: Middleware.TransformFunctionInputArgs,\n ): MaybePromise<Middleware.TransformFunctionInputArgs>;\n\n /**\n * Called when sending events. This is either `step.sendEvent` or\n * `client.send`. Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Serialize event data before sending it to the Inngest Server.\n *\n * Do not mutate arguments.\n */\n transformSendEvent?(\n arg: Middleware.TransformSendEventArgs,\n ): MaybePromise<Middleware.TransformSendEventArgs>;\n\n /**\n * Called 1 time per step per request (likely multiple times per step).\n * Return the (potentially modified) arg object.\n *\n * Use cases:\n * - Modify step options (e.g. the step ID).\n * - Modify step input args.\n *\n * Do not mutate arguments.\n */\n // @privateRemark\n // Step input transformation could happen in `wrapStep`, but we chose not to\n // for the following reasons:\n // 1. `wrapStep` may have a negative performance impact under certain\n // workloads.\n // 2. `wrapStep` is a little more complicated to use.\n // 3. Since `transformFunctionInput` must exist, having this hook\n // establishes a consistent pattern for input transformation.\n transformStepInput?(\n arg: TransformStepInputArgs,\n ): MaybePromise<TransformStepInputArgs>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - AsyncLocalStorage context.\n * - Function-level output/error transformation.\n * - Prepend/append steps around the function handler.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * **Important:** `next()` only resolves when the function completes. On\n * requests where a fresh step is discovered, control flow is interrupted\n * and `next()` never resolves.\n */\n wrapFunctionHandler?(args: WrapFunctionHandlerArgs): Promise<unknown>;\n\n /**\n * Called 1 time per request.\n *\n * Use cases:\n * - Custom auth.\n * - Expose request data to the Inngest function handler.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapRequest?(args: WrapRequestArgs): Promise<Response>;\n\n /**\n * Called each time events are sent (either `client.send` or\n * `step.sendEvent`).\n *\n * Use cases:\n * - Backup events (e.g. blob store) when they fail to send.\n * - Metrics.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n wrapSendEvent?(args: WrapSendEventArgs): Promise<SendEventBaseOutput>;\n\n /**\n * Called 1 time per step per request. Called for all step kinds. Depending\n * on your use case, you may want `wrapStepHandler` instead.\n *\n * Use cases:\n * - Deserialize step output before returning it to the function handler.\n * - Handle step failure errors (after exhausting retries).\n * - Prepend/append steps around a step.\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n *\n * NOTE: `next()` only resolves when the step completes/fails. On requests\n * where a fresh step is discovered, control flow is interrupted and\n * `next()` never resolves.\n */\n wrapStep?(args: WrapStepArgs): Promise<unknown>;\n\n /**\n * Called 1 time per step attempt. Wraps the step's handler. Only called for\n * `step.run` and `step.sendEvent`. Use this to modify the handler's\n * returned output or thrown error before it's sent to the Inngest Server.\n *\n * Use cases:\n * - Serialize step output before sending it to the Inngest Server.\n * - Handle step attempt errors (before exhausting retries).\n *\n * Must call `next()` to continue processing. Do not mutate arguments.\n */\n // @privateRemark\n // This hook exists because of checkpointing. For serialization middleware\n // to work with checkpointing, we need to both:\n // 1. Serialize the step output before sending it to the Inngest Server.\n // 2. Deserialize the step output before returning it to the function handler.\n //\n // We initially solved this by calling `wrapStep` twice per step per\n // request. But this breaks the \"prepend with step\" logic since we'd\n // encounter the prepended step twice; this caused us to run the prepended\n // step twice.\n //\n // Now that we have `wrapStepHandler`, it can be responsible for\n // serialization and `wrapStep` can be responsible for deserialization.\n wrapStepHandler?(args: WrapStepHandlerArgs): Promise<unknown>;\n }\n\n /**\n * A no-arg constructor for a BaseMiddleware subclass. Used in client and\n * function options so that fresh instances are created per-request.\n */\n export type Class = (new (args: {\n client: Inngest.Any;\n }) => BaseMiddleware) & {\n // Static methods aren't captured by `new () => ...`, so we repeat it here.\n onRegister?(arg: OnRegisterArgs): void;\n };\n}\n\ntype DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : // Do not make functions readonly, since that leads to weird stuff like not\n // being able to call `.catch()` on the returned promise.\n T extends Function\n ? T\n : // Do not recurse into these types. If that happens, then the resulting\n // type will not be compatible with the original type\n T extends Date | RegExp | Error | Map<unknown, unknown> | Set<unknown>\n ? Readonly<T>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"],"mappings":";;;CAiSS,MAAe,eAAe;EACnC,AAAS;EAqDT,YAAY,EAAE,UAAmC;AAC/C,QAAK,SAAS"}
@@ -1,9 +1,10 @@
1
1
  const require_types = require('../../types.cjs');
2
2
  const require_types$1 = require('../../helpers/types.cjs');
3
+ const require_temporal = require('../../helpers/temporal.cjs');
3
4
 
4
5
  //#region src/components/middleware/utils.ts
5
- function isTimeStrInput(value) {
6
- return typeof value === "string" || typeof value === "number" || value instanceof Date;
6
+ function isSleepInput(value) {
7
+ return typeof value === "string" || typeof value === "number" || value instanceof Date || require_temporal.isTemporalDuration(value);
7
8
  }
8
9
  /**
9
10
  * Build an onion-style middleware chain for `wrapSendEvent`.
@@ -65,6 +66,7 @@ function stepTypeFromOpCode(op, opts, logger) {
65
66
  if (opts?.type === "group.experiment") return "group.experiment";
66
67
  } else if (op === require_types.StepOpCode.Sleep) return "sleep";
67
68
  else if (op === require_types.StepOpCode.WaitForEvent) return "waitForEvent";
69
+ else if (op === require_types.StepOpCode.WaitForSignal) return "waitForSignal";
68
70
  logger.warn({
69
71
  op,
70
72
  type: opts?.type
@@ -109,7 +111,7 @@ var UnreachableError = class extends Error {
109
111
  exports.UnreachableError = UnreachableError;
110
112
  exports.buildWrapRequestChain = buildWrapRequestChain;
111
113
  exports.buildWrapSendEventChain = buildWrapSendEventChain;
112
- exports.isTimeStrInput = isTimeStrInput;
114
+ exports.isSleepInput = isSleepInput;
113
115
  exports.optsFromStepInput = optsFromStepInput;
114
116
  exports.stepInputFromOpts = stepInputFromOpts;
115
117
  exports.stepTypeFromOpCode = stepTypeFromOpCode;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["chain: () => Promise<SendEventBaseOutput>","chain: () => Promise<Middleware.Response>","StepOpCode","isRecord"],"sources":["../../../src/components/middleware/utils.ts"],"sourcesContent":["import { isRecord } from \"../../helpers/types\";\nimport type { Logger } from \"../../middleware/logger\";\nimport { type SendEventBaseOutput, StepOpCode } from \"../../types\";\nimport type { InngestFunction } from \"../InngestFunction\";\nimport type { Middleware } from \"./middleware\";\nimport type { ExtractLiteralStrings } from \"./types\";\n\nexport function isTimeStrInput(\n value: unknown,\n): value is string | number | Date {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n value instanceof Date\n );\n}\n\n/**\n * Build an onion-style middleware chain for `wrapSendEvent`.\n *\n * Same pattern as `buildWrapRequestChain` but wraps the outgoing HTTP call\n * in `client.send()` instead of the incoming execution request.\n */\nexport function buildWrapSendEventChain(\n middleware: Middleware.BaseMiddleware[],\n handler: () => Promise<SendEventBaseOutput>,\n payloads: Middleware.WrapSendEventArgs[\"events\"],\n fn: InngestFunction.Any | null,\n): () => Promise<SendEventBaseOutput> {\n let chain: () => Promise<SendEventBaseOutput> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapSendEvent) {\n const next = chain;\n chain = () => mw.wrapSendEvent!({ next, events: payloads, fn });\n }\n }\n return chain;\n}\n\n/**\n * Build an onion-style middleware chain for `wrapRequest`.\n *\n * Iterates in reverse order (so first middleware is outermost)\n * and returns a zero-arg function that kicks off the chain.\n */\nexport function buildWrapRequestChain({\n fn,\n handler,\n middleware,\n requestArgs,\n requestInfo,\n runId,\n}: {\n fn: InngestFunction.Any | null;\n handler: () => Promise<Middleware.Response>;\n middleware: Middleware.BaseMiddleware[];\n requestArgs: readonly unknown[];\n requestInfo: Middleware.Request;\n runId: string;\n}): () => Promise<Middleware.Response> {\n let chain: () => Promise<Middleware.Response> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapRequest) {\n const next = chain;\n chain = () =>\n mw.wrapRequest!({ next, requestArgs, requestInfo, runId, fn });\n }\n }\n return chain;\n}\n\n// Replace the \"and can be any string\" union member with \"unknown\". This\n// improves static type safety within `stepTypeFromOpCode`, since it ensures we\n// aren't returning any unknown StepType besides \"unknown\". We should never\n// actually return \"unknown\" at runtime, but we need a default\ntype StepTypeFromOpCodeReturn =\n | ExtractLiteralStrings<Middleware.StepType>\n | \"unknown\";\n\n/**\n * Convert an opcode (from the op) to a step type.\n */\nexport function stepTypeFromOpCode(\n op: StepOpCode,\n opts: Record<string, unknown> | undefined,\n logger: Logger,\n): StepTypeFromOpCodeReturn {\n if (op === StepOpCode.AiGateway) {\n if (opts?.type === \"step.ai.infer\") {\n return \"ai.infer\";\n }\n if (opts?.type === \"step.ai.wrap\") {\n return \"ai.wrap\";\n }\n } else if (op === StepOpCode.Gateway) {\n return \"fetch\";\n } else if (op === StepOpCode.InvokeFunction) {\n return \"invoke\";\n } else if (op === StepOpCode.StepPlanned) {\n if (opts?.type === undefined) {\n return \"run\";\n }\n if (opts?.type === \"step.sendEvent\") {\n return \"sendEvent\";\n }\n if (opts?.type === \"step.realtime.publish\") {\n return \"realtime.publish\";\n }\n if (opts?.type === \"group.experiment\") {\n return \"group.experiment\";\n }\n } else if (op === StepOpCode.Sleep) {\n return \"sleep\";\n } else if (op === StepOpCode.WaitForEvent) {\n return \"waitForEvent\";\n }\n\n logger.warn({ op, type: opts?.type }, \"Unknown step type\");\n return \"unknown\";\n}\n\n/**\n * Convert the opts object (from the op) to a step input array.\n *\n * Paired with `optsFromStepInput` which reverses this for step kinds that\n * wrap the entire opts as `[opts]`.\n */\nexport function stepInputFromOpts(\n stepType: Middleware.StepType,\n opts?: Record<string, unknown>,\n): unknown[] | undefined {\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n return [opts];\n }\n if (Array.isArray(opts?.input)) {\n return opts.input;\n }\n return undefined;\n}\n\n/**\n * Reverse of `stepInputFromOpts`: given middleware-transformed input, derive\n * the opts to use in the outgoing op.\n *\n * Returns undefined when the step kind doesn't derive opts from input.\n */\nexport function optsFromStepInput(\n stepType: Middleware.StepType,\n input: unknown[] | undefined,\n): Record<string, unknown> | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n // Step types where stepInputFromOpts wraps the entire opts as [opts]\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n const opts = input[0];\n if (isRecord(opts)) {\n return opts;\n }\n }\n\n return undefined;\n}\n\n/**\n * An error that is thrown when a code path is unreachable. Should never be\n * thrown at runtime.\n */\nexport class UnreachableError extends Error {\n constructor(...args: Parameters<typeof Error>) {\n super(...args);\n this.name = this.constructor.name;\n }\n}\n"],"mapp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AAa,YAAY,aAAa,eACxC,QAAO,CAAC,KAAK;AAEf,KAAI,MAAM,QAAQ,MAAM,MAAM,CAC5B,QAAO,KAAK;;;;;;;;AAWhB,SAAgB,kBACd,UACA,OACqC;AACrC,KAAI,UAAU,OACZ;AAIF,KAAI,aAAa,YAAY,aAAa,gBAAgB;EACxD,MAAM,OAAO,MAAM;AACnB,MAAIC,yBAAS,KAAK,CAChB,QAAO;;;;;;;AAWb,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,GAAG,MAAgC;AAC7C,QAAM,GAAG,KAAK;AACd,OAAK,OAAO,KAAK,YAAY"}
1
+ {"version":3,"file":"utils.cjs","names":["isTemporalDuration","chain: () => Promise<SendEventBaseOutput>","chain: () => Promise<Middleware.Response>","StepOpCode","isRecord"],"sources":["../../../src/components/middleware/utils.ts"],"sourcesContent":["import { type DurationLike, isTemporalDuration } from \"../../helpers/temporal\";\nimport { isRecord } from \"../../helpers/types\";\nimport type { Logger } from \"../../middleware/logger\";\nimport { type SendEventBaseOutput, StepOpCode } from \"../../types\";\nimport type { InngestFunction } from \"../InngestFunction\";\nimport type { Middleware } from \"./middleware\";\nimport type { ExtractLiteralStrings } from \"./types\";\n\nexport function isSleepInput(\n value: unknown,\n): value is string | number | Date | DurationLike {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n value instanceof Date ||\n isTemporalDuration(value)\n );\n}\n\n/**\n * Build an onion-style middleware chain for `wrapSendEvent`.\n *\n * Same pattern as `buildWrapRequestChain` but wraps the outgoing HTTP call\n * in `client.send()` instead of the incoming execution request.\n */\nexport function buildWrapSendEventChain(\n middleware: Middleware.BaseMiddleware[],\n handler: () => Promise<SendEventBaseOutput>,\n payloads: Middleware.WrapSendEventArgs[\"events\"],\n fn: InngestFunction.Any | null,\n): () => Promise<SendEventBaseOutput> {\n let chain: () => Promise<SendEventBaseOutput> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapSendEvent) {\n const next = chain;\n chain = () => mw.wrapSendEvent!({ next, events: payloads, fn });\n }\n }\n return chain;\n}\n\n/**\n * Build an onion-style middleware chain for `wrapRequest`.\n *\n * Iterates in reverse order (so first middleware is outermost)\n * and returns a zero-arg function that kicks off the chain.\n */\nexport function buildWrapRequestChain({\n fn,\n handler,\n middleware,\n requestArgs,\n requestInfo,\n runId,\n}: {\n fn: InngestFunction.Any | null;\n handler: () => Promise<Middleware.Response>;\n middleware: Middleware.BaseMiddleware[];\n requestArgs: readonly unknown[];\n requestInfo: Middleware.Request;\n runId: string;\n}): () => Promise<Middleware.Response> {\n let chain: () => Promise<Middleware.Response> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapRequest) {\n const next = chain;\n chain = () =>\n mw.wrapRequest!({ next, requestArgs, requestInfo, runId, fn });\n }\n }\n return chain;\n}\n\n// Replace the \"and can be any string\" union member with \"unknown\". This\n// improves static type safety within `stepTypeFromOpCode`, since it ensures we\n// aren't returning any unknown StepType besides \"unknown\". We should never\n// actually return \"unknown\" at runtime, but we need a default\ntype StepTypeFromOpCodeReturn =\n | ExtractLiteralStrings<Middleware.StepType>\n | \"unknown\";\n\n/**\n * Convert an opcode (from the op) to a step type.\n */\nexport function stepTypeFromOpCode(\n op: StepOpCode,\n opts: Record<string, unknown> | undefined,\n logger: Logger,\n): StepTypeFromOpCodeReturn {\n if (op === StepOpCode.AiGateway) {\n if (opts?.type === \"step.ai.infer\") {\n return \"ai.infer\";\n }\n if (opts?.type === \"step.ai.wrap\") {\n return \"ai.wrap\";\n }\n } else if (op === StepOpCode.Gateway) {\n return \"fetch\";\n } else if (op === StepOpCode.InvokeFunction) {\n return \"invoke\";\n } else if (op === StepOpCode.StepPlanned) {\n if (opts?.type === undefined) {\n return \"run\";\n }\n if (opts?.type === \"step.sendEvent\") {\n return \"sendEvent\";\n }\n if (opts?.type === \"step.realtime.publish\") {\n return \"realtime.publish\";\n }\n if (opts?.type === \"group.experiment\") {\n return \"group.experiment\";\n }\n } else if (op === StepOpCode.Sleep) {\n return \"sleep\";\n } else if (op === StepOpCode.WaitForEvent) {\n return \"waitForEvent\";\n } else if (op === StepOpCode.WaitForSignal) {\n return \"waitForSignal\";\n }\n\n logger.warn({ op, type: opts?.type }, \"Unknown step type\");\n return \"unknown\";\n}\n\n/**\n * Convert the opts object (from the op) to a step input array.\n *\n * Paired with `optsFromStepInput` which reverses this for step kinds that\n * wrap the entire opts as `[opts]`.\n */\nexport function stepInputFromOpts(\n stepType: Middleware.StepType,\n opts?: Record<string, unknown>,\n): unknown[] | undefined {\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n return [opts];\n }\n if (Array.isArray(opts?.input)) {\n return opts.input;\n }\n return undefined;\n}\n\n/**\n * Reverse of `stepInputFromOpts`: given middleware-transformed input, derive\n * the opts to use in the outgoing op.\n *\n * Returns undefined when the step kind doesn't derive opts from input.\n */\nexport function optsFromStepInput(\n stepType: Middleware.StepType,\n input: unknown[] | undefined,\n): Record<string, unknown> | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n // Step types where stepInputFromOpts wraps the entire opts as [opts]\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n const opts = input[0];\n if (isRecord(opts)) {\n return opts;\n }\n }\n\n return undefined;\n}\n\n/**\n * An error that is thrown when a code path is unreachable. Should never be\n * thrown at runtime.\n */\nexport class UnreachableError extends Error {\n constructor(...args: Parameters<typeof Error>) {\n super(...args);\n this.name = this.constructor.name;\n }\n}\n"],"mappings":";;;;;AAQA,SAAgB,aACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,iBAAiB,QACjBA,oCAAmB,MAAM;;;;;;;;AAU7B,SAAgB,wBACd,YACA,SACA,UACA,IACoC;CACpC,IAAIC,QAA4C;AAChD,MAAK,IAAI,IAAI,WAAW,SAAS,GAAG,KAAK,GAAG,KAAK;EAC/C,MAAM,KAAK,WAAW;AACtB,MAAI,IAAI,eAAe;GAC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,yBAAS,KAAK,CAChB,QAAO;;;;;;;AAWb,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,GAAG,MAAgC;AAC7C,QAAM,GAAG,KAAK;AACd,OAAK,OAAO,KAAK,YAAY"}
@@ -1,9 +1,10 @@
1
1
  import { StepOpCode } from "../../types.js";
2
2
  import { isRecord } from "../../helpers/types.js";
3
+ import { isTemporalDuration } from "../../helpers/temporal.js";
3
4
 
4
5
  //#region src/components/middleware/utils.ts
5
- function isTimeStrInput(value) {
6
- return typeof value === "string" || typeof value === "number" || value instanceof Date;
6
+ function isSleepInput(value) {
7
+ return typeof value === "string" || typeof value === "number" || value instanceof Date || isTemporalDuration(value);
7
8
  }
8
9
  /**
9
10
  * Build an onion-style middleware chain for `wrapSendEvent`.
@@ -65,6 +66,7 @@ function stepTypeFromOpCode(op, opts, logger) {
65
66
  if (opts?.type === "group.experiment") return "group.experiment";
66
67
  } else if (op === StepOpCode.Sleep) return "sleep";
67
68
  else if (op === StepOpCode.WaitForEvent) return "waitForEvent";
69
+ else if (op === StepOpCode.WaitForSignal) return "waitForSignal";
68
70
  logger.warn({
69
71
  op,
70
72
  type: opts?.type
@@ -106,5 +108,5 @@ var UnreachableError = class extends Error {
106
108
  };
107
109
 
108
110
  //#endregion
109
- export { UnreachableError, buildWrapRequestChain, buildWrapSendEventChain, isTimeStrInput, optsFromStepInput, stepInputFromOpts, stepTypeFromOpCode };
111
+ export { UnreachableError, buildWrapRequestChain, buildWrapSendEventChain, isSleepInput, optsFromStepInput, stepInputFromOpts, stepTypeFromOpCode };
110
112
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["chain: () => Promise<SendEventBaseOutput>","chain: () => Promise<Middleware.Response>"],"sources":["../../../src/components/middleware/utils.ts"],"sourcesContent":["import { isRecord } from \"../../helpers/types\";\nimport type { Logger } from \"../../middleware/logger\";\nimport { type SendEventBaseOutput, StepOpCode } from \"../../types\";\nimport type { InngestFunction } from \"../InngestFunction\";\nimport type { Middleware } from \"./middleware\";\nimport type { ExtractLiteralStrings } from \"./types\";\n\nexport function isTimeStrInput(\n value: unknown,\n): value is string | number | Date {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n value instanceof Date\n );\n}\n\n/**\n * Build an onion-style middleware chain for `wrapSendEvent`.\n *\n * Same pattern as `buildWrapRequestChain` but wraps the outgoing HTTP call\n * in `client.send()` instead of the incoming execution request.\n */\nexport function buildWrapSendEventChain(\n middleware: Middleware.BaseMiddleware[],\n handler: () => Promise<SendEventBaseOutput>,\n payloads: Middleware.WrapSendEventArgs[\"events\"],\n fn: InngestFunction.Any | null,\n): () => Promise<SendEventBaseOutput> {\n let chain: () => Promise<SendEventBaseOutput> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapSendEvent) {\n const next = chain;\n chain = () => mw.wrapSendEvent!({ next, events: payloads, fn });\n }\n }\n return chain;\n}\n\n/**\n * Build an onion-style middleware chain for `wrapRequest`.\n *\n * Iterates in reverse order (so first middleware is outermost)\n * and returns a zero-arg function that kicks off the chain.\n */\nexport function buildWrapRequestChain({\n fn,\n handler,\n middleware,\n requestArgs,\n requestInfo,\n runId,\n}: {\n fn: InngestFunction.Any | null;\n handler: () => Promise<Middleware.Response>;\n middleware: Middleware.BaseMiddleware[];\n requestArgs: readonly unknown[];\n requestInfo: Middleware.Request;\n runId: string;\n}): () => Promise<Middleware.Response> {\n let chain: () => Promise<Middleware.Response> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapRequest) {\n const next = chain;\n chain = () =>\n mw.wrapRequest!({ next, requestArgs, requestInfo, runId, fn });\n }\n }\n return chain;\n}\n\n// Replace the \"and can be any string\" union member with \"unknown\". This\n// improves static type safety within `stepTypeFromOpCode`, since it ensures we\n// aren't returning any unknown StepType besides \"unknown\". We should never\n// actually return \"unknown\" at runtime, but we need a default\ntype StepTypeFromOpCodeReturn =\n | ExtractLiteralStrings<Middleware.StepType>\n | \"unknown\";\n\n/**\n * Convert an opcode (from the op) to a step type.\n */\nexport function stepTypeFromOpCode(\n op: StepOpCode,\n opts: Record<string, unknown> | undefined,\n logger: Logger,\n): StepTypeFromOpCodeReturn {\n if (op === StepOpCode.AiGateway) {\n if (opts?.type === \"step.ai.infer\") {\n return \"ai.infer\";\n }\n if (opts?.type === \"step.ai.wrap\") {\n return \"ai.wrap\";\n }\n } else if (op === StepOpCode.Gateway) {\n return \"fetch\";\n } else if (op === StepOpCode.InvokeFunction) {\n return \"invoke\";\n } else if (op === StepOpCode.StepPlanned) {\n if (opts?.type === undefined) {\n return \"run\";\n }\n if (opts?.type === \"step.sendEvent\") {\n return \"sendEvent\";\n }\n if (opts?.type === \"step.realtime.publish\") {\n return \"realtime.publish\";\n }\n if (opts?.type === \"group.experiment\") {\n return \"group.experiment\";\n }\n } else if (op === StepOpCode.Sleep) {\n return \"sleep\";\n } else if (op === StepOpCode.WaitForEvent) {\n return \"waitForEvent\";\n }\n\n logger.warn({ op, type: opts?.type }, \"Unknown step type\");\n return \"unknown\";\n}\n\n/**\n * Convert the opts object (from the op) to a step input array.\n *\n * Paired with `optsFromStepInput` which reverses this for step kinds that\n * wrap the entire opts as `[opts]`.\n */\nexport function stepInputFromOpts(\n stepType: Middleware.StepType,\n opts?: Record<string, unknown>,\n): unknown[] | undefined {\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n return [opts];\n }\n if (Array.isArray(opts?.input)) {\n return opts.input;\n }\n return undefined;\n}\n\n/**\n * Reverse of `stepInputFromOpts`: given middleware-transformed input, derive\n * the opts to use in the outgoing op.\n *\n * Returns undefined when the step kind doesn't derive opts from input.\n */\nexport function optsFromStepInput(\n stepType: Middleware.StepType,\n input: unknown[] | undefined,\n): Record<string, unknown> | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n // Step types where stepInputFromOpts wraps the entire opts as [opts]\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n const opts = input[0];\n if (isRecord(opts)) {\n return opts;\n }\n }\n\n return undefined;\n}\n\n/**\n * An error that is thrown when a code path is unreachable. Should never be\n * thrown at runtime.\n */\nexport class UnreachableError extends Error {\n constructor(...args: Parameters<typeof Error>) {\n super(...args);\n this.name = this.constructor.name;\n }\n}\n"],"mappings":";;;;AAOA,SAAgB,eACd,OACiC;AACjC,QACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,iBAAiB;;;;;;;;AAUrB,SAAgB,wBACd,YACA,SACA,UACA,IACoC;CACpC,IAAIA,QAA4C;AAChD,MAAK,IAAI,IAAI,WAAW,SAAS,GAAG,KAAK,GAAG,KAAK;EAC/C,MAAM,KAAK,WAAW;AACtB,MAAI,IAAI,eAAe;GACrB,MAAM,OAAO;AACb,iBAAc,GAAG,cAAe;IAAE;IAAM,QAAQ;IAAU;IAAI,CAAC;;;AAGnE,QAAO;;;;;;;;AAST,SAAgB,sBAAsB,EACpC,IACA,SACA,YACA,aACA,aACA,SAQqC;CACrC,IAAIC,QAA4C;AAChD,MAAK,IAAI,IAAI,WAAW,SAAS,GAAG,KAAK,GAAG,KAAK;EAC/C,MAAM,KAAK,WAAW;AACtB,MAAI,IAAI,aAAa;GACnB,MAAM,OAAO;AACb,iBACE,GAAG,YAAa;IAAE;IAAM;IAAa;IAAa;IAAO;IAAI,CAAC;;;AAGpE,QAAO;;;;;AAcT,SAAgB,mBACd,IACA,MACA,QAC0B;AAC1B,KAAI,OAAO,WAAW,WAAW;AAC/B,MAAI,MAAM,SAAS,gBACjB,QAAO;AAET,MAAI,MAAM,SAAS,eACjB,QAAO;YAEA,OAAO,WAAW,QAC3B,QAAO;UACE,OAAO,WAAW,eAC3B,QAAO;UACE,OAAO,WAAW,aAAa;AACxC,MAAI,MAAM,SAAS,OACjB,QAAO;AAET,MAAI,MAAM,SAAS,iBACjB,QAAO;AAET,MAAI,MAAM,SAAS,wBACjB,QAAO;AAET,MAAI,MAAM,SAAS,mBACjB,QAAO;YAEA,OAAO,WAAW,MAC3B,QAAO;UACE,OAAO,WAAW,aAC3B,QAAO;AAGT,QAAO,KAAK;EAAE;EAAI,MAAM,MAAM;EAAM,EAAE,oBAAoB;AAC1D,QAAO;;;;;;;;AAST,SAAgB,kBACd,UACA,MACuB;AACvB,KAAI,aAAa,YAAY,aAAa,eACxC,QAAO,CAAC,KAAK;AAEf,KAAI,MAAM,QAAQ,MAAM,MAAM,CAC5B,QAAO,KAAK;;;;;;;;AAWhB,SAAgB,kBACd,UACA,OACqC;AACrC,KAAI,UAAU,OACZ;AAIF,KAAI,aAAa,YAAY,aAAa,gBAAgB;EACxD,MAAM,OAAO,MAAM;AACnB,MAAI,SAAS,KAAK,CAChB,QAAO;;;;;;;AAWb,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,GAAG,MAAgC;AAC7C,QAAM,GAAG,KAAK;AACd,OAAK,OAAO,KAAK,YAAY"}
1
+ {"version":3,"file":"utils.js","names":["chain: () => Promise<SendEventBaseOutput>","chain: () => Promise<Middleware.Response>"],"sources":["../../../src/components/middleware/utils.ts"],"sourcesContent":["import { type DurationLike, isTemporalDuration } from \"../../helpers/temporal\";\nimport { isRecord } from \"../../helpers/types\";\nimport type { Logger } from \"../../middleware/logger\";\nimport { type SendEventBaseOutput, StepOpCode } from \"../../types\";\nimport type { InngestFunction } from \"../InngestFunction\";\nimport type { Middleware } from \"./middleware\";\nimport type { ExtractLiteralStrings } from \"./types\";\n\nexport function isSleepInput(\n value: unknown,\n): value is string | number | Date | DurationLike {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n value instanceof Date ||\n isTemporalDuration(value)\n );\n}\n\n/**\n * Build an onion-style middleware chain for `wrapSendEvent`.\n *\n * Same pattern as `buildWrapRequestChain` but wraps the outgoing HTTP call\n * in `client.send()` instead of the incoming execution request.\n */\nexport function buildWrapSendEventChain(\n middleware: Middleware.BaseMiddleware[],\n handler: () => Promise<SendEventBaseOutput>,\n payloads: Middleware.WrapSendEventArgs[\"events\"],\n fn: InngestFunction.Any | null,\n): () => Promise<SendEventBaseOutput> {\n let chain: () => Promise<SendEventBaseOutput> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapSendEvent) {\n const next = chain;\n chain = () => mw.wrapSendEvent!({ next, events: payloads, fn });\n }\n }\n return chain;\n}\n\n/**\n * Build an onion-style middleware chain for `wrapRequest`.\n *\n * Iterates in reverse order (so first middleware is outermost)\n * and returns a zero-arg function that kicks off the chain.\n */\nexport function buildWrapRequestChain({\n fn,\n handler,\n middleware,\n requestArgs,\n requestInfo,\n runId,\n}: {\n fn: InngestFunction.Any | null;\n handler: () => Promise<Middleware.Response>;\n middleware: Middleware.BaseMiddleware[];\n requestArgs: readonly unknown[];\n requestInfo: Middleware.Request;\n runId: string;\n}): () => Promise<Middleware.Response> {\n let chain: () => Promise<Middleware.Response> = handler;\n for (let i = middleware.length - 1; i >= 0; i--) {\n const mw = middleware[i];\n if (mw?.wrapRequest) {\n const next = chain;\n chain = () =>\n mw.wrapRequest!({ next, requestArgs, requestInfo, runId, fn });\n }\n }\n return chain;\n}\n\n// Replace the \"and can be any string\" union member with \"unknown\". This\n// improves static type safety within `stepTypeFromOpCode`, since it ensures we\n// aren't returning any unknown StepType besides \"unknown\". We should never\n// actually return \"unknown\" at runtime, but we need a default\ntype StepTypeFromOpCodeReturn =\n | ExtractLiteralStrings<Middleware.StepType>\n | \"unknown\";\n\n/**\n * Convert an opcode (from the op) to a step type.\n */\nexport function stepTypeFromOpCode(\n op: StepOpCode,\n opts: Record<string, unknown> | undefined,\n logger: Logger,\n): StepTypeFromOpCodeReturn {\n if (op === StepOpCode.AiGateway) {\n if (opts?.type === \"step.ai.infer\") {\n return \"ai.infer\";\n }\n if (opts?.type === \"step.ai.wrap\") {\n return \"ai.wrap\";\n }\n } else if (op === StepOpCode.Gateway) {\n return \"fetch\";\n } else if (op === StepOpCode.InvokeFunction) {\n return \"invoke\";\n } else if (op === StepOpCode.StepPlanned) {\n if (opts?.type === undefined) {\n return \"run\";\n }\n if (opts?.type === \"step.sendEvent\") {\n return \"sendEvent\";\n }\n if (opts?.type === \"step.realtime.publish\") {\n return \"realtime.publish\";\n }\n if (opts?.type === \"group.experiment\") {\n return \"group.experiment\";\n }\n } else if (op === StepOpCode.Sleep) {\n return \"sleep\";\n } else if (op === StepOpCode.WaitForEvent) {\n return \"waitForEvent\";\n } else if (op === StepOpCode.WaitForSignal) {\n return \"waitForSignal\";\n }\n\n logger.warn({ op, type: opts?.type }, \"Unknown step type\");\n return \"unknown\";\n}\n\n/**\n * Convert the opts object (from the op) to a step input array.\n *\n * Paired with `optsFromStepInput` which reverses this for step kinds that\n * wrap the entire opts as `[opts]`.\n */\nexport function stepInputFromOpts(\n stepType: Middleware.StepType,\n opts?: Record<string, unknown>,\n): unknown[] | undefined {\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n return [opts];\n }\n if (Array.isArray(opts?.input)) {\n return opts.input;\n }\n return undefined;\n}\n\n/**\n * Reverse of `stepInputFromOpts`: given middleware-transformed input, derive\n * the opts to use in the outgoing op.\n *\n * Returns undefined when the step kind doesn't derive opts from input.\n */\nexport function optsFromStepInput(\n stepType: Middleware.StepType,\n input: unknown[] | undefined,\n): Record<string, unknown> | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n // Step types where stepInputFromOpts wraps the entire opts as [opts]\n if (stepType === \"invoke\" || stepType === \"waitForEvent\") {\n const opts = input[0];\n if (isRecord(opts)) {\n return opts;\n }\n }\n\n return undefined;\n}\n\n/**\n * An error that is thrown when a code path is unreachable. Should never be\n * thrown at runtime.\n */\nexport class UnreachableError extends Error {\n constructor(...args: Parameters<typeof Error>) {\n super(...args);\n this.name = this.constructor.name;\n }\n}\n"],"mappings":";;;;;AAQA,SAAgB,aACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,iBAAiB,QACjB,mBAAmB,MAAM;;;;;;;;AAU7B,SAAgB,wBACd,YAC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;;;AAWhB,SAAgB,kBACd,UACA,OACqC;AACrC,KAAI,UAAU,OACZ;AAIF,KAAI,aAAa,YAAY,aAAa,gBAAgB;EACxD,MAAM,OAAO,MAAM;AACnB,MAAI,SAAS,KAAK,CAChB,QAAO;;;;;;;AAWb,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,GAAG,MAAgC;AAC7C,QAAM,GAAG,KAAK;AACd,OAAK,OAAO,KAAK,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"typeHelpers.cjs","names":[],"sources":["../../../src/components/triggers/typeHelpers.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: it's fine\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { AsTuple } from \"../../helpers/types.ts\";\nimport type { createGroupTools } from \"../InngestGroupTools.ts\";\nimport type { EventType, EventTypeWithAnySchema } from \"./triggers.ts\";\n\nexport type AnySchema = StandardSchemaV1<any>;\ntype BasicDataUnknown = Record<string, unknown>;\ntype BasicDataAny = Record<string, any>;\n\ntype InvokeEventName = \"inngest/function.invoked\";\ntype CronEventName = \"inngest/scheduled.timer\";\ntype CronEventData = { cron: string };\n\n/**\n * Detects if a string type contains a wildcard character (*).\n */\ntype ContainsWildcard<T extends string> = T extends `${string}*${string}`\n ? true\n : false;\n\n/**\n * Converts wildcard event names to `unknown`, preserving literal names.\n */\ntype WildcardToUnknown<T extends string> = ContainsWildcard<T> extends true\n ? unknown\n : T;\n\n/**\n * Represents the structure of an event as received by function handlers.\n *\n * This is the runtime event shape that your function receives when triggered.\n *\n * @template TName - The event name as a string literal type\n * @template TData - The event data object type\n */\nexport type ReceivedEvent<TName, TData extends BasicDataUnknown> = {\n data: TData;\n id: string;\n name: TName;\n ts: number;\n v: string;\n};\n\n/**\n * Recursively checks if a trigger array contains an invoke trigger.\n *\n * This type is used to determine whether to add \"inngest/function.invoked\"\n * event to the received events tuple.\n *\n * @template T - Array of trigger definitions to check\n * @returns `true` if array contains an invoke trigger, `false` otherwise\n */\ntype HasInvokeTrigger<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventTypeWithAnySchema<InvokeEventName>\n ? true\n : HasInvokeTrigger<Rest>\n : false;\n\n/**\n * Converts an EventType instance to a ReceivedEvent type.\n *\n * Extracts the event name and schema from EventType and transforms it into\n * the ReceivedEvent shape that function handlers receive.\n *\n * @template TEventType - The EventType instance to convert\n * @returns ReceivedEvent type with extracted name and data\n */\ntype EventTypeToEvent<TEventType> = TEventType extends EventType<\n infer TName,\n infer TSchema\n>\n ? TSchema extends StandardSchemaV1<infer TData extends BasicDataUnknown>\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>\n : never;\n\n/**\n * Converts a plain event object trigger to a ReceivedEvent type.\n *\n * Handles triggers like `{ event: \"my-event\", schema?: z.object(...) }`.\n *\n * @template TName - Event name\n * @template TSchema - Optional schema type\n * @returns ReceivedEvent with typed data from schema, or Record<string, any> if no schema\n */\ntype PlainEventToReceivedEvent<\n TName extends string,\n TSchema,\n> = TSchema extends StandardSchemaV1<infer TData extends BasicDataUnknown>\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>;\n\n/**\n * Processes a single trigger and converts it to ReceivedEvent(s).\n *\n * @template TTrigger - The trigger to process\n * @template TSeenCron - Whether we've already seen a cron trigger\n * @returns Tuple of ReceivedEvent(s), or empty array if trigger should be skipped\n */\ntype ProcessSingleTrigger<\n TTrigger,\n TSeenCron extends boolean,\n> = TTrigger extends EventTypeWithAnySchema<InvokeEventName> // Is this an invoke trigger?\n ? [] // Skip invoke triggers (handled separately by ToReceivedEvent)\n : TTrigger extends EventTypeWithAnySchema<string> // Is this an event type trigger?\n ? [EventTypeToEvent<TTrigger>]\n : TTrigger extends { cron: string } // Is this a cron trigger?\n ? TSeenCron extends true\n ? [] // Skip additional cron triggers (they're merged into one)\n : [ReceivedEvent<CronEventName, CronEventData>]\n : // Is this an event trigger using an EventType?\n TTrigger extends {\n event: EventType<infer TName, infer TSchema>;\n if?: string;\n }\n ? [\n TSchema extends StandardSchemaV1<\n infer TData extends BasicDataUnknown\n >\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>,\n ]\n : // Is this an event trigger using a string name (i.e. not an EventType)?\n TTrigger extends {\n event: infer TName extends string;\n schema?: infer TSchema;\n }\n ? [PlainEventToReceivedEvent<TName, TSchema>]\n : []; // Unknown trigger type, skip it\n\n/**\n * Recursively processes trigger array, converting to event types while tracking\n * crons.\n *\n * This type iterates through a trigger array, converting each trigger to its\n * corresponding ReceivedEvent type. It handles:\n * - EventType instances → ReceivedEvent with typed data\n * - Cron triggers → \"inngest/scheduled.timer\" event (merged if multiple)\n * - Plain event objects → ReceivedEvent with typed or untyped data\n * - Invoke triggers → skipped (handled by ToReceivedEvent)\n *\n * @template T - Array of trigger definitions to process\n * @template SeenCron - Tracks whether we've already encountered a cron trigger\n *\n * @remarks\n * Multiple cron triggers are merged into a single \"inngest/scheduled.timer\" event.\n */\ntype TriggersToEventsWithCron<\n T extends readonly any[],\n SeenCron extends boolean = false,\n> = T extends readonly [infer First, ...infer Rest]\n ? [\n ...ProcessSingleTrigger<First, SeenCron>,\n ...TriggersToEventsWithCron<\n Rest,\n First extends { cron: string } ? true : SeenCron\n >,\n ]\n : [];\n\n/**\n * Alias for TriggersToEventsWithCron that processes all non-invoke triggers.\n *\n * Despite the name \"Filter\", this type actually:\n * 1. Converts event triggers to ReceivedEvent types\n * 2. Converts cron triggers to \"inngest/scheduled.timer\" events\n * 3. Merges multiple cron triggers into one\n * 4. Preserves the order of non-invoke triggers\n *\n * @template T - Array of trigger definitions to process\n */\ntype FilterNonInvokeTriggers<T extends readonly any[]> =\n TriggersToEventsWithCron<T>;\n\n/**\n * Extracts and builds a union of schema output types from invoke triggers.\n *\n * This recursively processes the trigger array and accumulates the output types\n * from all invoke trigger schemas (those with event: \"inngest/function.invoked\")\n * into a union type.\n *\n * @template T - Array of trigger definitions to process\n * @returns Union of all invoke trigger schema output types, or `never` if none found\n */\ntype ExtractInvokeSchemas<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventType<InvokeEventName, infer TSchema>\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractInvokeSchemas<Rest>\n : ExtractInvokeSchemas<Rest>\n : ExtractInvokeSchemas<Rest>\n : never;\n\n/**\n * Extracts and builds a union of all data types from all trigger schemas.\n *\n * Unlike ExtractInvokeSchemas which only processes invoke triggers, this type\n * processes ALL triggers (event and invoke triggers) and builds a union of\n * their data types. For event triggers without schemas, it returns Record<string, any>.\n *\n * @template T - Array of trigger definitions to process\n * @returns Union of all trigger data types, or `never` if none found\n */\ntype ExtractAllSchemaOutputs<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventType<string, infer TSchema>\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractAllSchemaOutputs<Rest>\n : BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : First extends { event: EventType<string, infer TSchema> }\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractAllSchemaOutputs<Rest>\n : BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : First extends {\n event: string;\n schema: StandardSchemaV1<infer TData>;\n }\n ? TData | ExtractAllSchemaOutputs<Rest>\n : First extends { event: string }\n ? BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : ExtractAllSchemaOutputs<Rest>\n : never;\n\n/**\n * Converts `never` type to empty object `{}` for data types.\n *\n * This utility is used to ensure that when no schemas are found, the data type\n * becomes `{}` instead of `never`, which provides better TypeScript error\n * messages and autocomplete.\n *\n * @template T - Type to check and potentially convert\n * @returns `{}` if T is `never`, otherwise returns T unchanged\n */\ntype NeverToEmpty<T> = [T] extends [never] ? {} : T;\n\n/**\n * Converts a trigger array to a tuple of ReceivedEvent types.\n *\n * This type transforms trigger definitions into the event types that a function\n * handler will receive. It always includes an invoke event type because\n * functions can be invoked directly regardless of their declared triggers.\n *\n * When invoke triggers are present, it uses their schemas for the invoke event\n * data. Otherwise, it derives the invoke event data type from all trigger\n * schemas.\n *\n * @template T - Array of trigger definitions to process\n */\nexport type ToReceivedEvent<T extends readonly any[]> =\n HasInvokeTrigger<T> extends true\n ? [\n ...FilterNonInvokeTriggers<T>,\n ReceivedEvent<InvokeEventName, NeverToEmpty<ExtractInvokeSchemas<T>>>,\n ]\n : [\n ...TriggersToEventsWithCron<T>,\n ReceivedEvent<\n InvokeEventName,\n NeverToEmpty<ExtractAllSchemaOutputs<T>>\n >,\n ];\n\n/**\n * Converts a tuple of ReceivedEvent types to a union.\n * @internal\n */\ntype ReceivedEventTupleToUnion<T extends readonly any[]> = T[number];\n\n/**\n * Base context object for handlers using the new trigger-based event typing.\n * This uses ToReceivedEvent to derive event types directly from triggers\n * rather than looking up from the client's event registry.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @internal\n */\nexport type BaseContextWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n> = {\n /**\n * The event data present in the payload.\n */\n event: ReceivedEventTupleToUnion<ToReceivedEvent<TTriggers>>;\n events: AsTuple<ReceivedEventTupleToUnion<ToReceivedEvent<TTriggers>>>;\n\n /**\n * The run ID for the current function execution\n */\n runId: string;\n\n step: TStepTools;\n\n /**\n * Tools for grouping and coordinating steps.\n */\n group: ReturnType<typeof createGroupTools>;\n\n /**\n * The current zero-indexed attempt number for this function execution.\n */\n attempt: number;\n\n /**\n * The maximum number of attempts allowed for this function.\n */\n maxAttempts?: number;\n};\n\n/**\n * Context object for handlers using trigger-based event typing with middleware overrides.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @template TOverrides - Properties to override from middleware\n * @internal\n */\nexport type ContextWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n TOverrides extends BasicDataUnknown = Record<never, never>,\n> = Omit<BaseContextWithTriggers<TStepTools, TTriggers>, keyof TOverrides> &\n TOverrides;\n\n/**\n * A handler type that computes its event type from a trigger array using ToReceivedEvent.\n * This provides proper typing for EventType instances and schema-bearing triggers.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @template TOverrides - Properties to override from middleware\n * @internal\n */\nexport type HandlerWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n TOverrides extends BasicDataUnknown = Record<never, never>,\n> = (\n /**\n * The context argument provides access to all data and tooling available to\n * the function.\n */\n ctx: ContextWithTriggers<TStepTools, TTriggers, TOverrides>,\n) => unknown;\n\n/**\n * Type guard to check if an object has a `validate` method. The use case is for\n * safely validating an event payload that might have a `validate` method\n */\nexport function isValidatable<T>(\n value: T,\n): value is T & { validate: () => Promise<void> } {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n if (!(\"validate\" in value)) {\n return false;\n }\n return typeof value.validate === \"function\";\n}\n"],"mappings":";;;;;;AAuWA,SAAgB,cACd,OACgD;AAChD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAET,KAAI,EAAE,cAAc,OAClB,QAAO;AAET,QAAO,OAAO,MAAM,aAAa"}
1
+ {"version":3,"file":"typeHelpers.cjs","names":[],"sources":["../../../src/components/triggers/typeHelpers.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: it's fine\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { AsTuple } from \"../../helpers/types.ts\";\nimport type { DeferFn } from \"../../types.ts\";\nimport type { createGroupTools } from \"../InngestGroupTools.ts\";\nimport type { EventType, EventTypeWithAnySchema } from \"./triggers.ts\";\n\nexport type AnySchema = StandardSchemaV1<any>;\ntype BasicDataUnknown = Record<string, unknown>;\ntype BasicDataAny = Record<string, any>;\n\ntype InvokeEventName = \"inngest/function.invoked\";\ntype CronEventName = \"inngest/scheduled.timer\";\ntype CronEventData = { cron: string };\n\n/**\n * Detects if a string type contains a wildcard character (*).\n */\ntype ContainsWildcard<T extends string> = T extends `${string}*${string}`\n ? true\n : false;\n\n/**\n * Converts wildcard event names to `unknown`, preserving literal names.\n */\ntype WildcardToUnknown<T extends string> = ContainsWildcard<T> extends true\n ? unknown\n : T;\n\n/**\n * Represents the structure of an event as received by function handlers.\n *\n * This is the runtime event shape that your function receives when triggered.\n *\n * @template TName - The event name as a string literal type\n * @template TData - The event data object type\n */\nexport type ReceivedEvent<TName, TData extends BasicDataUnknown> = {\n data: TData;\n id: string;\n name: TName;\n ts: number;\n v: string;\n};\n\n/**\n * Recursively checks if a trigger array contains an invoke trigger.\n *\n * This type is used to determine whether to add \"inngest/function.invoked\"\n * event to the received events tuple.\n *\n * @template T - Array of trigger definitions to check\n * @returns `true` if array contains an invoke trigger, `false` otherwise\n */\ntype HasInvokeTrigger<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventTypeWithAnySchema<InvokeEventName>\n ? true\n : HasInvokeTrigger<Rest>\n : false;\n\n/**\n * Converts an EventType instance to a ReceivedEvent type.\n *\n * Extracts the event name and schema from EventType and transforms it into\n * the ReceivedEvent shape that function handlers receive.\n *\n * @template TEventType - The EventType instance to convert\n * @returns ReceivedEvent type with extracted name and data\n */\ntype EventTypeToEvent<TEventType> = TEventType extends EventType<\n infer TName,\n infer TSchema\n>\n ? TSchema extends StandardSchemaV1<infer TData extends BasicDataUnknown>\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>\n : never;\n\n/**\n * Converts a plain event object trigger to a ReceivedEvent type.\n *\n * Handles triggers like `{ event: \"my-event\", schema?: z.object(...) }`.\n *\n * @template TName - Event name\n * @template TSchema - Optional schema type\n * @returns ReceivedEvent with typed data from schema, or Record<string, any> if no schema\n */\ntype PlainEventToReceivedEvent<\n TName extends string,\n TSchema,\n> = TSchema extends StandardSchemaV1<infer TData extends BasicDataUnknown>\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>;\n\n/**\n * Processes a single trigger and converts it to ReceivedEvent(s).\n *\n * @template TTrigger - The trigger to process\n * @template TSeenCron - Whether we've already seen a cron trigger\n * @returns Tuple of ReceivedEvent(s), or empty array if trigger should be skipped\n */\ntype ProcessSingleTrigger<\n TTrigger,\n TSeenCron extends boolean,\n> = TTrigger extends EventTypeWithAnySchema<InvokeEventName> // Is this an invoke trigger?\n ? [] // Skip invoke triggers (handled separately by ToReceivedEvent)\n : TTrigger extends EventTypeWithAnySchema<string> // Is this an event type trigger?\n ? [EventTypeToEvent<TTrigger>]\n : TTrigger extends { cron: string } // Is this a cron trigger?\n ? TSeenCron extends true\n ? [] // Skip additional cron triggers (they're merged into one)\n : [ReceivedEvent<CronEventName, CronEventData>]\n : // Is this an event trigger using an EventType?\n TTrigger extends {\n event: EventType<infer TName, infer TSchema>;\n if?: string;\n }\n ? [\n TSchema extends StandardSchemaV1<\n infer TData extends BasicDataUnknown\n >\n ? ReceivedEvent<WildcardToUnknown<TName>, TData>\n : ReceivedEvent<WildcardToUnknown<TName>, BasicDataAny>,\n ]\n : // Is this an event trigger using a string name (i.e. not an EventType)?\n TTrigger extends {\n event: infer TName extends string;\n schema?: infer TSchema;\n }\n ? [PlainEventToReceivedEvent<TName, TSchema>]\n : []; // Unknown trigger type, skip it\n\n/**\n * Recursively processes trigger array, converting to event types while tracking\n * crons.\n *\n * This type iterates through a trigger array, converting each trigger to its\n * corresponding ReceivedEvent type. It handles:\n * - EventType instances → ReceivedEvent with typed data\n * - Cron triggers → \"inngest/scheduled.timer\" event (merged if multiple)\n * - Plain event objects → ReceivedEvent with typed or untyped data\n * - Invoke triggers → skipped (handled by ToReceivedEvent)\n *\n * @template T - Array of trigger definitions to process\n * @template SeenCron - Tracks whether we've already encountered a cron trigger\n *\n * @remarks\n * Multiple cron triggers are merged into a single \"inngest/scheduled.timer\" event.\n */\ntype TriggersToEventsWithCron<\n T extends readonly any[],\n SeenCron extends boolean = false,\n> = T extends readonly [infer First, ...infer Rest]\n ? [\n ...ProcessSingleTrigger<First, SeenCron>,\n ...TriggersToEventsWithCron<\n Rest,\n First extends { cron: string } ? true : SeenCron\n >,\n ]\n : [];\n\n/**\n * Alias for TriggersToEventsWithCron that processes all non-invoke triggers.\n *\n * Despite the name \"Filter\", this type actually:\n * 1. Converts event triggers to ReceivedEvent types\n * 2. Converts cron triggers to \"inngest/scheduled.timer\" events\n * 3. Merges multiple cron triggers into one\n * 4. Preserves the order of non-invoke triggers\n *\n * @template T - Array of trigger definitions to process\n */\ntype FilterNonInvokeTriggers<T extends readonly any[]> =\n TriggersToEventsWithCron<T>;\n\n/**\n * Extracts and builds a union of schema output types from invoke triggers.\n *\n * This recursively processes the trigger array and accumulates the output types\n * from all invoke trigger schemas (those with event: \"inngest/function.invoked\")\n * into a union type.\n *\n * @template T - Array of trigger definitions to process\n * @returns Union of all invoke trigger schema output types, or `never` if none found\n */\ntype ExtractInvokeSchemas<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventType<InvokeEventName, infer TSchema>\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractInvokeSchemas<Rest>\n : ExtractInvokeSchemas<Rest>\n : ExtractInvokeSchemas<Rest>\n : never;\n\n/**\n * Extracts and builds a union of all data types from all trigger schemas.\n *\n * Unlike ExtractInvokeSchemas which only processes invoke triggers, this type\n * processes ALL triggers (event and invoke triggers) and builds a union of\n * their data types. For event triggers without schemas, it returns Record<string, any>.\n *\n * @template T - Array of trigger definitions to process\n * @returns Union of all trigger data types, or `never` if none found\n */\ntype ExtractAllSchemaOutputs<T extends readonly any[]> = T extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends EventType<string, infer TSchema>\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractAllSchemaOutputs<Rest>\n : BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : First extends { event: EventType<string, infer TSchema> }\n ? TSchema extends StandardSchemaV1<infer TData>\n ? TData | ExtractAllSchemaOutputs<Rest>\n : BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : First extends {\n event: string;\n schema: StandardSchemaV1<infer TData>;\n }\n ? TData | ExtractAllSchemaOutputs<Rest>\n : First extends { event: string }\n ? BasicDataAny | ExtractAllSchemaOutputs<Rest>\n : ExtractAllSchemaOutputs<Rest>\n : never;\n\n/**\n * Converts `never` type to empty object `{}` for data types.\n *\n * This utility is used to ensure that when no schemas are found, the data type\n * becomes `{}` instead of `never`, which provides better TypeScript error\n * messages and autocomplete.\n *\n * @template T - Type to check and potentially convert\n * @returns `{}` if T is `never`, otherwise returns T unchanged\n */\ntype NeverToEmpty<T> = [T] extends [never] ? {} : T;\n\n/**\n * Converts a trigger array to a tuple of ReceivedEvent types.\n *\n * This type transforms trigger definitions into the event types that a function\n * handler will receive. It always includes an invoke event type because\n * functions can be invoked directly regardless of their declared triggers.\n *\n * When invoke triggers are present, it uses their schemas for the invoke event\n * data. Otherwise, it derives the invoke event data type from all trigger\n * schemas.\n *\n * @template T - Array of trigger definitions to process\n */\nexport type ToReceivedEvent<T extends readonly any[]> =\n HasInvokeTrigger<T> extends true\n ? [\n ...FilterNonInvokeTriggers<T>,\n ReceivedEvent<InvokeEventName, NeverToEmpty<ExtractInvokeSchemas<T>>>,\n ]\n : [\n ...TriggersToEventsWithCron<T>,\n ReceivedEvent<\n InvokeEventName,\n NeverToEmpty<ExtractAllSchemaOutputs<T>>\n >,\n ];\n\n/**\n * Converts a tuple of ReceivedEvent types to a union.\n * @internal\n */\ntype ReceivedEventTupleToUnion<T extends readonly any[]> = T[number];\n\n/**\n * Base context object for handlers using the new trigger-based event typing.\n * This uses ToReceivedEvent to derive event types directly from triggers\n * rather than looking up from the client's event registry.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @internal\n */\nexport type BaseContextWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n> = {\n defer: DeferFn;\n\n /**\n * The event data present in the payload.\n */\n event: ReceivedEventTupleToUnion<ToReceivedEvent<TTriggers>>;\n events: AsTuple<ReceivedEventTupleToUnion<ToReceivedEvent<TTriggers>>>;\n\n /**\n * The run ID for the current function execution\n */\n runId: string;\n\n /**\n * The request ID for this individual outbound SDK invocation, if provided by\n * the executor.\n */\n requestId?: string;\n\n /**\n * The stable job ID for this invocation, if provided by the executor.\n */\n jobId?: string;\n\n step: TStepTools;\n\n /**\n * Tools for grouping and coordinating steps.\n */\n group: ReturnType<typeof createGroupTools>;\n\n /**\n * The current zero-indexed attempt number for this function execution.\n */\n attempt: number;\n\n /**\n * The maximum number of attempts allowed for this function.\n */\n maxAttempts?: number;\n};\n\n/**\n * Context object for handlers using trigger-based event typing with middleware overrides.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @template TOverrides - Properties to override from middleware\n * @internal\n */\nexport type ContextWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n TOverrides extends BasicDataUnknown = Record<never, never>,\n> = Omit<BaseContextWithTriggers<TStepTools, TTriggers>, keyof TOverrides> &\n TOverrides;\n\n/**\n * A handler type that computes its event type from a trigger array using ToReceivedEvent.\n * This provides proper typing for EventType instances and schema-bearing triggers.\n *\n * @template TStepTools - The step tools type for this context\n * @template TTriggers - Array of trigger definitions\n * @template TOverrides - Properties to override from middleware\n * @internal\n */\nexport type HandlerWithTriggers<\n TStepTools,\n TTriggers extends readonly any[],\n TOverrides extends BasicDataUnknown = Record<never, never>,\n> = (\n /**\n * The context argument provides access to all data and tooling available to\n * the function.\n */\n ctx: ContextWithTriggers<TStepTools, TTriggers, TOverrides>,\n) => unknown;\n\n/**\n * Type guard to check if an object has a `validate` method. The use case is for\n * safely validating an event payload that might have a `validate` method\n */\nexport function isValidatable<T>(\n value: T,\n): value is T & { validate: () => Promise<void> } {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n if (!(\"validate\" in value)) {\n return false;\n }\n return typeof value.validate === \"function\";\n}\n"],"mappings":";;;;;;AAqXA,SAAgB,cACd,OACgD;AAChD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAET,KAAI,EAAE,cAAc,OAClB,QAAO;AAET,QAAO,OAAO,MAAM,aAAa"}
@@ -1,6 +1,7 @@
1
1
  import { AsTuple } from "../../helpers/types.cjs";
2
2
  import { createGroupTools } from "../InngestGroupTools.cjs";
3
3
  import { EventType, EventTypeWithAnySchema } from "./triggers.cjs";
4
+ import { DeferFn } from "../../types.cjs";
4
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
6
 
6
7
  //#region src/components/triggers/typeHelpers.d.ts
@@ -181,6 +182,7 @@ type ReceivedEventTupleToUnion<T extends readonly any[]> = T[number];
181
182
  * @internal
182
183
  */
183
184
  type BaseContextWithTriggers<TStepTools, TTriggers extends readonly any[]> = {
185
+ defer: DeferFn;
184
186
  /**
185
187
  * The event data present in the payload.
186
188
  */
@@ -190,6 +192,15 @@ type BaseContextWithTriggers<TStepTools, TTriggers extends readonly any[]> = {
190
192
  * The run ID for the current function execution
191
193
  */
192
194
  runId: string;
195
+ /**
196
+ * The request ID for this individual outbound SDK invocation, if provided by
197
+ * the executor.
198
+ */
199
+ requestId?: string;
200
+ /**
201
+ * The stable job ID for this invocation, if provided by the executor.
202
+ */
203
+ jobId?: string;
193
204
  step: TStepTools;
194
205
  /**
195
206
  * Tools for grouping and coordinating steps.
@@ -1 +1 @@
1
- {"version":3,"file":"typeHelpers.d.cts","names":[],"sources":["../../../src/components/triggers/typeHelpers.ts"],"sourcesContent":[],"mappings":";;;;;;KAQK,gBAAA,GAAmB;AADsB,KAEzC,YAAA,GAAe,MADC,CAAA,MAAA,EAAG,GAAA,CAAA;AAAM,KAGzB,eAAA,GAFY,0BAAS;AAAA,KAGrB,aAAA,GADA,yBAAe;AAAA,KAEf,aAAA,GADa;EACb,IAAA,EAAA,MAAA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A,MAAA;QAnDlB;;;;SAKC,kBAAkB;;;;;;;;;;;;;;;;;;KAqBf,qFAGS,mBAAmB,wBACpC,KAAK,wBAAwB,YAAY,kBAAkB,cAC7D;;;;;;;;;;KAWU,qFAGS,mBAAmB;;;;;KAMjC,oBAAoB,YAAY,WAAW"}
@@ -1,6 +1,7 @@
1
1
  import { AsTuple } from "../../helpers/types.js";
2
2
  import { createGroupTools } from "../InngestGroupTools.js";
3
3
  import { EventType, EventTypeWithAnySchema } from "./triggers.js";
4
+ import { DeferFn } from "../../types.js";
4
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
6
 
6
7
  //#region src/components/triggers/typeHelpers.d.ts
@@ -181,6 +182,7 @@ type ReceivedEventTupleToUnion<T extends readonly any[]> = T[number];
181
182
  * @internal
182
183
  */
183
184
  type BaseContextWithTriggers<TStepTools, TTriggers extends readonly any[]> = {
185
+ defer: DeferFn;
184
186
  /**
185
187
  * The event data present in the payload.
186
188
  */
@@ -190,6 +192,15 @@ type BaseContextWithTriggers<TStepTools, TTriggers extends readonly any[]> = {
190
192
  * The run ID for the current function execution
191
193
  */
192
194
  runId: string;
195
+ /**
196
+ * The request ID for this individual outbound SDK invocation, if provided by
197
+ * the executor.
198
+ */
199
+ requestId?: string;
200
+ /**
201
+ * The stable job ID for this invocation, if provided by the executor.
202
+ */
203
+ jobId?: string;
193
204
  step: TStepTools;
194
205
  /**
195
206
  * Tools for grouping and coordinating steps.
@@ -1 +1 @@
1
- {"version":3,"file":"typeHelpers.d.ts","names":[],"sources":["../../../src/components/triggers/typeHelpers.ts"],"sourcesContent":[],"mappings":";;;;;;KAQK,gBAAA,GAAmB;AADsB,KAEzC,YAAA,GAAe,MADC,CAAA,MAAA,EAAG,GAAA,CAAA;AAAM,KAGzB,eAAA,GAFY,0BAAS;AAAA,KAGrB,aAAA,GADA,yBAAe;AAAA,KAEf,aAAA,GADa;EACb,IAAA,EAAA,MAAA;AAAa,CAAA;AAKyB;;;KAAtC,gBAOsC,CA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