@prisma/orm-family-sql 8.0.0-rc.12-dev.15 → 8.0.0-rc.12-dev.17

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.
Files changed (83) hide show
  1. package/dist/{authoring-type-constructors-C1ogrr_x-ChQC5e1v.mjs → authoring-type-constructors-C1ogrr_x-BZQc95SF.mjs} +2 -2
  2. package/dist/{authoring-type-constructors-C1ogrr_x-ChQC5e1v.mjs.map → authoring-type-constructors-C1ogrr_x-BZQc95SF.mjs.map} +1 -1
  3. package/dist/builder__runtime.d.mts +2 -2
  4. package/dist/builder__runtime.mjs +7 -7
  5. package/dist/builder__runtime.mjs.map +1 -1
  6. package/dist/{config-types-Dqe0LWuW.mjs → config-types-DlxXpXqA.mjs} +2 -2
  7. package/dist/{config-types-Dqe0LWuW.mjs.map → config-types-DlxXpXqA.mjs.map} +1 -1
  8. package/dist/{contract-builder-CojarVwS.mjs → contract-builder-3vURlaBN.mjs} +11 -12
  9. package/dist/contract-builder-3vURlaBN.mjs.map +1 -0
  10. package/dist/{contract-builder-C2VKBKK5.d.mts → contract-builder-Ct1IMc8_.d.mts} +311 -282
  11. package/dist/contract-builder-Ct1IMc8_.d.mts.map +1 -0
  12. package/dist/contract-emitter.mjs +1 -1
  13. package/dist/contract-prisma7__provider.mjs +2 -2
  14. package/dist/contract-psl.d.mts +2 -2
  15. package/dist/contract-psl.mjs +1 -1
  16. package/dist/contract-psl__provider.mjs +2 -2
  17. package/dist/contract-ts.d.mts +1 -1
  18. package/dist/contract-ts.mjs +3 -3
  19. package/dist/contract-ts__config-types.mjs +1 -1
  20. package/dist/contract-ts__contract-builder.d.mts +1 -1
  21. package/dist/contract-ts__contract-builder.mjs +2 -2
  22. package/dist/{control-DftpYMXw.d.mts → control-BKwzdenn.d.mts} +4 -4
  23. package/dist/{control-DftpYMXw.d.mts.map → control-BKwzdenn.d.mts.map} +1 -1
  24. package/dist/{control-BoloIwBt.mjs → control-BcWypsQy.mjs} +3 -3
  25. package/dist/{control-BoloIwBt.mjs.map → control-BcWypsQy.mjs.map} +1 -1
  26. package/dist/{derived-checks-BiClpWj6-Czjj2esH.mjs → derived-checks-Bsrdb2Wk-D4UfM06W.mjs} +93 -33
  27. package/dist/derived-checks-Bsrdb2Wk-D4UfM06W.mjs.map +1 -0
  28. package/dist/{diff-CHX4XHhC.d.mts → diff-B2b34L_E.d.mts} +4 -4
  29. package/dist/{diff-CHX4XHhC.d.mts.map → diff-B2b34L_E.d.mts.map} +1 -1
  30. package/dist/{dist-D5__KJs-.mjs → dist-U61NPKN3.mjs} +2 -2
  31. package/dist/{dist-D5__KJs-.mjs.map → dist-U61NPKN3.mjs.map} +1 -1
  32. package/dist/family.d.mts +6 -6
  33. package/dist/family.mjs +2 -2
  34. package/dist/family__control.d.mts +3 -3
  35. package/dist/family__control.mjs +1 -1
  36. package/dist/family__diff.d.mts +1 -1
  37. package/dist/family__migration.d.mts +1 -1
  38. package/dist/family__pack.mjs +1 -1
  39. package/dist/family__runtime.d.mts +1 -1
  40. package/dist/family__runtime.mjs +1 -1
  41. package/dist/{index-C10GDLBQ.d.mts → index-B-CraAhf.d.mts} +4 -4
  42. package/dist/{index-C10GDLBQ.d.mts.map → index-B-CraAhf.d.mts.map} +1 -1
  43. package/dist/{interpreter-BrW0_y8Q-Dl5e-p7f.mjs → interpreter-BrW0_y8Q-ChkFlzaN.mjs} +2 -2
  44. package/dist/{interpreter-BrW0_y8Q-Dl5e-p7f.mjs.map → interpreter-BrW0_y8Q-ChkFlzaN.mjs.map} +1 -1
  45. package/dist/{migration-BwA1d1OP.d.mts → migration-9GrLWqGg.d.mts} +2 -2
  46. package/dist/{migration-BwA1d1OP.d.mts.map → migration-9GrLWqGg.d.mts.map} +1 -1
  47. package/dist/orm-client.d.mts +6 -6
  48. package/dist/orm-client.mjs +10 -10
  49. package/dist/orm-client.mjs.map +1 -1
  50. package/dist/{prepared-statement-B6zvhJej-Dl488oBR.d.mts → prepared-statement-BHSj2pDk-CRzjNpcv.d.mts} +9 -26
  51. package/dist/prepared-statement-BHSj2pDk-CRzjNpcv.d.mts.map +1 -0
  52. package/dist/query-lane-context-BcXiJasG.d.mts +1 -0
  53. package/dist/{query-lane-context-Bi1GUXHp-Bo4OTjhW.d.mts → query-lane-context-D6o9YrEV-bouFPM6u.d.mts} +5 -31
  54. package/dist/query-lane-context-D6o9YrEV-bouFPM6u.d.mts.map +1 -0
  55. package/dist/relational-core.d.mts +4 -4
  56. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  57. package/dist/relational-core__codec-descriptor-registry.d.mts +1 -1
  58. package/dist/relational-core__query-lane-context.d.mts +3 -3
  59. package/dist/relational-core__types.d.mts +2 -2
  60. package/dist/{runtime-DYpzLADy.d.mts → runtime-DgOeosYa.d.mts} +5 -6
  61. package/dist/runtime-DgOeosYa.d.mts.map +1 -0
  62. package/dist/{runtime-DzmRvRj_.mjs → runtime-Z3nD7ix1.mjs} +4 -4
  63. package/dist/{runtime-DzmRvRj_.mjs.map → runtime-Z3nD7ix1.mjs.map} +1 -1
  64. package/dist/runtime.d.mts +4 -4
  65. package/dist/runtime.mjs +7 -85
  66. package/dist/runtime.mjs.map +1 -1
  67. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  68. package/dist/{schema-differ-DpG_gnur-CXVM1Oed.d.mts → schema-differ-DpG_gnur-B_rj2WAH.d.mts} +2 -2
  69. package/dist/{schema-differ-DpG_gnur-CXVM1Oed.d.mts.map → schema-differ-DpG_gnur-B_rj2WAH.d.mts.map} +1 -1
  70. package/dist/{types-BFPRCYGW-BheztqYQ.d.mts → types-BFPRCYGW-DWAEoFj7.d.mts} +2 -2
  71. package/dist/{types-BFPRCYGW-BheztqYQ.d.mts.map → types-BFPRCYGW-DWAEoFj7.d.mts.map} +1 -1
  72. package/dist/types-BvTYXSiS.d.mts +1 -0
  73. package/dist/{types-Bcujdkdw-2SDajXRo.d.mts → types-DFJNPLXY-vp6AGe5e.d.mts} +3 -3
  74. package/dist/{types-Bcujdkdw-2SDajXRo.d.mts.map → types-DFJNPLXY-vp6AGe5e.d.mts.map} +1 -1
  75. package/package.json +18 -18
  76. package/dist/contract-builder-C2VKBKK5.d.mts.map +0 -1
  77. package/dist/contract-builder-CojarVwS.mjs.map +0 -1
  78. package/dist/derived-checks-BiClpWj6-Czjj2esH.mjs.map +0 -1
  79. package/dist/prepared-statement-B6zvhJej-Dl488oBR.d.mts.map +0 -1
  80. package/dist/query-lane-context-Bi1GUXHp-Bo4OTjhW.d.mts.map +0 -1
  81. package/dist/query-lane-context-CJNBt8cm.d.mts +0 -1
  82. package/dist/runtime-DYpzLADy.d.mts.map +0 -1
  83. package/dist/types-nNy0nND_.d.mts +0 -1
@@ -11,11 +11,269 @@ import { i as IndexTypeRegistration } from "./index-types-DPVhsW0v-D-BikM4h.mjs"
11
11
  import "./index-types-CNhHgKHi.mjs";
12
12
  import { AuthoringArgumentDescriptor, AuthoringFieldPresetDescriptor, AuthoringTypeConstructorDescriptor, AuthoringWarning } from "@prisma/orm-framework/components/authoring";
13
13
  import { StorageType } from "@prisma/orm-framework/components/ir";
14
- import { ColumnDefault, ColumnDefaultLiteralInputValue, Contract, ContractEnum, ContractRelation, ContractValueObject, ControlPolicy, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue, NamespaceId, StorageHashBase } from "@prisma/orm-framework/contract/types";
15
- import { BoundEnumType, CodecInput, CodecTypeMap, EntityHelpersFromNamespace, EnumMember, EnumTypeHandle, ExtractAuthoringNamespaceFromPack, ForeignKeyDefaultsState, MergeExtensionAuthoringNamespaces, ResolveTemplateValue, TupleFromArgumentDescriptors, bindEnumType, enumType, member } from "@prisma/orm-framework/contract-authoring";
14
+ import { ColumnDefault, Contract, ContractEnum, ContractRelation, ContractValueObject, ControlPolicy, ExecutionMutationDefaultPhases, ExecutionMutationDefaultValue, NamespaceId, StorageHashBase } from "@prisma/orm-framework/contract/types";
15
+ import { BoundEnumType, CodecInput, CodecInput as CodecInput$1, CodecTypeMap, CodecTypeMap as CodecTypeMap$1, EntityHelpersFromNamespace, EnumMember, EnumTypeHandle, ExtractAuthoringNamespaceFromPack, ForeignKeyDefaultsState, MergeExtensionAuthoringNamespaces, ResolveTemplateValue, TupleFromArgumentDescriptors, bindEnumType, enumType, member } from "@prisma/orm-framework/contract-authoring";
16
16
  import { CodecLookup, ColumnTypeDescriptor } from "@prisma/orm-framework/components/codec";
17
17
  import { ExtensionPackRef, FamilyPackRef, TargetPackRef } from "@prisma/orm-framework/components/components";
18
18
  //#region ../../../2-sql/2-authoring/contract-ts/dist/contract-builder.d.mts
19
+ //#region src/contract-definition.d.ts
20
+ /**
21
+ * Namespace-scoped pack-entity attachments, the internal build IR carrying
22
+ * the lowered `entities` handle list: namespace id → entity kind (the
23
+ * discriminator the target/extension pack registered its
24
+ * `AuthoringContributions.entityTypes` descriptor under, e.g. `native_enum`)
25
+ * → entity name → the lowered entity instance. Generic on purpose — neither
26
+ * the framework nor `contract-ts` names a specific entity kind here; the
27
+ * shape mirrors `SqlNamespaceInput.entries` (`entries.<kind>[name]`), just
28
+ * namespace-nested so an attachment can target any declared namespace
29
+ * (default or named), not only the contract's default namespace. Produced by
30
+ * the generic entity-handle walk in `buildContractDefinition`; never an
31
+ * author-facing input.
32
+ */
33
+ type AttachedEntities = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>;
34
+ /**
35
+ * A literal default as an authoring surface builds it: a value of the column codec's input type, which the contract build encodes through that codec into a {@link ColumnDefault}. Only the codec knows the type, so it is `unknown` until encoded.
36
+ */
37
+ type AuthoredColumnDefaultLiteralValue = unknown;
38
+ type AuthoredColumnDefault = ColumnDefault | {
39
+ readonly kind: 'literal';
40
+ readonly value: AuthoredColumnDefaultLiteralValue;
41
+ /**
42
+ * Whether the value is already the canonical form the contract stores. A text contract source
43
+ * reads a written default into the canonical form itself, through the column's data type and
44
+ * its casts, so the build stores it as it stands; a TypeScript `.default(value)` hands over an
45
+ * application value, which the column's codec encodes. ADR 254.
46
+ */
47
+ readonly canonical?: boolean;
48
+ };
49
+ interface FieldNode {
50
+ readonly fieldName: string;
51
+ readonly columnName: string;
52
+ readonly descriptor: ColumnTypeDescriptor;
53
+ readonly nullable: boolean;
54
+ readonly default?: AuthoredColumnDefault;
55
+ readonly executionDefaults?: ExecutionMutationDefaultPhases;
56
+ readonly many?: boolean;
57
+ /**
58
+ * Generated-check kinds the author declined for this column. The PSL
59
+ * interpreter always writes concrete kinds; the TS builder's bare
60
+ * `noCheck()` arrives as `[]` and is resolved to the column shape's
61
+ * derivable kinds at contract build time.
62
+ */
63
+ readonly noCheck?: readonly CheckKind[];
64
+ /** Present when the field was authored with `field.namedType(enumHandle)`. */
65
+ readonly enumTypeHandle?: EnumTypeHandle;
66
+ }
67
+ interface PrimaryKeyNode {
68
+ readonly columns: readonly string[];
69
+ readonly name?: string;
70
+ }
71
+ interface UniqueConstraintNode {
72
+ readonly columns: readonly string[];
73
+ readonly name?: string;
74
+ }
75
+ /** A definition-tree index's element structure — column tuple xor expression. */
76
+ type IndexNodeElements = {
77
+ /** Column tuple. */
78
+ readonly columns: readonly string[];
79
+ readonly expression?: never;
80
+ } | {
81
+ readonly columns?: never;
82
+ /** Opaque SQL: the entire element list of CREATE INDEX — never parsed. */
83
+ readonly expression: string;
84
+ };
85
+ type IndexNode = IndexNodeElements & AuthoredIndexMethod & {
86
+ /** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
87
+ readonly where: string | undefined;
88
+ readonly unique: boolean | undefined;
89
+ /** Exact physical name (`map:`) — adopted verbatim, no wire hash. */
90
+ readonly map: string | undefined;
91
+ /** Wire-name prefix (`name:`) — lowers to `<name>_<8hex>`. */
92
+ readonly name: string | undefined;
93
+ };
94
+ /**
95
+ * A definition-tree check constraint: `map` adopts an exact physical name
96
+ * verbatim, `name` is a wire-name prefix — exactly one is required (a check
97
+ * has no column tuple to derive a default from, unlike an index).
98
+ */
99
+ type CheckNode = {
100
+ readonly expression: string;
101
+ readonly map: string | undefined;
102
+ readonly name: string | undefined;
103
+ };
104
+ interface ForeignKeyNode {
105
+ readonly columns: readonly string[];
106
+ readonly references: {
107
+ readonly model: string;
108
+ readonly table: string;
109
+ readonly columns: readonly string[];
110
+ /**
111
+ * Namespace coordinate of the referenced table. When omitted the
112
+ * assembler resolves the coordinate from the referenced model node's
113
+ * own `namespaceId`; the field exists so authoring paths that already
114
+ * know the target namespace can stamp it explicitly.
115
+ */
116
+ readonly namespaceId?: string;
117
+ /**
118
+ * Contract-space identity of the referenced table. When present, the
119
+ * table lives in a different contract space (identified by this value)
120
+ * rather than the current contract. Absent for local FKs.
121
+ */
122
+ readonly spaceId?: string;
123
+ };
124
+ readonly name?: string;
125
+ readonly onDelete?: ReferentialAction;
126
+ readonly onUpdate?: ReferentialAction;
127
+ readonly constraint?: boolean;
128
+ readonly index?: boolean;
129
+ }
130
+ interface RelationNode {
131
+ readonly fieldName: string;
132
+ readonly toModel: string;
133
+ /**
134
+ * Physical table of the related model. Undefined only for a cross-space
135
+ * relation whose handle carries no static table name.
136
+ */
137
+ readonly toTable: string | undefined;
138
+ /**
139
+ * Namespace coordinate of the related model. When omitted the assembler
140
+ * resolves the coordinate from the referenced model node's own
141
+ * `namespaceId`; the field exists so authoring paths that already know the
142
+ * target namespace can stamp it explicitly — required to disambiguate a
143
+ * relation to a model whose bare name also exists in another namespace.
144
+ */
145
+ readonly toNamespaceId?: string;
146
+ readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
147
+ /**
148
+ * Whether the related row may be absent, as stated by the schema. Present on
149
+ * every `'1:1'` and `'N:1'` relation; absent on `'1:N'` and `'N:M'`.
150
+ */
151
+ readonly nullable?: boolean;
152
+ /**
153
+ * Contract-space identity of the related model. When present, the
154
+ * related model lives in a different contract space. Absent for local
155
+ * (same-space) relations.
156
+ */
157
+ readonly spaceId?: string;
158
+ /**
159
+ * Namespace coordinate of the related model in the foreign space.
160
+ * Only set when `spaceId` is present.
161
+ */
162
+ readonly namespaceId?: string;
163
+ readonly on: {
164
+ readonly parentTable: string;
165
+ readonly parentColumns: readonly string[];
166
+ readonly childTable: string | undefined;
167
+ readonly childColumns: readonly string[];
168
+ };
169
+ readonly through?: {
170
+ readonly table: string;
171
+ /**
172
+ * Namespace the junction table lives in. Set from the junction model's
173
+ * declared namespace at lowering time; junction table names are unique per
174
+ * namespace, not globally, so this disambiguates a junction whose bare table
175
+ * name also exists in another namespace. Omitted for a junction in the
176
+ * default namespace (resolved to the target's default at build time).
177
+ */
178
+ readonly namespaceId?: string;
179
+ readonly parentColumns: readonly string[];
180
+ readonly childColumns: readonly string[];
181
+ };
182
+ }
183
+ interface ValueObjectFieldNode {
184
+ readonly fieldName: string;
185
+ readonly columnName: string;
186
+ readonly valueObjectName: string;
187
+ readonly nullable: boolean;
188
+ readonly default?: AuthoredColumnDefault;
189
+ readonly executionDefaults?: ExecutionMutationDefaultPhases;
190
+ readonly many?: boolean;
191
+ }
192
+ interface ValueObjectNode {
193
+ readonly name: string;
194
+ readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
195
+ }
196
+ interface ModelNode {
197
+ readonly modelName: string;
198
+ readonly tableName: string;
199
+ /**
200
+ * Resolved namespace coordinate for this model — the key into the
201
+ * parent contract's `SqlStorage.namespaces` map. Omitting the field
202
+ * (or setting it to the framework's `UNBOUND_NAMESPACE_ID` sentinel)
203
+ * selects the late-bound slot, which renders as unqualified DDL.
204
+ *
205
+ * Populated by per-target PSL interpreters from the resolved
206
+ * `namespace { … }` AST bucket; the TS builder also sets it from the
207
+ * per-model `namespace` field once that authoring surface lands.
208
+ */
209
+ readonly namespaceId?: string;
210
+ readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
211
+ readonly id?: PrimaryKeyNode;
212
+ readonly uniques?: readonly UniqueConstraintNode[];
213
+ readonly indexes?: readonly IndexNode[];
214
+ readonly checks?: readonly CheckNode[];
215
+ readonly foreignKeys?: readonly ForeignKeyNode[];
216
+ readonly relations?: readonly RelationNode[];
217
+ readonly control?: ControlPolicy;
218
+ /**
219
+ * Single-table-inheritance variants share their base model's storage table:
220
+ * the variant's columns are materialised onto the base `ModelNode`, and this
221
+ * model contributes a domain model but no storage table of its own. When set,
222
+ * the assembler builds the domain model but skips creating a (shadow) storage
223
+ * table and a root for this model — the base owns both.
224
+ */
225
+ readonly sharesBaseTable?: boolean;
226
+ }
227
+ interface ContractDefinition {
228
+ readonly target: TargetPackRef<'sql', string>;
229
+ readonly defaultControlPolicy?: ControlPolicy;
230
+ readonly extensions?: Record<string, ExtensionPackRef<'sql', string>>;
231
+ /**
232
+ * Test-fixture escape hatch: pins the emitted `storage.storageHash`
233
+ * instead of computing it from content. A pinned hash is not
234
+ * content-derived, so snapshot content verification
235
+ * (`MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`) rejects any migration
236
+ * snapshot addressed by it — never set this in a real project.
237
+ */
238
+ readonly storageHash?: string;
239
+ readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
240
+ readonly storageTypes?: Record<string, StorageTypeInstance>;
241
+ /**
242
+ * Declared namespace coordinates for this contract — populates
243
+ * `SqlStorage.namespaces` together with `createNamespace`.
244
+ */
245
+ readonly namespaces?: readonly string[];
246
+ /**
247
+ * Authoring warnings collected by the definition producer before the
248
+ * build runs (the PSL interpreter's entity factories run ahead of
249
+ * `buildSqlContractFromDefinition`); seeds the build's single per-build
250
+ * flush. Required key: a producer with nothing collected states
251
+ * `undefined` explicitly.
252
+ */
253
+ readonly warnings: readonly AuthoringWarning[] | undefined;
254
+ /** Target-supplied factory that materialises a `SqlNamespaceBase` concretion for a declared namespace coordinate. */
255
+ readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
256
+ readonly models: readonly ModelNode[];
257
+ readonly valueObjects?: readonly ValueObjectNode[];
258
+ /**
259
+ * Domain enum handles authored via `enumType()`. Each entry lowers to a
260
+ * domain `enum` entry and a storage `valueSet` entry in the contract's
261
+ * default namespace.
262
+ */
263
+ readonly enums?: Record<string, EnumTypeHandle>;
264
+ /**
265
+ * Pack-entity attachments lowered from the `entities` handle list, keyed by
266
+ * namespace then entity kind then name. Each entity lands in
267
+ * `storage.namespaces[ns].entries.<kind>`; when the registered entity-type
268
+ * descriptor's factory output implements the
269
+ * `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook, the derived
270
+ * value-set also folds into `entries.valueSet`, mirroring how `enums` flows
271
+ * there. Internal build IR — populated by `buildContractDefinition`, not an
272
+ * author input.
273
+ */
274
+ readonly attachedEntities?: AttachedEntities;
275
+ }
276
+ //#endregion
19
277
  //#region src/contract-dsl.d.ts
20
278
  type NamingStrategy = 'identity' | 'snake_case';
21
279
  type NamingConfig = {
@@ -32,7 +290,7 @@ type ScalarFieldState<Descriptor extends ColumnTypeDescriptor = ColumnTypeDescri
32
290
  readonly typeRef?: TypeRef | undefined;
33
291
  readonly nullable: Nullable;
34
292
  readonly columnName?: ColumnName | undefined;
35
- readonly default?: ColumnDefault | undefined;
293
+ readonly default?: AuthoredColumnDefault | undefined;
36
294
  readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
37
295
  readonly many?: Many extends true ? true : undefined;
38
296
  readonly noCheck?: readonly CheckKind[] | undefined;
@@ -51,7 +309,7 @@ type AnyScalarFieldState = {
51
309
  readonly typeRef?: NamedStorageTypeRef | undefined;
52
310
  readonly nullable: boolean;
53
311
  readonly columnName?: string | undefined;
54
- readonly default?: ColumnDefault | undefined;
312
+ readonly default?: AuthoredColumnDefault | undefined;
55
313
  readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
56
314
  readonly many?: boolean | undefined;
57
315
  readonly noCheck?: readonly CheckKind[] | undefined;
@@ -83,6 +341,22 @@ type GeneratedFieldSpec = {
83
341
  readonly typeParams?: Record<string, unknown>;
84
342
  readonly generated: ExecutionMutationDefaultValue;
85
343
  };
344
+ type CarriesCodecInput<Input> = {
345
+ /** Exists only in types: carries the input type of the column's codec, which `.default()` takes. */
346
+ __codecInput?(input: Input): void;
347
+ };
348
+ type WithCodecInput<Descriptor, Input> = Descriptor & CarriesCodecInput<Input>;
349
+ type DefaultInputOf<State> = State extends {
350
+ readonly descriptor?: infer Descriptor;
351
+ } ? NonNullable<Descriptor> extends CarriesCodecInput<infer Input> ? Input : unknown : unknown;
352
+ type IsList<State> = State extends {
353
+ readonly many?: infer Many;
354
+ } ? true extends Many ? true : false : false;
355
+ type DefaultLiteralOf<State> = unknown extends DefaultInputOf<State> ? unknown : IsList<State> extends true ? readonly DefaultInputOf<State>[] : DefaultInputOf<State>;
356
+ type EnumHandleOf<State> = State extends {
357
+ readonly typeRef?: infer TypeRef;
358
+ } ? string extends TypeRef ? never : Extract<TypeRef, EnumTypeHandle> : never;
359
+ type DefaultArgumentOf<State> = [EnumHandleOf<State>] extends [never] ? DefaultLiteralOf<State> | ColumnDefault : IsList<State> extends true ? readonly EnumHandleOf<State>['values'][number][] : EnumHandleOf<State>['values'][number];
86
360
  declare class ScalarFieldBuilder<State extends AnyScalarFieldState = AnyScalarFieldState> {
87
361
  private readonly state;
88
362
  readonly __state: State;
@@ -105,7 +379,9 @@ declare class ScalarFieldBuilder<State extends AnyScalarFieldState = AnyScalarFi
105
379
  * is waived.
106
380
  */
107
381
  noCheck(...kinds: readonly CheckKind[]): ScalarFieldBuilder<State>;
108
- default(value: ColumnDefaultLiteralInputValue | ColumnDefault): ScalarFieldBuilder<State>;
382
+ default<Self extends {
383
+ readonly __state: AnyScalarFieldState;
384
+ }>(this: Self, value: DefaultArgumentOf<Self['__state']>): ScalarFieldBuilder<State>;
109
385
  /**
110
386
  * @deprecated Write `.default(now())` or `.default(autoincrement())`, or `` .default(sql`...`) `` for any other SQL. Removed in 8.0.0.
111
387
  */
@@ -118,16 +394,21 @@ declare class ScalarFieldBuilder<State extends AnyScalarFieldState = AnyScalarFi
118
394
  declare class EnumScalarFieldBuilder<Handle extends EnumTypeHandle, State extends AnyScalarFieldState = ScalarFieldState<ColumnTypeDescriptor, Handle, false, undefined>> extends ScalarFieldBuilder<State> {
119
395
  #private;
120
396
  constructor(state: State, handle: Handle);
121
- default(value: Handle['values'][number]): EnumScalarFieldBuilder<Handle, State>;
397
+ default<Self extends {
398
+ readonly __state: AnyScalarFieldState;
399
+ }>(this: Self, value: DefaultArgumentOf<Self['__state']>): EnumScalarFieldBuilder<Handle, State>;
122
400
  defaultSql(_expression: never): never;
123
401
  }
124
- declare function columnField<Descriptor extends ColumnTypeDescriptor>(descriptor: Descriptor): ScalarFieldBuilder<ScalarFieldState<Descriptor, undefined, false, undefined>>;
402
+ type CodecTypesOfNoPacks = Record<never, never>;
403
+ type ColumnFieldHelper<CodecTypes extends CodecTypeMap = CodecTypesOfNoPacks> = <Descriptor extends ColumnTypeDescriptor>(descriptor: Descriptor) => ScalarFieldBuilder<ScalarFieldState<WithCodecInput<Descriptor, CodecInput<CodecTypes, Descriptor>>, undefined, false, undefined>>;
404
+ type NamedTypeFieldHelper<CodecTypes extends CodecTypeMap = CodecTypesOfNoPacks> = {
405
+ <TypeRef extends string>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor, TypeRef, false, undefined>>;
406
+ <TypeRef extends StorageTypeInstance>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<WithCodecInput<ColumnTypeDescriptor<TypeRef['codecId']>, CodecInput<CodecTypes, TypeRef>>, TypeRef, false, undefined>>;
407
+ <Handle extends EnumTypeHandle>(typeRef: Handle): EnumScalarFieldBuilder<Handle>;
408
+ };
125
409
  declare function generatedField<Descriptor extends ColumnTypeDescriptor>(spec: GeneratedFieldSpec & {
126
410
  readonly type: Descriptor;
127
411
  }): ScalarFieldBuilder<ScalarFieldState<Descriptor, undefined, false, undefined>>;
128
- declare function namedTypeField<TypeRef extends string>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor, TypeRef, false, undefined>>;
129
- declare function namedTypeField<TypeRef extends StorageTypeInstance>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor<TypeRef['codecId']>, TypeRef, false, undefined>>;
130
- declare function namedTypeField<Handle extends EnumTypeHandle>(typeRef: Handle): EnumScalarFieldBuilder<Handle>;
131
412
  type RelationModelRefSource = 'string' | 'token' | 'lazyToken';
132
413
  type TargetFieldRefSource = 'string' | 'token';
133
414
  type EagerRelationModelName<ModelName extends string = string, Source extends Exclude<RelationModelRefSource, 'lazyToken'> = Exclude<RelationModelRefSource, 'lazyToken'>> = {
@@ -671,9 +952,9 @@ declare const rel: {
671
952
  manyToMany: typeof manyToMany;
672
953
  };
673
954
  declare const field: {
674
- column: typeof columnField;
955
+ column: ColumnFieldHelper<CodecTypesOfNoPacks>;
675
956
  generated: typeof generatedField;
676
- namedType: typeof namedTypeField;
957
+ namedType: NamedTypeFieldHelper<CodecTypesOfNoPacks>;
677
958
  };
678
959
  type FieldStateOf<T> = T extends ScalarFieldBuilder<infer State> ? State : never;
679
960
  type RelationStateOf<T> = T extends RelationBuilder<infer State> ? State : never;
@@ -693,10 +974,13 @@ type SupportsNamedConstraintOptions<Descriptor extends AuthoringFieldPresetDescr
693
974
  } ? true : Descriptor['output'] extends {
694
975
  readonly unique: true;
695
976
  } ? true : false;
696
- type FieldBuilderFromPresetDescriptor<Descriptor extends AuthoringFieldPresetDescriptor, Args extends readonly unknown[] = readonly [], ConstraintName extends string | undefined = undefined> = ScalarFieldBuilder<ScalarFieldState<ColumnTypeDescriptor<ResolveTemplateValue<Descriptor['output']['codecId'], Args> extends string ? ResolveTemplateValue<Descriptor['output']['codecId'], Args> : string>, undefined, ResolveTemplateValue<Descriptor['output']['nullable'], Args> extends true ? true : false, undefined, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['id'], Args> extends true ? true : false, ConstraintName>, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['unique'], Args> extends true ? true : false, ConstraintName>>>;
697
- type FieldHelperFunctionWithoutNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
977
+ type PresetCodecId<Descriptor extends AuthoringFieldPresetDescriptor, Args extends readonly unknown[]> = ResolveTemplateValue<Descriptor['output']['codecId'], Args> extends string ? ResolveTemplateValue<Descriptor['output']['codecId'], Args> : string;
978
+ type FieldBuilderFromPresetDescriptor<Descriptor extends AuthoringFieldPresetDescriptor, Args extends readonly unknown[] = readonly [], ConstraintName extends string | undefined = undefined, CodecTypes extends CodecTypeMap = Record<never, never>> = ScalarFieldBuilder<ScalarFieldState<WithCodecInput<ColumnTypeDescriptor<PresetCodecId<Descriptor, Args>>, CodecInput<CodecTypes, {
979
+ readonly codecId: PresetCodecId<Descriptor, Args>;
980
+ }>>, undefined, ResolveTemplateValue<Descriptor['output']['nullable'], Args> extends true ? true : false, undefined, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['id'], Args> extends true ? true : false, ConstraintName>, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['unique'], Args> extends true ? true : false, ConstraintName>>>;
981
+ type FieldHelperFunctionWithoutNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor, CodecTypes extends CodecTypeMap = Record<never, never>> = Descriptor extends {
698
982
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
699
- } ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params> : () => FieldBuilderFromPresetDescriptor<Descriptor, readonly []>;
983
+ } ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params, undefined, CodecTypes> : () => FieldBuilderFromPresetDescriptor<Descriptor, readonly [], undefined, CodecTypes>;
700
984
  /**
701
985
  * An intersection of two call signatures rather than one rest-tuple signature
702
986
  * with a trailing `options?`. Once optional descriptors yield optional tuple
@@ -706,11 +990,11 @@ type FieldHelperFunctionWithoutNamedConstraint<Descriptor extends AuthoringField
706
990
  * signature first, and falling through to the options-required signature only
707
991
  * when the argument list cannot satisfy it, keeps both spellings working.
708
992
  */
709
- type FieldHelperFunctionWithNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
993
+ type FieldHelperFunctionWithNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor, CodecTypes extends CodecTypeMap = Record<never, never>> = Descriptor extends {
710
994
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
711
- } ? (<const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params>) & (<const Params extends TupleFromArgumentDescriptors<Args>, const Name extends string | undefined = undefined>(...args: [...params: Params, options: NamedConstraintSpec<Name>]) => FieldBuilderFromPresetDescriptor<Descriptor, Params, Name>) : <const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>) => FieldBuilderFromPresetDescriptor<Descriptor, readonly [], Name>;
712
- type FieldHelperFunction<Descriptor extends AuthoringFieldPresetDescriptor> = SupportsNamedConstraintOptions<Descriptor> extends true ? FieldHelperFunctionWithNamedConstraint<Descriptor> : FieldHelperFunctionWithoutNamedConstraint<Descriptor>;
713
- type FieldHelpersFromNamespace<Namespace> = { readonly [K in keyof Namespace]: Namespace[K] extends AuthoringFieldPresetDescriptor ? FieldHelperFunction<Namespace[K]> : Namespace[K] extends Record<string, unknown> ? FieldHelpersFromNamespace<Namespace[K]> : never; };
995
+ } ? (<const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params, undefined, CodecTypes>) & (<const Params extends TupleFromArgumentDescriptors<Args>, const Name extends string | undefined = undefined>(...args: [...params: Params, options: NamedConstraintSpec<Name>]) => FieldBuilderFromPresetDescriptor<Descriptor, Params, Name, CodecTypes>) : <const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>) => FieldBuilderFromPresetDescriptor<Descriptor, readonly [], Name, CodecTypes>;
996
+ type FieldHelperFunction<Descriptor extends AuthoringFieldPresetDescriptor, CodecTypes extends CodecTypeMap = Record<never, never>> = SupportsNamedConstraintOptions<Descriptor> extends true ? FieldHelperFunctionWithNamedConstraint<Descriptor, CodecTypes> : FieldHelperFunctionWithoutNamedConstraint<Descriptor, CodecTypes>;
997
+ type FieldHelpersFromNamespace<Namespace, CodecTypes extends CodecTypeMap = Record<never, never>> = { readonly [K in keyof Namespace]: Namespace[K] extends AuthoringFieldPresetDescriptor ? FieldHelperFunction<Namespace[K], CodecTypes> : Namespace[K] extends Record<string, unknown> ? FieldHelpersFromNamespace<Namespace[K], CodecTypes> : unknown; };
714
998
  //#endregion
715
999
  //#region src/contract-types.d.ts
716
1000
  type PublicCodecTypes<CodecTypes extends Record<string, {
@@ -1014,7 +1298,11 @@ type TypeHelperFunction<Descriptor extends AuthoringTypeConstructorDescriptor> =
1014
1298
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
1015
1299
  } ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => StorageTypeFromDescriptor<Descriptor, Params> : () => StorageTypeFromDescriptor<Descriptor, readonly []>;
1016
1300
  type TypeHelpersFromNamespace<Namespace> = { readonly [K in keyof Namespace]: Namespace[K] extends AuthoringTypeConstructorDescriptor ? TypeHelperFunction<Namespace[K]> : Namespace[K] extends Record<string, unknown> ? TypeHelpersFromNamespace<Namespace[K]> : never; };
1017
- type CoreFieldHelpers = Pick<typeof field, 'column' | 'generated' | 'namedType'>;
1301
+ type FieldHelpersForCodecs<CodecTypes extends CodecTypeMap> = Pick<typeof field, 'generated'> & {
1302
+ readonly column: ColumnFieldHelper<CodecTypes>;
1303
+ readonly namedType: NamedTypeFieldHelper<CodecTypes>;
1304
+ };
1305
+ type CodecTypesOfPacks<Family, Target, Extensions> = ExtractCodecTypesFromPack<Family> & ExtractCodecTypesFromPack<Target> & MergeExtensionCodecTypesSafe<Extensions>;
1018
1306
  type MergeAllPackIndexTypes<Family, Target, Extensions> = MergeExtensionIndexTypes<{
1019
1307
  readonly __family: Family;
1020
1308
  readonly __target: Target;
@@ -1032,271 +1320,12 @@ type PackAwareModel<IndexTypes extends IndexTypeMap> = {
1032
1320
  }): ContractModelBuilder<undefined, Fields, Relations, undefined, undefined, IndexTypes>;
1033
1321
  };
1034
1322
  type ComposedAuthoringHelpers<Family extends FamilyPackRef<string>, Target extends TargetPackRef<'sql', string>, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined> = EntityHelpersFromNamespace<ExtractEntitiesNamespaceFromPack<Family> & ExtractEntitiesNamespaceFromPack<Target> & MergeExtensionEntityNamespaces<Extensions>> & {
1035
- readonly field: CoreFieldHelpers & FieldHelpersFromNamespace<ExtractFieldNamespaceFromPack<Family> & ExtractFieldNamespaceFromPack<Target> & MergeExtensionFieldNamespaces<Extensions>>;
1323
+ readonly field: FieldHelpersForCodecs<CodecTypesOfPacks<Family, Target, Extensions>> & FieldHelpersFromNamespace<ExtractFieldNamespaceFromPack<Family> & ExtractFieldNamespaceFromPack<Target> & MergeExtensionFieldNamespaces<Extensions>, CodecTypesOfPacks<Family, Target, Extensions>>;
1036
1324
  readonly model: PackAwareModel<MergeAllPackIndexTypes<Family, Target, Extensions>>;
1037
1325
  readonly rel: typeof rel;
1038
1326
  readonly type: TypeHelpersFromNamespace<ExtractTypeNamespaceFromPack<Family> & ExtractTypeNamespaceFromPack<Target> & MergeExtensionTypeNamespaces<Extensions>>;
1039
1327
  };
1040
1328
  //#endregion
1041
- //#region src/contract-definition.d.ts
1042
- /**
1043
- * Namespace-scoped pack-entity attachments, the internal build IR carrying
1044
- * the lowered `entities` handle list: namespace id → entity kind (the
1045
- * discriminator the target/extension pack registered its
1046
- * `AuthoringContributions.entityTypes` descriptor under, e.g. `native_enum`)
1047
- * → entity name → the lowered entity instance. Generic on purpose — neither
1048
- * the framework nor `contract-ts` names a specific entity kind here; the
1049
- * shape mirrors `SqlNamespaceInput.entries` (`entries.<kind>[name]`), just
1050
- * namespace-nested so an attachment can target any declared namespace
1051
- * (default or named), not only the contract's default namespace. Produced by
1052
- * the generic entity-handle walk in `buildContractDefinition`; never an
1053
- * author-facing input.
1054
- */
1055
- type AttachedEntities = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>;
1056
- /**
1057
- * A literal default as an authoring surface builds it. The contract build encodes it through the
1058
- * column codec into a {@link ColumnDefault}, so it may hold a `bigint`, which JSON cannot.
1059
- */
1060
- type AuthoredColumnDefaultLiteralValue = ColumnDefaultLiteralInputValue | bigint | readonly AuthoredColumnDefaultLiteralValue[];
1061
- type AuthoredColumnDefault = ColumnDefault | {
1062
- readonly kind: 'literal';
1063
- readonly value: AuthoredColumnDefaultLiteralValue;
1064
- /**
1065
- * Whether the value is already the canonical form the contract stores. A text contract source
1066
- * reads a written default into the canonical form itself, through the column's data type and
1067
- * its casts, so the build stores it as it stands; a TypeScript `.default(value)` hands over an
1068
- * application value, which the column's codec encodes. ADR 254.
1069
- */
1070
- readonly canonical?: boolean;
1071
- };
1072
- interface FieldNode {
1073
- readonly fieldName: string;
1074
- readonly columnName: string;
1075
- readonly descriptor: ColumnTypeDescriptor;
1076
- readonly nullable: boolean;
1077
- readonly default?: AuthoredColumnDefault;
1078
- readonly executionDefaults?: ExecutionMutationDefaultPhases;
1079
- readonly many?: boolean;
1080
- /**
1081
- * Generated-check kinds the author declined for this column. The PSL
1082
- * interpreter always writes concrete kinds; the TS builder's bare
1083
- * `noCheck()` arrives as `[]` and is resolved to the column shape's
1084
- * derivable kinds at contract build time.
1085
- */
1086
- readonly noCheck?: readonly CheckKind[];
1087
- /** Present when the field was authored with `field.namedType(enumHandle)`. */
1088
- readonly enumTypeHandle?: EnumTypeHandle;
1089
- }
1090
- interface PrimaryKeyNode {
1091
- readonly columns: readonly string[];
1092
- readonly name?: string;
1093
- }
1094
- interface UniqueConstraintNode {
1095
- readonly columns: readonly string[];
1096
- readonly name?: string;
1097
- }
1098
- /** A definition-tree index's element structure — column tuple xor expression. */
1099
- type IndexNodeElements = {
1100
- /** Column tuple. */
1101
- readonly columns: readonly string[];
1102
- readonly expression?: never;
1103
- } | {
1104
- readonly columns?: never;
1105
- /** Opaque SQL: the entire element list of CREATE INDEX — never parsed. */
1106
- readonly expression: string;
1107
- };
1108
- type IndexNode = IndexNodeElements & AuthoredIndexMethod & {
1109
- /** Opaque SQL: partial-index predicate (WHERE body, without the keyword). */
1110
- readonly where: string | undefined;
1111
- readonly unique: boolean | undefined;
1112
- /** Exact physical name (`map:`) — adopted verbatim, no wire hash. */
1113
- readonly map: string | undefined;
1114
- /** Wire-name prefix (`name:`) — lowers to `<name>_<8hex>`. */
1115
- readonly name: string | undefined;
1116
- };
1117
- /**
1118
- * A definition-tree check constraint: `map` adopts an exact physical name
1119
- * verbatim, `name` is a wire-name prefix — exactly one is required (a check
1120
- * has no column tuple to derive a default from, unlike an index).
1121
- */
1122
- type CheckNode = {
1123
- readonly expression: string;
1124
- readonly map: string | undefined;
1125
- readonly name: string | undefined;
1126
- };
1127
- interface ForeignKeyNode {
1128
- readonly columns: readonly string[];
1129
- readonly references: {
1130
- readonly model: string;
1131
- readonly table: string;
1132
- readonly columns: readonly string[];
1133
- /**
1134
- * Namespace coordinate of the referenced table. When omitted the
1135
- * assembler resolves the coordinate from the referenced model node's
1136
- * own `namespaceId`; the field exists so authoring paths that already
1137
- * know the target namespace can stamp it explicitly.
1138
- */
1139
- readonly namespaceId?: string;
1140
- /**
1141
- * Contract-space identity of the referenced table. When present, the
1142
- * table lives in a different contract space (identified by this value)
1143
- * rather than the current contract. Absent for local FKs.
1144
- */
1145
- readonly spaceId?: string;
1146
- };
1147
- readonly name?: string;
1148
- readonly onDelete?: ReferentialAction;
1149
- readonly onUpdate?: ReferentialAction;
1150
- readonly constraint?: boolean;
1151
- readonly index?: boolean;
1152
- }
1153
- interface RelationNode {
1154
- readonly fieldName: string;
1155
- readonly toModel: string;
1156
- /**
1157
- * Physical table of the related model. Undefined only for a cross-space
1158
- * relation whose handle carries no static table name.
1159
- */
1160
- readonly toTable: string | undefined;
1161
- /**
1162
- * Namespace coordinate of the related model. When omitted the assembler
1163
- * resolves the coordinate from the referenced model node's own
1164
- * `namespaceId`; the field exists so authoring paths that already know the
1165
- * target namespace can stamp it explicitly — required to disambiguate a
1166
- * relation to a model whose bare name also exists in another namespace.
1167
- */
1168
- readonly toNamespaceId?: string;
1169
- readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
1170
- /**
1171
- * Whether the related row may be absent, as stated by the schema. Present on
1172
- * every `'1:1'` and `'N:1'` relation; absent on `'1:N'` and `'N:M'`.
1173
- */
1174
- readonly nullable?: boolean;
1175
- /**
1176
- * Contract-space identity of the related model. When present, the
1177
- * related model lives in a different contract space. Absent for local
1178
- * (same-space) relations.
1179
- */
1180
- readonly spaceId?: string;
1181
- /**
1182
- * Namespace coordinate of the related model in the foreign space.
1183
- * Only set when `spaceId` is present.
1184
- */
1185
- readonly namespaceId?: string;
1186
- readonly on: {
1187
- readonly parentTable: string;
1188
- readonly parentColumns: readonly string[];
1189
- readonly childTable: string | undefined;
1190
- readonly childColumns: readonly string[];
1191
- };
1192
- readonly through?: {
1193
- readonly table: string;
1194
- /**
1195
- * Namespace the junction table lives in. Set from the junction model's
1196
- * declared namespace at lowering time; junction table names are unique per
1197
- * namespace, not globally, so this disambiguates a junction whose bare table
1198
- * name also exists in another namespace. Omitted for a junction in the
1199
- * default namespace (resolved to the target's default at build time).
1200
- */
1201
- readonly namespaceId?: string;
1202
- readonly parentColumns: readonly string[];
1203
- readonly childColumns: readonly string[];
1204
- };
1205
- }
1206
- interface ValueObjectFieldNode {
1207
- readonly fieldName: string;
1208
- readonly columnName: string;
1209
- readonly valueObjectName: string;
1210
- readonly nullable: boolean;
1211
- readonly default?: AuthoredColumnDefault;
1212
- readonly executionDefaults?: ExecutionMutationDefaultPhases;
1213
- readonly many?: boolean;
1214
- }
1215
- interface ValueObjectNode {
1216
- readonly name: string;
1217
- readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
1218
- }
1219
- interface ModelNode {
1220
- readonly modelName: string;
1221
- readonly tableName: string;
1222
- /**
1223
- * Resolved namespace coordinate for this model — the key into the
1224
- * parent contract's `SqlStorage.namespaces` map. Omitting the field
1225
- * (or setting it to the framework's `UNBOUND_NAMESPACE_ID` sentinel)
1226
- * selects the late-bound slot, which renders as unqualified DDL.
1227
- *
1228
- * Populated by per-target PSL interpreters from the resolved
1229
- * `namespace { … }` AST bucket; the TS builder also sets it from the
1230
- * per-model `namespace` field once that authoring surface lands.
1231
- */
1232
- readonly namespaceId?: string;
1233
- readonly fields: readonly (FieldNode | ValueObjectFieldNode)[];
1234
- readonly id?: PrimaryKeyNode;
1235
- readonly uniques?: readonly UniqueConstraintNode[];
1236
- readonly indexes?: readonly IndexNode[];
1237
- readonly checks?: readonly CheckNode[];
1238
- readonly foreignKeys?: readonly ForeignKeyNode[];
1239
- readonly relations?: readonly RelationNode[];
1240
- readonly control?: ControlPolicy;
1241
- /**
1242
- * Single-table-inheritance variants share their base model's storage table:
1243
- * the variant's columns are materialised onto the base `ModelNode`, and this
1244
- * model contributes a domain model but no storage table of its own. When set,
1245
- * the assembler builds the domain model but skips creating a (shadow) storage
1246
- * table and a root for this model — the base owns both.
1247
- */
1248
- readonly sharesBaseTable?: boolean;
1249
- }
1250
- interface ContractDefinition {
1251
- readonly target: TargetPackRef<'sql', string>;
1252
- readonly defaultControlPolicy?: ControlPolicy;
1253
- readonly extensions?: Record<string, ExtensionPackRef<'sql', string>>;
1254
- /**
1255
- * Test-fixture escape hatch: pins the emitted `storage.storageHash`
1256
- * instead of computing it from content. A pinned hash is not
1257
- * content-derived, so snapshot content verification
1258
- * (`MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`) rejects any migration
1259
- * snapshot addressed by it — never set this in a real project.
1260
- */
1261
- readonly storageHash?: string;
1262
- readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
1263
- readonly storageTypes?: Record<string, StorageTypeInstance>;
1264
- /**
1265
- * Declared namespace coordinates for this contract — populates
1266
- * `SqlStorage.namespaces` together with `createNamespace`.
1267
- */
1268
- readonly namespaces?: readonly string[];
1269
- /**
1270
- * Authoring warnings collected by the definition producer before the
1271
- * build runs (the PSL interpreter's entity factories run ahead of
1272
- * `buildSqlContractFromDefinition`); seeds the build's single per-build
1273
- * flush. Required key: a producer with nothing collected states
1274
- * `undefined` explicitly.
1275
- */
1276
- readonly warnings: readonly AuthoringWarning[] | undefined;
1277
- /** Target-supplied factory that materialises a `SqlNamespaceBase` concretion for a declared namespace coordinate. */
1278
- readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
1279
- readonly models: readonly ModelNode[];
1280
- readonly valueObjects?: readonly ValueObjectNode[];
1281
- /**
1282
- * Domain enum handles authored via `enumType()`. Each entry lowers to a
1283
- * domain `enum` entry and a storage `valueSet` entry in the contract's
1284
- * default namespace.
1285
- */
1286
- readonly enums?: Record<string, EnumTypeHandle>;
1287
- /**
1288
- * Pack-entity attachments lowered from the `entities` handle list, keyed by
1289
- * namespace then entity kind then name. Each entity lands in
1290
- * `storage.namespaces[ns].entries.<kind>`; when the registered entity-type
1291
- * descriptor's factory output implements the
1292
- * `SqlValueSetDerivingEntityTypeOutput.deriveValueSet` hook, the derived
1293
- * value-set also folds into `entries.valueSet`, mirroring how `enums` flows
1294
- * there. Internal build IR — populated by `buildContractDefinition`, not an
1295
- * author input.
1296
- */
1297
- readonly attachedEntities?: AttachedEntities;
1298
- }
1299
- //#endregion
1300
1329
  //#region src/build-contract.d.ts
1301
1330
  declare function buildSqlContractFromDefinition(definition: ContractDefinition, codecLookup?: CodecLookup): Contract<SqlStorage>;
1302
1331
  //#endregion
@@ -1418,5 +1447,5 @@ declare function autoincrement(): ColumnDefault;
1418
1447
  */
1419
1448
  declare function sql(strings: TemplateStringsArray, ...values: readonly never[]): ColumnDefault;
1420
1449
  //#endregion
1421
- export { UniqueConstraintNode as A, field as B, MergeEnums as C, RelationNode as D, PrimaryKeyNode as E, buildSqlContractFromDefinition as F, sql as G, model as H, check as I, defineContract as L, bindEnumType as M, buildBoundContract as N, ScalarFieldBuilder as O, buildContractDefinition as P, enumType as R, IndexNode as S, ModelNode as T, now as U, member as V, rel as W, ExtractCodecTypesFromPack as _, CheckNode as a, IndexConstraint as b, ColumnRef as c, ContractInput as d, ContractModelBuilder as f, EnumTypeHandle as g, EnumMember as h, BoundEnumType as i, autoincrement as j, TargetFieldRef as k, ComposedAuthoringHelpers as l, DeferredIndexExpression as m, AuthoredColumnDefault as n, CodecInput as o, DeferredIndexColumn as p, AuthoredColumnDefaultLiteralValue as r, CodecTypeMap as s, AttachedEntities as t, ContractDefinition as u, FieldNode as v, ModelLike as w, IndexExpressionInput as x, ForeignKeyNode as y, extensionModel as z };
1422
- //# sourceMappingURL=contract-builder-C2VKBKK5.d.mts.map
1450
+ export { UniqueConstraintNode as A, field as B, MergeEnums as C, RelationNode as D, PrimaryKeyNode as E, buildSqlContractFromDefinition as F, sql as G, model as H, check as I, defineContract as L, bindEnumType as M, buildBoundContract as N, ScalarFieldBuilder as O, buildContractDefinition as P, enumType as R, IndexNode as S, ModelNode as T, now as U, member as V, rel as W, ExtractCodecTypesFromPack as _, CheckNode as a, IndexConstraint as b, ColumnRef as c, ContractInput as d, ContractModelBuilder as f, EnumTypeHandle as g, EnumMember as h, BoundEnumType as i, autoincrement as j, TargetFieldRef as k, ComposedAuthoringHelpers as l, DeferredIndexExpression as m, AuthoredColumnDefault as n, CodecInput$1 as o, DeferredIndexColumn as p, AuthoredColumnDefaultLiteralValue as r, CodecTypeMap$1 as s, AttachedEntities as t, ContractDefinition as u, FieldNode as v, ModelLike as w, IndexExpressionInput as x, ForeignKeyNode as y, extensionModel as z };
1451
+ //# sourceMappingURL=contract-builder-Ct1IMc8_.d.mts.map