@dudousxd/nestjs-durable-core 0.49.2 → 0.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -57,17 +57,21 @@ __export(index_exports, {
57
57
  attributeOperand: () => attributeOperand,
58
58
  bindWorkflowClass: () => bindWorkflowClass,
59
59
  breakpointToken: () => breakpointToken,
60
+ classifyWaiterToken: () => classifyWaiterToken,
60
61
  collectMetrics: () => collectMetrics,
61
62
  createStepLogger: () => createStepLogger,
62
63
  currentWorkflowCtx: () => currentWorkflowCtx,
63
64
  eventMatchOf: () => eventMatchOf,
64
65
  eventMatches: () => eventMatches,
66
+ eventNameOf: () => eventNameOf,
65
67
  eventPrefix: () => eventPrefix,
66
68
  eventToken: () => eventToken,
69
+ indexWaitersByRun: () => indexWaitersByRun,
67
70
  matchesAttributes: () => matchesAttributes,
68
71
  normalizeAttributeRows: () => normalizeAttributeRows,
69
72
  parseDuration: () => parseDuration,
70
73
  prevCronFireMs: () => prevCronFireMs,
74
+ resolveRunWaiting: () => resolveRunWaiting,
71
75
  runInWorkflowCtx: () => runInWorkflowCtx,
72
76
  runSchedules: () => runSchedules,
73
77
  runStepHandler: () => runStepHandler,
@@ -861,6 +865,14 @@ function eventToken(name, match, runId, seq) {
861
865
  return `${eventPrefix(name)}${enc(JSON.stringify(match ?? {}))}:${runId}#${seq}`;
862
866
  }
863
867
  __name(eventToken, "eventToken");
868
+ function eventNameOf(token) {
869
+ try {
870
+ return dec(token.split(":")[1] ?? "");
871
+ } catch {
872
+ return token;
873
+ }
874
+ }
875
+ __name(eventNameOf, "eventNameOf");
864
876
  function eventMatchOf(token) {
865
877
  try {
866
878
  return JSON.parse(dec(token.split(":")[2] ?? ""));
@@ -4376,6 +4388,42 @@ var TERMINAL_RUN_STATUSES = [
4376
4388
  "dead"
4377
4389
  ];
4378
4390
 
4391
+ // src/run-waiting.ts
4392
+ var WEBHOOK_PREFIX = "wh:";
4393
+ var CHILD_PREFIX = "child:";
4394
+ var EVENT_PREFIX = "event:";
4395
+ function classifyWaiterToken(token) {
4396
+ if (token.startsWith(WEBHOOK_PREFIX)) return {
4397
+ on: "webhook",
4398
+ name: token
4399
+ };
4400
+ if (token.startsWith(CHILD_PREFIX)) return {
4401
+ on: "child",
4402
+ name: token.slice(CHILD_PREFIX.length)
4403
+ };
4404
+ if (token.startsWith(EVENT_PREFIX)) return {
4405
+ on: "signal",
4406
+ name: eventNameOf(token)
4407
+ };
4408
+ return {
4409
+ on: "signal",
4410
+ name: token
4411
+ };
4412
+ }
4413
+ __name(classifyWaiterToken, "classifyWaiterToken");
4414
+ function resolveRunWaiting(run, waiterByRun) {
4415
+ if (run.status !== "suspended") return void 0;
4416
+ const waiter = waiterByRun.get(run.id);
4417
+ return waiter ? classifyWaiterToken(waiter.token) : void 0;
4418
+ }
4419
+ __name(resolveRunWaiting, "resolveRunWaiting");
4420
+ function indexWaitersByRun(waiters) {
4421
+ const byRun = /* @__PURE__ */ new Map();
4422
+ for (const w of waiters) if (!byRun.has(w.runId)) byRun.set(w.runId, w);
4423
+ return byRun;
4424
+ }
4425
+ __name(indexWaitersByRun, "indexWaitersByRun");
4426
+
4379
4427
  // src/codec-state-store.ts
4380
4428
  var CodecStateStore = class {
4381
4429
  static {
@@ -5131,17 +5179,21 @@ var InMemoryTransport = class {
5131
5179
  attributeOperand,
5132
5180
  bindWorkflowClass,
5133
5181
  breakpointToken,
5182
+ classifyWaiterToken,
5134
5183
  collectMetrics,
5135
5184
  createStepLogger,
5136
5185
  currentWorkflowCtx,
5137
5186
  eventMatchOf,
5138
5187
  eventMatches,
5188
+ eventNameOf,
5139
5189
  eventPrefix,
5140
5190
  eventToken,
5191
+ indexWaitersByRun,
5141
5192
  matchesAttributes,
5142
5193
  normalizeAttributeRows,
5143
5194
  parseDuration,
5144
5195
  prevCronFireMs,
5196
+ resolveRunWaiting,
5145
5197
  runInWorkflowCtx,
5146
5198
  runSchedules,
5147
5199
  runStepHandler,