inngest 4.7.0 → 4.9.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 (138) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/components/DeferredFunction.cjs +52 -0
  3. package/components/DeferredFunction.cjs.map +1 -1
  4. package/components/DeferredFunction.d.cts +35 -9
  5. package/components/DeferredFunction.d.cts.map +1 -1
  6. package/components/DeferredFunction.d.ts +35 -9
  7. package/components/DeferredFunction.d.ts.map +1 -1
  8. package/components/DeferredFunction.js +53 -1
  9. package/components/DeferredFunction.js.map +1 -1
  10. package/components/Inngest.cjs +24 -1
  11. package/components/Inngest.cjs.map +1 -1
  12. package/components/Inngest.d.cts +23 -3
  13. package/components/Inngest.d.cts.map +1 -1
  14. package/components/Inngest.d.ts +23 -3
  15. package/components/Inngest.d.ts.map +1 -1
  16. package/components/Inngest.js +24 -1
  17. package/components/Inngest.js.map +1 -1
  18. package/components/InngestCommHandler.d.cts +2 -2
  19. package/components/InngestCommHandler.d.ts +2 -2
  20. package/components/InngestFunction.d.cts +2 -2
  21. package/components/InngestFunction.d.ts +2 -2
  22. package/components/InngestGroupTools.cjs +7 -4
  23. package/components/InngestGroupTools.cjs.map +1 -1
  24. package/components/InngestGroupTools.d.cts +5 -24
  25. package/components/InngestGroupTools.d.cts.map +1 -1
  26. package/components/InngestGroupTools.d.ts +5 -24
  27. package/components/InngestGroupTools.d.ts.map +1 -1
  28. package/components/InngestGroupTools.js +7 -4
  29. package/components/InngestGroupTools.js.map +1 -1
  30. package/components/InngestMetadata.cjs +18 -4
  31. package/components/InngestMetadata.cjs.map +1 -1
  32. package/components/InngestMetadata.d.cts +2 -2
  33. package/components/InngestMetadata.d.cts.map +1 -1
  34. package/components/InngestMetadata.d.ts +2 -2
  35. package/components/InngestMetadata.d.ts.map +1 -1
  36. package/components/InngestMetadata.js +18 -5
  37. package/components/InngestMetadata.js.map +1 -1
  38. package/components/InngestScore.cjs +93 -0
  39. package/components/InngestScore.cjs.map +1 -0
  40. package/components/InngestScore.d.cts +89 -0
  41. package/components/InngestScore.d.cts.map +1 -0
  42. package/components/InngestScore.d.ts +89 -0
  43. package/components/InngestScore.d.ts.map +1 -0
  44. package/components/InngestScore.js +88 -0
  45. package/components/InngestScore.js.map +1 -0
  46. package/components/InngestStepTools.cjs +9 -0
  47. package/components/InngestStepTools.cjs.map +1 -1
  48. package/components/InngestStepTools.d.cts +5 -3
  49. package/components/InngestStepTools.d.cts.map +1 -1
  50. package/components/InngestStepTools.d.ts +5 -3
  51. package/components/InngestStepTools.d.ts.map +1 -1
  52. package/components/InngestStepTools.js +9 -0
  53. package/components/InngestStepTools.js.map +1 -1
  54. package/components/ScoreFunction.cjs +37 -0
  55. package/components/ScoreFunction.cjs.map +1 -0
  56. package/components/ScoreFunction.d.cts +24 -0
  57. package/components/ScoreFunction.d.cts.map +1 -0
  58. package/components/ScoreFunction.d.ts +24 -0
  59. package/components/ScoreFunction.d.ts.map +1 -0
  60. package/components/ScoreFunction.js +37 -0
  61. package/components/ScoreFunction.js.map +1 -0
  62. package/components/execution/InngestExecution.d.cts +2 -2
  63. package/components/execution/InngestExecution.d.ts +2 -2
  64. package/components/execution/als.cjs.map +1 -1
  65. package/components/execution/als.d.cts +1 -0
  66. package/components/execution/als.d.cts.map +1 -1
  67. package/components/execution/als.d.ts +1 -0
  68. package/components/execution/als.d.ts.map +1 -1
  69. package/components/execution/als.js.map +1 -1
  70. package/components/execution/engine.cjs +12 -10
  71. package/components/execution/engine.cjs.map +1 -1
  72. package/components/execution/engine.d.cts +1 -1
  73. package/components/execution/engine.d.cts.map +1 -1
  74. package/components/execution/engine.d.ts +1 -1
  75. package/components/execution/engine.d.ts.map +1 -1
  76. package/components/execution/engine.js +13 -11
  77. package/components/execution/engine.js.map +1 -1
  78. package/components/execution/otel/aiExtractor.cjs +90 -125
  79. package/components/execution/otel/aiExtractor.cjs.map +1 -1
  80. package/components/execution/otel/aiExtractor.d.cts +48 -5
  81. package/components/execution/otel/aiExtractor.d.cts.map +1 -1
  82. package/components/execution/otel/aiExtractor.d.ts +48 -5
  83. package/components/execution/otel/aiExtractor.d.ts.map +1 -1
  84. package/components/execution/otel/aiExtractor.js +90 -125
  85. package/components/execution/otel/aiExtractor.js.map +1 -1
  86. package/components/execution/otel/middleware.cjs +3 -1
  87. package/components/execution/otel/middleware.cjs.map +1 -1
  88. package/components/execution/otel/middleware.d.cts +19 -12
  89. package/components/execution/otel/middleware.d.cts.map +1 -1
  90. package/components/execution/otel/middleware.d.ts +19 -12
  91. package/components/execution/otel/middleware.d.ts.map +1 -1
  92. package/components/execution/otel/middleware.js +4 -2
  93. package/components/execution/otel/middleware.js.map +1 -1
  94. package/components/execution/otel/util.cjs +9 -1
  95. package/components/execution/otel/util.cjs.map +1 -1
  96. package/components/execution/otel/util.js +9 -2
  97. package/components/execution/otel/util.js.map +1 -1
  98. package/components/realtime/types.d.cts +3 -3
  99. package/components/realtime/types.d.cts.map +1 -1
  100. package/components/realtime/types.d.ts +3 -3
  101. package/components/realtime/types.d.ts.map +1 -1
  102. package/experimental.cjs +5 -1
  103. package/experimental.d.cts +4 -1
  104. package/experimental.d.ts +4 -1
  105. package/experimental.js +3 -1
  106. package/helpers/consts.cjs +7 -0
  107. package/helpers/consts.cjs.map +1 -1
  108. package/helpers/consts.d.cts.map +1 -1
  109. package/helpers/consts.d.ts.map +1 -1
  110. package/helpers/consts.js +7 -1
  111. package/helpers/consts.js.map +1 -1
  112. package/helpers/errors.cjs +16 -0
  113. package/helpers/errors.cjs.map +1 -1
  114. package/helpers/errors.d.cts +12 -1
  115. package/helpers/errors.d.cts.map +1 -1
  116. package/helpers/errors.d.ts +12 -1
  117. package/helpers/errors.d.ts.map +1 -1
  118. package/helpers/errors.js +16 -1
  119. package/helpers/errors.js.map +1 -1
  120. package/helpers/types.cjs +4 -0
  121. package/helpers/types.cjs.map +1 -1
  122. package/helpers/types.js +4 -1
  123. package/helpers/types.js.map +1 -1
  124. package/index.d.cts +2 -2
  125. package/index.d.ts +2 -2
  126. package/package.json +1 -1
  127. package/types.cjs.map +1 -1
  128. package/types.d.cts +30 -9
  129. package/types.d.cts.map +1 -1
  130. package/types.d.ts +30 -9
  131. package/types.d.ts.map +1 -1
  132. package/types.js.map +1 -1
  133. package/version.cjs +1 -1
  134. package/version.cjs.map +1 -1
  135. package/version.d.cts +1 -1
  136. package/version.d.ts +1 -1
  137. package/version.js +1 -1
  138. package/version.js.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import { Simplify } from "../../helpers/types.cjs";
2
- import { FoundStep } from "../InngestStepTools.cjs";
3
2
  import { MetadataUpdate } from "../InngestMetadata.cjs";
3
+ import { FoundStep } from "../InngestStepTools.cjs";
4
4
  import { BasicFoundStep, InngestExecutionFactory, MemoizedOp } from "./InngestExecution.cjs";
5
5
  import { OutgoingOp } from "../../types.cjs";
6
6
  import { StepError } from "../StepError.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.cts","names":[],"sources":["../../../src/components/execution/engine.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAoIa,uBAAuB;;;;UAgzFnB,WAAA;;YACU,cAAc;;;IAjzF5B,KAAA,EAAA,OAAA;EAgzFI,CAAA;EAAW,mBAAA,EAAA;IACD,IAAA,EAAA,OAAA;;kBAIjB,EAAA;IACM,IAAA,EADN,UACM;IAAc,UAAA,EAAd,cAAc,EAAA;IAOzB,eAAU,EAAA,MAAA;EAAA,CAAA;iCACD,EAAA,CAAA,CAAA;yCAA+B,EAAA,CAAA,CAAA;;KADxC,UAAA,GAC0D,QAAnC,MAAd,WAAc,GAAA,QAAA,CAAA;EACpB,IAAA,EADqC,CACrC;AAAW,CAAA,GADgC,WAChC,CAD4C,CAC5C,CAAA,CAAA,EA+BnB,CAAA,MA/BQ,WA+BS,CAAA;AAAc,UAAd,cAAA,CAAc;;;;;;eAoBlB,CAAA,EAdK,QAcL,CAdc,IAcd,CAdmB,UAcnB,EAAA,IAAA,CA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;;;;;WAoDD,EA5GZ,MA4GY,CAAA,MAAA,EA5GG,UA4GH,CAAA;;;AACxB;AAgBkC;;;aA6BjC,EAlJa,MAkJb,CAAA,MAAA,EAAA,OAAA,CAAA;;;;;gBAME,EAAA,MAAA;EAAyB;AAsC7B;;;OAnFiC,EA/FxB,GA+FwB,CAAA,MAAA,EA/FZ,SA+FY,CAAA;;;;;;;;;;;QAlFzB,eAAe;;;;wBAKC;;;;;;;;;;;;;;;0BAkBE;;;;;;;;;;;;;;;8BAgBI;;;;;;;;;;;;;;;;;;;;;2BAwBH;;;;;;WAOhB;;;;aAKE,YAAY,MAAM;;;;;UAiBrB,yBAAA;;;;;;;;;;;;;;;iBA2BD,sBAAA;;;;;;mBAMU;YACP,YAAY;IACpB;;;;cAsCS;eAnFO,eAAa"}
@@ -1,6 +1,6 @@
1
1
  import { Simplify } from "../../helpers/types.js";
2
- import { FoundStep } from "../InngestStepTools.js";
3
2
  import { MetadataUpdate } from "../InngestMetadata.js";
3
+ import { FoundStep } from "../InngestStepTools.js";
4
4
  import { BasicFoundStep, InngestExecutionFactory, MemoizedOp } from "./InngestExecution.js";
5
5
  import { OutgoingOp } from "../../types.js";
6
6
  import { StepError } from "../StepError.js";
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","names":[],"sources":["../../../src/components/execution/engine.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;cAoIa,uBAAuB;;;;UAgzFnB,WAAA;;YACU,cAAc;;;IAjzF5B,KAAA,EAAA,OAAA;EAgzFI,CAAA;EAAW,mBAAA,EAAA;IACD,IAAA,EAAA,OAAA;;kBAIjB,EAAA;IACM,IAAA,EADN,UACM;IAAc,UAAA,EAAd,cAAc,EAAA;IAOzB,eAAU,EAAA,MAAA;EAAA,CAAA;iCACD,EAAA,CAAA,CAAA;yCAA+B,EAAA,CAAA,CAAA;;KADxC,UAAA,GAC0D,QAAnC,MAAd,WAAc,GAAA,QAAA,CAAA;EACpB,IAAA,EADqC,CACrC;A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AAA,EA+BnB,CAAA,MA/BQ,WA+BS,CAAA;AAAc,UAAd,cAAA,CAAc;;;;;;eAoBlB,CAAA,EAdK,QAcL,CAdc,IAcd,CAdmB,UAcnB,EAAA,IAAA,CAAA,CAAA;;;;;;;yBAwDa,CAAA,EA9DE,UA8DF;;;;;WAoDD,EA5GZ,MA4GY,CAAA,MAAA,EA5GG,UA4GH,CAAA;;;AACxB;AAgBkC;;;aA6BjC,EAlJa,MAkJb,CAAA,MAAA,EAAA,OAAA,CAAA;;;;;gBAME,EAAA,MAAA;EAAyB;AAsC7B;;;OAnFiC,EA/FxB,GA+FwB,CAAA,MAAA,EA/FZ,SA+FY,CAAA;;;;;;;;;;;QAlFzB,eAAe;;;;wBAKC;;;;;;;;;;;;;;;0BAkBE;;;;;;;;;;;;;;;8BAgBI;;;;;;;;;;;;;;;;;;;;;2BAwBH;;;;;;WAOhB;;;;aAKE,YAAY,MAAM;;;;;UAiBrB,yBAAA;;;;;;;;;;;;;;;iBA2BD,sBAAA;;;;;;mBAMU;YACP,YAAY;IACpB;;;;cAsCS;eAnFO,eAAa"}
@@ -1,5 +1,5 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.js";
2
- import { ExecutionVersion, defaultMaxRetries, headerKeys } from "../../helpers/consts.js";
2
+ import { ExecutionVersion, defaultMaxRetries, deferExperimentKey, headerKeys } from "../../helpers/consts.js";
3
3
  import { version } from "../../version.js";
4
4
  import { NonRetriableError } from "../NonRetriableError.js";
5
5
  import { ErrCode, deserializeError, serializeError } from "../../helpers/errors.js";
@@ -192,7 +192,7 @@ var InngestExecutionEngine = class extends InngestExecution {
192
192
  traceparent: this.options.headers[headerKeys.TraceParent],
193
193
  tracestate: this.options.headers[headerKeys.TraceState]
194
194
  });
195
- metadataSpanProcessor.declareStartingSpan({
195
+ if (this.options.client.aiMetadataEnabled) metadataSpanProcessor.declareStartingSpan({
196
196
  span,
197
197
  traceparent: this.options.headers[headerKeys.TraceParent],
198
198
  onAIMetadata: (aiMetadata) => {
@@ -910,7 +910,8 @@ var InngestExecutionEngine = class extends InngestExecution {
910
910
  if (store?.execution) store.execution.executingStep = {
911
911
  id,
912
912
  name: displayName,
913
- hashedId
913
+ hashedId,
914
+ userlandId: userland.id
914
915
  };
915
916
  this.devDebug(`executing step "${id}"`);
916
917
  if (this.rootSpanId && this.options.checkpointingConfig) clientProcessorMap.get(this.options.client)?.declareStepExecution(this.rootSpanId, userland.id ?? "", userland.index ?? 0, hashedId, this.options.data?.attempt ?? 0);
@@ -1043,8 +1044,10 @@ var InngestExecutionEngine = class extends InngestExecution {
1043
1044
  })), triggers);
1044
1045
  }
1045
1046
  /**
1046
- * Validate the deferred event's data against the defer function's own
1047
- * schema (set via `createDefer`'s `opts.schema`).
1047
+ * Validate the deferred event's data against the defer function's own schema
1048
+ * (set via `createDefer`'s `opts.schema`). Our internal metadata
1049
+ * (`event.data._inngest`) was already stripped, so that won't affect
1050
+ * validation.
1048
1051
  */
1049
1052
  async validateDeferEventSchema() {
1050
1053
  const fn = this.options.fn;
@@ -1187,10 +1190,6 @@ var InngestExecutionEngine = class extends InngestExecution {
1187
1190
  group: createGroupTools({ experimentStepRun }),
1188
1191
  defer
1189
1192
  };
1190
- if (this.options.handlerKind === "defer") {
1191
- delete fnArg.event.data._inngest;
1192
- for (const event of fnArg.events) delete event.data._inngest;
1193
- }
1194
1193
  /**
1195
1194
  * Handle use of the `onFailure` option by deserializing the error.
1196
1195
  */
@@ -1484,7 +1483,7 @@ var InngestExecutionEngine = class extends InngestExecution {
1484
1483
  * schema mismatch) are logged and the call is silently skipped.
1485
1484
  */
1486
1485
  buildDefer(stepHandler) {
1487
- return (idOrOptions, { function: deferFn, data }) => {
1486
+ return (idOrOptions, { function: deferFn, data, experiment }) => {
1488
1487
  const log = this.options.client[internalLoggerSymbol];
1489
1488
  const runId = this.fnArg.runId;
1490
1489
  try {
@@ -1511,7 +1510,10 @@ var InngestExecutionEngine = class extends InngestExecution {
1511
1510
  input = result.value ?? data;
1512
1511
  }
1513
1512
  stepHandler({
1514
- args: [idOrOptions, input],
1513
+ args: [idOrOptions, experiment && isRecord(input) ? {
1514
+ ...input,
1515
+ [deferExperimentKey]: experiment
1516
+ } : input],
1515
1517
  matchOp: (stepOptions, inputArg) => ({
1516
1518
  id: stepOptions.id,
1517
1519
  mode: StepMode.Sync,