@pattern-stack/codegen 0.4.4 → 0.4.5
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/runtime/subsystems/index.d.ts +7 -0
- package/dist/runtime/subsystems/index.js +905 -208
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/observability/index.d.ts +10 -0
- package/dist/runtime/subsystems/observability/index.js +895 -0
- package/dist/runtime/subsystems/observability/index.js.map +1 -0
- package/dist/runtime/subsystems/observability/observability.drizzle-backend.d.ts +15 -0
- package/dist/runtime/subsystems/observability/observability.drizzle-backend.js +465 -0
- package/dist/runtime/subsystems/observability/observability.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/observability/observability.memory-backend.d.ts +28 -0
- package/dist/runtime/subsystems/observability/observability.memory-backend.js +75 -0
- package/dist/runtime/subsystems/observability/observability.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/observability/observability.module.d.ts +56 -0
- package/dist/runtime/subsystems/observability/observability.module.js +887 -0
- package/dist/runtime/subsystems/observability/observability.module.js.map +1 -0
- package/dist/runtime/subsystems/observability/observability.protocol.d.ts +155 -0
- package/dist/runtime/subsystems/observability/observability.protocol.js +1 -0
- package/dist/runtime/subsystems/observability/observability.protocol.js.map +1 -0
- package/dist/runtime/subsystems/observability/observability.tokens.d.ts +19 -0
- package/dist/runtime/subsystems/observability/observability.tokens.js +8 -0
- package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -0
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +79 -0
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js +425 -0
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -0
- package/dist/runtime/subsystems/sync/sync-audit.schema.d.ts +4 -4
- package/package.json +6 -1
- package/runtime/subsystems/index.ts +23 -0
- package/runtime/subsystems/observability/index.ts +35 -0
- package/runtime/subsystems/observability/observability.drizzle-backend.ts +223 -0
- package/runtime/subsystems/observability/observability.memory-backend.ts +111 -0
- package/runtime/subsystems/observability/observability.module.ts +115 -0
- package/runtime/subsystems/observability/observability.protocol.ts +167 -0
- package/runtime/subsystems/observability/observability.tokens.ts +18 -0
- package/runtime/subsystems/observability/reporters/bridge-metrics.reporter.ts +222 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../runtime/subsystems/observability/observability.memory-backend.ts"],"sourcesContent":["/**\n * MemoryObservabilityService — in-memory test backend for\n * IObservabilityService.\n *\n * Stores snapshot data set by the test harness and returns it verbatim.\n * This is deliberately NOT a replay-from-events simulator — the point of\n * the memory backend is to let tests assert \"when the subsystem returns\n * X, does the caller render Y correctly?\" without standing up Postgres.\n *\n * Tests populate the backend via the `seed*` methods, then exercise the\n * protocol reads. Each seed method replaces (not merges) its slice, which\n * keeps the mental model simple: the backend is a fixture holder.\n *\n * No lifecycle hooks (no background work to manage).\n */\nimport { Injectable } from '@nestjs/common';\nimport type {\n CursorSnapshot,\n IObservabilityService,\n JobRunFailure,\n PoolDepth,\n StatusHistogram,\n SyncRunSummary,\n} from './observability.protocol';\n\n@Injectable()\nexport class MemoryObservabilityService implements IObservabilityService {\n private pools: PoolDepth[] = [];\n private syncRuns: SyncRunSummary[] = [];\n private bridgeHistogram: StatusHistogram = {};\n private failedJobs: JobRunFailure[] = [];\n private cursors: CursorSnapshot[] = [];\n\n // ─── Core contract ─────────────────────────────────────────────────────\n\n async getPoolDepths(): Promise<PoolDepth[]> {\n return [...this.pools];\n }\n\n async getRecentSyncRuns(\n limit: number,\n integrationId?: string,\n ): Promise<SyncRunSummary[]> {\n const filtered =\n integrationId !== undefined\n ? this.syncRuns.filter((r) => r.integrationId === integrationId)\n : this.syncRuns;\n return filtered\n .slice()\n .sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime())\n .slice(0, limit);\n }\n\n async getBridgeDeliveryHistogram(\n _windowHours: number,\n ): Promise<StatusHistogram> {\n // Memory backend ignores the window — tests that care about windowing\n // should seed the histogram for the window they're simulating.\n return { ...this.bridgeHistogram };\n }\n\n async getRecentFailedJobs(limit: number): Promise<JobRunFailure[]> {\n return this.failedJobs\n .slice()\n .sort(\n (a, b) =>\n (b.finishedAt?.getTime() ?? 0) - (a.finishedAt?.getTime() ?? 0),\n )\n .slice(0, limit);\n }\n\n async getCursors(): Promise<CursorSnapshot[]> {\n return [...this.cursors];\n }\n\n // ─── Test seams ────────────────────────────────────────────────────────\n\n /** Replace the pool-depth slice. */\n seedPools(pools: PoolDepth[]): void {\n this.pools = [...pools];\n }\n\n /** Replace the sync-run slice. */\n seedSyncRuns(runs: SyncRunSummary[]): void {\n this.syncRuns = [...runs];\n }\n\n /** Replace the bridge-delivery histogram. */\n seedBridgeHistogram(hist: StatusHistogram): void {\n this.bridgeHistogram = { ...hist };\n }\n\n /** Replace the failed-jobs slice. */\n seedFailedJobs(jobs: JobRunFailure[]): void {\n this.failedJobs = [...jobs];\n }\n\n /** Replace the cursor slice. */\n seedCursors(cursors: CursorSnapshot[]): void {\n this.cursors = [...cursors];\n }\n\n /** Reset every slice — for afterEach hooks. */\n reset(): void {\n this.pools = [];\n this.syncRuns = [];\n this.bridgeHistogram = {};\n this.failedJobs = [];\n this.cursors = [];\n }\n}\n"],"mappings":";;;;;;;;;;;;AAeA,SAAS,kBAAkB;AAWpB,IAAM,6BAAN,MAAkE;AAAA,EAC/D,QAAqB,CAAC;AAAA,EACtB,WAA6B,CAAC;AAAA,EAC9B,kBAAmC,CAAC;AAAA,EACpC,aAA8B,CAAC;AAAA,EAC/B,UAA4B,CAAC;AAAA;AAAA,EAIrC,MAAM,gBAAsC;AAC1C,WAAO,CAAC,GAAG,KAAK,KAAK;AAAA,EACvB;AAAA,EAEA,MAAM,kBACJ,OACA,eAC2B;AAC3B,UAAM,WACJ,kBAAkB,SACd,KAAK,SAAS,OAAO,CAAC,MAAM,EAAE,kBAAkB,aAAa,IAC7D,KAAK;AACX,WAAO,SACJ,MAAM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ability
|
|
5
|
+
* subsystem (ADR-008, 5th subsystem).
|
|
6
|
+
*
|
|
7
|
+
* Usage in AppModule:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* ObservabilityModule.forRoot({
|
|
10
|
+
* backend: 'drizzle',
|
|
11
|
+
* reporters: { bridgeMetrics: true }, // optional — requires bridge subsystem
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Usage in tests:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* ObservabilityModule.forRoot({ backend: 'memory' })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* `global: true` means any module that needs `IObservabilityService` can
|
|
21
|
+
* inject `OBSERVABILITY` without importing this module. Register once in
|
|
22
|
+
* AppModule.
|
|
23
|
+
*
|
|
24
|
+
* The drizzle backend requires `DRIZZLE` to be provided globally (e.g.,
|
|
25
|
+
* via DatabaseModule). The memory backend has no dependencies.
|
|
26
|
+
*
|
|
27
|
+
* # Reporters
|
|
28
|
+
*
|
|
29
|
+
* Reporters are orthogonal to backends — they compose on top of either
|
|
30
|
+
* drizzle or memory. The `reporters.bridgeMetrics` flag enables the
|
|
31
|
+
* `BridgeMetricsReporter` sampler. Gated because the reporter imports the
|
|
32
|
+
* bridge + events schemas; consumers without the bridge subsystem should
|
|
33
|
+
* leave it off (the default).
|
|
34
|
+
*
|
|
35
|
+
* `ScheduleModule.forRoot()` is imported conditionally — only when a
|
|
36
|
+
* reporter that needs it is enabled. Keeps the module dependency-light
|
|
37
|
+
* for consumers that only want the read surface.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface ObservabilityReporterOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Register `BridgeMetricsReporter` — periodic log sampler over
|
|
43
|
+
* `bridge_delivery`. Requires the bridge subsystem (schemas imported
|
|
44
|
+
* transitively). Defaults to `false`.
|
|
45
|
+
*/
|
|
46
|
+
bridgeMetrics?: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface ObservabilityModuleOptions {
|
|
49
|
+
backend: 'drizzle' | 'memory';
|
|
50
|
+
reporters?: ObservabilityReporterOptions;
|
|
51
|
+
}
|
|
52
|
+
declare class ObservabilityModule {
|
|
53
|
+
static forRoot(options?: ObservabilityModuleOptions): DynamicModule;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ObservabilityModule, type ObservabilityModuleOptions, type ObservabilityReporterOptions };
|