@pattern-stack/codegen 0.4.2 → 0.4.4

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 (31) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/runtime/subsystems/bridge/bridge.module.d.ts +1 -0
  3. package/dist/runtime/subsystems/bridge/bridge.module.js +42 -23
  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 +33 -14
  7. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  8. package/dist/runtime/subsystems/index.js +35 -16
  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 +31 -12
  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 +10 -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 +7 -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 +31 -12
  21. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  22. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +10 -4
  23. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  24. package/dist/src/cli/index.js +71 -7
  25. package/dist/src/cli/index.js.map +1 -1
  26. package/dist/src/index.js +27 -2
  27. package/dist/src/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +16 -2
  30. package/runtime/subsystems/jobs/job-worker.module.ts +20 -2
  31. package/runtime/subsystems/jobs/job-worker.ts +18 -3
@@ -21,3 +21,4 @@ import '../events/event-bus.protocol.js';
21
21
  import '../../types/drizzle.js';
22
22
  import 'drizzle-orm/node-postgres';
23
23
  import '@nestjs/common';
24
+ import '@nestjs/core';
@@ -841,12 +841,13 @@ function serialiseError(err, attempt, retryable) {
841
841
  };
842
842
  }
843
843
  var JobWorker = class {
844
- constructor(db, orchestrator, runService, stepService, options) {
844
+ constructor(db, orchestrator, runService, stepService, options, moduleRef) {
845
845
  this.db = db;
846
846
  this.orchestrator = orchestrator;
847
847
  this.runService = runService;
848
848
  this.stepService = stepService;
849
849
  this.options = options;
850
+ this.moduleRef = moduleRef;
850
851
  this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
851
852
  this.staleSweeperIntervalMs = options.staleSweeperIntervalMs ?? DEFAULT_STALE_SWEEPER_INTERVAL_MS;
852
853
  this.staleThresholdMs = options.staleThresholdMs ?? DEFAULT_STALE_THRESHOLD_MS;
@@ -863,6 +864,7 @@ var JobWorker = class {
863
864
  runService;
864
865
  stepService;
865
866
  options;
867
+ moduleRef;
866
868
  logger = new Logger2(JobWorker.name);
867
869
  shuttingDown = false;
868
870
  inFlight = /* @__PURE__ */ new Set();
@@ -1034,7 +1036,10 @@ var JobWorker = class {
1034
1036
  }
1035
1037
  const meta = registryEntry.meta;
1036
1038
  const HandlerClass = registryEntry.handlerClass;
1037
- const handler = new HandlerClass();
1039
+ const handler = this.moduleRef.get(
1040
+ HandlerClass,
1041
+ { strict: false }
1042
+ );
1038
1043
  const ctx = {
1039
1044
  input: claimed.input,
1040
1045
  run: claimed,
@@ -1208,7 +1213,7 @@ var MemoryJobStore = class {
1208
1213
 
1209
1214
  // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
1210
1215
  import { randomUUID as randomUUID2 } from "crypto";
1211
- import { Inject as Inject5, Injectable as Injectable5, Logger as Logger3 } from "@nestjs/common";
1216
+ import { Inject as Inject5, Injectable as Injectable5, Logger as Logger3, Optional } from "@nestjs/common";
1212
1217
  var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
1213
1218
  var TERMINAL_STATUSES2 = [
1214
1219
  "completed",
@@ -1245,14 +1250,16 @@ var PromiseMutex = class {
1245
1250
  }
1246
1251
  };
1247
1252
  var MemoryJobOrchestrator = class {
1248
- constructor(store, stepService, multiTenant) {
1253
+ constructor(store, stepService, multiTenant, moduleRef) {
1249
1254
  this.store = store;
1250
1255
  this.stepService = stepService;
1251
1256
  this.multiTenant = multiTenant;
1257
+ this.moduleRef = moduleRef;
1252
1258
  }
1253
1259
  store;
1254
1260
  stepService;
1255
1261
  multiTenant;
1262
+ moduleRef;
1256
1263
  logger = new Logger3(MemoryJobOrchestrator.name);
1257
1264
  mutex = new PromiseMutex();
1258
1265
  handlerRegistry = /* @__PURE__ */ new Map();
@@ -1593,7 +1600,10 @@ var MemoryJobOrchestrator = class {
1593
1600
  }
1594
1601
  const meta = registration.meta;
1595
1602
  const HandlerClass = registration.handlerClass;
1596
- const handler = new HandlerClass();
1603
+ const handler = this.moduleRef ? this.moduleRef.get(
1604
+ HandlerClass,
1605
+ { strict: false }
1606
+ ) : new HandlerClass();
1597
1607
  const ctx = {
1598
1608
  input: run.input,
1599
1609
  run,
@@ -1773,7 +1783,8 @@ var MemoryJobOrchestrator = class {
1773
1783
  };
1774
1784
  MemoryJobOrchestrator = __decorateClass([
1775
1785
  Injectable5(),
1776
- __decorateParam(2, Inject5(JOBS_MULTI_TENANT))
1786
+ __decorateParam(2, Inject5(JOBS_MULTI_TENANT)),
1787
+ __decorateParam(3, Optional())
1777
1788
  ], MemoryJobOrchestrator);
1778
1789
  function classifyError2(err, policy, currentAttempts) {
1779
1790
  if (!policy) return "fail";
@@ -2068,7 +2079,7 @@ import {
2068
2079
  Injectable as Injectable8,
2069
2080
  Logger as Logger4,
2070
2081
  Module as Module2,
2071
- Optional
2082
+ Optional as Optional2
2072
2083
  } from "@nestjs/common";
2073
2084
 
2074
2085
  // runtime/subsystems/jobs/pool-config.loader.ts
@@ -2194,18 +2205,20 @@ function extractUserPools(raw) {
2194
2205
  var DEFAULT_SHUTDOWN_TIMEOUT_MS2 = 3e4;
2195
2206
  var JOB_WORKER_MODULE_OPTIONS = /* @__PURE__ */ Symbol("JOB_WORKER_MODULE_OPTIONS");
2196
2207
  var JobWorkerOrchestrator = class {
2197
- constructor(orchestrator, runService, stepService, options, db = null) {
2208
+ constructor(orchestrator, runService, stepService, options, db = null, moduleRef) {
2198
2209
  this.orchestrator = orchestrator;
2199
2210
  this.runService = runService;
2200
2211
  this.stepService = stepService;
2201
2212
  this.options = options;
2202
2213
  this.db = db;
2214
+ this.moduleRef = moduleRef;
2203
2215
  }
2204
2216
  orchestrator;
2205
2217
  runService;
2206
2218
  stepService;
2207
2219
  options;
2208
2220
  db;
2221
+ moduleRef;
2209
2222
  logger = new Logger4(JobWorkerOrchestrator.name);
2210
2223
  workers = [];
2211
2224
  // ============================================================================
@@ -2232,7 +2245,7 @@ var JobWorkerOrchestrator = class {
2232
2245
  );
2233
2246
  }
2234
2247
  const workerOptions = {
2235
- pool: def.queue,
2248
+ pool: poolName,
2236
2249
  concurrency: def.concurrency,
2237
2250
  shutdownTimeoutMs: this.options.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS2
2238
2251
  };
@@ -2240,7 +2253,7 @@ var JobWorkerOrchestrator = class {
2240
2253
  worker.onModuleInit();
2241
2254
  this.workers.push(worker);
2242
2255
  this.logger.log(
2243
- `JobWorker started: pool='${def.queue}' concurrency=${def.concurrency}`
2256
+ `JobWorker started: pool='${poolName}' (queue='${def.queue}') concurrency=${def.concurrency}`
2244
2257
  );
2245
2258
  }
2246
2259
  }
@@ -2304,12 +2317,18 @@ var JobWorkerOrchestrator = class {
2304
2317
  `JobWorkerModule: in-process worker spawning requires the Drizzle backend (no DRIZZLE provider available). Memory-mode tests must pass 'workerFactory' to inject a stub.`
2305
2318
  );
2306
2319
  }
2320
+ if (!this.moduleRef) {
2321
+ throw new Error(
2322
+ `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).`
2323
+ );
2324
+ }
2307
2325
  return new JobWorker(
2308
2326
  this.db,
2309
2327
  this.orchestrator,
2310
2328
  this.runService,
2311
2329
  this.stepService,
2312
- workerOptions
2330
+ workerOptions,
2331
+ this.moduleRef
2313
2332
  );
2314
2333
  }
2315
2334
  };
@@ -2319,7 +2338,7 @@ JobWorkerOrchestrator = __decorateClass([
2319
2338
  __decorateParam(1, Inject7(JOB_RUN_SERVICE)),
2320
2339
  __decorateParam(2, Inject7(JOB_STEP_SERVICE)),
2321
2340
  __decorateParam(3, Inject7(JOB_WORKER_MODULE_OPTIONS)),
2322
- __decorateParam(4, Optional()),
2341
+ __decorateParam(4, Optional2()),
2323
2342
  __decorateParam(4, Inject7(DRIZZLE))
2324
2343
  ], JobWorkerOrchestrator);
2325
2344
  var JobWorkerModule = class {