@pattern-stack/codegen 0.14.0 → 0.14.1

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 (30) hide show
  1. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.d.ts +1 -1
  2. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +2 -2
  3. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
  4. package/dist/runtime/subsystems/bridge/bridge.module.js +172 -159
  5. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  6. package/dist/runtime/subsystems/bridge/index.js +154 -141
  7. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  8. package/dist/runtime/subsystems/index.js +161 -148
  9. package/dist/runtime/subsystems/index.js.map +1 -1
  10. package/dist/runtime/subsystems/jobs/index.js +128 -115
  11. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  12. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +128 -6
  13. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  14. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +17 -0
  15. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
  16. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +25 -2
  17. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
  18. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +26 -1
  19. package/dist/runtime/subsystems/jobs/job-worker.module.js +150 -137
  20. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  21. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +133 -124
  22. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  23. package/dist/src/cli/index.js +804 -454
  24. package/dist/src/cli/index.js.map +1 -1
  25. package/package.json +1 -1
  26. package/runtime/subsystems/bridge/bridge-delivery.memory-backend.ts +8 -1
  27. package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +8 -3
  28. package/runtime/subsystems/jobs/job-run-service.memory-backend.ts +4 -1
  29. package/runtime/subsystems/jobs/job-step-service.memory-backend.ts +7 -2
  30. package/runtime/subsystems/jobs/job-worker.module.ts +13 -1
@@ -839,8 +839,9 @@ DrizzleJobStepService = __decorateClass([
839
839
  ], DrizzleJobStepService);
840
840
 
841
841
  // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
842
- import { randomUUID as randomUUID2 } from "crypto";
843
- import { Inject as Inject4, Injectable as Injectable4, Logger as Logger2, Optional } from "@nestjs/common";
842
+ import { randomUUID as randomUUID3 } from "crypto";
843
+ import { Inject as Inject5, Injectable as Injectable5, Logger as Logger2, Optional } from "@nestjs/common";
844
+ import { ModuleRef } from "@nestjs/core";
844
845
 
845
846
  // runtime/subsystems/jobs/job-handler.base.ts
846
847
  var JOB_HANDLER_REGISTRY = /* @__PURE__ */ new Map();
@@ -857,6 +858,124 @@ var HandlerRegistry;
857
858
  HandlerRegistry2.get = get;
858
859
  })(HandlerRegistry || (HandlerRegistry = {}));
859
860
 
861
+ // runtime/subsystems/jobs/memory-job-store.ts
862
+ var MemoryJobStore = class {
863
+ /** Runs keyed by `id` (single source of truth for status/scope/lineage). */
864
+ runs = /* @__PURE__ */ new Map();
865
+ /** Steps keyed by `job_run_id`; array order matches insertion order. */
866
+ steps = /* @__PURE__ */ new Map();
867
+ /** Job definitions keyed by `type` — memory mirror of the `job` table. */
868
+ jobs = /* @__PURE__ */ new Map();
869
+ /** Reset everything. Tests call this in `beforeEach`. */
870
+ clear() {
871
+ this.runs.clear();
872
+ this.steps.clear();
873
+ this.jobs.clear();
874
+ }
875
+ };
876
+
877
+ // runtime/subsystems/jobs/job-step-service.memory-backend.ts
878
+ import { randomUUID as randomUUID2 } from "crypto";
879
+ import { Inject as Inject4, Injectable as Injectable4 } from "@nestjs/common";
880
+ var MemoryJobStepService = class {
881
+ // ADR-037 (package-mode DI): explicit `@Inject(MemoryJobStore)` — the
882
+ // published bundle carries no `design:paramtypes`, so a by-type inject
883
+ // would resolve to `undefined` in package mode.
884
+ constructor(store) {
885
+ this.store = store;
886
+ }
887
+ store;
888
+ async findStep(runId, stepId) {
889
+ const rows = this.store.steps.get(runId);
890
+ if (!rows) return null;
891
+ const match = rows.find(
892
+ (r) => r.stepId === stepId && r.status === "completed"
893
+ );
894
+ return match ?? null;
895
+ }
896
+ async recordStep(input) {
897
+ const rows = this.getOrCreateRows(input.jobRunId);
898
+ const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
899
+ const normalisedInput = input.input ?? null;
900
+ const normalisedOutput = input.output ?? null;
901
+ if (existingIdx >= 0) {
902
+ const prev = rows[existingIdx];
903
+ const next = {
904
+ ...prev,
905
+ status: input.status,
906
+ input: normalisedInput ?? prev.input,
907
+ output: normalisedOutput ?? prev.output,
908
+ error: input.error ?? prev.error,
909
+ attempts: input.attempts ?? prev.attempts,
910
+ startedAt: input.startedAt ?? prev.startedAt,
911
+ finishedAt: input.finishedAt ?? prev.finishedAt
912
+ };
913
+ rows[existingIdx] = next;
914
+ return next;
915
+ }
916
+ const seq = input.seq ?? this.nextSeq(rows);
917
+ const row = {
918
+ id: randomUUID2(),
919
+ jobRunId: input.jobRunId,
920
+ stepId: input.stepId,
921
+ kind: input.kind,
922
+ seq,
923
+ status: input.status,
924
+ input: normalisedInput,
925
+ output: normalisedOutput,
926
+ error: input.error ?? null,
927
+ attempts: input.attempts ?? 0,
928
+ startedAt: input.startedAt ?? null,
929
+ finishedAt: input.finishedAt ?? null
930
+ };
931
+ rows.push(row);
932
+ return row;
933
+ }
934
+ /**
935
+ * Replay helper — wipe every step row for a run. Mirrors the `scratch`
936
+ * replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
937
+ */
938
+ clearStepsForRun(runId) {
939
+ this.store.steps.delete(runId);
940
+ }
941
+ /**
942
+ * Remove every non-`completed` row for the run. Memoized (`completed`)
943
+ * rows are preserved — this is the `last_checkpoint` / `last_step`
944
+ * semantics the Drizzle backend implements via
945
+ * `DELETE … WHERE status != 'completed'`. Both replay modes route here
946
+ * (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
947
+ */
948
+ clearIncompleteSteps(runId) {
949
+ const rows = this.store.steps.get(runId);
950
+ if (!rows) return;
951
+ const kept = rows.filter((r) => r.status === "completed");
952
+ if (kept.length === 0) {
953
+ this.store.steps.delete(runId);
954
+ } else {
955
+ this.store.steps.set(runId, kept);
956
+ }
957
+ }
958
+ getOrCreateRows(runId) {
959
+ let rows = this.store.steps.get(runId);
960
+ if (!rows) {
961
+ rows = [];
962
+ this.store.steps.set(runId, rows);
963
+ }
964
+ return rows;
965
+ }
966
+ nextSeq(rows) {
967
+ let max = 0;
968
+ for (const r of rows) {
969
+ if (r.seq > max) max = r.seq;
970
+ }
971
+ return max + 1;
972
+ }
973
+ };
974
+ MemoryJobStepService = __decorateClass([
975
+ Injectable4(),
976
+ __decorateParam(0, Inject4(MemoryJobStore))
977
+ ], MemoryJobStepService);
978
+
860
979
  // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
861
980
  var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
862
981
  var TERMINAL_STATUSES2 = [
@@ -1028,7 +1147,7 @@ var MemoryJobOrchestrator = class {
1028
1147
  }
1029
1148
  }
1030
1149
  }
1031
- const newId = randomUUID2();
1150
+ const newId = randomUUID3();
1032
1151
  let rootRunId = newId;
1033
1152
  if (opts.parentRunId) {
1034
1153
  const parent = this.store.runs.get(opts.parentRunId);
@@ -1426,9 +1545,12 @@ var MemoryJobOrchestrator = class {
1426
1545
  }
1427
1546
  };
1428
1547
  MemoryJobOrchestrator = __decorateClass([
1429
- Injectable4(),
1430
- __decorateParam(2, Inject4(JOBS_MULTI_TENANT)),
1431
- __decorateParam(3, Optional())
1548
+ Injectable5(),
1549
+ __decorateParam(0, Inject5(MemoryJobStore)),
1550
+ __decorateParam(1, Inject5(MemoryJobStepService)),
1551
+ __decorateParam(2, Inject5(JOBS_MULTI_TENANT)),
1552
+ __decorateParam(3, Optional()),
1553
+ __decorateParam(3, Inject5(ModuleRef))
1432
1554
  ], MemoryJobOrchestrator);
1433
1555
  function classifyError(err, policy, currentAttempts) {
1434
1556
  if (!policy) return "fail";
@@ -1462,7 +1584,7 @@ function serialiseError(err, attempt, retryable) {
1462
1584
  }
1463
1585
 
1464
1586
  // runtime/subsystems/jobs/job-run-service.memory-backend.ts
1465
- import { Inject as Inject5, Injectable as Injectable5 } from "@nestjs/common";
1587
+ import { Inject as Inject6, Injectable as Injectable6 } from "@nestjs/common";
1466
1588
  var NON_TERMINAL_STATUSES2 = [
1467
1589
  "pending",
1468
1590
  "running",
@@ -1629,9 +1751,10 @@ var MemoryJobRunService = class {
1629
1751
  }
1630
1752
  };
1631
1753
  MemoryJobRunService = __decorateClass([
1632
- Injectable5(),
1633
- __decorateParam(1, Inject5(JOB_ORCHESTRATOR)),
1634
- __decorateParam(2, Inject5(JOBS_MULTI_TENANT))
1754
+ Injectable6(),
1755
+ __decorateParam(0, Inject6(MemoryJobStore)),
1756
+ __decorateParam(1, Inject6(JOB_ORCHESTRATOR)),
1757
+ __decorateParam(2, Inject6(JOBS_MULTI_TENANT))
1635
1758
  ], MemoryJobRunService);
1636
1759
  function compareBy(a, b, order) {
1637
1760
  switch (order) {
@@ -1647,120 +1770,6 @@ function compareBy(a, b, order) {
1647
1770
  }
1648
1771
  }
1649
1772
 
1650
- // runtime/subsystems/jobs/job-step-service.memory-backend.ts
1651
- import { randomUUID as randomUUID3 } from "crypto";
1652
- import { Injectable as Injectable6 } from "@nestjs/common";
1653
- var MemoryJobStepService = class {
1654
- constructor(store) {
1655
- this.store = store;
1656
- }
1657
- store;
1658
- async findStep(runId, stepId) {
1659
- const rows = this.store.steps.get(runId);
1660
- if (!rows) return null;
1661
- const match = rows.find(
1662
- (r) => r.stepId === stepId && r.status === "completed"
1663
- );
1664
- return match ?? null;
1665
- }
1666
- async recordStep(input) {
1667
- const rows = this.getOrCreateRows(input.jobRunId);
1668
- const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
1669
- const normalisedInput = input.input ?? null;
1670
- const normalisedOutput = input.output ?? null;
1671
- if (existingIdx >= 0) {
1672
- const prev = rows[existingIdx];
1673
- const next = {
1674
- ...prev,
1675
- status: input.status,
1676
- input: normalisedInput ?? prev.input,
1677
- output: normalisedOutput ?? prev.output,
1678
- error: input.error ?? prev.error,
1679
- attempts: input.attempts ?? prev.attempts,
1680
- startedAt: input.startedAt ?? prev.startedAt,
1681
- finishedAt: input.finishedAt ?? prev.finishedAt
1682
- };
1683
- rows[existingIdx] = next;
1684
- return next;
1685
- }
1686
- const seq = input.seq ?? this.nextSeq(rows);
1687
- const row = {
1688
- id: randomUUID3(),
1689
- jobRunId: input.jobRunId,
1690
- stepId: input.stepId,
1691
- kind: input.kind,
1692
- seq,
1693
- status: input.status,
1694
- input: normalisedInput,
1695
- output: normalisedOutput,
1696
- error: input.error ?? null,
1697
- attempts: input.attempts ?? 0,
1698
- startedAt: input.startedAt ?? null,
1699
- finishedAt: input.finishedAt ?? null
1700
- };
1701
- rows.push(row);
1702
- return row;
1703
- }
1704
- /**
1705
- * Replay helper — wipe every step row for a run. Mirrors the `scratch`
1706
- * replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
1707
- */
1708
- clearStepsForRun(runId) {
1709
- this.store.steps.delete(runId);
1710
- }
1711
- /**
1712
- * Remove every non-`completed` row for the run. Memoized (`completed`)
1713
- * rows are preserved — this is the `last_checkpoint` / `last_step`
1714
- * semantics the Drizzle backend implements via
1715
- * `DELETE … WHERE status != 'completed'`. Both replay modes route here
1716
- * (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
1717
- */
1718
- clearIncompleteSteps(runId) {
1719
- const rows = this.store.steps.get(runId);
1720
- if (!rows) return;
1721
- const kept = rows.filter((r) => r.status === "completed");
1722
- if (kept.length === 0) {
1723
- this.store.steps.delete(runId);
1724
- } else {
1725
- this.store.steps.set(runId, kept);
1726
- }
1727
- }
1728
- getOrCreateRows(runId) {
1729
- let rows = this.store.steps.get(runId);
1730
- if (!rows) {
1731
- rows = [];
1732
- this.store.steps.set(runId, rows);
1733
- }
1734
- return rows;
1735
- }
1736
- nextSeq(rows) {
1737
- let max = 0;
1738
- for (const r of rows) {
1739
- if (r.seq > max) max = r.seq;
1740
- }
1741
- return max + 1;
1742
- }
1743
- };
1744
- MemoryJobStepService = __decorateClass([
1745
- Injectable6()
1746
- ], MemoryJobStepService);
1747
-
1748
- // runtime/subsystems/jobs/memory-job-store.ts
1749
- var MemoryJobStore = class {
1750
- /** Runs keyed by `id` (single source of truth for status/scope/lineage). */
1751
- runs = /* @__PURE__ */ new Map();
1752
- /** Steps keyed by `job_run_id`; array order matches insertion order. */
1753
- steps = /* @__PURE__ */ new Map();
1754
- /** Job definitions keyed by `type` — memory mirror of the `job` table. */
1755
- jobs = /* @__PURE__ */ new Map();
1756
- /** Reset everything. Tests call this in `beforeEach`. */
1757
- clear() {
1758
- this.runs.clear();
1759
- this.steps.clear();
1760
- this.jobs.clear();
1761
- }
1762
- };
1763
-
1764
1773
  // runtime/subsystems/jobs/pool-config.loader.ts
1765
1774
  import { existsSync, readFileSync } from "fs";
1766
1775
  import { resolve } from "path";