@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
|
@@ -16,11 +16,15 @@ import { Module } from "@nestjs/common";
|
|
|
16
16
|
// runtime/constants/tokens.ts
|
|
17
17
|
var DRIZZLE = "DRIZZLE";
|
|
18
18
|
|
|
19
|
+
// runtime/subsystems/token-key.ts
|
|
20
|
+
var PKG = "@pattern-stack/codegen";
|
|
21
|
+
var tokenKey = (area, name) => `${PKG}.${area}.${name}`;
|
|
22
|
+
|
|
19
23
|
// runtime/subsystems/jobs/jobs-domain.tokens.ts
|
|
20
|
-
var JOB_ORCHESTRATOR =
|
|
21
|
-
var JOB_RUN_SERVICE =
|
|
22
|
-
var JOB_STEP_SERVICE =
|
|
23
|
-
var JOBS_MULTI_TENANT =
|
|
24
|
+
var JOB_ORCHESTRATOR = Symbol.for(tokenKey("jobs", "orchestrator"));
|
|
25
|
+
var JOB_RUN_SERVICE = Symbol.for(tokenKey("jobs", "run-service"));
|
|
26
|
+
var JOB_STEP_SERVICE = Symbol.for(tokenKey("jobs", "step-service"));
|
|
27
|
+
var JOBS_MULTI_TENANT = Symbol.for(tokenKey("jobs", "multi-tenant"));
|
|
24
28
|
|
|
25
29
|
// runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
|
|
26
30
|
import { randomUUID } from "crypto";
|
|
@@ -835,11 +839,13 @@ DrizzleJobStepService = __decorateClass([
|
|
|
835
839
|
], DrizzleJobStepService);
|
|
836
840
|
|
|
837
841
|
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
838
|
-
import { randomUUID as
|
|
839
|
-
import { Inject as
|
|
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";
|
|
840
845
|
|
|
841
846
|
// runtime/subsystems/jobs/job-handler.base.ts
|
|
842
847
|
var JOB_HANDLER_REGISTRY = /* @__PURE__ */ new Map();
|
|
848
|
+
var JOB_HANDLER_METADATA_KEY = Symbol.for(tokenKey("jobs", "handler-metadata"));
|
|
843
849
|
var HandlerRegistry;
|
|
844
850
|
((HandlerRegistry2) => {
|
|
845
851
|
function getAll() {
|
|
@@ -852,6 +858,124 @@ var HandlerRegistry;
|
|
|
852
858
|
HandlerRegistry2.get = get;
|
|
853
859
|
})(HandlerRegistry || (HandlerRegistry = {}));
|
|
854
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
|
+
|
|
855
979
|
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
856
980
|
var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
|
|
857
981
|
var TERMINAL_STATUSES2 = [
|
|
@@ -1023,7 +1147,7 @@ var MemoryJobOrchestrator = class {
|
|
|
1023
1147
|
}
|
|
1024
1148
|
}
|
|
1025
1149
|
}
|
|
1026
|
-
const newId =
|
|
1150
|
+
const newId = randomUUID3();
|
|
1027
1151
|
let rootRunId = newId;
|
|
1028
1152
|
if (opts.parentRunId) {
|
|
1029
1153
|
const parent = this.store.runs.get(opts.parentRunId);
|
|
@@ -1421,9 +1545,12 @@ var MemoryJobOrchestrator = class {
|
|
|
1421
1545
|
}
|
|
1422
1546
|
};
|
|
1423
1547
|
MemoryJobOrchestrator = __decorateClass([
|
|
1424
|
-
|
|
1425
|
-
__decorateParam(
|
|
1426
|
-
__decorateParam(
|
|
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))
|
|
1427
1554
|
], MemoryJobOrchestrator);
|
|
1428
1555
|
function classifyError(err, policy, currentAttempts) {
|
|
1429
1556
|
if (!policy) return "fail";
|
|
@@ -1457,7 +1584,7 @@ function serialiseError(err, attempt, retryable) {
|
|
|
1457
1584
|
}
|
|
1458
1585
|
|
|
1459
1586
|
// runtime/subsystems/jobs/job-run-service.memory-backend.ts
|
|
1460
|
-
import { Inject as
|
|
1587
|
+
import { Inject as Inject6, Injectable as Injectable6 } from "@nestjs/common";
|
|
1461
1588
|
var NON_TERMINAL_STATUSES2 = [
|
|
1462
1589
|
"pending",
|
|
1463
1590
|
"running",
|
|
@@ -1624,9 +1751,10 @@ var MemoryJobRunService = class {
|
|
|
1624
1751
|
}
|
|
1625
1752
|
};
|
|
1626
1753
|
MemoryJobRunService = __decorateClass([
|
|
1627
|
-
|
|
1628
|
-
__decorateParam(
|
|
1629
|
-
__decorateParam(
|
|
1754
|
+
Injectable6(),
|
|
1755
|
+
__decorateParam(0, Inject6(MemoryJobStore)),
|
|
1756
|
+
__decorateParam(1, Inject6(JOB_ORCHESTRATOR)),
|
|
1757
|
+
__decorateParam(2, Inject6(JOBS_MULTI_TENANT))
|
|
1630
1758
|
], MemoryJobRunService);
|
|
1631
1759
|
function compareBy(a, b, order) {
|
|
1632
1760
|
switch (order) {
|
|
@@ -1642,120 +1770,6 @@ function compareBy(a, b, order) {
|
|
|
1642
1770
|
}
|
|
1643
1771
|
}
|
|
1644
1772
|
|
|
1645
|
-
// runtime/subsystems/jobs/job-step-service.memory-backend.ts
|
|
1646
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
1647
|
-
import { Injectable as Injectable6 } from "@nestjs/common";
|
|
1648
|
-
var MemoryJobStepService = class {
|
|
1649
|
-
constructor(store) {
|
|
1650
|
-
this.store = store;
|
|
1651
|
-
}
|
|
1652
|
-
store;
|
|
1653
|
-
async findStep(runId, stepId) {
|
|
1654
|
-
const rows = this.store.steps.get(runId);
|
|
1655
|
-
if (!rows) return null;
|
|
1656
|
-
const match = rows.find(
|
|
1657
|
-
(r) => r.stepId === stepId && r.status === "completed"
|
|
1658
|
-
);
|
|
1659
|
-
return match ?? null;
|
|
1660
|
-
}
|
|
1661
|
-
async recordStep(input) {
|
|
1662
|
-
const rows = this.getOrCreateRows(input.jobRunId);
|
|
1663
|
-
const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
|
|
1664
|
-
const normalisedInput = input.input ?? null;
|
|
1665
|
-
const normalisedOutput = input.output ?? null;
|
|
1666
|
-
if (existingIdx >= 0) {
|
|
1667
|
-
const prev = rows[existingIdx];
|
|
1668
|
-
const next = {
|
|
1669
|
-
...prev,
|
|
1670
|
-
status: input.status,
|
|
1671
|
-
input: normalisedInput ?? prev.input,
|
|
1672
|
-
output: normalisedOutput ?? prev.output,
|
|
1673
|
-
error: input.error ?? prev.error,
|
|
1674
|
-
attempts: input.attempts ?? prev.attempts,
|
|
1675
|
-
startedAt: input.startedAt ?? prev.startedAt,
|
|
1676
|
-
finishedAt: input.finishedAt ?? prev.finishedAt
|
|
1677
|
-
};
|
|
1678
|
-
rows[existingIdx] = next;
|
|
1679
|
-
return next;
|
|
1680
|
-
}
|
|
1681
|
-
const seq = input.seq ?? this.nextSeq(rows);
|
|
1682
|
-
const row = {
|
|
1683
|
-
id: randomUUID3(),
|
|
1684
|
-
jobRunId: input.jobRunId,
|
|
1685
|
-
stepId: input.stepId,
|
|
1686
|
-
kind: input.kind,
|
|
1687
|
-
seq,
|
|
1688
|
-
status: input.status,
|
|
1689
|
-
input: normalisedInput,
|
|
1690
|
-
output: normalisedOutput,
|
|
1691
|
-
error: input.error ?? null,
|
|
1692
|
-
attempts: input.attempts ?? 0,
|
|
1693
|
-
startedAt: input.startedAt ?? null,
|
|
1694
|
-
finishedAt: input.finishedAt ?? null
|
|
1695
|
-
};
|
|
1696
|
-
rows.push(row);
|
|
1697
|
-
return row;
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* Replay helper — wipe every step row for a run. Mirrors the `scratch`
|
|
1701
|
-
* replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
|
|
1702
|
-
*/
|
|
1703
|
-
clearStepsForRun(runId) {
|
|
1704
|
-
this.store.steps.delete(runId);
|
|
1705
|
-
}
|
|
1706
|
-
/**
|
|
1707
|
-
* Remove every non-`completed` row for the run. Memoized (`completed`)
|
|
1708
|
-
* rows are preserved — this is the `last_checkpoint` / `last_step`
|
|
1709
|
-
* semantics the Drizzle backend implements via
|
|
1710
|
-
* `DELETE … WHERE status != 'completed'`. Both replay modes route here
|
|
1711
|
-
* (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
|
|
1712
|
-
*/
|
|
1713
|
-
clearIncompleteSteps(runId) {
|
|
1714
|
-
const rows = this.store.steps.get(runId);
|
|
1715
|
-
if (!rows) return;
|
|
1716
|
-
const kept = rows.filter((r) => r.status === "completed");
|
|
1717
|
-
if (kept.length === 0) {
|
|
1718
|
-
this.store.steps.delete(runId);
|
|
1719
|
-
} else {
|
|
1720
|
-
this.store.steps.set(runId, kept);
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
getOrCreateRows(runId) {
|
|
1724
|
-
let rows = this.store.steps.get(runId);
|
|
1725
|
-
if (!rows) {
|
|
1726
|
-
rows = [];
|
|
1727
|
-
this.store.steps.set(runId, rows);
|
|
1728
|
-
}
|
|
1729
|
-
return rows;
|
|
1730
|
-
}
|
|
1731
|
-
nextSeq(rows) {
|
|
1732
|
-
let max = 0;
|
|
1733
|
-
for (const r of rows) {
|
|
1734
|
-
if (r.seq > max) max = r.seq;
|
|
1735
|
-
}
|
|
1736
|
-
return max + 1;
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1739
|
-
MemoryJobStepService = __decorateClass([
|
|
1740
|
-
Injectable6()
|
|
1741
|
-
], MemoryJobStepService);
|
|
1742
|
-
|
|
1743
|
-
// runtime/subsystems/jobs/memory-job-store.ts
|
|
1744
|
-
var MemoryJobStore = class {
|
|
1745
|
-
/** Runs keyed by `id` (single source of truth for status/scope/lineage). */
|
|
1746
|
-
runs = /* @__PURE__ */ new Map();
|
|
1747
|
-
/** Steps keyed by `job_run_id`; array order matches insertion order. */
|
|
1748
|
-
steps = /* @__PURE__ */ new Map();
|
|
1749
|
-
/** Job definitions keyed by `type` — memory mirror of the `job` table. */
|
|
1750
|
-
jobs = /* @__PURE__ */ new Map();
|
|
1751
|
-
/** Reset everything. Tests call this in `beforeEach`. */
|
|
1752
|
-
clear() {
|
|
1753
|
-
this.runs.clear();
|
|
1754
|
-
this.steps.clear();
|
|
1755
|
-
this.jobs.clear();
|
|
1756
|
-
}
|
|
1757
|
-
};
|
|
1758
|
-
|
|
1759
1773
|
// runtime/subsystems/jobs/pool-config.loader.ts
|
|
1760
1774
|
import { existsSync, readFileSync } from "fs";
|
|
1761
1775
|
import { resolve } from "path";
|
|
@@ -1797,8 +1811,8 @@ var RESERVED_POOL_NAMES = new Set(
|
|
|
1797
1811
|
);
|
|
1798
1812
|
|
|
1799
1813
|
// runtime/subsystems/jobs/bullmq.config.ts
|
|
1800
|
-
var BULLMQ_CONNECTION =
|
|
1801
|
-
var BULLMQ_RESOLVED_CONFIG =
|
|
1814
|
+
var BULLMQ_CONNECTION = Symbol.for(tokenKey("jobs", "bullmq-connection"));
|
|
1815
|
+
var BULLMQ_RESOLVED_CONFIG = Symbol.for(tokenKey("jobs", "bullmq-resolved-config"));
|
|
1802
1816
|
var DEFAULT_REDIS_URL = "redis://localhost:6379";
|
|
1803
1817
|
var DEFAULT_BULL_BOARD_MOUNT = "/admin/queues";
|
|
1804
1818
|
function resolveBullMqConfig(ext) {
|