@pattern-stack/codegen 0.14.0 → 0.14.2

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 (33) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.d.ts +1 -1
  3. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +2 -2
  4. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
  5. package/dist/runtime/subsystems/bridge/bridge.module.d.ts +22 -0
  6. package/dist/runtime/subsystems/bridge/bridge.module.js +177 -160
  7. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  8. package/dist/runtime/subsystems/bridge/index.js +159 -142
  9. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  10. package/dist/runtime/subsystems/index.js +161 -148
  11. package/dist/runtime/subsystems/index.js.map +1 -1
  12. package/dist/runtime/subsystems/jobs/index.js +128 -115
  13. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  14. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +128 -6
  15. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  16. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +17 -0
  17. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
  18. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +25 -2
  19. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
  20. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +26 -1
  21. package/dist/runtime/subsystems/jobs/job-worker.module.js +150 -137
  22. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  23. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +133 -124
  24. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  25. package/dist/src/cli/index.js +1040 -635
  26. package/dist/src/cli/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/runtime/subsystems/bridge/bridge-delivery.memory-backend.ts +8 -1
  29. package/runtime/subsystems/bridge/bridge.module.ts +26 -1
  30. package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +8 -3
  31. package/runtime/subsystems/jobs/job-run-service.memory-backend.ts +4 -1
  32. package/runtime/subsystems/jobs/job-step-service.memory-backend.ts +7 -2
  33. package/runtime/subsystems/jobs/job-worker.module.ts +13 -1
@@ -1479,8 +1479,113 @@ var MemoryJobStore = class {
1479
1479
  };
1480
1480
 
1481
1481
  // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
1482
+ import { randomUUID as randomUUID3 } from "crypto";
1483
+ import { Inject as Inject6, Injectable as Injectable6, Logger as Logger3, Optional } from "@nestjs/common";
1484
+ import { ModuleRef } from "@nestjs/core";
1485
+
1486
+ // runtime/subsystems/jobs/job-step-service.memory-backend.ts
1482
1487
  import { randomUUID as randomUUID2 } from "crypto";
1483
- import { Inject as Inject5, Injectable as Injectable5, Logger as Logger3, Optional } from "@nestjs/common";
1488
+ import { Inject as Inject5, Injectable as Injectable5 } from "@nestjs/common";
1489
+ var MemoryJobStepService = class {
1490
+ // ADR-037 (package-mode DI): explicit `@Inject(MemoryJobStore)` — the
1491
+ // published bundle carries no `design:paramtypes`, so a by-type inject
1492
+ // would resolve to `undefined` in package mode.
1493
+ constructor(store) {
1494
+ this.store = store;
1495
+ }
1496
+ store;
1497
+ async findStep(runId, stepId) {
1498
+ const rows = this.store.steps.get(runId);
1499
+ if (!rows) return null;
1500
+ const match = rows.find(
1501
+ (r) => r.stepId === stepId && r.status === "completed"
1502
+ );
1503
+ return match ?? null;
1504
+ }
1505
+ async recordStep(input) {
1506
+ const rows = this.getOrCreateRows(input.jobRunId);
1507
+ const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
1508
+ const normalisedInput = input.input ?? null;
1509
+ const normalisedOutput = input.output ?? null;
1510
+ if (existingIdx >= 0) {
1511
+ const prev = rows[existingIdx];
1512
+ const next = {
1513
+ ...prev,
1514
+ status: input.status,
1515
+ input: normalisedInput ?? prev.input,
1516
+ output: normalisedOutput ?? prev.output,
1517
+ error: input.error ?? prev.error,
1518
+ attempts: input.attempts ?? prev.attempts,
1519
+ startedAt: input.startedAt ?? prev.startedAt,
1520
+ finishedAt: input.finishedAt ?? prev.finishedAt
1521
+ };
1522
+ rows[existingIdx] = next;
1523
+ return next;
1524
+ }
1525
+ const seq = input.seq ?? this.nextSeq(rows);
1526
+ const row = {
1527
+ id: randomUUID2(),
1528
+ jobRunId: input.jobRunId,
1529
+ stepId: input.stepId,
1530
+ kind: input.kind,
1531
+ seq,
1532
+ status: input.status,
1533
+ input: normalisedInput,
1534
+ output: normalisedOutput,
1535
+ error: input.error ?? null,
1536
+ attempts: input.attempts ?? 0,
1537
+ startedAt: input.startedAt ?? null,
1538
+ finishedAt: input.finishedAt ?? null
1539
+ };
1540
+ rows.push(row);
1541
+ return row;
1542
+ }
1543
+ /**
1544
+ * Replay helper — wipe every step row for a run. Mirrors the `scratch`
1545
+ * replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
1546
+ */
1547
+ clearStepsForRun(runId) {
1548
+ this.store.steps.delete(runId);
1549
+ }
1550
+ /**
1551
+ * Remove every non-`completed` row for the run. Memoized (`completed`)
1552
+ * rows are preserved — this is the `last_checkpoint` / `last_step`
1553
+ * semantics the Drizzle backend implements via
1554
+ * `DELETE … WHERE status != 'completed'`. Both replay modes route here
1555
+ * (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
1556
+ */
1557
+ clearIncompleteSteps(runId) {
1558
+ const rows = this.store.steps.get(runId);
1559
+ if (!rows) return;
1560
+ const kept = rows.filter((r) => r.status === "completed");
1561
+ if (kept.length === 0) {
1562
+ this.store.steps.delete(runId);
1563
+ } else {
1564
+ this.store.steps.set(runId, kept);
1565
+ }
1566
+ }
1567
+ getOrCreateRows(runId) {
1568
+ let rows = this.store.steps.get(runId);
1569
+ if (!rows) {
1570
+ rows = [];
1571
+ this.store.steps.set(runId, rows);
1572
+ }
1573
+ return rows;
1574
+ }
1575
+ nextSeq(rows) {
1576
+ let max = 0;
1577
+ for (const r of rows) {
1578
+ if (r.seq > max) max = r.seq;
1579
+ }
1580
+ return max + 1;
1581
+ }
1582
+ };
1583
+ MemoryJobStepService = __decorateClass([
1584
+ Injectable5(),
1585
+ __decorateParam(0, Inject5(MemoryJobStore))
1586
+ ], MemoryJobStepService);
1587
+
1588
+ // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
1484
1589
  var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
1485
1590
  var TERMINAL_STATUSES2 = [
1486
1591
  "completed",
@@ -1651,7 +1756,7 @@ var MemoryJobOrchestrator = class {
1651
1756
  }
1652
1757
  }
1653
1758
  }
1654
- const newId = randomUUID2();
1759
+ const newId = randomUUID3();
1655
1760
  let rootRunId = newId;
1656
1761
  if (opts.parentRunId) {
1657
1762
  const parent = this.store.runs.get(opts.parentRunId);
@@ -2049,9 +2154,12 @@ var MemoryJobOrchestrator = class {
2049
2154
  }
2050
2155
  };
2051
2156
  MemoryJobOrchestrator = __decorateClass([
2052
- Injectable5(),
2053
- __decorateParam(2, Inject5(JOBS_MULTI_TENANT)),
2054
- __decorateParam(3, Optional())
2157
+ Injectable6(),
2158
+ __decorateParam(0, Inject6(MemoryJobStore)),
2159
+ __decorateParam(1, Inject6(MemoryJobStepService)),
2160
+ __decorateParam(2, Inject6(JOBS_MULTI_TENANT)),
2161
+ __decorateParam(3, Optional()),
2162
+ __decorateParam(3, Inject6(ModuleRef))
2055
2163
  ], MemoryJobOrchestrator);
2056
2164
  function classifyError2(err, policy, currentAttempts) {
2057
2165
  if (!policy) return "fail";
@@ -2085,7 +2193,7 @@ function serialiseError2(err, attempt, retryable) {
2085
2193
  }
2086
2194
 
2087
2195
  // runtime/subsystems/jobs/job-run-service.memory-backend.ts
2088
- import { Inject as Inject6, Injectable as Injectable6 } from "@nestjs/common";
2196
+ import { Inject as Inject7, Injectable as Injectable7 } from "@nestjs/common";
2089
2197
  var NON_TERMINAL_STATUSES2 = [
2090
2198
  "pending",
2091
2199
  "running",
@@ -2252,9 +2360,10 @@ var MemoryJobRunService = class {
2252
2360
  }
2253
2361
  };
2254
2362
  MemoryJobRunService = __decorateClass([
2255
- Injectable6(),
2256
- __decorateParam(1, Inject6(JOB_ORCHESTRATOR)),
2257
- __decorateParam(2, Inject6(JOBS_MULTI_TENANT))
2363
+ Injectable7(),
2364
+ __decorateParam(0, Inject7(MemoryJobStore)),
2365
+ __decorateParam(1, Inject7(JOB_ORCHESTRATOR)),
2366
+ __decorateParam(2, Inject7(JOBS_MULTI_TENANT))
2258
2367
  ], MemoryJobRunService);
2259
2368
  function compareBy(a, b, order) {
2260
2369
  switch (order) {
@@ -2270,104 +2379,6 @@ function compareBy(a, b, order) {
2270
2379
  }
2271
2380
  }
2272
2381
 
2273
- // runtime/subsystems/jobs/job-step-service.memory-backend.ts
2274
- import { randomUUID as randomUUID3 } from "crypto";
2275
- import { Injectable as Injectable7 } from "@nestjs/common";
2276
- var MemoryJobStepService = class {
2277
- constructor(store) {
2278
- this.store = store;
2279
- }
2280
- store;
2281
- async findStep(runId, stepId) {
2282
- const rows = this.store.steps.get(runId);
2283
- if (!rows) return null;
2284
- const match = rows.find(
2285
- (r) => r.stepId === stepId && r.status === "completed"
2286
- );
2287
- return match ?? null;
2288
- }
2289
- async recordStep(input) {
2290
- const rows = this.getOrCreateRows(input.jobRunId);
2291
- const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
2292
- const normalisedInput = input.input ?? null;
2293
- const normalisedOutput = input.output ?? null;
2294
- if (existingIdx >= 0) {
2295
- const prev = rows[existingIdx];
2296
- const next = {
2297
- ...prev,
2298
- status: input.status,
2299
- input: normalisedInput ?? prev.input,
2300
- output: normalisedOutput ?? prev.output,
2301
- error: input.error ?? prev.error,
2302
- attempts: input.attempts ?? prev.attempts,
2303
- startedAt: input.startedAt ?? prev.startedAt,
2304
- finishedAt: input.finishedAt ?? prev.finishedAt
2305
- };
2306
- rows[existingIdx] = next;
2307
- return next;
2308
- }
2309
- const seq = input.seq ?? this.nextSeq(rows);
2310
- const row = {
2311
- id: randomUUID3(),
2312
- jobRunId: input.jobRunId,
2313
- stepId: input.stepId,
2314
- kind: input.kind,
2315
- seq,
2316
- status: input.status,
2317
- input: normalisedInput,
2318
- output: normalisedOutput,
2319
- error: input.error ?? null,
2320
- attempts: input.attempts ?? 0,
2321
- startedAt: input.startedAt ?? null,
2322
- finishedAt: input.finishedAt ?? null
2323
- };
2324
- rows.push(row);
2325
- return row;
2326
- }
2327
- /**
2328
- * Replay helper — wipe every step row for a run. Mirrors the `scratch`
2329
- * replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
2330
- */
2331
- clearStepsForRun(runId) {
2332
- this.store.steps.delete(runId);
2333
- }
2334
- /**
2335
- * Remove every non-`completed` row for the run. Memoized (`completed`)
2336
- * rows are preserved — this is the `last_checkpoint` / `last_step`
2337
- * semantics the Drizzle backend implements via
2338
- * `DELETE … WHERE status != 'completed'`. Both replay modes route here
2339
- * (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
2340
- */
2341
- clearIncompleteSteps(runId) {
2342
- const rows = this.store.steps.get(runId);
2343
- if (!rows) return;
2344
- const kept = rows.filter((r) => r.status === "completed");
2345
- if (kept.length === 0) {
2346
- this.store.steps.delete(runId);
2347
- } else {
2348
- this.store.steps.set(runId, kept);
2349
- }
2350
- }
2351
- getOrCreateRows(runId) {
2352
- let rows = this.store.steps.get(runId);
2353
- if (!rows) {
2354
- rows = [];
2355
- this.store.steps.set(runId, rows);
2356
- }
2357
- return rows;
2358
- }
2359
- nextSeq(rows) {
2360
- let max = 0;
2361
- for (const r of rows) {
2362
- if (r.seq > max) max = r.seq;
2363
- }
2364
- return max + 1;
2365
- }
2366
- };
2367
- MemoryJobStepService = __decorateClass([
2368
- Injectable7()
2369
- ], MemoryJobStepService);
2370
-
2371
2382
  // runtime/subsystems/jobs/jobs-domain.module.ts
2372
2383
  import { Module } from "@nestjs/common";
2373
2384
  var JobsDomainModule = class {
@@ -2438,12 +2449,13 @@ JobsDomainModule = __decorateClass([
2438
2449
 
2439
2450
  // runtime/subsystems/jobs/job-worker.module.ts
2440
2451
  import {
2441
- Inject as Inject7,
2452
+ Inject as Inject8,
2442
2453
  Injectable as Injectable8,
2443
2454
  Logger as Logger4,
2444
2455
  Module as Module2,
2445
2456
  Optional as Optional2
2446
2457
  } from "@nestjs/common";
2458
+ import { ModuleRef as ModuleRef2 } from "@nestjs/core";
2447
2459
  var DEFAULT_SHUTDOWN_TIMEOUT_MS2 = 3e4;
2448
2460
  var JOB_WORKER_MODULE_OPTIONS = Symbol.for(tokenKey("jobs", "worker-module-options"));
2449
2461
  var JobWorkerOrchestrator = class {
@@ -2638,16 +2650,17 @@ var JobWorkerOrchestrator = class {
2638
2650
  };
2639
2651
  JobWorkerOrchestrator = __decorateClass([
2640
2652
  Injectable8(),
2641
- __decorateParam(0, Inject7(JOB_ORCHESTRATOR)),
2642
- __decorateParam(1, Inject7(JOB_RUN_SERVICE)),
2643
- __decorateParam(2, Inject7(JOB_STEP_SERVICE)),
2644
- __decorateParam(3, Inject7(JOB_WORKER_MODULE_OPTIONS)),
2653
+ __decorateParam(0, Inject8(JOB_ORCHESTRATOR)),
2654
+ __decorateParam(1, Inject8(JOB_RUN_SERVICE)),
2655
+ __decorateParam(2, Inject8(JOB_STEP_SERVICE)),
2656
+ __decorateParam(3, Inject8(JOB_WORKER_MODULE_OPTIONS)),
2645
2657
  __decorateParam(4, Optional2()),
2646
- __decorateParam(4, Inject7(DRIZZLE)),
2658
+ __decorateParam(4, Inject8(DRIZZLE)),
2659
+ __decorateParam(5, Inject8(ModuleRef2)),
2647
2660
  __decorateParam(6, Optional2()),
2648
- __decorateParam(6, Inject7(BULLMQ_CONNECTION)),
2661
+ __decorateParam(6, Inject8(BULLMQ_CONNECTION)),
2649
2662
  __decorateParam(7, Optional2()),
2650
- __decorateParam(7, Inject7(BULLMQ_RESOLVED_CONFIG))
2663
+ __decorateParam(7, Inject8(BULLMQ_RESOLVED_CONFIG))
2651
2664
  ], JobWorkerOrchestrator);
2652
2665
  var JobWorkerModule = class {
2653
2666
  static forRoot(opts) {