@pattern-stack/codegen 0.9.0 → 0.9.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.
- package/dist/{job-orchestrator.protocol-BwsBd37o.d.ts → job-orchestrator.protocol-CHOEqBDk.d.ts} +36 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.d.ts +2 -2
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.module.d.ts +2 -1
- package/dist/runtime/subsystems/bridge/bridge.module.js +3 -0
- package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
- package/dist/runtime/subsystems/bridge/event-flow.service.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/index.d.ts +1 -1
- package/dist/runtime/subsystems/bridge/index.js +3 -0
- package/dist/runtime/subsystems/bridge/index.js.map +1 -1
- package/dist/runtime/subsystems/index.d.ts +2 -2
- package/dist/runtime/subsystems/index.js +3 -0
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/index.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/index.js +3 -0
- package/dist/runtime/subsystems/jobs/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.protocol.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js +3 -0
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +3 -0
- 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 +2 -1
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +3 -0
- 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 +11 -2
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.d.ts +2 -1
- package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +3 -2
- package/dist/runtime/subsystems/jobs/job-worker.module.js +3 -0
- package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +3 -0
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-errors.d.ts +2 -1
- package/dist/runtime/subsystems/observability/index.d.ts +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/reporters/bridge-metrics.reporter.d.ts +2 -2
- package/dist/runtime/subsystems/observability/reporters/index.d.ts +2 -2
- package/package.json +5 -1
- package/runtime/subsystems/jobs/job-handler.base.ts +36 -0
- package/runtime/subsystems/jobs/job-run-keyset-cursor.ts +3 -0
- package/runtime/subsystems/jobs/job-run-service.protocol.ts +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as JobRun } from '../../../job-orchestrator.protocol-
|
|
1
|
+
import { i as JobRun } from '../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
2
2
|
import '../events/event-bus.protocol.js';
|
|
3
3
|
import '../../types/drizzle.js';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
@@ -6,6 +6,7 @@ import './job-orchestration.schema.js';
|
|
|
6
6
|
import 'drizzle-orm/pg-core';
|
|
7
7
|
import 'drizzle-orm';
|
|
8
8
|
import '@nestjs/common';
|
|
9
|
+
import '../events/generated/types.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Typed errors for the job orchestration domain (ADR-022, JOB-3).
|
|
@@ -12,7 +12,7 @@ import '@nestjs/common';
|
|
|
12
12
|
import '../events/event-bus.protocol.js';
|
|
13
13
|
import '../../types/drizzle.js';
|
|
14
14
|
import 'drizzle-orm/node-postgres';
|
|
15
|
-
import '../../../job-orchestrator.protocol-
|
|
15
|
+
import '../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
16
16
|
import '../jobs/job-orchestration.schema.js';
|
|
17
17
|
import 'drizzle-orm/pg-core';
|
|
18
18
|
import 'drizzle-orm';
|
|
@@ -3,7 +3,7 @@ import { ListEventsQuery, EventPage, EventSummary } from '../events/event-read.p
|
|
|
3
3
|
import { StatusHistogram } from '../bridge/bridge.protocol.js';
|
|
4
4
|
import { SyncRunSummary } from '../sync/sync-run-recorder.protocol.js';
|
|
5
5
|
import { CursorSnapshot } from '../sync/sync-cursor-store.protocol.js';
|
|
6
|
-
import '../../../job-orchestrator.protocol-
|
|
6
|
+
import '../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
7
7
|
import '../events/event-bus.protocol.js';
|
|
8
8
|
import '../../types/drizzle.js';
|
|
9
9
|
import 'drizzle-orm/node-postgres';
|
|
@@ -4,7 +4,7 @@ import { IJobBridge, StatusHistogram } from '../bridge/bridge.protocol.js';
|
|
|
4
4
|
import { ISyncRunRecorder, SyncRunSummary } from '../sync/sync-run-recorder.protocol.js';
|
|
5
5
|
import { ICursorStore, CursorSnapshot } from '../sync/sync-cursor-store.protocol.js';
|
|
6
6
|
import { IObservability, CorrelationTimeline } from './observability.protocol.js';
|
|
7
|
-
import '../../../job-orchestrator.protocol-
|
|
7
|
+
import '../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
8
8
|
import '../events/event-bus.protocol.js';
|
|
9
9
|
import '../../types/drizzle.js';
|
|
10
10
|
import 'drizzle-orm/node-postgres';
|
|
@@ -2,16 +2,16 @@ import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
|
2
2
|
import { IObservability } from '../observability.protocol.js';
|
|
3
3
|
import { ObservabilityModuleOptions } from '../observability.module.js';
|
|
4
4
|
import '../../jobs/job-run-service.protocol.js';
|
|
5
|
-
import '../../../../job-orchestrator.protocol-
|
|
5
|
+
import '../../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
6
6
|
import '../../events/event-bus.protocol.js';
|
|
7
7
|
import '../../../types/drizzle.js';
|
|
8
8
|
import 'drizzle-orm/node-postgres';
|
|
9
9
|
import '../../jobs/job-orchestration.schema.js';
|
|
10
10
|
import 'drizzle-orm/pg-core';
|
|
11
11
|
import 'drizzle-orm';
|
|
12
|
+
import '../../events/generated/types.js';
|
|
12
13
|
import '../../events/event-read.protocol.js';
|
|
13
14
|
import '../../bridge/bridge.protocol.js';
|
|
14
|
-
import '../../events/generated/types.js';
|
|
15
15
|
import '../../bridge/bridge-delivery.schema.js';
|
|
16
16
|
import '../../sync/sync-run-recorder.protocol.js';
|
|
17
17
|
import '../../sync/sync-field-diff.protocol.js';
|
|
@@ -2,16 +2,16 @@ export { BridgeMetricsReporter } from './bridge-metrics.reporter.js';
|
|
|
2
2
|
import '@nestjs/common';
|
|
3
3
|
import '../observability.protocol.js';
|
|
4
4
|
import '../../jobs/job-run-service.protocol.js';
|
|
5
|
-
import '../../../../job-orchestrator.protocol-
|
|
5
|
+
import '../../../../job-orchestrator.protocol-CHOEqBDk.js';
|
|
6
6
|
import '../../events/event-bus.protocol.js';
|
|
7
7
|
import '../../../types/drizzle.js';
|
|
8
8
|
import 'drizzle-orm/node-postgres';
|
|
9
9
|
import '../../jobs/job-orchestration.schema.js';
|
|
10
10
|
import 'drizzle-orm/pg-core';
|
|
11
11
|
import 'drizzle-orm';
|
|
12
|
+
import '../../events/generated/types.js';
|
|
12
13
|
import '../../events/event-read.protocol.js';
|
|
13
14
|
import '../../bridge/bridge.protocol.js';
|
|
14
|
-
import '../../events/generated/types.js';
|
|
15
15
|
import '../../bridge/bridge-delivery.schema.js';
|
|
16
16
|
import '../../sync/sync-run-recorder.protocol.js';
|
|
17
17
|
import '../../sync/sync-field-diff.protocol.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pattern-stack/codegen",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Entity-driven code generation for full-stack TypeScript applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -131,9 +131,11 @@
|
|
|
131
131
|
"@nestjs/core": "10",
|
|
132
132
|
"@nestjs/schedule": "^4.0.0",
|
|
133
133
|
"@nestjs/testing": "^10",
|
|
134
|
+
"@testcontainers/postgresql": "^12.0.0",
|
|
134
135
|
"@types/bun": "latest",
|
|
135
136
|
"@types/ejs": "^3.1.5",
|
|
136
137
|
"@types/node": "^25.6.0",
|
|
138
|
+
"@types/pg": "^8.20.0",
|
|
137
139
|
"@types/pluralize": "^0.0.33",
|
|
138
140
|
"bullmq": "^5.0.0",
|
|
139
141
|
"class-transformer": "^0.5.1",
|
|
@@ -141,8 +143,10 @@
|
|
|
141
143
|
"ejs": "^5.0.2",
|
|
142
144
|
"hygen": "^6.2.11",
|
|
143
145
|
"ioredis": "^5.3.0",
|
|
146
|
+
"pg": "^8.21.0",
|
|
144
147
|
"reflect-metadata": "^0.2.2",
|
|
145
148
|
"rxjs": "^7.8.2",
|
|
149
|
+
"testcontainers": "^12.0.0",
|
|
146
150
|
"tsup": "^8.5.1"
|
|
147
151
|
},
|
|
148
152
|
"directories": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
// TODO(logging-subsystem): swap to ILogger once ADR-028 lands
|
|
18
18
|
import type { Logger } from '@nestjs/common';
|
|
19
|
+
import type { EventOfType, EventTypeName } from '../events/generated/types';
|
|
19
20
|
import type { JobRun } from './job-orchestrator.protocol';
|
|
20
21
|
|
|
21
22
|
// ─── ParentClosePolicy ──────────────────────────────────────────────────────
|
|
@@ -60,6 +61,35 @@ export interface ScopeRef<TInput, TScope extends string = string> {
|
|
|
60
61
|
from: (input: TInput) => string;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Bridge trigger authoring shape (BRIDGE-6 follow-up — BRIDGE-6 shipped the
|
|
66
|
+
* generator + runtime for `@JobHandler({ triggers })` but never added the
|
|
67
|
+
* authoring field to this type; the generator's tests scan source as strings,
|
|
68
|
+
* so a real decorator was never compiled and the gap went uncaught).
|
|
69
|
+
*
|
|
70
|
+
* Declared on `@JobHandler({ triggers })`; the codegen bridge-registry
|
|
71
|
+
* generator (`src/cli/shared/bridge-registry-generator.ts`) scans these from
|
|
72
|
+
* source and emits `bridge/generated/registry.ts`, validating each `event`
|
|
73
|
+
* against the generated `eventRegistry` at `gen-all`. The distributed union
|
|
74
|
+
* narrows `map`/`when` per `event`, so callbacks are typed against the event
|
|
75
|
+
* payload (ADR-023, "typed against PayloadOfType<T>").
|
|
76
|
+
*
|
|
77
|
+
* Typed against events' generated types — the same `import type` coupling the
|
|
78
|
+
* bridge already has (erased at runtime). `jobs` must NOT import `bridge`, so
|
|
79
|
+
* the post-gen `BridgeTriggerEntry` is deliberately not referenced here;
|
|
80
|
+
* `triggerId`/`jobType` are computed by the generator, not authored.
|
|
81
|
+
*/
|
|
82
|
+
export type JobTrigger<TInput> = {
|
|
83
|
+
[T in EventTypeName]: {
|
|
84
|
+
/** Event type that fires this trigger. Validated against `eventRegistry`. */
|
|
85
|
+
event: T;
|
|
86
|
+
/** Maps the event to the job input. Inlined verbatim into the registry. */
|
|
87
|
+
map: (event: EventOfType<T>) => TInput;
|
|
88
|
+
/** Optional guard; `false` → wrapper records `status='skipped'`. */
|
|
89
|
+
when?: (event: EventOfType<T>) => boolean;
|
|
90
|
+
};
|
|
91
|
+
}[EventTypeName];
|
|
92
|
+
|
|
63
93
|
export interface JobHandlerMeta<TInput> {
|
|
64
94
|
pool?: string;
|
|
65
95
|
scope?: ScopeRef<TInput>;
|
|
@@ -68,6 +98,12 @@ export interface JobHandlerMeta<TInput> {
|
|
|
68
98
|
dedupe?: DedupePolicy<TInput>;
|
|
69
99
|
timeoutMs?: number;
|
|
70
100
|
replayFrom?: 'scratch' | 'last_step' | 'last_checkpoint';
|
|
101
|
+
/**
|
|
102
|
+
* Bridge triggers (ADR-023 Tier 3). Codegen scans these into `bridgeRegistry`;
|
|
103
|
+
* the framework `BridgeDeliveryHandler` starts this job per matched event.
|
|
104
|
+
* Absent for jobs started directly or via `IEventFlow.publishAndStart`.
|
|
105
|
+
*/
|
|
106
|
+
triggers?: readonly JobTrigger<TInput>[];
|
|
71
107
|
}
|
|
72
108
|
|
|
73
109
|
// ─── Runtime option shapes ──────────────────────────────────────────────────
|
|
@@ -72,6 +72,9 @@ export function toJobRunSummary(r: JobRunRow): JobRunSummary {
|
|
|
72
72
|
return {
|
|
73
73
|
runId: r.id,
|
|
74
74
|
rootRunId: r.rootRunId,
|
|
75
|
+
parentRunId: r.parentRunId,
|
|
76
|
+
triggerSource: r.triggerSource,
|
|
77
|
+
triggerRef: r.triggerRef,
|
|
75
78
|
jobType: r.jobType,
|
|
76
79
|
pool: r.pool,
|
|
77
80
|
status: r.status,
|
|
@@ -95,11 +95,19 @@ export interface ListJobRunsQuery {
|
|
|
95
95
|
/**
|
|
96
96
|
* Summary row for the `job_run` list (OBS-LIST-1). A narrow projection over
|
|
97
97
|
* `JobRun` carrying the columns a runs viewer renders. `rootRunId` is
|
|
98
|
-
* included so the correlation timeline can stitch runs to events
|
|
98
|
+
* included so the correlation timeline can stitch runs to events; the
|
|
99
|
+
* lineage fields (`parentRunId`, `triggerSource`, `triggerRef`) let a viewer
|
|
100
|
+
* render the run tree and explain why each run was started without a second
|
|
101
|
+
* fetch. `triggerSource` is non-null (the column is `NOT NULL`); the literal
|
|
102
|
+
* union mirrors `job_trigger_source` — `JobRun['triggerSource']` is optional
|
|
103
|
+
* and would admit `undefined`, which this projection never produces.
|
|
99
104
|
*/
|
|
100
105
|
export interface JobRunSummary {
|
|
101
106
|
runId: string;
|
|
102
107
|
rootRunId: string;
|
|
108
|
+
parentRunId: string | null;
|
|
109
|
+
triggerSource: 'manual' | 'schedule' | 'event' | 'parent';
|
|
110
|
+
triggerRef: string | null;
|
|
103
111
|
jobType: string;
|
|
104
112
|
pool: string;
|
|
105
113
|
status: JobRun['status'];
|