@dudousxd/nestjs-durable 0.27.0 → 0.29.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.
package/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ __export(index_exports, {
40
40
  InAppWorkerBootstrap: () => InAppWorkerBootstrap,
41
41
  ON_EVENT_METADATA: () => ON_EVENT_METADATA,
42
42
  On: () => On,
43
+ OnDurableEvent: () => OnDurableEvent,
43
44
  OnEvent: () => OnEvent,
44
45
  ProxyRunGateway: () => ProxyRunGateway,
45
46
  RUN_GATEWAY: () => RUN_GATEWAY,
@@ -155,7 +156,7 @@ function isDeadLetterHandler(method) {
155
156
  }
156
157
  __name(isDeadLetterHandler, "isDeadLetterHandler");
157
158
  var ON_EVENT_METADATA = Symbol("nestjs-durable:on-event");
158
- function OnEvent(...events) {
159
+ function OnDurableEvent(...events) {
159
160
  return (target) => {
160
161
  const existing = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
161
162
  Reflect.defineMetadata(ON_EVENT_METADATA, [
@@ -164,7 +165,8 @@ function OnEvent(...events) {
164
165
  ], target);
165
166
  };
166
167
  }
167
- __name(OnEvent, "OnEvent");
168
+ __name(OnDurableEvent, "OnDurableEvent");
169
+ var OnEvent = OnDurableEvent;
168
170
  function getOnEvents(meta, target) {
169
171
  const fromDecorator = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
170
172
  return [
@@ -493,6 +495,9 @@ function unavailableRunGateway() {
493
495
  listRuns(_query) {
494
496
  return tenantGatewayUnavailable("listRuns");
495
497
  },
498
+ workerHealth() {
499
+ return tenantGatewayUnavailable("workerHealth");
500
+ },
496
501
  cancel(_runId) {
497
502
  return tenantGatewayUnavailable("cancel");
498
503
  },
@@ -890,6 +895,12 @@ var ProxyRunGateway = class {
890
895
  query
891
896
  });
892
897
  }
898
+ /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
899
+ workerHealth() {
900
+ return this.request({
901
+ kind: "workerHealth"
902
+ });
903
+ }
893
904
  cancel(runId, opts) {
894
905
  return this.request(opts === void 0 ? {
895
906
  kind: "cancel",
@@ -1086,6 +1097,17 @@ var RunRequestResponder = class {
1086
1097
  }
1087
1098
  };
1088
1099
  }
1100
+ if (body.kind === "workerHealth") {
1101
+ const all = await this.gateway.workerHealth();
1102
+ const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
1103
+ return {
1104
+ requestId: msg.requestId,
1105
+ result: {
1106
+ ok: true,
1107
+ data
1108
+ }
1109
+ };
1110
+ }
1089
1111
  const detail = await this.gateway.getRunDetail(body.runId);
1090
1112
  if (detail && detail.run.namespace !== msg.tenant) {
1091
1113
  return {
@@ -1189,6 +1211,11 @@ var StoreRunGateway = class {
1189
1211
  listRuns(query) {
1190
1212
  return this.store.listRuns(query);
1191
1213
  }
1214
+ /** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
1215
+ * `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
1216
+ workerHealth() {
1217
+ return this.engine.workerHealth();
1218
+ }
1192
1219
  cancel(runId, opts) {
1193
1220
  return this.engine.cancel(runId, opts);
1194
1221
  }
@@ -1488,6 +1515,10 @@ var WorkflowRegistrar = class {
1488
1515
  executor: new import_nestjs_durable_core10.RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
1489
1516
  } : {}
1490
1517
  });
1518
+ (0, import_nestjs_durable_core10.bindWorkflowClass)(workflowCtor, {
1519
+ start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
1520
+ waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
1521
+ });
1491
1522
  const inline = this.findDeadLetterHandler(workflow);
1492
1523
  if (inline && meta.deadLetterWorkflow) {
1493
1524
  throw new Error(`@Workflow ${meta.name} declares both an inline @DeadLetter() method and a deadLetterWorkflow option. Use one: the inline handler, or the reference.`);
@@ -1604,7 +1635,7 @@ var WorkflowService = class {
1604
1635
  }
1605
1636
  /**
1606
1637
  * Publish a named event. Resumes runs waiting on it via `ctx.waitForEvent(name, { match })` and
1607
- * starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnEvent` (the
1638
+ * starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
1608
1639
  * payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
1609
1640
  * touched (resumed + started).
1610
1641
  */
@@ -1939,6 +1970,7 @@ DurableModule = _ts_decorate12([
1939
1970
  InAppWorkerBootstrap,
1940
1971
  ON_EVENT_METADATA,
1941
1972
  On,
1973
+ OnDurableEvent,
1942
1974
  OnEvent,
1943
1975
  ProxyRunGateway,
1944
1976
  RUN_GATEWAY,