@zodmire/core 0.1.0

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/mod.d.mts ADDED
@@ -0,0 +1,812 @@
1
+ import { a as contextArtifactOwnership, c as mergeGeneratedArtifacts, d as sliceArtifactOwnership, f as withArtifactOwnership, i as applyOwnershipIfMissing, l as resolveArtifactOwnership, n as GeneratedArtifact, o as createGeneratedArtifact, r as OwnershipScope, s as inferArtifactOwnership, t as ArtifactOwnership, u as sharedArtifactOwnership } from "./artifacts-QqCpfT50.mjs";
2
+ import { MaterializationScope } from "./materialize.mjs";
3
+ import { CodegenMeta, CommandEffect, CompositionConfig, ComputedFieldSpec, ContextConfig, FilterOperator, InvariantRule, ProjectionRebuildMeta, ProjectionSourceMeta, ProjectionSubscriptionMeta, ReadModelIndexMeta, ReadModelUniqueConstraintMeta } from "@zodmire/config";
4
+
5
+ //#region packages/core/naming.d.ts
6
+ declare function buildArtifactPath(root: string, context: string, file: string): string;
7
+ declare function wordsFromName(value: string): string[];
8
+ declare function pascalCase(value: string): string;
9
+ declare function camelCase(value: string): string;
10
+ declare function kebabCase(value: string): string;
11
+ declare function snakeCase(str: string): string;
12
+ declare function snakeUpperCase(value: string): string;
13
+ /** Alias for snakeUpperCase — UPPER_SNAKE_CASE conversion. */
14
+ declare const toUpperSnakeCase: typeof snakeUpperCase;
15
+ declare function normalizeModulePath(modulePath: string): string;
16
+ declare function contractFileName(schemaRef: string): string;
17
+ declare function repositoryPortFileName(portName: string): string;
18
+ declare function repositoryPortTypeName(portName: string): string;
19
+ //#endregion
20
+ //#region packages/core/init.d.ts
21
+ /** Describes a vendored file: output name and its source path relative to repo root. */
22
+ interface VendoredFileEntry {
23
+ outputName: string;
24
+ sourceRelativePath: string;
25
+ }
26
+ /** The manifest of config files to vendor into end-user projects. */
27
+ declare const VENDORED_FILE_MANIFEST: readonly VendoredFileEntry[];
28
+ /** Rewrite Deno-style `npm:zod@*` imports to bare `"zod"` for end-user consumption. */
29
+ declare function rewriteImports(content: string): string;
30
+ /** Apply import rewriting and prepend a version header. */
31
+ declare function prepareVendoredFile(content: string, generatorVersion: string): string;
32
+ /** A resolved vendored file ready for persistence or disk write. */
33
+ interface PreparedVendoredFile {
34
+ outputName: string;
35
+ content: string;
36
+ }
37
+ /**
38
+ * Prepare all vendored files from pre-read source contents.
39
+ * @param sourceContents Map from `sourceRelativePath` to raw file content.
40
+ * @param generatorVersion Version string stamped into the file header.
41
+ */
42
+ declare function prepareAllVendoredFiles(sourceContents: ReadonlyMap<string, string>, generatorVersion: string): PreparedVendoredFile[];
43
+ //#endregion
44
+ //#region packages/core/tree_helpers.d.ts
45
+ type NormalizedEntityWithChildren = {
46
+ name: string;
47
+ collectionFieldName: string;
48
+ fields: {
49
+ name: string;
50
+ type: string;
51
+ optional: boolean;
52
+ array: boolean;
53
+ }[];
54
+ idField: string;
55
+ idType: string;
56
+ tableName: string;
57
+ children: NormalizedEntityWithChildren[];
58
+ rehydrationStateName?: string;
59
+ persistenceStateName?: string;
60
+ };
61
+ type NormalizedAggregateWithChildren = {
62
+ name: string;
63
+ fields: {
64
+ name: string;
65
+ type: string;
66
+ optional: boolean;
67
+ array: boolean;
68
+ }[];
69
+ idField: string;
70
+ idType: string;
71
+ tableName: string;
72
+ invariants: any[];
73
+ children: NormalizedEntityWithChildren[];
74
+ };
75
+ type EntityVisitor = (entity: NormalizedEntityWithChildren, context: {
76
+ depth: number;
77
+ parent: NormalizedAggregateWithChildren | NormalizedEntityWithChildren;
78
+ parentField: string;
79
+ path: string[];
80
+ }) => void;
81
+ declare function flattenEntities(aggregate: NormalizedAggregateWithChildren): NormalizedEntityWithChildren[];
82
+ declare function walkEntityTree(aggregate: NormalizedAggregateWithChildren, visitor: EntityVisitor): void;
83
+ //#endregion
84
+ //#region packages/core/schema_pipeline.d.ts
85
+ type IntrospectedField = {
86
+ name: string;
87
+ type: string;
88
+ optional: boolean;
89
+ array: boolean;
90
+ nestedFields?: IntrospectedField[];
91
+ columnType?: string;
92
+ };
93
+ type SchemaReadResult = {
94
+ aggregates: Array<{
95
+ name: string;
96
+ fields: IntrospectedField[];
97
+ idField: string;
98
+ idType: string;
99
+ tableName: string;
100
+ invariants: InvariantRule[];
101
+ children: NormalizedEntityWithChildren[];
102
+ }>;
103
+ entities: Array<{
104
+ name: string;
105
+ fields: IntrospectedField[];
106
+ idField: string;
107
+ idType: string;
108
+ tableName: string;
109
+ }>;
110
+ valueObjects: Array<{
111
+ name: string;
112
+ fields: IntrospectedField[];
113
+ declaredInFile?: string;
114
+ }>;
115
+ commands: Array<{
116
+ name: string;
117
+ inputFields: IntrospectedField[];
118
+ targetAggregate: string;
119
+ commandKind: "create" | "update";
120
+ lifecycle?: "create" | "mutate";
121
+ loadBy?: string;
122
+ preconditions: string[];
123
+ emits: string[];
124
+ effects: CommandEffect[];
125
+ }>;
126
+ queries: Array<{
127
+ name: string;
128
+ inputFields?: IntrospectedField[];
129
+ outputFields: IntrospectedField[];
130
+ outputSchemaPath: string;
131
+ outputSchemaExportName: string;
132
+ targetAggregate?: string;
133
+ readModelName?: string;
134
+ queryKind: "findById" | "list";
135
+ pagination?: {
136
+ style: "offset" | "cursor";
137
+ };
138
+ filters?: Record<string, FilterOperator[]>;
139
+ sorting?: {
140
+ sortableFields: string[];
141
+ defaultSort: {
142
+ field: string;
143
+ direction: "asc" | "desc";
144
+ };
145
+ };
146
+ computedFields?: Record<string, ComputedFieldSpec>;
147
+ }>;
148
+ readModels: Array<{
149
+ name: string;
150
+ fields: IntrospectedField[];
151
+ schemaPath: string;
152
+ schemaExportName: string;
153
+ ownerContext: string;
154
+ ownerAggregate: string;
155
+ tableName: string;
156
+ primaryKey: string[];
157
+ indexes: ReadModelIndexMeta[];
158
+ uniqueConstraints: ReadModelUniqueConstraintMeta[];
159
+ servesQueries?: string[];
160
+ }>;
161
+ projections: Array<{
162
+ name: string;
163
+ readModelName: string;
164
+ sources: ProjectionSourceMeta[];
165
+ rebuild?: ProjectionRebuildMeta;
166
+ subscription?: ProjectionSubscriptionMeta;
167
+ schemaPath: string;
168
+ schemaExportName: string;
169
+ }>;
170
+ domainEvents: Array<{
171
+ name: string;
172
+ fields: IntrospectedField[];
173
+ }>;
174
+ };
175
+ type CodegenRegistry = {
176
+ get(schema: unknown): CodegenMeta | undefined;
177
+ };
178
+ declare function unwrapFieldType(schema: unknown): {
179
+ type: string;
180
+ optional: boolean;
181
+ array: boolean;
182
+ };
183
+ declare function introspectObjectShape(schema: unknown, registry: CodegenRegistry, exportName?: string): IntrospectedField[];
184
+ declare function isRegisteredEntity(schema: unknown, registry: CodegenRegistry): boolean;
185
+ declare function introspectSchema(schema: unknown, registry: CodegenRegistry, exportName?: string): {
186
+ fields: IntrospectedField[];
187
+ children: NormalizedEntityWithChildren[];
188
+ };
189
+ declare function readSchemaFile(filePath: string, registry: CodegenRegistry): Promise<SchemaReadResult>;
190
+ declare function mergeSchemaReadResults(results: SchemaReadResult[]): SchemaReadResult;
191
+ //#endregion
192
+ //#region packages/core/normalizer.d.ts
193
+ type DomainErrorDef = {
194
+ invariantName: string;
195
+ errorTypeName: string;
196
+ factoryName: string;
197
+ defaultMessage: string;
198
+ };
199
+ type ApplicationErrorDef = {
200
+ errorTypeName: string;
201
+ factoryName: string;
202
+ aggregateName: string;
203
+ };
204
+ type NormalizedAggregate = {
205
+ name: string;
206
+ fields: IntrospectedField[];
207
+ idField: string;
208
+ idType: string;
209
+ tableName: string;
210
+ invariants: InvariantRule[];
211
+ children: NormalizedEntityWithChildren[];
212
+ domainErrors: DomainErrorDef[];
213
+ applicationErrors: ApplicationErrorDef[];
214
+ rehydrationStateName: string;
215
+ persistenceStateName: string;
216
+ };
217
+ type NormalizedCommand = {
218
+ name: string;
219
+ inputFields: IntrospectedField[];
220
+ targetAggregate: string;
221
+ commandKind: "create" | "update";
222
+ lifecycle: "create" | "mutate";
223
+ loadBy?: string;
224
+ preconditions: string[];
225
+ emits: string[];
226
+ effects: CommandEffect[];
227
+ };
228
+ type NormalizedComputedField = {
229
+ kind: "builtin";
230
+ fn: "count" | "exists";
231
+ childTableName: string;
232
+ childFkColumn: string;
233
+ outputFieldType: "number" | "boolean";
234
+ } | {
235
+ kind: "builtin";
236
+ fn: "sum";
237
+ childTableName: string;
238
+ childFkColumn: string;
239
+ childFieldColumn: string;
240
+ outputFieldType: "number";
241
+ };
242
+ type NormalizedQueryReadSide = {
243
+ readModelName: string;
244
+ searchFields: string[];
245
+ pagination?: {
246
+ style: "offset";
247
+ };
248
+ filters?: Record<string, FilterOperator[]>;
249
+ sorting?: {
250
+ sortableFields: string[];
251
+ defaultSort: {
252
+ field: string;
253
+ direction: "asc" | "desc";
254
+ };
255
+ };
256
+ };
257
+ type NormalizedFindByIdQuery = {
258
+ queryKind: "findById";
259
+ name: string;
260
+ targetAggregate: string;
261
+ inputFields: IntrospectedField[];
262
+ outputFields: IntrospectedField[];
263
+ outputSchemaPath: string;
264
+ outputSchemaExportName: string;
265
+ readModelName?: string;
266
+ readSide: NormalizedQueryReadSide;
267
+ };
268
+ type NormalizedListQuery = {
269
+ queryKind: "list";
270
+ name: string;
271
+ targetAggregate: string;
272
+ inputFields: IntrospectedField[];
273
+ outputFields: IntrospectedField[];
274
+ outputSchemaPath: string;
275
+ outputSchemaExportName: string;
276
+ readModelName?: string;
277
+ readSide: NormalizedQueryReadSide;
278
+ pagination: {
279
+ style: "offset";
280
+ };
281
+ filters: Record<string, FilterOperator[]>;
282
+ sorting: {
283
+ sortableFields: string[];
284
+ defaultSort: {
285
+ field: string;
286
+ direction: "asc" | "desc";
287
+ };
288
+ };
289
+ computedFields: Record<string, NormalizedComputedField>;
290
+ };
291
+ type NormalizedQuery = NormalizedFindByIdQuery | NormalizedListQuery;
292
+ type NormalizedReadModel = {
293
+ name: string;
294
+ normalizedId: string;
295
+ logicalPathKey: string;
296
+ ownerContext: string;
297
+ ownerAggregate: string;
298
+ fields: IntrospectedField[];
299
+ schemaPath: string;
300
+ schemaExportName: string;
301
+ tableName: string;
302
+ primaryKey: string[];
303
+ indexes: SchemaReadResult["readModels"][number]["indexes"];
304
+ uniqueConstraints: SchemaReadResult["readModels"][number]["uniqueConstraints"];
305
+ servesQueries: string[];
306
+ };
307
+ type NormalizedProjectionSource = SchemaReadResult["projections"][number]["sources"][number] & {
308
+ locality: "local" | "external";
309
+ };
310
+ type NormalizedProjection = {
311
+ name: string;
312
+ normalizedId: string;
313
+ logicalPathKey: string;
314
+ readModelName: string;
315
+ ownerContext: string;
316
+ ownerAggregate: string;
317
+ mode: "event-driven";
318
+ rebuild: Exclude<SchemaReadResult["projections"][number]["rebuild"], undefined> | {
319
+ enabled: false;
320
+ };
321
+ subscription?: SchemaReadResult["projections"][number]["subscription"];
322
+ sources: NormalizedProjectionSource[];
323
+ };
324
+ type NormalizedDomainEvent = {
325
+ name: string;
326
+ fields: IntrospectedField[];
327
+ sourceAggregate: string;
328
+ };
329
+ type NormalizedEntity = NormalizedEntityWithChildren;
330
+ type NormalizedValueObject = {
331
+ name: string;
332
+ fields: IntrospectedField[];
333
+ declaredInFile: string;
334
+ };
335
+ type NormalizedSpec = {
336
+ context: {
337
+ name: string;
338
+ modulePath: string;
339
+ };
340
+ aggregate: NormalizedAggregate;
341
+ entities: NormalizedEntity[];
342
+ valueObjects: NormalizedValueObject[];
343
+ commands: NormalizedCommand[];
344
+ queries: NormalizedQuery[];
345
+ readModels: NormalizedReadModel[];
346
+ projections: NormalizedProjection[];
347
+ domainEvents: NormalizedDomainEvent[];
348
+ ports: ContextConfig["ports"];
349
+ adapters: ContextConfig["adapters"];
350
+ presentation: ContextConfig["presentation"];
351
+ materialization: ContextConfig["materialization"];
352
+ };
353
+ type ContextNormalizedSpec = {
354
+ context: {
355
+ name: string;
356
+ modulePath: string;
357
+ };
358
+ aggregates: NormalizedAggregate[];
359
+ commands: NormalizedCommand[];
360
+ queries: NormalizedQuery[];
361
+ readModels: NormalizedReadModel[];
362
+ projections: NormalizedProjection[];
363
+ domainEvents: NormalizedDomainEvent[];
364
+ entities: NormalizedEntity[];
365
+ valueObjects: NormalizedValueObject[];
366
+ ports: ContextConfig["ports"];
367
+ adapters: ContextConfig["adapters"];
368
+ acls: ContextConfig["acls"];
369
+ presentation: ContextConfig["presentation"];
370
+ materialization: ContextConfig["materialization"];
371
+ };
372
+ declare function buildContextNormalizedSpec(schemaResult: SchemaReadResult, config: ContextConfig): ContextNormalizedSpec;
373
+ declare function buildNormalizedSpec(schemaResult: SchemaReadResult, config: ContextConfig): NormalizedSpec;
374
+ //#endregion
375
+ //#region packages/core/composition_normalizer.d.ts
376
+ type ResolvedSubscription = {
377
+ targetContext: string;
378
+ targetModulePath: string;
379
+ action: string;
380
+ handlerName: string;
381
+ handlerFactoryName: string;
382
+ };
383
+ type ResolvedCrossContextEvent = {
384
+ eventType: string;
385
+ sourceContext: string;
386
+ sourceModulePath: string;
387
+ payloadSchema: unknown;
388
+ payloadTypeName: string;
389
+ subscriptions: ResolvedSubscription[];
390
+ };
391
+ type NormalizedAclMapping = {
392
+ targetPath: string;
393
+ kind: "from";
394
+ sourcePath: string;
395
+ } | {
396
+ targetPath: string;
397
+ kind: "const";
398
+ value: string | number | boolean | null;
399
+ };
400
+ type NormalizedAclSymbols = {
401
+ requestContractName: string;
402
+ responseContractName: string;
403
+ adapterName: string;
404
+ containerRegistrationToken: string;
405
+ };
406
+ type ResolvedPublishedBoundary<TProcedureKind extends "query" | "command"> = {
407
+ procedureName: string;
408
+ operationName: string;
409
+ kind: TProcedureKind;
410
+ };
411
+ type NormalizedReadAcl = {
412
+ kind: "read";
413
+ name: string;
414
+ port: string;
415
+ consumerContext: {
416
+ name: string;
417
+ modulePath: string;
418
+ };
419
+ sourceContext: {
420
+ name: string;
421
+ modulePath: string;
422
+ };
423
+ sourceBoundary: ResolvedPublishedBoundary<"query">;
424
+ sourceQuery: NormalizedQuery;
425
+ requestMappings: NormalizedAclMapping[];
426
+ responseMappings: NormalizedAclMapping[];
427
+ symbols: NormalizedAclSymbols;
428
+ };
429
+ type NormalizedWriteAcl = {
430
+ kind: "write" | "ack";
431
+ name: string;
432
+ port: string;
433
+ consumerContext: {
434
+ name: string;
435
+ modulePath: string;
436
+ };
437
+ targetContext: {
438
+ name: string;
439
+ modulePath: string;
440
+ };
441
+ targetBoundary: ResolvedPublishedBoundary<"command">;
442
+ targetCommand: NormalizedCommand;
443
+ requestMappings: NormalizedAclMapping[];
444
+ responseMappings: NormalizedAclMapping[];
445
+ acknowledgeMappings: NormalizedAclMapping[];
446
+ symbols: NormalizedAclSymbols;
447
+ };
448
+ type NormalizedCompositionAcl = NormalizedReadAcl | NormalizedWriteAcl;
449
+ type NormalizedCompositionSpec = {
450
+ name: string;
451
+ contexts: Array<{
452
+ name: string;
453
+ modulePath: string;
454
+ }>;
455
+ crossContextEvents: ResolvedCrossContextEvent[];
456
+ acls: NormalizedCompositionAcl[];
457
+ materialization: {
458
+ targetRoot: string;
459
+ };
460
+ };
461
+ declare function buildNormalizedCompositionSpec(config: CompositionConfig, contextSpecs: ContextNormalizedSpec[]): NormalizedCompositionSpec;
462
+ //#endregion
463
+ //#region packages/core/slicer.d.ts
464
+ type AggregateNormalizedSpecView = NormalizedSpec & {
465
+ /** VOs referenced by this aggregate but owned by another aggregate. Needed for import generation. */externalValueObjects: Array<{
466
+ name: string;
467
+ ownerAggregate: string;
468
+ }>;
469
+ };
470
+ declare function discoverReferencedVos(aggregate: NormalizedAggregate, contextSpec: ContextNormalizedSpec): Set<string>;
471
+ declare function resolveVoOwner(vo: NormalizedValueObject, contextSpec: ContextNormalizedSpec): string;
472
+ declare function collectOwnedValueObjects(aggregate: NormalizedAggregate, contextSpec: ContextNormalizedSpec): NormalizedValueObject[];
473
+ declare function sliceContextIntoAggregateViews(contextSpec: ContextNormalizedSpec): AggregateNormalizedSpecView[];
474
+ //#endregion
475
+ //#region packages/core/orchestrator.d.ts
476
+ declare function generateContextArtifacts(contextSpec: ContextNormalizedSpec): GeneratedArtifact[];
477
+ //#endregion
478
+ //#region packages/core/spec_artifact.d.ts
479
+ declare const SPEC_ARTIFACT_SCHEMA_VERSION = 1;
480
+ declare function serializeContextSpec(spec: ContextNormalizedSpec, generatorVersion: string): string;
481
+ declare function serializeCompositionSpec(spec: NormalizedCompositionSpec, generatorVersion: string): string;
482
+ //#endregion
483
+ //#region packages/core/spec_diff.d.ts
484
+ declare const SPEC_DIFF_SCHEMA_VERSION = 1;
485
+ type DiffBucket = {
486
+ added: string[];
487
+ removed: string[];
488
+ changed: string[];
489
+ };
490
+ type SpecDiffArtifact = {
491
+ artifactType: "spec-diff";
492
+ schemaVersion: number;
493
+ generatorVersion: string;
494
+ basis: "context" | "composition";
495
+ targetName: string;
496
+ hasPrevious: boolean;
497
+ hasChanges: boolean;
498
+ hasBreakingChanges: boolean;
499
+ schemaRelevantChanges: boolean;
500
+ changes: {
501
+ contexts: DiffBucket;
502
+ aggregates: DiffBucket;
503
+ commands: DiffBucket;
504
+ queries: DiffBucket;
505
+ domainEvents: DiffBucket;
506
+ valueObjects: DiffBucket;
507
+ crossContextEvents: DiffBucket;
508
+ acls: DiffBucket;
509
+ };
510
+ };
511
+ declare function buildContextSpecDiff(previous: ContextNormalizedSpec | null, current: ContextNormalizedSpec, generatorVersion: string): SpecDiffArtifact;
512
+ declare function buildCompositionSpecDiff(previous: NormalizedCompositionSpec | null, current: NormalizedCompositionSpec, generatorVersion: string): SpecDiffArtifact;
513
+ declare function contextSpecDiffDataName(modulePath: string): string;
514
+ declare function compositionSpecDiffDataName(name: string): string;
515
+ //#endregion
516
+ //#region packages/core/data_tags.d.ts
517
+ type Producer = "swamp" | "cli";
518
+ type Basis = "context" | "composition" | "migration" | "init";
519
+ type BaseTagInput = {
520
+ generatorVersion: string;
521
+ generationRunId: string;
522
+ methodName: string;
523
+ producer: Producer;
524
+ producerName?: string;
525
+ basis: Basis;
526
+ contextName?: string;
527
+ compositionName?: string;
528
+ };
529
+ declare function buildFileArtifactTags(input: BaseTagInput & {
530
+ logicalPath: string;
531
+ ownershipScope?: GeneratedArtifact["ownershipScope"];
532
+ scopeKey?: string;
533
+ }): Record<string, string>;
534
+ declare function buildSummaryTags(input: BaseTagInput): Record<string, string>;
535
+ declare function buildNormalizedSpecTags(input: BaseTagInput): Record<string, string>;
536
+ declare function buildMaterializationManifestTags(input: BaseTagInput): Record<string, string>;
537
+ declare function buildSpecDiffTags(input: BaseTagInput & {
538
+ hasChanges: boolean;
539
+ hasBreakingChanges: boolean;
540
+ schemaRelevantChanges: boolean;
541
+ }): Record<string, string>;
542
+ declare function buildVendoredFileTags(input: BaseTagInput & {
543
+ outputFileName: string;
544
+ }): Record<string, string>;
545
+ declare function buildMigrationResultTags(input: Omit<BaseTagInput, "basis"> & {
546
+ mode: "dry-run" | "apply";
547
+ applied: boolean;
548
+ skipped: boolean;
549
+ schemaRelevantChanges: boolean;
550
+ contextNames: string[];
551
+ compositionName?: string;
552
+ }): Record<string, string>;
553
+ //#endregion
554
+ //#region packages/core/migrate.d.ts
555
+ /**
556
+ * migrate.ts — Migration pipeline module for bounded context codegen v5.
557
+ *
558
+ * Self-contained; no Swamp dependencies. Consumed by the `migrate` model method (Task 4).
559
+ */
560
+ type MigrationPlan = {
561
+ tablesToCreate: string[];
562
+ tablesToAlter: Array<{
563
+ table: string;
564
+ changes: string[];
565
+ }>;
566
+ tablesToDrop: string[];
567
+ rawSummary?: string[];
568
+ };
569
+ type MigrationResult = {
570
+ engine: "drizzle-kit";
571
+ mode: "dry-run" | "apply";
572
+ success: boolean;
573
+ generationRunId: string;
574
+ plan: MigrationPlan;
575
+ sqlPreview: string[];
576
+ applied: boolean;
577
+ warnings: string[];
578
+ errors: string[];
579
+ targetDatabase: {
580
+ host: string;
581
+ database: string;
582
+ port?: number;
583
+ schema?: string;
584
+ };
585
+ contextNames: string[];
586
+ compositionName?: string;
587
+ };
588
+ declare const GENERATED_READ_SIDE_SCHEMA_LOGICAL_PATH = "infrastructure/view-models/drizzle/schema.ts";
589
+ declare function resolveGeneratedMigrationSchemaPath(workspaceRoot: string): string;
590
+ /**
591
+ * Parse a PostgreSQL connection string into structured metadata.
592
+ *
593
+ * @example
594
+ * parseConnectionString("postgresql://user:pass@localhost:5432/mydb?schema=public")
595
+ * // → { host: "localhost", database: "mydb", port: 5432, schema: "public" }
596
+ */
597
+ declare function parseConnectionString(url: string): MigrationResult["targetDatabase"];
598
+ /**
599
+ * Generate the content of a drizzle.config.ts file.
600
+ */
601
+ declare function buildDrizzleConfig(schemaPath: string, databaseUrl: string): string;
602
+ /**
603
+ * Parse drizzle-kit push stdout/stderr into structured plan data.
604
+ */
605
+ declare function parseDrizzleKitOutput(stdout: string, stderr: string): {
606
+ plan: MigrationPlan;
607
+ sqlPreview: string[];
608
+ warnings: string[];
609
+ };
610
+ type RunMigrationOptions = {
611
+ /** Absolute path to the generated schema file (or barrel) to migrate. */schemaPath: string; /** PostgreSQL connection string. */
612
+ databaseUrl: string; /** When false, appends --dry-run to the drizzle-kit command. */
613
+ execute: boolean; /** Unique ID for this generation run (used in MigrationResult). */
614
+ generationRunId: string; /** Names of the bounded contexts being migrated. */
615
+ contextNames: string[]; /** Optional composition name. */
616
+ compositionName?: string;
617
+ };
618
+ /**
619
+ * Orchestrate a drizzle-kit push migration.
620
+ *
621
+ * Steps:
622
+ * 1. Parse connection string → targetDatabase metadata.
623
+ * 2. Create a temp workspace directory.
624
+ * 3. Copy (symlink) or reference the schema file; write drizzle.config.ts.
625
+ * 4. Run `drizzle-kit push [--dry-run]`.
626
+ * 5. Parse stdout/stderr into a structured MigrationPlan.
627
+ * 6. Remove temp workspace.
628
+ * 7. Return MigrationResult.
629
+ */
630
+ declare function runMigration(opts: RunMigrationOptions): Promise<MigrationResult>;
631
+ //#endregion
632
+ //#region packages/core/config_resolver.d.ts
633
+ type ContextConfigLike = {
634
+ schemaFiles?: string[];
635
+ _codegenSupportPath?: string;
636
+ materialization?: {
637
+ targetRoot?: string;
638
+ };
639
+ };
640
+ type ResolvedContextInputs = {
641
+ contextConfigPath: string;
642
+ codegenSupportPath: string;
643
+ config: ContextConfigLike;
644
+ };
645
+ declare function toImportURL(pathOrUrl: string): string;
646
+ declare function resolveFactoryPath(baseDir: string, relativePath: string): string;
647
+ declare function inferCodegenSupportPathFromSchemaFile(configDir: string, schemaFile: string): string;
648
+ declare function inferCodegenSupportPathForContext(resolvedContextConfigPath: string, schemaFiles: string[]): string;
649
+ declare function loadContextConfig(contextConfigPath: string): Promise<ContextConfigLike>;
650
+ declare function resolveAbsoluteContextInputs(contextConfigPath: string): Promise<ResolvedContextInputs>;
651
+ declare function resolveContextInputs(baseDir: string, contextConfig: string): Promise<ResolvedContextInputs>;
652
+ declare function resolveSchemaFilePathsForContext(resolvedContextConfigPath: string, schemaFiles: string[]): string[];
653
+ //#endregion
654
+ //#region packages/core/checks.d.ts
655
+ type MethodArgsSource = {
656
+ getMethodArguments(methodName: string): Record<string, unknown>;
657
+ };
658
+ type CheckContextLike = {
659
+ globalArgs?: Record<string, unknown>;
660
+ methodName: string;
661
+ methodArgs?: Record<string, unknown>;
662
+ modelType?: unknown;
663
+ modelId?: unknown;
664
+ definitionRepository?: {
665
+ findById(type: unknown, id: unknown): Promise<MethodArgsSource | null>;
666
+ };
667
+ };
668
+ type CheckResult = {
669
+ pass: boolean;
670
+ errors?: string[];
671
+ };
672
+ type ResolvedCheckMethodInputs = {
673
+ contextConfigs: ResolvedContextInputs[];
674
+ compositionConfigPath?: string;
675
+ };
676
+ declare function resolveMethodContextInputsForCheck(context: CheckContextLike): Promise<ResolvedCheckMethodInputs>;
677
+ declare function ensureContextSupportFilesExist(resolved: ResolvedContextInputs): Promise<void>;
678
+ declare function validateContextImports(resolved: ResolvedContextInputs): Promise<void>;
679
+ declare function buildContextInputChecks(): {
680
+ "context-inputs-resolve": {
681
+ description: string;
682
+ appliesTo: string[];
683
+ execute: (context: CheckContextLike) => Promise<CheckResult>;
684
+ };
685
+ "schema-files-exist": {
686
+ description: string;
687
+ appliesTo: string[];
688
+ execute: (context: CheckContextLike) => Promise<CheckResult>;
689
+ };
690
+ "schema-imports-parse": {
691
+ description: string;
692
+ appliesTo: string[];
693
+ execute: (context: CheckContextLike) => Promise<CheckResult>;
694
+ };
695
+ "composition-inputs-resolve": {
696
+ description: string;
697
+ appliesTo: string[];
698
+ execute: (context: CheckContextLike) => Promise<CheckResult>;
699
+ };
700
+ };
701
+ //#endregion
702
+ //#region packages/core/composition_filter.d.ts
703
+ declare function filterPerContextArtifactsForComposition(artifacts: GeneratedArtifact[]): GeneratedArtifact[];
704
+ //#endregion
705
+ //#region packages/core/materialization_scopes.d.ts
706
+ type ScopeCarrier = {
707
+ ownershipScope?: string;
708
+ scopeKey?: string;
709
+ };
710
+ declare function inferReconcileScopes(artifacts: ScopeCarrier[], seedScopes?: MaterializationScope[]): MaterializationScope[];
711
+ //#endregion
712
+ //#region packages/core/pipeline.d.ts
713
+ declare function buildNormalizedSpecFromConfig(input: {
714
+ contextConfigPath: string;
715
+ codegenSupportPath: string;
716
+ }): Promise<NormalizedSpec>;
717
+ declare function buildContextNormalizedSpecFromConfig(input: {
718
+ contextConfigPath: string;
719
+ codegenSupportPath: string;
720
+ }): Promise<ContextNormalizedSpec>;
721
+ declare function buildV5ContextArtifacts(input: {
722
+ contextConfigPath: string;
723
+ codegenSupportPath: string;
724
+ }): Promise<GeneratedArtifact[]>;
725
+ declare function buildV5Artifacts(input: {
726
+ contextConfigPath: string;
727
+ codegenSupportPath: string;
728
+ }): Promise<GeneratedArtifact[]>;
729
+ declare function buildCompositionArtifacts(compositionConfigPath: string, contextSpecs: ContextNormalizedSpec[]): Promise<GeneratedArtifact[]>;
730
+ //#endregion
731
+ //#region packages/core/generators/lib.d.ts
732
+ declare function buildV5LibArtifacts(): GeneratedArtifact[];
733
+ //#endregion
734
+ //#region packages/core/generators/shared_kernel.d.ts
735
+ declare function buildV5SharedKernelArtifacts(spec?: NormalizedSpec | ContextNormalizedSpec): GeneratedArtifact[];
736
+ //#endregion
737
+ //#region packages/core/generators/ports.d.ts
738
+ declare function buildV5PortArtifacts(): GeneratedArtifact[];
739
+ //#endregion
740
+ //#region packages/core/generators/domain.d.ts
741
+ declare function buildV5DomainArtifacts(spec: NormalizedSpec): GeneratedArtifact[];
742
+ //#endregion
743
+ //#region packages/core/generators/application.d.ts
744
+ type ApplicationArtifactOptions = {
745
+ /** Skip context-wide artifacts (handler-deps, handler-map) when generating per-aggregate. */skipContextWideArtifacts?: boolean;
746
+ };
747
+ declare function buildV5ApplicationArtifacts(spec: NormalizedSpec, options?: ApplicationArtifactOptions): GeneratedArtifact[];
748
+ declare function buildV5ApplicationContextArtifacts(contextSpec: ContextNormalizedSpec): GeneratedArtifact[];
749
+ //#endregion
750
+ //#region packages/core/generators/infrastructure.d.ts
751
+ type InfrastructureArtifactOptions = {
752
+ /** Skip context-wide artifacts (tables.ts) when generating per-aggregate. */skipContextWideArtifacts?: boolean;
753
+ };
754
+ declare function buildV5InfrastructureArtifacts(spec: NormalizedSpec, options?: InfrastructureArtifactOptions): GeneratedArtifact[];
755
+ declare function buildReadModelCompositionArtifacts(contextSpecs: ContextNormalizedSpec[]): GeneratedArtifact[];
756
+ declare function buildV5InfrastructureContextArtifacts(contextSpec: ContextNormalizedSpec): GeneratedArtifact[];
757
+ //#endregion
758
+ //#region packages/core/generators/projections.d.ts
759
+ declare function buildProjectionArtifacts(contextSpec: ContextNormalizedSpec): GeneratedArtifact[];
760
+ //#endregion
761
+ //#region packages/core/generators/presentation.d.ts
762
+ declare function buildV5PresentationArtifacts(spec: NormalizedSpec | ContextNormalizedSpec): GeneratedArtifact[];
763
+ //#endregion
764
+ //#region packages/core/generators/tests.d.ts
765
+ declare function buildV5TestArtifacts(spec: NormalizedSpec): GeneratedArtifact[];
766
+ //#endregion
767
+ //#region packages/core/generators/routes.d.ts
768
+ type RouteSpec = NormalizedSpec | ContextNormalizedSpec;
769
+ declare function buildV5RouteArtifacts(spec: RouteSpec): GeneratedArtifact[];
770
+ //#endregion
771
+ //#region packages/core/generators/consumer_acls.d.ts
772
+ declare function buildConsumerAclArtifacts(contextSpec: ContextNormalizedSpec): GeneratedArtifact[];
773
+ //#endregion
774
+ //#region packages/core/generators/composition_container.d.ts
775
+ /**
776
+ * Build the DI container and RepositoryFactory artifacts that wire all contexts
777
+ * together with their command/query handlers and repository adapters.
778
+ */
779
+ declare function buildCompositionContainerArtifacts(compositionSpec: NormalizedCompositionSpec, contextSpecs: ContextNormalizedSpec[]): GeneratedArtifact[];
780
+ //#endregion
781
+ //#region packages/core/generators/composition_router.d.ts
782
+ /**
783
+ * Build the root tRPC router artifact that merges all per-context routers.
784
+ */
785
+ declare function buildCompositionRouterArtifacts(_compositionSpec: NormalizedCompositionSpec, contextSpecs: ContextNormalizedSpec[]): GeneratedArtifact[];
786
+ //#endregion
787
+ //#region packages/core/generators/composition_subscriptions.d.ts
788
+ /**
789
+ * Build subscription registry, per-subscription event handler factories,
790
+ * and integration event payload types for all cross-context events.
791
+ */
792
+ declare function buildCompositionSubscriptionArtifacts(compositionSpec: NormalizedCompositionSpec): GeneratedArtifact[];
793
+ //#endregion
794
+ //#region packages/core/generators/composition_outbox.d.ts
795
+ declare function buildCompositionOutboxArtifacts(): GeneratedArtifact[];
796
+ //#endregion
797
+ //#region packages/core/generators/composition_bus.d.ts
798
+ declare function buildCompositionBusArtifacts(): GeneratedArtifact[];
799
+ //#endregion
800
+ //#region packages/core/generators/composition_types.d.ts
801
+ declare function buildCompositionTypeArtifacts(): GeneratedArtifact[];
802
+ //#endregion
803
+ //#region packages/core/generators/composition_acls.d.ts
804
+ type CollisionSafeModulePathNames = {
805
+ symbolStem: string;
806
+ propertyStem: string;
807
+ pathSegment: string;
808
+ };
809
+ declare function buildCollisionSafeModulePathNames(modulePaths: string[]): Map<string, CollisionSafeModulePathNames>;
810
+ declare function buildCompositionAclArtifacts(compositionSpec: NormalizedCompositionSpec): GeneratedArtifact[];
811
+ //#endregion
812
+ export { AggregateNormalizedSpecView, ApplicationArtifactOptions, ApplicationErrorDef, ArtifactOwnership, CollisionSafeModulePathNames, ContextConfigLike, ContextNormalizedSpec, DiffBucket, DomainErrorDef, EntityVisitor, GENERATED_READ_SIDE_SCHEMA_LOGICAL_PATH, GeneratedArtifact, InfrastructureArtifactOptions, IntrospectedField, MigrationPlan, MigrationResult, NormalizedAggregate, NormalizedAggregateWithChildren, NormalizedCommand, NormalizedCompositionAcl, NormalizedCompositionSpec, NormalizedComputedField, NormalizedDomainEvent, NormalizedEntity, NormalizedEntityWithChildren, NormalizedFindByIdQuery, NormalizedListQuery, NormalizedProjection, NormalizedProjectionSource, NormalizedQuery, NormalizedQueryReadSide, NormalizedReadAcl, NormalizedReadModel, NormalizedSpec, NormalizedValueObject, NormalizedWriteAcl, OwnershipScope, PreparedVendoredFile, ResolvedContextInputs, ResolvedCrossContextEvent, ResolvedSubscription, RunMigrationOptions, SPEC_ARTIFACT_SCHEMA_VERSION, SPEC_DIFF_SCHEMA_VERSION, SchemaReadResult, SpecDiffArtifact, VENDORED_FILE_MANIFEST, VendoredFileEntry, applyOwnershipIfMissing, buildArtifactPath, buildCollisionSafeModulePathNames, buildCompositionAclArtifacts, buildCompositionArtifacts, buildCompositionBusArtifacts, buildCompositionContainerArtifacts, buildCompositionOutboxArtifacts, buildCompositionRouterArtifacts, buildCompositionSpecDiff, buildCompositionSubscriptionArtifacts, buildCompositionTypeArtifacts, buildConsumerAclArtifacts, buildContextInputChecks, buildContextNormalizedSpec, buildContextNormalizedSpecFromConfig, buildContextSpecDiff, buildDrizzleConfig, buildFileArtifactTags, buildMaterializationManifestTags, buildMigrationResultTags, buildNormalizedCompositionSpec, buildNormalizedSpec, buildNormalizedSpecFromConfig, buildNormalizedSpecTags, buildProjectionArtifacts, buildReadModelCompositionArtifacts, buildSpecDiffTags, buildSummaryTags, buildV5ApplicationArtifacts, buildV5ApplicationContextArtifacts, buildV5Artifacts, buildV5ContextArtifacts, buildV5DomainArtifacts, buildV5InfrastructureArtifacts, buildV5InfrastructureContextArtifacts, buildV5LibArtifacts, buildV5PortArtifacts, buildV5PresentationArtifacts, buildV5RouteArtifacts, buildV5SharedKernelArtifacts, buildV5TestArtifacts, buildVendoredFileTags, camelCase, collectOwnedValueObjects, compositionSpecDiffDataName, contextArtifactOwnership, contextSpecDiffDataName, contractFileName, createGeneratedArtifact, discoverReferencedVos, ensureContextSupportFilesExist, filterPerContextArtifactsForComposition, flattenEntities, generateContextArtifacts, inferArtifactOwnership, inferCodegenSupportPathForContext, inferCodegenSupportPathFromSchemaFile, inferReconcileScopes, introspectObjectShape, introspectSchema, isRegisteredEntity, kebabCase, loadContextConfig, mergeGeneratedArtifacts, mergeSchemaReadResults, normalizeModulePath, parseConnectionString, parseDrizzleKitOutput, pascalCase, prepareAllVendoredFiles, prepareVendoredFile, readSchemaFile, repositoryPortFileName, repositoryPortTypeName, resolveAbsoluteContextInputs, resolveArtifactOwnership, resolveContextInputs, resolveFactoryPath, resolveGeneratedMigrationSchemaPath, resolveMethodContextInputsForCheck, resolveSchemaFilePathsForContext, resolveVoOwner, rewriteImports, runMigration, serializeCompositionSpec, serializeContextSpec, sharedArtifactOwnership, sliceArtifactOwnership, sliceContextIntoAggregateViews, snakeCase, snakeUpperCase, toImportURL, toUpperSnakeCase, unwrapFieldType, validateContextImports, walkEntityTree, withArtifactOwnership, wordsFromName };