@pattern-stack/codegen 0.13.1 → 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.
- package/dist/{job-orchestrator.protocol-CHOEqBDk.d.ts → job-orchestrator.protocol-CARhMLCO.d.ts} +1 -1
- package/dist/runtime/subsystems/analytics/analytics.module.js +6 -2
- package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -1
- package/dist/runtime/subsystems/analytics/analytics.tokens.d.ts +0 -11
- package/dist/runtime/subsystems/analytics/analytics.tokens.js +6 -2
- package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -1
- package/dist/runtime/subsystems/analytics/cube-backend.js +6 -2
- package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -1
- package/dist/runtime/subsystems/analytics/index.js +6 -2
- package/dist/runtime/subsystems/analytics/index.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.module.js +12 -6
- package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.tokens.d.ts +0 -28
- package/dist/runtime/subsystems/auth/auth.tokens.js +12 -8
- package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js +12 -5
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
- package/dist/runtime/subsystems/auth/index.js +12 -8
- package/dist/runtime/subsystems/auth/index.js.map +1 -1
- package/dist/runtime/subsystems/auth/middleware/requester-context.js +12 -1
- package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +10 -2
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +2 -2
- package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +10 -2
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.module.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/bridge.module.js +186 -168
- package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.protocol.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/event-flow.service.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/event-flow.service.js +9 -1
- package/dist/runtime/subsystems/bridge/event-flow.service.js.map +1 -1
- package/dist/runtime/subsystems/bridge/index.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/index.js +168 -150
- package/dist/runtime/subsystems/bridge/index.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +6 -1
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.memory-backend.js +6 -1
- package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.module.js +6 -2
- package/dist/runtime/subsystems/cache/cache.module.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.tokens.d.ts +0 -10
- package/dist/runtime/subsystems/cache/cache.tokens.js +6 -2
- package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -1
- package/dist/runtime/subsystems/cache/index.js +6 -2
- package/dist/runtime/subsystems/cache/index.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +5 -0
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js +5 -0
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js +5 -1
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/events.module.js +5 -1
- package/dist/runtime/subsystems/events/events.module.js.map +1 -1
- package/dist/runtime/subsystems/events/events.tokens.d.ts +5 -11
- package/dist/runtime/subsystems/events/events.tokens.js +5 -1
- package/dist/runtime/subsystems/events/events.tokens.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/bus.js +5 -0
- package/dist/runtime/subsystems/events/generated/bus.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/index.js +5 -0
- package/dist/runtime/subsystems/events/generated/index.js.map +1 -1
- package/dist/runtime/subsystems/events/index.js +5 -1
- package/dist/runtime/subsystems/events/index.js.map +1 -1
- package/dist/runtime/subsystems/index.d.ts +2 -2
- package/dist/runtime/subsystems/index.js +186 -168
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/bullmq.config.d.ts +0 -9
- package/dist/runtime/subsystems/jobs/bullmq.config.js +6 -2
- package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
- package/dist/runtime/subsystems/jobs/index.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/index.js +141 -124
- package/dist/runtime/subsystems/jobs/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.js +5 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +10 -3
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +8 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +137 -7
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.protocol.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +8 -2
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +25 -2
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.protocol.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +25 -2
- package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +5 -0
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.d.ts +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.js +10 -4
- package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +31 -3
- package/dist/runtime/subsystems/jobs/job-worker.module.js +163 -145
- package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +144 -130
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.tokens.d.ts +0 -11
- package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js +8 -4
- package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-errors.d.ts +1 -1
- package/dist/runtime/subsystems/observability/index.d.ts +1 -1
- package/dist/runtime/subsystems/observability/index.js +9 -1
- package/dist/runtime/subsystems/observability/index.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.module.js +9 -1
- package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.protocol.d.ts +1 -1
- package/dist/runtime/subsystems/observability/observability.service.d.ts +1 -1
- package/dist/runtime/subsystems/observability/observability.service.js +9 -1
- package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +1 -1
- package/dist/runtime/subsystems/observability/reporters/index.d.ts +1 -1
- package/dist/runtime/subsystems/storage/index.js +5 -1
- package/dist/runtime/subsystems/storage/index.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.module.js +5 -1
- package/dist/runtime/subsystems/storage/storage.module.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.tokens.d.ts +0 -8
- package/dist/runtime/subsystems/storage/storage.tokens.js +5 -1
- package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -1
- package/dist/runtime/subsystems/token-key.d.ts +7 -0
- package/dist/runtime/subsystems/token-key.js +8 -0
- package/dist/runtime/subsystems/token-key.js.map +1 -0
- package/dist/src/cli/index.js +1160 -694
- package/dist/src/cli/index.js.map +1 -1
- package/package.json +5 -1
- package/runtime/subsystems/analytics/analytics.tokens.ts +6 -2
- package/runtime/subsystems/auth/auth.tokens.ts +15 -8
- package/runtime/subsystems/bridge/bridge-delivery.memory-backend.ts +8 -1
- package/runtime/subsystems/cache/cache.tokens.ts +7 -2
- package/runtime/subsystems/events/events.tokens.ts +8 -1
- package/runtime/subsystems/index.ts +5 -1
- package/runtime/subsystems/jobs/bullmq.config.ts +5 -2
- package/runtime/subsystems/jobs/job-handler.base.ts +6 -1
- package/runtime/subsystems/jobs/job-orchestrator.memory-backend.ts +8 -3
- package/runtime/subsystems/jobs/job-run-service.memory-backend.ts +4 -1
- package/runtime/subsystems/jobs/job-step-service.memory-backend.ts +7 -2
- package/runtime/subsystems/jobs/job-worker.module.ts +18 -2
- package/runtime/subsystems/jobs/job-worker.ts +4 -1
- package/runtime/subsystems/jobs/jobs-domain.tokens.ts +10 -7
- package/runtime/subsystems/storage/storage.tokens.ts +6 -1
- package/runtime/subsystems/token-key.ts +7 -0
- package/src/config/runtime-mode.mjs +82 -0
- package/templates/entity/new/backend/modules/core/integration-source.ejs.t +3 -2
- package/templates/entity/new/clean-lite-ps/controller.ejs.t +1 -1
- package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
- package/templates/entity/new/clean-lite-ps/prompt-extension.js +8 -2
- package/templates/entity/new/clean-lite-ps/repository.ejs.t +4 -4
- package/templates/entity/new/clean-lite-ps/service.ejs.t +4 -4
- package/templates/entity/new/prompt.js +49 -10
|
@@ -12,18 +12,24 @@ var __decorateParam = (index2, decorator) => (target, key) => decorator(target,
|
|
|
12
12
|
|
|
13
13
|
// runtime/subsystems/jobs/job-worker.module.ts
|
|
14
14
|
import {
|
|
15
|
-
Inject as
|
|
15
|
+
Inject as Inject8,
|
|
16
16
|
Injectable as Injectable8,
|
|
17
17
|
Logger as Logger4,
|
|
18
18
|
Module as Module2,
|
|
19
19
|
Optional as Optional2
|
|
20
20
|
} from "@nestjs/common";
|
|
21
|
+
import { ModuleRef as ModuleRef2 } from "@nestjs/core";
|
|
22
|
+
|
|
23
|
+
// runtime/subsystems/token-key.ts
|
|
24
|
+
var PKG = "@pattern-stack/codegen";
|
|
25
|
+
var tokenKey = (area, name) => `${PKG}.${area}.${name}`;
|
|
21
26
|
|
|
22
27
|
// runtime/constants/tokens.ts
|
|
23
28
|
var DRIZZLE = "DRIZZLE";
|
|
24
29
|
|
|
25
30
|
// runtime/subsystems/jobs/job-handler.base.ts
|
|
26
31
|
var JOB_HANDLER_REGISTRY = /* @__PURE__ */ new Map();
|
|
32
|
+
var JOB_HANDLER_METADATA_KEY = Symbol.for(tokenKey("jobs", "handler-metadata"));
|
|
27
33
|
var HandlerRegistry;
|
|
28
34
|
((HandlerRegistry2) => {
|
|
29
35
|
function getAll() {
|
|
@@ -40,10 +46,10 @@ var HandlerRegistry;
|
|
|
40
46
|
import { Module } from "@nestjs/common";
|
|
41
47
|
|
|
42
48
|
// runtime/subsystems/jobs/jobs-domain.tokens.ts
|
|
43
|
-
var JOB_ORCHESTRATOR =
|
|
44
|
-
var JOB_RUN_SERVICE =
|
|
45
|
-
var JOB_STEP_SERVICE =
|
|
46
|
-
var JOBS_MULTI_TENANT =
|
|
49
|
+
var JOB_ORCHESTRATOR = Symbol.for(tokenKey("jobs", "orchestrator"));
|
|
50
|
+
var JOB_RUN_SERVICE = Symbol.for(tokenKey("jobs", "run-service"));
|
|
51
|
+
var JOB_STEP_SERVICE = Symbol.for(tokenKey("jobs", "step-service"));
|
|
52
|
+
var JOBS_MULTI_TENANT = Symbol.for(tokenKey("jobs", "multi-tenant"));
|
|
47
53
|
|
|
48
54
|
// runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
|
|
49
55
|
import { randomUUID } from "crypto";
|
|
@@ -879,8 +885,129 @@ DrizzleJobStepService = __decorateClass([
|
|
|
879
885
|
], DrizzleJobStepService);
|
|
880
886
|
|
|
881
887
|
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
888
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
889
|
+
import { Inject as Inject5, Injectable as Injectable5, Logger as Logger2, Optional } from "@nestjs/common";
|
|
890
|
+
import { ModuleRef } from "@nestjs/core";
|
|
891
|
+
|
|
892
|
+
// runtime/subsystems/jobs/memory-job-store.ts
|
|
893
|
+
var MemoryJobStore = class {
|
|
894
|
+
/** Runs keyed by `id` (single source of truth for status/scope/lineage). */
|
|
895
|
+
runs = /* @__PURE__ */ new Map();
|
|
896
|
+
/** Steps keyed by `job_run_id`; array order matches insertion order. */
|
|
897
|
+
steps = /* @__PURE__ */ new Map();
|
|
898
|
+
/** Job definitions keyed by `type` — memory mirror of the `job` table. */
|
|
899
|
+
jobs = /* @__PURE__ */ new Map();
|
|
900
|
+
/** Reset everything. Tests call this in `beforeEach`. */
|
|
901
|
+
clear() {
|
|
902
|
+
this.runs.clear();
|
|
903
|
+
this.steps.clear();
|
|
904
|
+
this.jobs.clear();
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
// runtime/subsystems/jobs/job-step-service.memory-backend.ts
|
|
882
909
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
883
|
-
import { Inject as Inject4, Injectable as Injectable4
|
|
910
|
+
import { Inject as Inject4, Injectable as Injectable4 } from "@nestjs/common";
|
|
911
|
+
var MemoryJobStepService = class {
|
|
912
|
+
// ADR-037 (package-mode DI): explicit `@Inject(MemoryJobStore)` — the
|
|
913
|
+
// published bundle carries no `design:paramtypes`, so a by-type inject
|
|
914
|
+
// would resolve to `undefined` in package mode.
|
|
915
|
+
constructor(store) {
|
|
916
|
+
this.store = store;
|
|
917
|
+
}
|
|
918
|
+
store;
|
|
919
|
+
async findStep(runId, stepId) {
|
|
920
|
+
const rows = this.store.steps.get(runId);
|
|
921
|
+
if (!rows) return null;
|
|
922
|
+
const match = rows.find(
|
|
923
|
+
(r) => r.stepId === stepId && r.status === "completed"
|
|
924
|
+
);
|
|
925
|
+
return match ?? null;
|
|
926
|
+
}
|
|
927
|
+
async recordStep(input) {
|
|
928
|
+
const rows = this.getOrCreateRows(input.jobRunId);
|
|
929
|
+
const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
|
|
930
|
+
const normalisedInput = input.input ?? null;
|
|
931
|
+
const normalisedOutput = input.output ?? null;
|
|
932
|
+
if (existingIdx >= 0) {
|
|
933
|
+
const prev = rows[existingIdx];
|
|
934
|
+
const next = {
|
|
935
|
+
...prev,
|
|
936
|
+
status: input.status,
|
|
937
|
+
input: normalisedInput ?? prev.input,
|
|
938
|
+
output: normalisedOutput ?? prev.output,
|
|
939
|
+
error: input.error ?? prev.error,
|
|
940
|
+
attempts: input.attempts ?? prev.attempts,
|
|
941
|
+
startedAt: input.startedAt ?? prev.startedAt,
|
|
942
|
+
finishedAt: input.finishedAt ?? prev.finishedAt
|
|
943
|
+
};
|
|
944
|
+
rows[existingIdx] = next;
|
|
945
|
+
return next;
|
|
946
|
+
}
|
|
947
|
+
const seq = input.seq ?? this.nextSeq(rows);
|
|
948
|
+
const row = {
|
|
949
|
+
id: randomUUID2(),
|
|
950
|
+
jobRunId: input.jobRunId,
|
|
951
|
+
stepId: input.stepId,
|
|
952
|
+
kind: input.kind,
|
|
953
|
+
seq,
|
|
954
|
+
status: input.status,
|
|
955
|
+
input: normalisedInput,
|
|
956
|
+
output: normalisedOutput,
|
|
957
|
+
error: input.error ?? null,
|
|
958
|
+
attempts: input.attempts ?? 0,
|
|
959
|
+
startedAt: input.startedAt ?? null,
|
|
960
|
+
finishedAt: input.finishedAt ?? null
|
|
961
|
+
};
|
|
962
|
+
rows.push(row);
|
|
963
|
+
return row;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Replay helper — wipe every step row for a run. Mirrors the `scratch`
|
|
967
|
+
* replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
|
|
968
|
+
*/
|
|
969
|
+
clearStepsForRun(runId) {
|
|
970
|
+
this.store.steps.delete(runId);
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Remove every non-`completed` row for the run. Memoized (`completed`)
|
|
974
|
+
* rows are preserved — this is the `last_checkpoint` / `last_step`
|
|
975
|
+
* semantics the Drizzle backend implements via
|
|
976
|
+
* `DELETE … WHERE status != 'completed'`. Both replay modes route here
|
|
977
|
+
* (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
|
|
978
|
+
*/
|
|
979
|
+
clearIncompleteSteps(runId) {
|
|
980
|
+
const rows = this.store.steps.get(runId);
|
|
981
|
+
if (!rows) return;
|
|
982
|
+
const kept = rows.filter((r) => r.status === "completed");
|
|
983
|
+
if (kept.length === 0) {
|
|
984
|
+
this.store.steps.delete(runId);
|
|
985
|
+
} else {
|
|
986
|
+
this.store.steps.set(runId, kept);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
getOrCreateRows(runId) {
|
|
990
|
+
let rows = this.store.steps.get(runId);
|
|
991
|
+
if (!rows) {
|
|
992
|
+
rows = [];
|
|
993
|
+
this.store.steps.set(runId, rows);
|
|
994
|
+
}
|
|
995
|
+
return rows;
|
|
996
|
+
}
|
|
997
|
+
nextSeq(rows) {
|
|
998
|
+
let max = 0;
|
|
999
|
+
for (const r of rows) {
|
|
1000
|
+
if (r.seq > max) max = r.seq;
|
|
1001
|
+
}
|
|
1002
|
+
return max + 1;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
MemoryJobStepService = __decorateClass([
|
|
1006
|
+
Injectable4(),
|
|
1007
|
+
__decorateParam(0, Inject4(MemoryJobStore))
|
|
1008
|
+
], MemoryJobStepService);
|
|
1009
|
+
|
|
1010
|
+
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
884
1011
|
var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
|
|
885
1012
|
var TERMINAL_STATUSES2 = [
|
|
886
1013
|
"completed",
|
|
@@ -1051,7 +1178,7 @@ var MemoryJobOrchestrator = class {
|
|
|
1051
1178
|
}
|
|
1052
1179
|
}
|
|
1053
1180
|
}
|
|
1054
|
-
const newId =
|
|
1181
|
+
const newId = randomUUID3();
|
|
1055
1182
|
let rootRunId = newId;
|
|
1056
1183
|
if (opts.parentRunId) {
|
|
1057
1184
|
const parent = this.store.runs.get(opts.parentRunId);
|
|
@@ -1449,9 +1576,12 @@ var MemoryJobOrchestrator = class {
|
|
|
1449
1576
|
}
|
|
1450
1577
|
};
|
|
1451
1578
|
MemoryJobOrchestrator = __decorateClass([
|
|
1452
|
-
|
|
1453
|
-
__decorateParam(
|
|
1454
|
-
__decorateParam(
|
|
1579
|
+
Injectable5(),
|
|
1580
|
+
__decorateParam(0, Inject5(MemoryJobStore)),
|
|
1581
|
+
__decorateParam(1, Inject5(MemoryJobStepService)),
|
|
1582
|
+
__decorateParam(2, Inject5(JOBS_MULTI_TENANT)),
|
|
1583
|
+
__decorateParam(3, Optional()),
|
|
1584
|
+
__decorateParam(3, Inject5(ModuleRef))
|
|
1455
1585
|
], MemoryJobOrchestrator);
|
|
1456
1586
|
function classifyError(err, policy, currentAttempts) {
|
|
1457
1587
|
if (!policy) return "fail";
|
|
@@ -1485,7 +1615,7 @@ function serialiseError(err, attempt, retryable) {
|
|
|
1485
1615
|
}
|
|
1486
1616
|
|
|
1487
1617
|
// runtime/subsystems/jobs/job-run-service.memory-backend.ts
|
|
1488
|
-
import { Inject as
|
|
1618
|
+
import { Inject as Inject6, Injectable as Injectable6 } from "@nestjs/common";
|
|
1489
1619
|
var NON_TERMINAL_STATUSES2 = [
|
|
1490
1620
|
"pending",
|
|
1491
1621
|
"running",
|
|
@@ -1652,9 +1782,10 @@ var MemoryJobRunService = class {
|
|
|
1652
1782
|
}
|
|
1653
1783
|
};
|
|
1654
1784
|
MemoryJobRunService = __decorateClass([
|
|
1655
|
-
|
|
1656
|
-
__decorateParam(
|
|
1657
|
-
__decorateParam(
|
|
1785
|
+
Injectable6(),
|
|
1786
|
+
__decorateParam(0, Inject6(MemoryJobStore)),
|
|
1787
|
+
__decorateParam(1, Inject6(JOB_ORCHESTRATOR)),
|
|
1788
|
+
__decorateParam(2, Inject6(JOBS_MULTI_TENANT))
|
|
1658
1789
|
], MemoryJobRunService);
|
|
1659
1790
|
function compareBy(a, b, order) {
|
|
1660
1791
|
switch (order) {
|
|
@@ -1670,120 +1801,6 @@ function compareBy(a, b, order) {
|
|
|
1670
1801
|
}
|
|
1671
1802
|
}
|
|
1672
1803
|
|
|
1673
|
-
// runtime/subsystems/jobs/job-step-service.memory-backend.ts
|
|
1674
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
1675
|
-
import { Injectable as Injectable6 } from "@nestjs/common";
|
|
1676
|
-
var MemoryJobStepService = class {
|
|
1677
|
-
constructor(store) {
|
|
1678
|
-
this.store = store;
|
|
1679
|
-
}
|
|
1680
|
-
store;
|
|
1681
|
-
async findStep(runId, stepId) {
|
|
1682
|
-
const rows = this.store.steps.get(runId);
|
|
1683
|
-
if (!rows) return null;
|
|
1684
|
-
const match = rows.find(
|
|
1685
|
-
(r) => r.stepId === stepId && r.status === "completed"
|
|
1686
|
-
);
|
|
1687
|
-
return match ?? null;
|
|
1688
|
-
}
|
|
1689
|
-
async recordStep(input) {
|
|
1690
|
-
const rows = this.getOrCreateRows(input.jobRunId);
|
|
1691
|
-
const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
|
|
1692
|
-
const normalisedInput = input.input ?? null;
|
|
1693
|
-
const normalisedOutput = input.output ?? null;
|
|
1694
|
-
if (existingIdx >= 0) {
|
|
1695
|
-
const prev = rows[existingIdx];
|
|
1696
|
-
const next = {
|
|
1697
|
-
...prev,
|
|
1698
|
-
status: input.status,
|
|
1699
|
-
input: normalisedInput ?? prev.input,
|
|
1700
|
-
output: normalisedOutput ?? prev.output,
|
|
1701
|
-
error: input.error ?? prev.error,
|
|
1702
|
-
attempts: input.attempts ?? prev.attempts,
|
|
1703
|
-
startedAt: input.startedAt ?? prev.startedAt,
|
|
1704
|
-
finishedAt: input.finishedAt ?? prev.finishedAt
|
|
1705
|
-
};
|
|
1706
|
-
rows[existingIdx] = next;
|
|
1707
|
-
return next;
|
|
1708
|
-
}
|
|
1709
|
-
const seq = input.seq ?? this.nextSeq(rows);
|
|
1710
|
-
const row = {
|
|
1711
|
-
id: randomUUID3(),
|
|
1712
|
-
jobRunId: input.jobRunId,
|
|
1713
|
-
stepId: input.stepId,
|
|
1714
|
-
kind: input.kind,
|
|
1715
|
-
seq,
|
|
1716
|
-
status: input.status,
|
|
1717
|
-
input: normalisedInput,
|
|
1718
|
-
output: normalisedOutput,
|
|
1719
|
-
error: input.error ?? null,
|
|
1720
|
-
attempts: input.attempts ?? 0,
|
|
1721
|
-
startedAt: input.startedAt ?? null,
|
|
1722
|
-
finishedAt: input.finishedAt ?? null
|
|
1723
|
-
};
|
|
1724
|
-
rows.push(row);
|
|
1725
|
-
return row;
|
|
1726
|
-
}
|
|
1727
|
-
/**
|
|
1728
|
-
* Replay helper — wipe every step row for a run. Mirrors the `scratch`
|
|
1729
|
-
* replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
|
|
1730
|
-
*/
|
|
1731
|
-
clearStepsForRun(runId) {
|
|
1732
|
-
this.store.steps.delete(runId);
|
|
1733
|
-
}
|
|
1734
|
-
/**
|
|
1735
|
-
* Remove every non-`completed` row for the run. Memoized (`completed`)
|
|
1736
|
-
* rows are preserved — this is the `last_checkpoint` / `last_step`
|
|
1737
|
-
* semantics the Drizzle backend implements via
|
|
1738
|
-
* `DELETE … WHERE status != 'completed'`. Both replay modes route here
|
|
1739
|
-
* (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
|
|
1740
|
-
*/
|
|
1741
|
-
clearIncompleteSteps(runId) {
|
|
1742
|
-
const rows = this.store.steps.get(runId);
|
|
1743
|
-
if (!rows) return;
|
|
1744
|
-
const kept = rows.filter((r) => r.status === "completed");
|
|
1745
|
-
if (kept.length === 0) {
|
|
1746
|
-
this.store.steps.delete(runId);
|
|
1747
|
-
} else {
|
|
1748
|
-
this.store.steps.set(runId, kept);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
getOrCreateRows(runId) {
|
|
1752
|
-
let rows = this.store.steps.get(runId);
|
|
1753
|
-
if (!rows) {
|
|
1754
|
-
rows = [];
|
|
1755
|
-
this.store.steps.set(runId, rows);
|
|
1756
|
-
}
|
|
1757
|
-
return rows;
|
|
1758
|
-
}
|
|
1759
|
-
nextSeq(rows) {
|
|
1760
|
-
let max = 0;
|
|
1761
|
-
for (const r of rows) {
|
|
1762
|
-
if (r.seq > max) max = r.seq;
|
|
1763
|
-
}
|
|
1764
|
-
return max + 1;
|
|
1765
|
-
}
|
|
1766
|
-
};
|
|
1767
|
-
MemoryJobStepService = __decorateClass([
|
|
1768
|
-
Injectable6()
|
|
1769
|
-
], MemoryJobStepService);
|
|
1770
|
-
|
|
1771
|
-
// runtime/subsystems/jobs/memory-job-store.ts
|
|
1772
|
-
var MemoryJobStore = class {
|
|
1773
|
-
/** Runs keyed by `id` (single source of truth for status/scope/lineage). */
|
|
1774
|
-
runs = /* @__PURE__ */ new Map();
|
|
1775
|
-
/** Steps keyed by `job_run_id`; array order matches insertion order. */
|
|
1776
|
-
steps = /* @__PURE__ */ new Map();
|
|
1777
|
-
/** Job definitions keyed by `type` — memory mirror of the `job` table. */
|
|
1778
|
-
jobs = /* @__PURE__ */ new Map();
|
|
1779
|
-
/** Reset everything. Tests call this in `beforeEach`. */
|
|
1780
|
-
clear() {
|
|
1781
|
-
this.runs.clear();
|
|
1782
|
-
this.steps.clear();
|
|
1783
|
-
this.jobs.clear();
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
|
|
1787
1804
|
// runtime/subsystems/jobs/pool-config.loader.ts
|
|
1788
1805
|
import { existsSync, readFileSync } from "fs";
|
|
1789
1806
|
import { resolve } from "path";
|
|
@@ -1907,8 +1924,8 @@ function extractUserPools(raw) {
|
|
|
1907
1924
|
}
|
|
1908
1925
|
|
|
1909
1926
|
// runtime/subsystems/jobs/bullmq.config.ts
|
|
1910
|
-
var BULLMQ_CONNECTION =
|
|
1911
|
-
var BULLMQ_RESOLVED_CONFIG =
|
|
1927
|
+
var BULLMQ_CONNECTION = Symbol.for(tokenKey("jobs", "bullmq-connection"));
|
|
1928
|
+
var BULLMQ_RESOLVED_CONFIG = Symbol.for(tokenKey("jobs", "bullmq-resolved-config"));
|
|
1912
1929
|
var DEFAULT_REDIS_URL = "redis://localhost:6379";
|
|
1913
1930
|
var DEFAULT_BULL_BOARD_MOUNT = "/admin/queues";
|
|
1914
1931
|
function resolveBullMqConfig(ext) {
|
|
@@ -1999,9 +2016,9 @@ JobsDomainModule = __decorateClass([
|
|
|
1999
2016
|
], JobsDomainModule);
|
|
2000
2017
|
|
|
2001
2018
|
// runtime/subsystems/jobs/job-worker.ts
|
|
2002
|
-
import { Inject as
|
|
2019
|
+
import { Inject as Inject7, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
|
|
2003
2020
|
import { and as and4, asc as asc2, desc as desc3, eq as eq4, inArray as inArray3, lt as lt2, lte, sql as sql4 } from "drizzle-orm";
|
|
2004
|
-
var JOB_WORKER_OPTIONS =
|
|
2021
|
+
var JOB_WORKER_OPTIONS = Symbol.for(tokenKey("jobs", "worker-options"));
|
|
2005
2022
|
var DEFAULT_POLL_INTERVAL_MS = 1e3;
|
|
2006
2023
|
var DEFAULT_STALE_SWEEPER_INTERVAL_MS = 6e4;
|
|
2007
2024
|
var DEFAULT_STALE_THRESHOLD_MS = 5 * 6e4;
|
|
@@ -2386,16 +2403,16 @@ var JobWorker = class {
|
|
|
2386
2403
|
};
|
|
2387
2404
|
JobWorker = __decorateClass([
|
|
2388
2405
|
Injectable7(),
|
|
2389
|
-
__decorateParam(0,
|
|
2390
|
-
__decorateParam(1,
|
|
2391
|
-
__decorateParam(2,
|
|
2392
|
-
__decorateParam(3,
|
|
2393
|
-
__decorateParam(4,
|
|
2406
|
+
__decorateParam(0, Inject7(DRIZZLE)),
|
|
2407
|
+
__decorateParam(1, Inject7(JOB_ORCHESTRATOR)),
|
|
2408
|
+
__decorateParam(2, Inject7(JOB_RUN_SERVICE)),
|
|
2409
|
+
__decorateParam(3, Inject7(JOB_STEP_SERVICE)),
|
|
2410
|
+
__decorateParam(4, Inject7(JOB_WORKER_OPTIONS))
|
|
2394
2411
|
], JobWorker);
|
|
2395
2412
|
|
|
2396
2413
|
// runtime/subsystems/jobs/job-worker.module.ts
|
|
2397
2414
|
var DEFAULT_SHUTDOWN_TIMEOUT_MS2 = 3e4;
|
|
2398
|
-
var JOB_WORKER_MODULE_OPTIONS =
|
|
2415
|
+
var JOB_WORKER_MODULE_OPTIONS = Symbol.for(tokenKey("jobs", "worker-module-options"));
|
|
2399
2416
|
var JobWorkerOrchestrator = class {
|
|
2400
2417
|
constructor(orchestrator, runService, stepService, options, db = null, moduleRef, bullConnection = null, bullConfig = null) {
|
|
2401
2418
|
this.orchestrator = orchestrator;
|
|
@@ -2588,16 +2605,17 @@ var JobWorkerOrchestrator = class {
|
|
|
2588
2605
|
};
|
|
2589
2606
|
JobWorkerOrchestrator = __decorateClass([
|
|
2590
2607
|
Injectable8(),
|
|
2591
|
-
__decorateParam(0,
|
|
2592
|
-
__decorateParam(1,
|
|
2593
|
-
__decorateParam(2,
|
|
2594
|
-
__decorateParam(3,
|
|
2608
|
+
__decorateParam(0, Inject8(JOB_ORCHESTRATOR)),
|
|
2609
|
+
__decorateParam(1, Inject8(JOB_RUN_SERVICE)),
|
|
2610
|
+
__decorateParam(2, Inject8(JOB_STEP_SERVICE)),
|
|
2611
|
+
__decorateParam(3, Inject8(JOB_WORKER_MODULE_OPTIONS)),
|
|
2595
2612
|
__decorateParam(4, Optional2()),
|
|
2596
|
-
__decorateParam(4,
|
|
2613
|
+
__decorateParam(4, Inject8(DRIZZLE)),
|
|
2614
|
+
__decorateParam(5, Inject8(ModuleRef2)),
|
|
2597
2615
|
__decorateParam(6, Optional2()),
|
|
2598
|
-
__decorateParam(6,
|
|
2616
|
+
__decorateParam(6, Inject8(BULLMQ_CONNECTION)),
|
|
2599
2617
|
__decorateParam(7, Optional2()),
|
|
2600
|
-
__decorateParam(7,
|
|
2618
|
+
__decorateParam(7, Inject8(BULLMQ_RESOLVED_CONFIG))
|
|
2601
2619
|
], JobWorkerOrchestrator);
|
|
2602
2620
|
var JobWorkerModule = class {
|
|
2603
2621
|
static forRoot(opts) {
|