@pattern-stack/codegen 0.4.2 → 0.4.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/runtime/subsystems/bridge/bridge.module.d.ts +1 -0
  3. package/dist/runtime/subsystems/bridge/bridge.module.js +38 -21
  4. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  5. package/dist/runtime/subsystems/bridge/index.d.ts +1 -0
  6. package/dist/runtime/subsystems/bridge/index.js +29 -12
  7. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  8. package/dist/runtime/subsystems/index.js +31 -14
  9. package/dist/runtime/subsystems/index.js.map +1 -1
  10. package/dist/runtime/subsystems/jobs/index.d.ts +1 -0
  11. package/dist/runtime/subsystems/jobs/index.js +27 -10
  12. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  13. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.d.ts +3 -1
  14. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +9 -4
  15. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  16. package/dist/runtime/subsystems/jobs/job-worker.d.ts +3 -1
  17. package/dist/runtime/subsystems/jobs/job-worker.js +6 -2
  18. package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
  19. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +3 -1
  20. package/dist/runtime/subsystems/jobs/job-worker.module.js +27 -10
  21. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  22. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +9 -4
  23. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  24. package/dist/src/cli/index.js +29 -2
  25. package/dist/src/cli/index.js.map +1 -1
  26. package/package.json +1 -1
  27. package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +12 -2
  28. package/runtime/subsystems/jobs/job-worker.module.ts +10 -0
  29. package/runtime/subsystems/jobs/job-worker.ts +12 -3
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.4.3] — 2026-04-22
8
+
9
+ ### Fixed
10
+ - **`fix(jobs)`** — handlers are now instantiated via `ModuleRef` so `@Inject()`-annotated constructor parameters resolve correctly. Applies to both the Drizzle and in-memory job backends. Before this fix, handlers with DI-injected dependencies would fail at runtime because the worker constructed them outside Nest's container. (commits e7348cd, c685a63)
11
+ - **`fix(bridge)` #193** — bridge registry codegen is gated on the bridge subsystem being installed (PR #192), and `bridgeHandlersDir` now resolves under `paths.backend_src` instead of hard-coding `src/jobs` (PR #194). Together these close the "stray `src/shared/subsystems/bridge/generated/registry.ts` with broken `../bridge.protocol` import" bug for both the "bridge declared in config but not installed" case and the "installed with non-default backend_src so triggers were never scanned" case.
12
+
7
13
  ## [0.4.1] — 2026-04-21
8
14
 
9
15
  ### Added
@@ -1,5 +1,6 @@
1
1
  import { OnModuleInit, DynamicModule } from '@nestjs/common';
2
2
  import { JobWorkerModuleOptions } from '../jobs/job-worker.module.js';
3
+ import '@nestjs/core';
3
4
  import '../../types/drizzle.js';
4
5
  import 'drizzle-orm/node-postgres';
5
6
  import '../jobs/jobs-domain.module.js';
@@ -14,7 +14,7 @@ var __decorateParam = (index4, decorator) => (target, key2) => decorator(target,
14
14
  import {
15
15
  Inject as Inject12,
16
16
  Module as Module3,
17
- Optional as Optional6
17
+ Optional as Optional7
18
18
  } from "@nestjs/common";
19
19
 
20
20
  // runtime/subsystems/jobs/job-worker.module.ts
@@ -23,7 +23,7 @@ import {
23
23
  Injectable as Injectable8,
24
24
  Logger as Logger4,
25
25
  Module as Module2,
26
- Optional
26
+ Optional as Optional2
27
27
  } from "@nestjs/common";
28
28
 
29
29
  // runtime/constants/tokens.ts
@@ -797,7 +797,7 @@ DrizzleJobStepService = __decorateClass([
797
797
 
798
798
  // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
799
799
  import { randomUUID as randomUUID2 } from "crypto";
800
- import { Inject as Inject4, Injectable as Injectable4, Logger as Logger2 } from "@nestjs/common";
800
+ import { Inject as Inject4, Injectable as Injectable4, Logger as Logger2, Optional } from "@nestjs/common";
801
801
  var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
802
802
  var TERMINAL_STATUSES2 = [
803
803
  "completed",
@@ -834,14 +834,16 @@ var PromiseMutex = class {
834
834
  }
835
835
  };
836
836
  var MemoryJobOrchestrator = class {
837
- constructor(store, stepService, multiTenant) {
837
+ constructor(store, stepService, multiTenant, moduleRef) {
838
838
  this.store = store;
839
839
  this.stepService = stepService;
840
840
  this.multiTenant = multiTenant;
841
+ this.moduleRef = moduleRef;
841
842
  }
842
843
  store;
843
844
  stepService;
844
845
  multiTenant;
846
+ moduleRef;
845
847
  logger = new Logger2(MemoryJobOrchestrator.name);
846
848
  mutex = new PromiseMutex();
847
849
  handlerRegistry = /* @__PURE__ */ new Map();
@@ -1182,7 +1184,9 @@ var MemoryJobOrchestrator = class {
1182
1184
  }
1183
1185
  const meta = registration.meta;
1184
1186
  const HandlerClass = registration.handlerClass;
1185
- const handler = new HandlerClass();
1187
+ const handler = this.moduleRef ? await this.moduleRef.create(
1188
+ HandlerClass
1189
+ ) : new HandlerClass();
1186
1190
  const ctx = {
1187
1191
  input: run.input,
1188
1192
  run,
@@ -1362,7 +1366,8 @@ var MemoryJobOrchestrator = class {
1362
1366
  };
1363
1367
  MemoryJobOrchestrator = __decorateClass([
1364
1368
  Injectable4(),
1365
- __decorateParam(2, Inject4(JOBS_MULTI_TENANT))
1369
+ __decorateParam(2, Inject4(JOBS_MULTI_TENANT)),
1370
+ __decorateParam(3, Optional())
1366
1371
  ], MemoryJobOrchestrator);
1367
1372
  function classifyError(err, policy, currentAttempts) {
1368
1373
  if (!policy) return "fail";
@@ -1826,12 +1831,13 @@ function serialiseError2(err, attempt, retryable) {
1826
1831
  };
1827
1832
  }
1828
1833
  var JobWorker = class {
1829
- constructor(db, orchestrator, runService, stepService, options) {
1834
+ constructor(db, orchestrator, runService, stepService, options, moduleRef) {
1830
1835
  this.db = db;
1831
1836
  this.orchestrator = orchestrator;
1832
1837
  this.runService = runService;
1833
1838
  this.stepService = stepService;
1834
1839
  this.options = options;
1840
+ this.moduleRef = moduleRef;
1835
1841
  this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
1836
1842
  this.staleSweeperIntervalMs = options.staleSweeperIntervalMs ?? DEFAULT_STALE_SWEEPER_INTERVAL_MS;
1837
1843
  this.staleThresholdMs = options.staleThresholdMs ?? DEFAULT_STALE_THRESHOLD_MS;
@@ -1848,6 +1854,7 @@ var JobWorker = class {
1848
1854
  runService;
1849
1855
  stepService;
1850
1856
  options;
1857
+ moduleRef;
1851
1858
  logger = new Logger3(JobWorker.name);
1852
1859
  shuttingDown = false;
1853
1860
  inFlight = /* @__PURE__ */ new Set();
@@ -2019,7 +2026,9 @@ var JobWorker = class {
2019
2026
  }
2020
2027
  const meta = registryEntry.meta;
2021
2028
  const HandlerClass = registryEntry.handlerClass;
2022
- const handler = new HandlerClass();
2029
+ const handler = await this.moduleRef.create(
2030
+ HandlerClass
2031
+ );
2023
2032
  const ctx = {
2024
2033
  input: claimed.input,
2025
2034
  run: claimed,
@@ -2179,18 +2188,20 @@ JobWorker = __decorateClass([
2179
2188
  var DEFAULT_SHUTDOWN_TIMEOUT_MS2 = 3e4;
2180
2189
  var JOB_WORKER_MODULE_OPTIONS = /* @__PURE__ */ Symbol("JOB_WORKER_MODULE_OPTIONS");
2181
2190
  var JobWorkerOrchestrator = class {
2182
- constructor(orchestrator, runService, stepService, options, db = null) {
2191
+ constructor(orchestrator, runService, stepService, options, db = null, moduleRef) {
2183
2192
  this.orchestrator = orchestrator;
2184
2193
  this.runService = runService;
2185
2194
  this.stepService = stepService;
2186
2195
  this.options = options;
2187
2196
  this.db = db;
2197
+ this.moduleRef = moduleRef;
2188
2198
  }
2189
2199
  orchestrator;
2190
2200
  runService;
2191
2201
  stepService;
2192
2202
  options;
2193
2203
  db;
2204
+ moduleRef;
2194
2205
  logger = new Logger4(JobWorkerOrchestrator.name);
2195
2206
  workers = [];
2196
2207
  // ============================================================================
@@ -2289,12 +2300,18 @@ var JobWorkerOrchestrator = class {
2289
2300
  `JobWorkerModule: in-process worker spawning requires the Drizzle backend (no DRIZZLE provider available). Memory-mode tests must pass 'workerFactory' to inject a stub.`
2290
2301
  );
2291
2302
  }
2303
+ if (!this.moduleRef) {
2304
+ throw new Error(
2305
+ `JobWorkerModule: ModuleRef not available \u2014 cannot construct JobWorker with handler DI support. Ensure the orchestrator is resolved through the Nest container (not instantiated manually in tests).`
2306
+ );
2307
+ }
2292
2308
  return new JobWorker(
2293
2309
  this.db,
2294
2310
  this.orchestrator,
2295
2311
  this.runService,
2296
2312
  this.stepService,
2297
- workerOptions
2313
+ workerOptions,
2314
+ this.moduleRef
2298
2315
  );
2299
2316
  }
2300
2317
  };
@@ -2304,7 +2321,7 @@ JobWorkerOrchestrator = __decorateClass([
2304
2321
  __decorateParam(1, Inject7(JOB_RUN_SERVICE)),
2305
2322
  __decorateParam(2, Inject7(JOB_STEP_SERVICE)),
2306
2323
  __decorateParam(3, Inject7(JOB_WORKER_MODULE_OPTIONS)),
2307
- __decorateParam(4, Optional()),
2324
+ __decorateParam(4, Optional2()),
2308
2325
  __decorateParam(4, Inject7(DRIZZLE))
2309
2326
  ], JobWorkerOrchestrator);
2310
2327
  var JobWorkerModule = class {
@@ -2456,7 +2473,7 @@ var MemoryBridgeDeliveryRepo = class {
2456
2473
  };
2457
2474
 
2458
2475
  // runtime/subsystems/bridge/bridge-delivery.drizzle-backend.ts
2459
- import { Inject as Inject8, Injectable as Injectable9, Optional as Optional2 } from "@nestjs/common";
2476
+ import { Inject as Inject8, Injectable as Injectable9, Optional as Optional3 } from "@nestjs/common";
2460
2477
  import { eq as eq5, and as and5 } from "drizzle-orm";
2461
2478
 
2462
2479
  // runtime/subsystems/bridge/bridge-delivery.schema.ts
@@ -2649,16 +2666,16 @@ var DrizzleBridgeDeliveryRepo = class {
2649
2666
  DrizzleBridgeDeliveryRepo = __decorateClass([
2650
2667
  Injectable9(),
2651
2668
  __decorateParam(0, Inject8(DRIZZLE)),
2652
- __decorateParam(1, Optional2()),
2669
+ __decorateParam(1, Optional3()),
2653
2670
  __decorateParam(1, Inject8(BRIDGE_MULTI_TENANT))
2654
2671
  ], DrizzleBridgeDeliveryRepo);
2655
2672
 
2656
2673
  // runtime/subsystems/bridge/bridge-outbox-drain-hook.ts
2657
- import { Inject as Inject10, Injectable as Injectable11, Logger as Logger6, Optional as Optional4 } from "@nestjs/common";
2674
+ import { Inject as Inject10, Injectable as Injectable11, Logger as Logger6, Optional as Optional5 } from "@nestjs/common";
2658
2675
  import { randomUUID as randomUUID5 } from "crypto";
2659
2676
 
2660
2677
  // runtime/subsystems/bridge/bridge-delivery-handler.ts
2661
- import { Inject as Inject9, Injectable as Injectable10, Logger as Logger5, Optional as Optional3 } from "@nestjs/common";
2678
+ import { Inject as Inject9, Injectable as Injectable10, Logger as Logger5, Optional as Optional4 } from "@nestjs/common";
2662
2679
 
2663
2680
  // runtime/subsystems/events/events.tokens.ts
2664
2681
  var EVENT_BUS = "EVENT_BUS";
@@ -2751,7 +2768,7 @@ BridgeDeliveryHandler = __decorateClass([
2751
2768
  __decorateParam(1, Inject9(JOB_ORCHESTRATOR)),
2752
2769
  __decorateParam(2, Inject9(EVENT_BUS)),
2753
2770
  __decorateParam(3, Inject9(BRIDGE_REGISTRY)),
2754
- __decorateParam(4, Optional3()),
2771
+ __decorateParam(4, Optional4()),
2755
2772
  __decorateParam(4, Inject9(BRIDGE_MULTI_TENANT))
2756
2773
  ], BridgeDeliveryHandler);
2757
2774
 
@@ -2828,12 +2845,12 @@ var BridgeOutboxDrainHook = class {
2828
2845
  };
2829
2846
  BridgeOutboxDrainHook = __decorateClass([
2830
2847
  Injectable11(),
2831
- __decorateParam(0, Optional4()),
2848
+ __decorateParam(0, Optional5()),
2832
2849
  __decorateParam(0, Inject10(BRIDGE_REGISTRY))
2833
2850
  ], BridgeOutboxDrainHook);
2834
2851
 
2835
2852
  // runtime/subsystems/bridge/event-flow.service.ts
2836
- import { Inject as Inject11, Injectable as Injectable12, Optional as Optional5 } from "@nestjs/common";
2853
+ import { Inject as Inject11, Injectable as Injectable12, Optional as Optional6 } from "@nestjs/common";
2837
2854
  var EventFlowService = class {
2838
2855
  constructor(db, eventBus, orchestrator, bridgeRepo, registry = {}, multiTenant = false) {
2839
2856
  this.db = db;
@@ -2909,9 +2926,9 @@ EventFlowService = __decorateClass([
2909
2926
  __decorateParam(1, Inject11(EVENT_BUS)),
2910
2927
  __decorateParam(2, Inject11(JOB_ORCHESTRATOR)),
2911
2928
  __decorateParam(3, Inject11(BRIDGE_DELIVERY_REPO)),
2912
- __decorateParam(4, Optional5()),
2929
+ __decorateParam(4, Optional6()),
2913
2930
  __decorateParam(4, Inject11(BRIDGE_REGISTRY)),
2914
- __decorateParam(5, Optional5()),
2931
+ __decorateParam(5, Optional6()),
2915
2932
  __decorateParam(5, Inject11(BRIDGE_MULTI_TENANT))
2916
2933
  ], EventFlowService);
2917
2934
 
@@ -2989,7 +3006,7 @@ var BridgeModule = class {
2989
3006
  };
2990
3007
  BridgeModule = __decorateClass([
2991
3008
  Module3({}),
2992
- __decorateParam(0, Optional6()),
3009
+ __decorateParam(0, Optional7()),
2993
3010
  __decorateParam(0, Inject12(JOB_WORKER_MODULE_OPTIONS))
2994
3011
  ], BridgeModule);
2995
3012
  export {