@prisma-next/sql-contract-ts 0.5.0-dev.7 → 0.5.0-dev.71

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.
@@ -1,8 +1,8 @@
1
- import { ColumnDefault, ColumnDefaultLiteralInputValue, Contract, ContractRelation, ExecutionMutationDefaultValue, StorageHashBase } from "@prisma-next/contract/types";
1
+ import { ColumnDefault, ColumnDefaultLiteralInputValue, Contract, ContractRelation, ExecutionMutationDefaultPhases, ExecutionMutationDefaultPhases as ExecutionMutationDefaultPhases$1, ExecutionMutationDefaultValue, StorageHashBase } from "@prisma-next/contract/types";
2
2
  import { ContractWithTypeMaps, Index as Index$1, ReferentialAction, SqlStorage, StorageTypeInstance, TypeMaps } from "@prisma-next/sql-contract/types";
3
3
  import { AuthoringArgumentDescriptor, AuthoringFieldNamespace, AuthoringFieldPresetDescriptor, AuthoringTypeConstructorDescriptor, AuthoringTypeNamespace } from "@prisma-next/framework-components/authoring";
4
- import { ColumnTypeDescriptor, ForeignKeyDefaultsState } from "@prisma-next/contract-authoring";
5
- import { CodecLookup } from "@prisma-next/framework-components/codec";
4
+ import { ForeignKeyDefaultsState } from "@prisma-next/contract-authoring";
5
+ import { CodecLookup, ColumnTypeDescriptor } from "@prisma-next/framework-components/codec";
6
6
  import { ExtensionPackRef, FamilyPackRef, TargetPackRef } from "@prisma-next/framework-components/components";
7
7
 
8
8
  //#region src/contract-dsl.d.ts
@@ -12,25 +12,25 @@ type NamingConfig = {
12
12
  readonly columns?: NamingStrategy;
13
13
  };
14
14
  type NamedStorageTypeRef = string | StorageTypeInstance;
15
- type NamedConstraintNameSpec<Name$1 extends string = string> = {
16
- readonly name: Name$1;
15
+ type NamedConstraintNameSpec<Name extends string = string> = {
16
+ readonly name: Name;
17
17
  };
18
- type ScalarFieldState<CodecId$1 extends string = string, TypeRef$1 extends NamedStorageTypeRef | undefined = undefined, Nullable$1 extends boolean = boolean, ColumnName extends string | undefined = string | undefined, IdSpec$1 extends NamedConstraintSpec | undefined = undefined, UniqueSpec$1 extends NamedConstraintSpec | undefined = undefined> = {
18
+ type ScalarFieldState<CodecId extends string = string, TypeRef extends NamedStorageTypeRef | undefined = undefined, Nullable extends boolean = boolean, ColumnName extends string | undefined = string | undefined, IdSpec extends NamedConstraintSpec | undefined = undefined, UniqueSpec extends NamedConstraintSpec | undefined = undefined> = {
19
19
  readonly kind: 'scalar';
20
20
  readonly descriptor?: (ColumnTypeDescriptor & {
21
- readonly codecId: CodecId$1;
21
+ readonly codecId: CodecId;
22
22
  }) | undefined;
23
- readonly typeRef?: TypeRef$1 | undefined;
24
- readonly nullable: Nullable$1;
23
+ readonly typeRef?: TypeRef | undefined;
24
+ readonly nullable: Nullable;
25
25
  readonly columnName?: ColumnName | undefined;
26
26
  readonly default?: ColumnDefault | undefined;
27
- readonly executionDefault?: ExecutionMutationDefaultValue | undefined;
28
- } & (IdSpec$1 extends NamedConstraintSpec ? {
29
- readonly id: IdSpec$1;
27
+ readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
28
+ } & (IdSpec extends NamedConstraintSpec ? {
29
+ readonly id: IdSpec;
30
30
  } : {
31
31
  readonly id?: undefined;
32
- }) & (UniqueSpec$1 extends NamedConstraintSpec ? {
33
- readonly unique: UniqueSpec$1;
32
+ }) & (UniqueSpec extends NamedConstraintSpec ? {
33
+ readonly unique: UniqueSpec;
34
34
  } : {
35
35
  readonly unique?: undefined;
36
36
  });
@@ -43,7 +43,7 @@ type AnyScalarFieldState = {
43
43
  readonly nullable: boolean;
44
44
  readonly columnName?: string | undefined;
45
45
  readonly default?: ColumnDefault | undefined;
46
- readonly executionDefault?: ExecutionMutationDefaultValue | undefined;
46
+ readonly executionDefaults?: ExecutionMutationDefaultPhases | undefined;
47
47
  readonly id?: NamedConstraintSpec | undefined;
48
48
  readonly unique?: NamedConstraintSpec | undefined;
49
49
  };
@@ -80,8 +80,8 @@ declare class ScalarFieldBuilder<State extends AnyScalarFieldState = AnyScalarFi
80
80
  column<ColumnName extends string>(name: ColumnName): ScalarFieldBuilder<State extends ScalarFieldState<infer CodecId, infer TypeRef, infer Nullable, string | undefined, infer IdSpec, infer UniqueSpec> ? ScalarFieldState<CodecId, TypeRef, Nullable, ColumnName, IdSpec, UniqueSpec> : never>;
81
81
  default(value: ColumnDefaultLiteralInputValue | ColumnDefault): ScalarFieldBuilder<State>;
82
82
  defaultSql(expression: string): ScalarFieldBuilder<State>;
83
- id<const Name$1 extends string | undefined = undefined>(options?: NamedConstraintSpec<Name$1>): ScalarFieldBuilder<State extends ScalarFieldState<infer CodecId, infer TypeRef, infer Nullable, infer ColumnName, NamedConstraintSpec | undefined, infer UniqueSpec> ? ScalarFieldState<CodecId, TypeRef, Nullable, ColumnName, NamedConstraintSpec<Name$1>, UniqueSpec> : never>;
84
- unique<const Name$1 extends string | undefined = undefined>(options?: NamedConstraintSpec<Name$1>): ScalarFieldBuilder<State extends ScalarFieldState<infer CodecId, infer TypeRef, infer Nullable, infer ColumnName, infer IdSpec, NamedConstraintSpec | undefined> ? ScalarFieldState<CodecId, TypeRef, Nullable, ColumnName, IdSpec, NamedConstraintSpec<Name$1>> : never>;
83
+ id<const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>): ScalarFieldBuilder<State extends ScalarFieldState<infer CodecId, infer TypeRef, infer Nullable, infer ColumnName, NamedConstraintSpec | undefined, infer UniqueSpec> ? ScalarFieldState<CodecId, TypeRef, Nullable, ColumnName, NamedConstraintSpec<Name>, UniqueSpec> : never>;
84
+ unique<const Name extends string | undefined = undefined>(options?: NamedConstraintSpec<Name>): ScalarFieldBuilder<State extends ScalarFieldState<infer CodecId, infer TypeRef, infer Nullable, infer ColumnName, infer IdSpec, NamedConstraintSpec | undefined> ? ScalarFieldState<CodecId, TypeRef, Nullable, ColumnName, IdSpec, NamedConstraintSpec<Name>> : never>;
85
85
  sql<const Spec extends FieldSqlSpecForState<State>>(spec: Spec): ScalarFieldBuilder<ApplyFieldSqlSpec<State, Spec>>;
86
86
  build(): State;
87
87
  }
@@ -89,44 +89,44 @@ declare function columnField<Descriptor extends ColumnTypeDescriptor>(descriptor
89
89
  declare function generatedField<Descriptor extends ColumnTypeDescriptor>(spec: GeneratedFieldSpec & {
90
90
  readonly type: Descriptor;
91
91
  }): ScalarFieldBuilder<ScalarFieldState<Descriptor['codecId'], undefined, false, undefined>>;
92
- declare function namedTypeField<TypeRef$1 extends string>(typeRef: TypeRef$1): ScalarFieldBuilder<ScalarFieldState<string, TypeRef$1, false, undefined>>;
93
- declare function namedTypeField<TypeRef$1 extends StorageTypeInstance>(typeRef: TypeRef$1): ScalarFieldBuilder<ScalarFieldState<TypeRef$1['codecId'], TypeRef$1, false, undefined>>;
92
+ declare function namedTypeField<TypeRef extends string>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<string, TypeRef, false, undefined>>;
93
+ declare function namedTypeField<TypeRef extends StorageTypeInstance>(typeRef: TypeRef): ScalarFieldBuilder<ScalarFieldState<TypeRef['codecId'], TypeRef, false, undefined>>;
94
94
  type RelationModelRefSource = 'string' | 'token' | 'lazyToken';
95
95
  type TargetFieldRefSource = 'string' | 'token';
96
- type EagerRelationModelName<ModelName$1 extends string = string, Source extends Exclude<RelationModelRefSource, 'lazyToken'> = Exclude<RelationModelRefSource, 'lazyToken'>> = {
96
+ type EagerRelationModelName<ModelName extends string = string, Source extends Exclude<RelationModelRefSource, 'lazyToken'> = Exclude<RelationModelRefSource, 'lazyToken'>> = {
97
97
  readonly kind: 'relationModelName';
98
98
  readonly source: Source;
99
- readonly modelName: ModelName$1;
99
+ readonly modelName: ModelName;
100
100
  };
101
- type LazyRelationModelName<ModelName$1 extends string = string> = {
101
+ type LazyRelationModelName<ModelName extends string = string> = {
102
102
  readonly kind: 'lazyRelationModelName';
103
103
  readonly source: 'lazyToken';
104
- readonly resolve: () => ModelName$1;
104
+ readonly resolve: () => ModelName;
105
105
  };
106
- type RelationModelSource<ModelName$1 extends string = string> = EagerRelationModelName<ModelName$1> | LazyRelationModelName<ModelName$1>;
107
- type BelongsToRelation<ToModel$1 extends string = string, FromField$1 extends string | readonly string[] = string | readonly string[], ToField$1 extends string | readonly string[] = string | readonly string[], SqlSpec extends BelongsToRelationSqlSpec | undefined = undefined> = {
106
+ type RelationModelSource<ModelName extends string = string> = EagerRelationModelName<ModelName> | LazyRelationModelName<ModelName>;
107
+ type BelongsToRelation<ToModel extends string = string, FromField extends string | readonly string[] = string | readonly string[], ToField extends string | readonly string[] = string | readonly string[], SqlSpec extends BelongsToRelationSqlSpec | undefined = undefined> = {
108
108
  readonly kind: 'belongsTo';
109
- readonly toModel: RelationModelSource<ToModel$1>;
110
- readonly from: FromField$1;
111
- readonly to: ToField$1;
109
+ readonly toModel: RelationModelSource<ToModel>;
110
+ readonly from: FromField;
111
+ readonly to: ToField;
112
112
  readonly sql?: SqlSpec;
113
113
  };
114
- type HasManyRelation<ToModel$1 extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
114
+ type HasManyRelation<ToModel extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
115
115
  readonly kind: 'hasMany';
116
- readonly toModel: RelationModelSource<ToModel$1>;
116
+ readonly toModel: RelationModelSource<ToModel>;
117
117
  readonly by: ByField;
118
118
  };
119
- type HasOneRelation<ToModel$1 extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
119
+ type HasOneRelation<ToModel extends string = string, ByField extends string | readonly string[] = string | readonly string[]> = {
120
120
  readonly kind: 'hasOne';
121
- readonly toModel: RelationModelSource<ToModel$1>;
121
+ readonly toModel: RelationModelSource<ToModel>;
122
122
  readonly by: ByField;
123
123
  };
124
- type ManyToManyRelation<ToModel$1 extends string = string, ThroughModel extends string = string, FromField$1 extends string | readonly string[] = string | readonly string[], ToField$1 extends string | readonly string[] = string | readonly string[]> = {
124
+ type ManyToManyRelation<ToModel extends string = string, ThroughModel extends string = string, FromField extends string | readonly string[] = string | readonly string[], ToField extends string | readonly string[] = string | readonly string[]> = {
125
125
  readonly kind: 'manyToMany';
126
- readonly toModel: RelationModelSource<ToModel$1>;
126
+ readonly toModel: RelationModelSource<ToModel>;
127
127
  readonly through: RelationModelSource<ThroughModel>;
128
- readonly from: FromField$1;
129
- readonly to: ToField$1;
128
+ readonly from: FromField;
129
+ readonly to: ToField;
130
130
  };
131
131
  type RelationState = BelongsToRelation<string, string | readonly string[], string | readonly string[], BelongsToRelationSqlSpec | undefined> | HasManyRelation | HasOneRelation | ManyToManyRelation;
132
132
  type AnyRelationState = RelationState;
@@ -139,79 +139,79 @@ declare class RelationBuilder<State extends RelationState = AnyRelationState> {
139
139
  sql<const SqlSpec extends BelongsToRelationSqlSpec>(this: State extends BelongsToRelation<string, string | readonly string[], string | readonly string[], BelongsToRelationSqlSpec | undefined> ? RelationBuilder<State> : never, spec: SqlSpec): RelationBuilder<ApplyBelongsToRelationSqlSpec<State, SqlSpec>>;
140
140
  build(): State;
141
141
  }
142
- type ColumnRef<FieldName$1 extends string = string> = {
142
+ type ColumnRef<FieldName extends string = string> = {
143
143
  readonly kind: 'columnRef';
144
- readonly fieldName: FieldName$1;
144
+ readonly fieldName: FieldName;
145
145
  };
146
- type TargetFieldRef<ModelName$1 extends string = string, FieldName$1 extends string = string, Source extends TargetFieldRefSource = TargetFieldRefSource> = {
146
+ type TargetFieldRef<ModelName extends string = string, FieldName extends string = string, Source extends TargetFieldRefSource = TargetFieldRefSource> = {
147
147
  readonly kind: 'targetFieldRef';
148
148
  readonly source: Source;
149
- readonly modelName: ModelName$1;
150
- readonly fieldName: FieldName$1;
149
+ readonly modelName: ModelName;
150
+ readonly fieldName: FieldName;
151
151
  };
152
- type ModelTokenRefs<ModelName$1 extends string, Fields$1 extends Record<string, ScalarFieldBuilder>> = { readonly [K in keyof Fields$1]: TargetFieldRef<ModelName$1, K & string> };
153
- type ConstraintOptions<Name$1 extends string | undefined = string | undefined> = {
154
- readonly name?: Name$1;
152
+ type ModelTokenRefs<ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>> = { readonly [K in keyof Fields]: TargetFieldRef<ModelName, K & string> };
153
+ type ConstraintOptions<Name extends string | undefined = string | undefined> = {
154
+ readonly name?: Name;
155
155
  };
156
- type IndexOptions<Name$1 extends string | undefined = string | undefined> = ConstraintOptions<Name$1> & {
156
+ type IndexOptions<Name extends string | undefined = string | undefined> = ConstraintOptions<Name> & {
157
157
  readonly using?: string;
158
158
  readonly config?: Record<string, unknown>;
159
159
  };
160
- type ForeignKeyOptions<Name$1 extends string | undefined = string | undefined> = ConstraintOptions<Name$1> & {
160
+ type ForeignKeyOptions<Name extends string | undefined = string | undefined> = ConstraintOptions<Name> & {
161
161
  readonly onDelete?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
162
162
  readonly onUpdate?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
163
163
  readonly constraint?: boolean;
164
164
  readonly index?: boolean;
165
165
  };
166
- type BelongsToRelationSqlSpec<Name$1 extends string | undefined = string | undefined> = {
167
- readonly fk?: ForeignKeyOptions<Name$1>;
166
+ type BelongsToRelationSqlSpec<Name extends string | undefined = string | undefined> = {
167
+ readonly fk?: ForeignKeyOptions<Name>;
168
168
  };
169
- type IdConstraint<FieldNames extends readonly string[] = readonly string[], Name$1 extends string | undefined = string | undefined> = {
169
+ type IdConstraint<FieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = {
170
170
  readonly kind: 'id';
171
171
  readonly fields: FieldNames;
172
- readonly name?: Name$1;
172
+ readonly name?: Name;
173
173
  };
174
174
  type UniqueConstraint<FieldNames extends readonly string[] = readonly string[]> = {
175
175
  readonly kind: 'unique';
176
176
  readonly fields: FieldNames;
177
177
  readonly name?: string;
178
178
  };
179
- type IndexConstraint<FieldNames extends readonly string[] = readonly string[], Name$1 extends string | undefined = string | undefined> = {
179
+ type IndexConstraint<FieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = {
180
180
  readonly kind: 'index';
181
181
  readonly fields: FieldNames;
182
- readonly name?: Name$1;
182
+ readonly name?: Name;
183
183
  readonly using?: string;
184
184
  readonly config?: Record<string, unknown>;
185
185
  };
186
- type ForeignKeyConstraint<SourceFieldNames extends readonly string[] = readonly string[], TargetModelName extends string = string, TargetFieldNames extends readonly string[] = readonly string[], Name$1 extends string | undefined = string | undefined> = {
186
+ type ForeignKeyConstraint<SourceFieldNames extends readonly string[] = readonly string[], TargetModelName extends string = string, TargetFieldNames extends readonly string[] = readonly string[], Name extends string | undefined = string | undefined> = {
187
187
  readonly kind: 'fk';
188
188
  readonly fields: SourceFieldNames;
189
189
  readonly targetModel: TargetModelName;
190
190
  readonly targetFields: TargetFieldNames;
191
191
  readonly targetSource?: TargetFieldRefSource;
192
- readonly name?: Name$1;
192
+ readonly name?: Name;
193
193
  readonly onDelete?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
194
194
  readonly onUpdate?: 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
195
195
  readonly constraint?: boolean;
196
196
  readonly index?: boolean;
197
197
  };
198
198
  declare function createConstraintsDsl(): {
199
- ref: <ModelName$1 extends string, FieldName$1 extends string>(modelName: ModelName$1, fieldName: FieldName$1) => TargetFieldRef<ModelName$1, FieldName$1>;
199
+ ref: <ModelName extends string, FieldName extends string>(modelName: ModelName, fieldName: FieldName) => TargetFieldRef<ModelName, FieldName>;
200
200
  id: {
201
- <FieldName$1 extends string, Name$1 extends string | undefined = undefined>(field: ColumnRef<FieldName$1>, options?: NamedConstraintSpec<Name$1>): IdConstraint<readonly [FieldName$1], Name$1>;
202
- <FieldNames extends readonly string[], Name$1 extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string> }, options?: NamedConstraintSpec<Name$1>): IdConstraint<FieldNames, Name$1>;
201
+ <FieldName extends string, Name extends string | undefined = undefined>(field: ColumnRef<FieldName>, options?: NamedConstraintSpec<Name>): IdConstraint<readonly [FieldName], Name>;
202
+ <FieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string> }, options?: NamedConstraintSpec<Name>): IdConstraint<FieldNames, Name>;
203
203
  };
204
204
  unique: {
205
- <FieldName$1 extends string>(field: ColumnRef<FieldName$1>, options?: ConstraintOptions): UniqueConstraint<readonly [FieldName$1]>;
205
+ <FieldName extends string>(field: ColumnRef<FieldName>, options?: ConstraintOptions): UniqueConstraint<readonly [FieldName]>;
206
206
  <FieldNames extends readonly string[]>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string> }, options?: ConstraintOptions): UniqueConstraint<FieldNames>;
207
207
  };
208
208
  index: {
209
- <FieldName$1 extends string, Name$1 extends string | undefined = undefined>(field: ColumnRef<FieldName$1>, options?: IndexOptions<Name$1>): IndexConstraint<readonly [FieldName$1], Name$1>;
210
- <FieldNames extends readonly string[], Name$1 extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string> }, options?: IndexOptions<Name$1>): IndexConstraint<FieldNames, Name$1>;
209
+ <FieldName extends string, Name extends string | undefined = undefined>(field: ColumnRef<FieldName>, options?: IndexOptions<Name>): IndexConstraint<readonly [FieldName], Name>;
210
+ <FieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof FieldNames]: ColumnRef<FieldNames[K] & string> }, options?: IndexOptions<Name>): IndexConstraint<FieldNames, Name>;
211
211
  };
212
212
  foreignKey: {
213
- <SourceFieldName extends string, TargetModelName extends string, TargetFieldName extends string, Name$1 extends string | undefined = undefined>(field: ColumnRef<SourceFieldName>, target: TargetFieldRef<TargetModelName, TargetFieldName>, options?: ForeignKeyOptions<Name$1>): ForeignKeyConstraint<readonly [SourceFieldName], TargetModelName, readonly [TargetFieldName], Name$1>;
214
- <SourceFieldNames extends readonly string[], TargetModelName extends string, TargetFieldNames extends readonly string[], Name$1 extends string | undefined = undefined>(fields: { readonly [K in keyof SourceFieldNames]: ColumnRef<SourceFieldNames[K] & string> }, target: { readonly [K in keyof TargetFieldNames]: TargetFieldRef<TargetModelName, TargetFieldNames[K] & string> }, options?: ForeignKeyOptions<Name$1>): ForeignKeyConstraint<SourceFieldNames, TargetModelName, TargetFieldNames, Name$1>;
213
+ <SourceFieldName extends string, TargetModelName extends string, TargetFieldName extends string, Name extends string | undefined = undefined>(field: ColumnRef<SourceFieldName>, target: TargetFieldRef<TargetModelName, TargetFieldName>, options?: ForeignKeyOptions<Name>): ForeignKeyConstraint<readonly [SourceFieldName], TargetModelName, readonly [TargetFieldName], Name>;
214
+ <SourceFieldNames extends readonly string[], TargetModelName extends string, TargetFieldNames extends readonly string[], Name extends string | undefined = undefined>(fields: { readonly [K in keyof SourceFieldNames]: ColumnRef<SourceFieldNames[K] & string> }, target: { readonly [K in keyof TargetFieldNames]: TargetFieldRef<TargetModelName, TargetFieldNames[K] & string> }, options?: ForeignKeyOptions<Name>): ForeignKeyConstraint<SourceFieldNames, TargetModelName, TargetFieldNames, Name>;
215
215
  };
216
216
  };
217
217
  type ConstraintsDsl = ReturnType<typeof createConstraintsDsl>;
@@ -224,32 +224,32 @@ type SqlStageSpec = {
224
224
  readonly indexes?: readonly IndexConstraint[];
225
225
  readonly foreignKeys?: readonly ForeignKeyConstraint[];
226
226
  };
227
- type FieldRefs<Fields$1 extends Record<string, ScalarFieldBuilder>> = { readonly [K in keyof Fields$1]: ColumnRef<K & string> };
228
- type AttributeContext<Fields$1 extends Record<string, ScalarFieldBuilder>> = {
229
- readonly fields: FieldRefs<Fields$1>;
227
+ type FieldRefs<Fields extends Record<string, ScalarFieldBuilder>> = { readonly [K in keyof Fields]: ColumnRef<K & string> };
228
+ type AttributeContext<Fields extends Record<string, ScalarFieldBuilder>> = {
229
+ readonly fields: FieldRefs<Fields>;
230
230
  readonly constraints: Pick<ConstraintsDsl, 'id' | 'unique'>;
231
231
  };
232
- type SqlContext<Fields$1 extends Record<string, ScalarFieldBuilder>> = {
233
- readonly cols: FieldRefs<Fields$1>;
232
+ type SqlContext<Fields extends Record<string, ScalarFieldBuilder>> = {
233
+ readonly cols: FieldRefs<Fields>;
234
234
  readonly constraints: Pick<ConstraintsDsl, 'index' | 'foreignKey' | 'ref'>;
235
235
  };
236
236
  type StageInput<Context, Spec> = Spec | ((context: Context) => Spec);
237
- type StaticLiteralName<Name$1> = Name$1 extends string ? (string extends Name$1 ? never : Name$1) : never;
237
+ type StaticLiteralName<Name> = Name extends string ? (string extends Name ? never : Name) : never;
238
238
  type NamedConstraintLiteralName<Constraint> = Constraint extends {
239
239
  readonly name?: infer Name;
240
240
  } ? StaticLiteralName<Name> : never;
241
241
  type DuplicateLiteralNames<Items extends readonly unknown[], Seen extends string = never, Duplicates extends string = never> = Items extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? NamedConstraintLiteralName<First> extends infer Name extends string ? Name extends Seen ? DuplicateLiteralNames<Rest, Seen, Duplicates | Name> : DuplicateLiteralNames<Rest, Seen | Name, Duplicates> : DuplicateLiteralNames<Rest, Seen, Duplicates> : Duplicates;
242
- type InlineIdLiteralName<Fields$1 extends Record<string, ScalarFieldBuilder>> = { readonly [FieldName in keyof Fields$1]: FieldStateOf<Fields$1[FieldName]> extends {
242
+ type InlineIdLiteralName<Fields extends Record<string, ScalarFieldBuilder>> = { readonly [FieldName in keyof Fields]: FieldStateOf<Fields[FieldName]> extends {
243
243
  readonly id: {
244
244
  readonly name?: infer Name;
245
245
  };
246
- } ? StaticLiteralName<Name> : never }[keyof Fields$1];
246
+ } ? StaticLiteralName<Name> : never }[keyof Fields];
247
247
  type AttributeIdLiteralName<AttributesSpec extends ModelAttributesSpec | undefined> = AttributesSpec extends {
248
248
  readonly id?: {
249
249
  readonly name?: infer Name;
250
250
  };
251
251
  } ? StaticLiteralName<Name> : never;
252
- type ModelIdLiteralName<Fields$1 extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined> = [AttributeIdLiteralName<AttributesSpec>] extends [never] ? InlineIdLiteralName<Fields$1> : AttributeIdLiteralName<AttributesSpec>;
252
+ type ModelIdLiteralName<Fields extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined> = [AttributeIdLiteralName<AttributesSpec>] extends [never] ? InlineIdLiteralName<Fields> : AttributeIdLiteralName<AttributesSpec>;
253
253
  type SqlIndexes<SqlSpec extends SqlStageSpec> = SqlSpec extends {
254
254
  readonly indexes?: infer Indexes extends readonly unknown[];
255
255
  } ? Indexes : readonly [];
@@ -257,43 +257,43 @@ type SqlForeignKeys<SqlSpec extends SqlStageSpec> = SqlSpec extends {
257
257
  readonly foreignKeys?: infer ForeignKeys extends readonly unknown[];
258
258
  } ? ForeignKeys : readonly [];
259
259
  type SqlNamedObjects<SqlSpec extends SqlStageSpec> = [...SqlIndexes<SqlSpec>, ...SqlForeignKeys<SqlSpec>];
260
- type ValidateSqlStageSpec<Fields$1 extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined, SqlSpec extends SqlStageSpec> = [DuplicateLiteralNames<SqlNamedObjects<SqlSpec>>] extends [never] ? [Extract<ModelIdLiteralName<Fields$1, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? SqlSpec : never : never;
261
- type ValidateAttributesStageSpec<Fields$1 extends Record<string, ScalarFieldBuilder>, SqlSpec extends SqlStageSpec | undefined, AttributesSpec extends ModelAttributesSpec> = SqlSpec extends SqlStageSpec ? [Extract<ModelIdLiteralName<Fields$1, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? AttributesSpec : never : AttributesSpec;
262
- declare class ContractModelBuilder<ModelName$1 extends string | undefined, Fields$1 extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>, AttributesSpec extends ModelAttributesSpec | undefined = undefined, SqlSpec extends SqlStageSpec | undefined = undefined> {
260
+ type ValidateSqlStageSpec<Fields extends Record<string, ScalarFieldBuilder>, AttributesSpec extends ModelAttributesSpec | undefined, SqlSpec extends SqlStageSpec> = [DuplicateLiteralNames<SqlNamedObjects<SqlSpec>>] extends [never] ? [Extract<ModelIdLiteralName<Fields, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? SqlSpec : never : never;
261
+ type ValidateAttributesStageSpec<Fields extends Record<string, ScalarFieldBuilder>, SqlSpec extends SqlStageSpec | undefined, AttributesSpec extends ModelAttributesSpec> = SqlSpec extends SqlStageSpec ? [Extract<ModelIdLiteralName<Fields, AttributesSpec>, NamedConstraintLiteralName<SqlNamedObjects<SqlSpec>[number]>>] extends [never] ? AttributesSpec : never : AttributesSpec;
262
+ declare class ContractModelBuilder<ModelName extends string | undefined, Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>, AttributesSpec extends ModelAttributesSpec | undefined = undefined, SqlSpec extends SqlStageSpec | undefined = undefined> {
263
263
  readonly stageOne: {
264
- readonly modelName?: ModelName$1;
265
- readonly fields: Fields$1;
264
+ readonly modelName?: ModelName;
265
+ readonly fields: Fields;
266
266
  readonly relations: Relations;
267
267
  };
268
- readonly attributesFactory?: StageInput<AttributeContext<Fields$1>, AttributesSpec> | undefined;
269
- readonly sqlFactory?: StageInput<SqlContext<Fields$1>, SqlSpec> | undefined;
270
- readonly __name: ModelName$1;
271
- readonly __fields: Fields$1;
268
+ readonly attributesFactory?: StageInput<AttributeContext<Fields>, AttributesSpec> | undefined;
269
+ readonly sqlFactory?: StageInput<SqlContext<Fields>, SqlSpec> | undefined;
270
+ readonly __name: ModelName;
271
+ readonly __fields: Fields;
272
272
  readonly __relations: Relations;
273
273
  readonly __attributes: AttributesSpec;
274
274
  readonly __sql: SqlSpec;
275
- readonly refs: ModelName$1 extends string ? ModelTokenRefs<ModelName$1, Fields$1> : never;
275
+ readonly refs: ModelName extends string ? ModelTokenRefs<ModelName, Fields> : never;
276
276
  constructor(stageOne: {
277
- readonly modelName?: ModelName$1;
278
- readonly fields: Fields$1;
277
+ readonly modelName?: ModelName;
278
+ readonly fields: Fields;
279
279
  readonly relations: Relations;
280
- }, attributesFactory?: StageInput<AttributeContext<Fields$1>, AttributesSpec> | undefined, sqlFactory?: StageInput<SqlContext<Fields$1>, SqlSpec> | undefined);
281
- ref<FieldName$1 extends keyof Fields$1 & string>(this: ModelName$1 extends string ? ContractModelBuilder<ModelName$1, Fields$1, Relations, AttributesSpec, SqlSpec> : never, fieldName: FieldName$1): TargetFieldRef<ModelName$1 & string, FieldName$1>;
282
- relations<const NextRelations extends Record<string, AnyRelationBuilder>>(relations: NextRelations): ContractModelBuilder<ModelName$1, Fields$1, Relations & NextRelations, AttributesSpec, SqlSpec>;
283
- attributes<const NextAttributesSpec extends ModelAttributesSpec>(specOrFactory: StageInput<AttributeContext<Fields$1>, ValidateAttributesStageSpec<Fields$1, SqlSpec, NextAttributesSpec>>): ContractModelBuilder<ModelName$1, Fields$1, Relations, NextAttributesSpec, SqlSpec>;
284
- sql<const NextSqlSpec extends SqlStageSpec>(specOrFactory: StageInput<SqlContext<Fields$1>, NextSqlSpec>): [ValidateSqlStageSpec<Fields$1, AttributesSpec, NextSqlSpec>] extends [never] ? ContractModelBuilder<ModelName$1, Fields$1, Relations, AttributesSpec, never> : ContractModelBuilder<ModelName$1, Fields$1, Relations, AttributesSpec, NextSqlSpec>;
280
+ }, attributesFactory?: StageInput<AttributeContext<Fields>, AttributesSpec> | undefined, sqlFactory?: StageInput<SqlContext<Fields>, SqlSpec> | undefined);
281
+ ref<FieldName extends keyof Fields & string>(this: ModelName extends string ? ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, SqlSpec> : never, fieldName: FieldName): TargetFieldRef<ModelName & string, FieldName>;
282
+ relations<const NextRelations extends Record<string, AnyRelationBuilder>>(relations: NextRelations): ContractModelBuilder<ModelName, Fields, Relations & NextRelations, AttributesSpec, SqlSpec>;
283
+ attributes<const NextAttributesSpec extends ModelAttributesSpec>(specOrFactory: StageInput<AttributeContext<Fields>, ValidateAttributesStageSpec<Fields, SqlSpec, NextAttributesSpec>>): ContractModelBuilder<ModelName, Fields, Relations, NextAttributesSpec, SqlSpec>;
284
+ sql<const NextSqlSpec extends SqlStageSpec>(specOrFactory: StageInput<SqlContext<Fields>, NextSqlSpec>): [ValidateSqlStageSpec<Fields, AttributesSpec, NextSqlSpec>] extends [never] ? ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, never> : ContractModelBuilder<ModelName, Fields, Relations, AttributesSpec, NextSqlSpec>;
285
285
  buildAttributesSpec(): AttributesSpec;
286
286
  buildSqlSpec(): SqlSpec;
287
287
  }
288
- type NamedModelTokenShape<ModelName$1 extends string = string, Fields$1 extends Record<string, ScalarFieldBuilder> = Record<string, ScalarFieldBuilder>> = {
288
+ type NamedModelTokenShape<ModelName extends string = string, Fields extends Record<string, ScalarFieldBuilder> = Record<string, ScalarFieldBuilder>> = {
289
289
  readonly stageOne: {
290
- readonly modelName?: ModelName$1;
291
- readonly fields: Fields$1;
290
+ readonly modelName?: ModelName;
291
+ readonly fields: Fields;
292
292
  };
293
293
  };
294
294
  type AnyNamedModelToken = NamedModelTokenShape<string, Record<string, ScalarFieldBuilder>>;
295
- type LazyNamedModelToken<Token$1 extends AnyNamedModelToken = AnyNamedModelToken> = () => Token$1;
296
- type RelationFieldSelection<FieldName$1 extends string> = FieldName$1 | readonly FieldName$1[];
295
+ type LazyNamedModelToken<Token extends AnyNamedModelToken = AnyNamedModelToken> = () => Token;
296
+ type RelationFieldSelection<FieldName extends string> = FieldName | readonly FieldName[];
297
297
  type RelationModelName<Target> = Target extends NamedModelTokenShape<infer ModelName extends string, Record<string, ScalarFieldBuilder>> ? ModelName : Target extends (() => infer Token) ? RelationModelName<Token> : never;
298
298
  type RelationModelFieldNames<Target> = Target extends NamedModelTokenShape<string, infer Fields> ? keyof Fields & string : Target extends (() => infer Token) ? RelationModelFieldNames<Token> : never;
299
299
  type ContractInput<Family extends FamilyPackRef<string> = FamilyPackRef<string>, Target extends TargetPackRef<'sql', string> = TargetPackRef<'sql', string>, Types extends Record<string, StorageTypeInstance> = Record<never, never>, Models extends Record<string, ContractModelBuilder<string | undefined, Record<string, ScalarFieldBuilder>, Record<string, AnyRelationBuilder>, ModelAttributesSpec | undefined, SqlStageSpec | undefined>> = Record<never, never>, ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined> = {
@@ -308,44 +308,44 @@ type ContractInput<Family extends FamilyPackRef<string> = FamilyPackRef<string>,
308
308
  readonly models?: Models;
309
309
  readonly codecLookup?: CodecLookup;
310
310
  };
311
- declare function model<const ModelName$1 extends string, Fields$1 extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(modelName: ModelName$1, input: {
312
- readonly fields: Fields$1;
311
+ declare function model<const ModelName extends string, Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(modelName: ModelName, input: {
312
+ readonly fields: Fields;
313
313
  readonly relations?: Relations;
314
- }): ContractModelBuilder<ModelName$1, Fields$1, Relations>;
315
- declare function model<Fields$1 extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(input: {
316
- readonly fields: Fields$1;
314
+ }): ContractModelBuilder<ModelName, Fields, Relations>;
315
+ declare function model<Fields extends Record<string, ScalarFieldBuilder>, Relations extends Record<string, AnyRelationBuilder> = Record<never, never>>(input: {
316
+ readonly fields: Fields;
317
317
  readonly relations?: Relations;
318
- }): ContractModelBuilder<undefined, Fields$1, Relations>;
319
- declare function belongsTo<Token$1 extends AnyNamedModelToken, FromField$1 extends string | readonly string[], ToField$1 extends RelationFieldSelection<RelationModelFieldNames<Token$1>>>(toModel: Token$1 | LazyNamedModelToken<Token$1>, options: {
320
- readonly from: FromField$1;
321
- readonly to: ToField$1;
322
- }): RelationBuilder<BelongsToRelation<RelationModelName<Token$1>, FromField$1, ToField$1>>;
323
- declare function belongsTo<ToModel$1 extends string, FromField$1 extends string | readonly string[], ToField$1 extends string | readonly string[]>(toModel: ToModel$1, options: {
324
- readonly from: FromField$1;
325
- readonly to: ToField$1;
326
- }): RelationBuilder<BelongsToRelation<ToModel$1, FromField$1, ToField$1>>;
327
- declare function hasMany<Token$1 extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token$1>>>(toModel: Token$1 | LazyNamedModelToken<Token$1>, options: {
318
+ }): ContractModelBuilder<undefined, Fields, Relations>;
319
+ declare function belongsTo<Token extends AnyNamedModelToken, FromField extends string | readonly string[], ToField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
320
+ readonly from: FromField;
321
+ readonly to: ToField;
322
+ }): RelationBuilder<BelongsToRelation<RelationModelName<Token>, FromField, ToField>>;
323
+ declare function belongsTo<ToModel extends string, FromField extends string | readonly string[], ToField extends string | readonly string[]>(toModel: ToModel, options: {
324
+ readonly from: FromField;
325
+ readonly to: ToField;
326
+ }): RelationBuilder<BelongsToRelation<ToModel, FromField, ToField>>;
327
+ declare function hasMany<Token extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
328
328
  readonly by: ByField;
329
- }): RelationBuilder<HasManyRelation<RelationModelName<Token$1>, ByField>>;
330
- declare function hasMany<ToModel$1 extends string, ByField extends string | readonly string[]>(toModel: ToModel$1, options: {
329
+ }): RelationBuilder<HasManyRelation<RelationModelName<Token>, ByField>>;
330
+ declare function hasMany<ToModel extends string, ByField extends string | readonly string[]>(toModel: ToModel, options: {
331
331
  readonly by: ByField;
332
- }): RelationBuilder<HasManyRelation<ToModel$1, ByField>>;
333
- declare function hasOne<Token$1 extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token$1>>>(toModel: Token$1 | LazyNamedModelToken<Token$1>, options: {
332
+ }): RelationBuilder<HasManyRelation<ToModel, ByField>>;
333
+ declare function hasOne<Token extends AnyNamedModelToken, ByField extends RelationFieldSelection<RelationModelFieldNames<Token>>>(toModel: Token | LazyNamedModelToken<Token>, options: {
334
334
  readonly by: ByField;
335
- }): RelationBuilder<HasOneRelation<RelationModelName<Token$1>, ByField>>;
336
- declare function hasOne<ToModel$1 extends string, ByField extends string | readonly string[]>(toModel: ToModel$1, options: {
335
+ }): RelationBuilder<HasOneRelation<RelationModelName<Token>, ByField>>;
336
+ declare function hasOne<ToModel extends string, ByField extends string | readonly string[]>(toModel: ToModel, options: {
337
337
  readonly by: ByField;
338
- }): RelationBuilder<HasOneRelation<ToModel$1, ByField>>;
339
- declare function manyToMany<ToToken extends AnyNamedModelToken, ThroughToken extends AnyNamedModelToken, FromField$1 extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>, ToField$1 extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>>(toModel: ToToken | LazyNamedModelToken<ToToken>, options: {
338
+ }): RelationBuilder<HasOneRelation<ToModel, ByField>>;
339
+ declare function manyToMany<ToToken extends AnyNamedModelToken, ThroughToken extends AnyNamedModelToken, FromField extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>, ToField extends RelationFieldSelection<RelationModelFieldNames<ThroughToken>>>(toModel: ToToken | LazyNamedModelToken<ToToken>, options: {
340
340
  readonly through: ThroughToken | LazyNamedModelToken<ThroughToken>;
341
- readonly from: FromField$1;
342
- readonly to: ToField$1;
343
- }): RelationBuilder<ManyToManyRelation<RelationModelName<ToToken>, RelationModelName<ThroughToken>, FromField$1, ToField$1>>;
344
- declare function manyToMany<ToModel$1 extends string, ThroughModel extends string, FromField$1 extends string | readonly string[], ToField$1 extends string | readonly string[]>(toModel: ToModel$1, options: {
341
+ readonly from: FromField;
342
+ readonly to: ToField;
343
+ }): RelationBuilder<ManyToManyRelation<RelationModelName<ToToken>, RelationModelName<ThroughToken>, FromField, ToField>>;
344
+ declare function manyToMany<ToModel extends string, ThroughModel extends string, FromField extends string | readonly string[], ToField extends string | readonly string[]>(toModel: ToModel, options: {
345
345
  readonly through: ThroughModel;
346
- readonly from: FromField$1;
347
- readonly to: ToField$1;
348
- }): RelationBuilder<ManyToManyRelation<ToModel$1, ThroughModel, FromField$1, ToField$1>>;
346
+ readonly from: FromField;
347
+ readonly to: ToField;
348
+ }): RelationBuilder<ManyToManyRelation<ToModel, ThroughModel, FromField, ToField>>;
349
349
  declare const rel: {
350
350
  belongsTo: typeof belongsTo;
351
351
  hasMany: typeof hasMany;
@@ -365,14 +365,14 @@ type AttributeStageIdFieldNames<T> = T extends {
365
365
  //#endregion
366
366
  //#region src/authoring-type-utils.d.ts
367
367
  type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends ((value: infer I) => void) ? I : never;
368
- type NamedConstraintSpec<Name$1 extends string | undefined = string | undefined> = {
369
- readonly name?: Name$1;
368
+ type NamedConstraintSpec<Name extends string | undefined = string | undefined> = {
369
+ readonly name?: Name;
370
370
  };
371
- type NamedConstraintState<Enabled extends boolean, Name$1 extends string | undefined = undefined> = Enabled extends true ? NamedConstraintSpec<Name$1> : undefined;
372
- type OptionalObjectArgumentKeys<Properties$1 extends Record<string, AuthoringArgumentDescriptor>> = { readonly [K in keyof Properties$1]: Properties$1[K] extends {
371
+ type NamedConstraintState<Enabled extends boolean, Name extends string | undefined = undefined> = Enabled extends true ? NamedConstraintSpec<Name> : undefined;
372
+ type OptionalObjectArgumentKeys<Properties extends Record<string, AuthoringArgumentDescriptor>> = { readonly [K in keyof Properties]: Properties[K] extends {
373
373
  readonly optional: true;
374
- } ? K : never }[keyof Properties$1];
375
- type ObjectArgumentType<Properties$1 extends Record<string, AuthoringArgumentDescriptor>> = { readonly [K in Exclude<keyof Properties$1, OptionalObjectArgumentKeys<Properties$1>>]: ArgTypeFromDescriptor<Properties$1[K]> } & { readonly [K in OptionalObjectArgumentKeys<Properties$1>]?: ArgTypeFromDescriptor<Properties$1[K]> };
374
+ } ? K : never }[keyof Properties];
375
+ type ObjectArgumentType<Properties extends Record<string, AuthoringArgumentDescriptor>> = { readonly [K in Exclude<keyof Properties, OptionalObjectArgumentKeys<Properties>>]: ArgTypeFromDescriptor<Properties[K]> } & { readonly [K in OptionalObjectArgumentKeys<Properties>]?: ArgTypeFromDescriptor<Properties[K]> };
376
376
  type ArgTypeFromDescriptor<Arg extends AuthoringArgumentDescriptor> = Arg extends {
377
377
  readonly kind: 'string';
378
378
  } ? string : Arg extends {
@@ -383,28 +383,28 @@ type ArgTypeFromDescriptor<Arg extends AuthoringArgumentDescriptor> = Arg extend
383
383
  readonly kind: 'object';
384
384
  readonly properties: infer Properties extends Record<string, AuthoringArgumentDescriptor>;
385
385
  } ? ObjectArgumentType<Properties> : never;
386
- type TupleFromArgumentDescriptors<Args$1 extends readonly AuthoringArgumentDescriptor[]> = { readonly [K in keyof Args$1]: Args$1[K] extends AuthoringArgumentDescriptor ? ArgTypeFromDescriptor<Args$1[K]> : never };
386
+ type TupleFromArgumentDescriptors<Args extends readonly AuthoringArgumentDescriptor[]> = { readonly [K in keyof Args]: Args[K] extends AuthoringArgumentDescriptor ? ArgTypeFromDescriptor<Args[K]> : never };
387
387
  type SupportsNamedConstraintOptions<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor['output'] extends {
388
388
  readonly id: true;
389
389
  } ? true : Descriptor['output'] extends {
390
390
  readonly unique: true;
391
391
  } ? true : false;
392
- type ResolveTemplateValue<Template, Args$1 extends readonly unknown[]> = Template extends {
392
+ type ResolveTemplateValue<Template, Args extends readonly unknown[]> = Template extends {
393
393
  readonly kind: 'arg';
394
394
  readonly index: infer Index extends number;
395
395
  readonly path?: infer Path extends readonly string[] | undefined;
396
396
  readonly default?: infer Default;
397
- } ? ResolveTemplateArgValue<Args$1[Index], Path, Default, Args$1> : Template extends readonly unknown[] ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args$1> } : Template extends Record<string, unknown> ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args$1> } : Template;
398
- type ResolveTemplatePathValue<Value, Path$1 extends readonly string[] | undefined> = Path$1 extends readonly [infer Segment extends string, ...infer Rest extends readonly string[]] ? Segment extends keyof NonNullable<Value> ? ResolveTemplatePathValue<NonNullable<Value>[Segment], Rest> : never : Value;
399
- type ResolveTemplateDefaultValue<Value, Default$1, Args$1 extends readonly unknown[]> = Default$1 extends undefined ? Value : [Value] extends [never] ? ResolveTemplateValue<Default$1, Args$1> : undefined extends Value ? Exclude<Value, undefined> | ResolveTemplateValue<Default$1, Args$1> : Value;
400
- type ResolveTemplateArgValue<Value, Path$1 extends readonly string[] | undefined, Default$1, Args$1 extends readonly unknown[]> = ResolveTemplateDefaultValue<ResolveTemplatePathValue<Value, Path$1>, Default$1, Args$1>;
401
- type FieldBuilderFromPresetDescriptor<Descriptor extends AuthoringFieldPresetDescriptor, Args$1 extends readonly unknown[] = readonly [], ConstraintName extends string | undefined = undefined> = ScalarFieldBuilder<ScalarFieldState<ResolveTemplateValue<Descriptor['output']['codecId'], Args$1> extends string ? ResolveTemplateValue<Descriptor['output']['codecId'], Args$1> : string, undefined, ResolveTemplateValue<Descriptor['output']['nullable'], Args$1> extends true ? true : false, undefined, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['id'], Args$1> extends true ? true : false, ConstraintName>, NamedConstraintState<ResolveTemplateValue<Descriptor['output']['unique'], Args$1> extends true ? true : false, ConstraintName>>>;
397
+ } ? ResolveTemplateArgValue<Args[Index], Path, Default, Args> : Template extends readonly unknown[] ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args> } : Template extends Record<string, unknown> ? { readonly [K in keyof Template]: ResolveTemplateValue<Template[K], Args> } : Template;
398
+ type ResolveTemplatePathValue<Value, Path extends readonly string[] | undefined> = Path extends readonly [infer Segment extends string, ...infer Rest extends readonly string[]] ? Segment extends keyof NonNullable<Value> ? ResolveTemplatePathValue<NonNullable<Value>[Segment], Rest> : never : Value;
399
+ type ResolveTemplateDefaultValue<Value, Default, Args extends readonly unknown[]> = Default extends undefined ? Value : [Value] extends [never] ? ResolveTemplateValue<Default, Args> : undefined extends Value ? Exclude<Value, undefined> | ResolveTemplateValue<Default, Args> : Value;
400
+ type ResolveTemplateArgValue<Value, Path extends readonly string[] | undefined, Default, Args extends readonly unknown[]> = ResolveTemplateDefaultValue<ResolveTemplatePathValue<Value, Path>, Default, Args>;
401
+ type FieldBuilderFromPresetDescriptor<Descriptor extends AuthoringFieldPresetDescriptor, Args extends readonly unknown[] = readonly [], ConstraintName extends string | undefined = undefined> = ScalarFieldBuilder<ScalarFieldState<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>>>;
402
402
  type FieldHelperFunctionWithoutNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
403
403
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
404
404
  } ? <const Params extends TupleFromArgumentDescriptors<Args>>(...args: Params) => FieldBuilderFromPresetDescriptor<Descriptor, Params> : () => FieldBuilderFromPresetDescriptor<Descriptor, readonly []>;
405
405
  type FieldHelperFunctionWithNamedConstraint<Descriptor extends AuthoringFieldPresetDescriptor> = Descriptor extends {
406
406
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
407
- } ? <const Params extends TupleFromArgumentDescriptors<Args>, const Name$1 extends string | undefined = undefined>(...args: [...params: Params, options?: NamedConstraintSpec<Name$1>]) => FieldBuilderFromPresetDescriptor<Descriptor, Params, Name$1> : <const Name$1 extends string | undefined = undefined>(options?: NamedConstraintSpec<Name$1>) => FieldBuilderFromPresetDescriptor<Descriptor, readonly [], Name$1>;
407
+ } ? <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>;
408
408
  type FieldHelperFunction<Descriptor extends AuthoringFieldPresetDescriptor> = SupportsNamedConstraintOptions<Descriptor> extends true ? FieldHelperFunctionWithNamedConstraint<Descriptor> : FieldHelperFunctionWithoutNamedConstraint<Descriptor>;
409
409
  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 };
410
410
  //#endregion
@@ -421,13 +421,13 @@ type ExtractFieldNamespaceFromPack<Pack> = Pack extends {
421
421
  } ? Namespace : Record<never, never>;
422
422
  type MergeExtensionTypeNamespaces<ExtensionPacks> = ExtensionPacks extends Record<string, unknown> ? keyof ExtensionPacks extends never ? Record<never, never> : UnionToIntersection<{ [K in keyof ExtensionPacks]: ExtractTypeNamespaceFromPack<ExtensionPacks[K]> }[keyof ExtensionPacks]> : Record<never, never>;
423
423
  type MergeExtensionFieldNamespaces<ExtensionPacks> = ExtensionPacks extends Record<string, unknown> ? keyof ExtensionPacks extends never ? Record<never, never> : UnionToIntersection<{ [K in keyof ExtensionPacks]: ExtractFieldNamespaceFromPack<ExtensionPacks[K]> }[keyof ExtensionPacks]> : Record<never, never>;
424
- type StorageTypeFromDescriptor<Descriptor extends AuthoringTypeConstructorDescriptor, Args$1 extends readonly unknown[]> = {
425
- readonly codecId: ResolveTemplateValue<Descriptor['output']['codecId'], Args$1>;
426
- readonly nativeType: ResolveTemplateValue<Descriptor['output']['nativeType'], Args$1>;
424
+ type StorageTypeFromDescriptor<Descriptor extends AuthoringTypeConstructorDescriptor, Args extends readonly unknown[]> = {
425
+ readonly codecId: ResolveTemplateValue<Descriptor['output']['codecId'], Args>;
426
+ readonly nativeType: ResolveTemplateValue<Descriptor['output']['nativeType'], Args>;
427
427
  } & (Descriptor['output'] extends {
428
428
  readonly typeParams: infer TypeParams extends Record<string, unknown>;
429
429
  } ? {
430
- readonly typeParams: ResolveTemplateValue<TypeParams, Args$1>;
430
+ readonly typeParams: ResolveTemplateValue<TypeParams, Args>;
431
431
  } : Record<never, never>);
432
432
  type TypeHelperFunction<Descriptor extends AuthoringTypeConstructorDescriptor> = Descriptor extends {
433
433
  readonly args: infer Args extends readonly AuthoringArgumentDescriptor[];
@@ -480,28 +480,28 @@ type DefinitionColumnNaming<Definition> = Definition extends {
480
480
  } ? Strategy : undefined;
481
481
  type FirstChar<S extends string> = S extends `${infer First}${string}` ? First : '';
482
482
  type CharKind<C extends string> = C extends '' ? 'end' : C extends Lowercase<C> ? C extends Uppercase<C> ? 'other' : 'lower' : 'upper';
483
- type ShouldInsertSnakeUnderscore<PrevKind extends 'start' | 'lower' | 'upper' | 'other' | 'end', Current$1 extends string, Next extends string> = CharKind<Current$1> extends 'upper' ? PrevKind extends 'start' ? false : PrevKind extends 'lower' | 'other' ? true : CharKind<Next> extends 'lower' ? true : false : false;
483
+ type ShouldInsertSnakeUnderscore<PrevKind extends 'start' | 'lower' | 'upper' | 'other' | 'end', Current extends string, Next extends string> = CharKind<Current> extends 'upper' ? PrevKind extends 'start' ? false : PrevKind extends 'lower' | 'other' ? true : CharKind<Next> extends 'lower' ? true : false : false;
484
484
  type SnakeCaseInternal<S extends string, PrevKind extends 'start' | 'lower' | 'upper' | 'other' | 'end' = 'start'> = S extends `${infer Current}${infer Rest}` ? `${ShouldInsertSnakeUnderscore<PrevKind, Current, FirstChar<Rest>> extends true ? '_' : ''}${Lowercase<Current>}${SnakeCaseInternal<Rest, CharKind<Current>>}` : '';
485
485
  type SnakeCase<S extends string> = string extends S ? string : SnakeCaseInternal<S>;
486
- type ApplyNamingType<Name$1 extends string, Strategy extends string | undefined> = string extends Name$1 ? string : Strategy extends 'snake_case' ? SnakeCase<Name$1> : Name$1;
486
+ type ApplyNamingType<Name extends string, Strategy extends string | undefined> = string extends Name ? string : Strategy extends 'snake_case' ? SnakeCase<Name> : Name;
487
487
  type ModelNames<Definition> = keyof DefinitionModels<Definition> & string;
488
- type ModelFields<Definition, ModelName$1 extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName$1] extends {
488
+ type ModelFields<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
489
489
  readonly stageOne: {
490
490
  readonly fields: Record<string, ScalarFieldBuilder>;
491
491
  };
492
- } ? DefinitionModels<Definition>[ModelName$1]['stageOne']['fields'] : Record<never, never>;
493
- type ModelFieldNames<Definition, ModelName$1 extends ModelNames<Definition>> = keyof ModelFields<Definition, ModelName$1> & string;
494
- type StagedModelRelations<Definition, ModelName$1 extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName$1] extends {
492
+ } ? DefinitionModels<Definition>[ModelName]['stageOne']['fields'] : Record<never, never>;
493
+ type ModelFieldNames<Definition, ModelName extends ModelNames<Definition>> = keyof ModelFields<Definition, ModelName> & string;
494
+ type StagedModelRelations<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
495
495
  readonly stageOne: {
496
496
  readonly relations: infer R;
497
497
  };
498
498
  } ? R extends Record<string, unknown> ? R : Record<never, never> : Record<never, never>;
499
- type StagedModelRelationNames<Definition, ModelName$1 extends ModelNames<Definition>> = keyof StagedModelRelations<Definition, ModelName$1> & string;
500
- type ModelFieldState<Definition, ModelName$1 extends ModelNames<Definition>, FieldName$1 extends ModelFieldNames<Definition, ModelName$1>> = FieldStateOf<ModelFields<Definition, ModelName$1>[FieldName$1]>;
501
- type ModelSql<Definition, ModelName$1 extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName$1] extends {
499
+ type StagedModelRelationNames<Definition, ModelName extends ModelNames<Definition>> = keyof StagedModelRelations<Definition, ModelName> & string;
500
+ type ModelFieldState<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>> = FieldStateOf<ModelFields<Definition, ModelName>[FieldName]>;
501
+ type ModelSql<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
502
502
  readonly __sql: infer SqlSpec;
503
503
  } ? SqlSpec : undefined;
504
- type ModelAttributes<Definition, ModelName$1 extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName$1] extends {
504
+ type ModelAttributes<Definition, ModelName extends ModelNames<Definition>> = DefinitionModels<Definition>[ModelName] extends {
505
505
  readonly __attributes: infer AttributesSpec;
506
506
  } ? AttributesSpec : undefined;
507
507
  type FieldDescriptorOf<FieldState> = Present<FieldState extends {
@@ -531,43 +531,43 @@ type DescriptorTypeParams<Descriptor> = Descriptor extends {
531
531
  type DescriptorTypeRef<Descriptor> = Descriptor extends {
532
532
  readonly typeRef: infer TypeRef extends string;
533
533
  } ? TypeRef : undefined;
534
- type LookupNamedStorageTypeKeyByValue<Definition, TypeRef$1 extends StorageTypeInstance> = { [TypeName in keyof DefinitionTypes<Definition> & string]: [TypeRef$1] extends [DefinitionTypes<Definition>[TypeName]] ? [DefinitionTypes<Definition>[TypeName]] extends [TypeRef$1] ? TypeName : never : never }[keyof DefinitionTypes<Definition> & string];
535
- type ResolveNamedStorageTypeKey<Definition, TypeRef$1> = TypeRef$1 extends string ? TypeRef$1 : TypeRef$1 extends StorageTypeInstance ? [LookupNamedStorageTypeKeyByValue<Definition, TypeRef$1>] extends [never] ? string : LookupNamedStorageTypeKeyByValue<Definition, TypeRef$1> : never;
536
- type ResolveNamedStorageType<Definition, TypeRef$1> = ResolveNamedStorageTypeKey<Definition, TypeRef$1> extends infer TypeName extends string ? TypeName extends keyof DefinitionTypes<Definition> ? DefinitionTypes<Definition>[TypeName] : StorageTypeInstance : StorageTypeInstance;
534
+ type LookupNamedStorageTypeKeyByValue<Definition, TypeRef extends StorageTypeInstance> = { [TypeName in keyof DefinitionTypes<Definition> & string]: [TypeRef] extends [DefinitionTypes<Definition>[TypeName]] ? [DefinitionTypes<Definition>[TypeName]] extends [TypeRef] ? TypeName : never : never }[keyof DefinitionTypes<Definition> & string];
535
+ type ResolveNamedStorageTypeKey<Definition, TypeRef> = TypeRef extends string ? TypeRef : TypeRef extends StorageTypeInstance ? [LookupNamedStorageTypeKeyByValue<Definition, TypeRef>] extends [never] ? string : LookupNamedStorageTypeKeyByValue<Definition, TypeRef> : never;
536
+ type ResolveNamedStorageType<Definition, TypeRef> = ResolveNamedStorageTypeKey<Definition, TypeRef> extends infer TypeName extends string ? TypeName extends keyof DefinitionTypes<Definition> ? DefinitionTypes<Definition>[TypeName] : StorageTypeInstance : StorageTypeInstance;
537
537
  type ResolveFieldDescriptor<Definition, FieldState> = [FieldDescriptorOf<FieldState>] extends [never] ? ResolveNamedStorageType<Definition, FieldTypeRefOf<FieldState>> : FieldDescriptorOf<FieldState>;
538
538
  type ResolveFieldColumnTypeRef<Definition, FieldState> = [FieldTypeRefOf<FieldState>] extends [never] ? DescriptorTypeRef<FieldDescriptorOf<FieldState>> : ResolveNamedStorageTypeKey<Definition, FieldTypeRefOf<FieldState>>;
539
539
  type ResolveFieldColumnTypeParams<Definition, FieldState> = [ResolveFieldColumnTypeRef<Definition, FieldState>] extends [string] ? undefined : DescriptorTypeParams<FieldDescriptorOf<FieldState>>;
540
- type ModelTableName<Definition, ModelName$1 extends ModelNames<Definition>> = [Present<ModelSql<Definition, ModelName$1> extends {
540
+ type ModelTableName<Definition, ModelName extends ModelNames<Definition>> = [Present<ModelSql<Definition, ModelName> extends {
541
541
  readonly table?: infer TableName;
542
- } ? TableName : never>] extends [never] ? ApplyNamingType<ModelName$1, DefinitionTableNaming<Definition>> : Present<ModelSql<Definition, ModelName$1> extends {
542
+ } ? TableName : never>] extends [never] ? ApplyNamingType<ModelName, DefinitionTableNaming<Definition>> : Present<ModelSql<Definition, ModelName> extends {
543
543
  readonly table?: infer TableName;
544
- } ? TableName : never> extends infer ExplicitTableName extends string ? ExplicitTableName : ApplyNamingType<ModelName$1, DefinitionTableNaming<Definition>>;
545
- type ModelColumnName<Definition, ModelName$1 extends ModelNames<Definition>, FieldName$1 extends ModelFieldNames<Definition, ModelName$1>> = [FieldColumnOverrideOf<ModelFieldState<Definition, ModelName$1, FieldName$1>>] extends [never] ? ApplyNamingType<FieldName$1, DefinitionColumnNaming<Definition>> : FieldColumnOverrideOf<ModelFieldState<Definition, ModelName$1, FieldName$1>> extends infer ExplicitColumnName extends string ? ExplicitColumnName : ApplyNamingType<FieldName$1, DefinitionColumnNaming<Definition>>;
546
- type FieldNamesToColumnNames<Definition, ModelName$1 extends ModelNames<Definition>, FieldNames extends readonly string[]> = FieldNames extends readonly [] ? readonly [] : FieldNames extends readonly [infer First extends ModelFieldNames<Definition, ModelName$1>, ...infer Rest extends readonly string[]] ? readonly [ModelColumnName<Definition, ModelName$1, First>, ...FieldNamesToColumnNames<Definition, ModelName$1, Rest>] : readonly string[];
547
- type InlineIdFieldName<Definition, ModelName$1 extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName$1>]: [FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName$1, FieldName>>] extends [never] ? never : FieldName }[ModelFieldNames<Definition, ModelName$1>];
548
- type InlineIdFieldNames<Definition, ModelName$1 extends ModelNames<Definition>> = [InlineIdFieldName<Definition, ModelName$1>] extends [never] ? undefined : readonly [InlineIdFieldName<Definition, ModelName$1>];
549
- type InlineIdName<Definition, ModelName$1 extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName$1>]: FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName$1, FieldName>> extends {
544
+ } ? TableName : never> extends infer ExplicitTableName extends string ? ExplicitTableName : ApplyNamingType<ModelName, DefinitionTableNaming<Definition>>;
545
+ type ModelColumnName<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>> = [FieldColumnOverrideOf<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] ? ApplyNamingType<FieldName, DefinitionColumnNaming<Definition>> : FieldColumnOverrideOf<ModelFieldState<Definition, ModelName, FieldName>> extends infer ExplicitColumnName extends string ? ExplicitColumnName : ApplyNamingType<FieldName, DefinitionColumnNaming<Definition>>;
546
+ type FieldNamesToColumnNames<Definition, ModelName extends ModelNames<Definition>, FieldNames extends readonly string[]> = FieldNames extends readonly [] ? readonly [] : FieldNames extends readonly [infer First extends ModelFieldNames<Definition, ModelName>, ...infer Rest extends readonly string[]] ? readonly [ModelColumnName<Definition, ModelName, First>, ...FieldNamesToColumnNames<Definition, ModelName, Rest>] : readonly string[];
547
+ type InlineIdFieldName<Definition, ModelName extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName>]: [FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName, FieldName>>] extends [never] ? never : FieldName }[ModelFieldNames<Definition, ModelName>];
548
+ type InlineIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = [InlineIdFieldName<Definition, ModelName>] extends [never] ? undefined : readonly [InlineIdFieldName<Definition, ModelName>];
549
+ type InlineIdName<Definition, ModelName extends ModelNames<Definition>> = { [FieldName in ModelFieldNames<Definition, ModelName>]: FieldInlineIdSpecOf<ModelFieldState<Definition, ModelName, FieldName>> extends {
550
550
  readonly name?: infer Name extends string;
551
- } ? Name : never }[ModelFieldNames<Definition, ModelName$1>];
552
- type AttributeIdFieldNames<Definition, ModelName$1 extends ModelNames<Definition>> = AttributeStageIdFieldNames<ModelAttributes<Definition, ModelName$1>>;
553
- type AttributeIdName<Definition, ModelName$1 extends ModelNames<Definition>> = Present<ModelAttributes<Definition, ModelName$1> extends {
551
+ } ? Name : never }[ModelFieldNames<Definition, ModelName>];
552
+ type AttributeIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = AttributeStageIdFieldNames<ModelAttributes<Definition, ModelName>>;
553
+ type AttributeIdName<Definition, ModelName extends ModelNames<Definition>> = Present<ModelAttributes<Definition, ModelName> extends {
554
554
  readonly id?: {
555
555
  readonly name?: infer Name extends string;
556
556
  };
557
557
  } ? Name : never>;
558
- type ModelIdFieldNames<Definition, ModelName$1 extends ModelNames<Definition>> = [AttributeIdFieldNames<Definition, ModelName$1>] extends [undefined] ? InlineIdFieldNames<Definition, ModelName$1> : AttributeIdFieldNames<Definition, ModelName$1>;
559
- type ModelIdName<Definition, ModelName$1 extends ModelNames<Definition>> = [AttributeIdName<Definition, ModelName$1>] extends [never] ? Present<InlineIdName<Definition, ModelName$1>> : AttributeIdName<Definition, ModelName$1>;
560
- type StorageColumn<CodecId$1 extends string, Nullable$1 extends boolean, NativeType extends string, TypeRef$1 extends string | undefined = undefined, TypeParams$1 extends Record<string, unknown> | undefined = undefined> = {
558
+ type ModelIdFieldNames<Definition, ModelName extends ModelNames<Definition>> = [AttributeIdFieldNames<Definition, ModelName>] extends [undefined] ? InlineIdFieldNames<Definition, ModelName> : AttributeIdFieldNames<Definition, ModelName>;
559
+ type ModelIdName<Definition, ModelName extends ModelNames<Definition>> = [AttributeIdName<Definition, ModelName>] extends [never] ? Present<InlineIdName<Definition, ModelName>> : AttributeIdName<Definition, ModelName>;
560
+ type StorageColumn<CodecId extends string, Nullable extends boolean, NativeType extends string, TypeRef extends string | undefined = undefined, TypeParams extends Record<string, unknown> | undefined = undefined> = {
561
561
  readonly nativeType: NativeType;
562
- readonly codecId: CodecId$1;
563
- readonly nullable: Nullable$1;
562
+ readonly codecId: CodecId;
563
+ readonly nullable: Nullable;
564
564
  readonly default?: ColumnDefault;
565
- } & (TypeRef$1 extends string ? {
566
- readonly typeRef: TypeRef$1;
567
- } : Record<string, never>) & (TypeParams$1 extends Record<string, unknown> ? {
568
- readonly typeParams: TypeParams$1;
565
+ } & (TypeRef extends string ? {
566
+ readonly typeRef: TypeRef;
567
+ } : Record<string, never>) & (TypeParams extends Record<string, unknown> ? {
568
+ readonly typeParams: TypeParams;
569
569
  } : Record<string, never>);
570
- type ModelStorageColumn<Definition, ModelName$1 extends ModelNames<Definition>, FieldName$1 extends string> = FieldName$1 extends ModelFieldNames<Definition, ModelName$1> ? StorageColumn<DescriptorCodecId<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName$1, FieldName$1>>>, FieldNullableOf<ModelFieldState<Definition, ModelName$1, FieldName$1>>, DescriptorNativeType<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName$1, FieldName$1>>>, ResolveFieldColumnTypeRef<Definition, ModelFieldState<Definition, ModelName$1, FieldName$1>>, ResolveFieldColumnTypeParams<Definition, ModelFieldState<Definition, ModelName$1, FieldName$1>>> : never;
570
+ type ModelStorageColumn<Definition, ModelName extends ModelNames<Definition>, FieldName extends string> = FieldName extends ModelFieldNames<Definition, ModelName> ? StorageColumn<DescriptorCodecId<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName, FieldName>>>, FieldNullableOf<ModelFieldState<Definition, ModelName, FieldName>>, DescriptorNativeType<ResolveFieldDescriptor<Definition, ModelFieldState<Definition, ModelName, FieldName>>>, ResolveFieldColumnTypeRef<Definition, ModelFieldState<Definition, ModelName, FieldName>>, ResolveFieldColumnTypeParams<Definition, ModelFieldState<Definition, ModelName, FieldName>>> : never;
571
571
  type BuiltModels<Definition> = { readonly [ModelName in ModelNames<Definition>]: {
572
572
  readonly storage: {
573
573
  readonly table: ModelTableName<Definition, ModelName>;
@@ -584,9 +584,9 @@ type BuiltModels<Definition> = { readonly [ModelName in ModelNames<Definition>]:
584
584
  } };
585
585
  readonly relations: { readonly [RelName in StagedModelRelationNames<Definition, ModelName>]: ContractRelation };
586
586
  } };
587
- type BuiltModelColumnMappings<Definition, ModelName$1 extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName$1]['storage']['fields'];
588
- type BuiltModelTableName<Definition, ModelName$1 extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName$1]['storage']['table'];
589
- type BuiltStorageTableColumns<Definition, ModelName$1 extends ModelNames<Definition>> = { readonly [FieldName in keyof BuiltModelColumnMappings<Definition, ModelName$1> & string as BuiltModelColumnMappings<Definition, ModelName$1>[FieldName]['column']]: ModelStorageColumn<Definition, ModelName$1, FieldName> };
587
+ type BuiltModelColumnMappings<Definition, ModelName extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName]['storage']['fields'];
588
+ type BuiltModelTableName<Definition, ModelName extends ModelNames<Definition>> = BuiltModels<Definition>[ModelName]['storage']['table'];
589
+ type BuiltStorageTableColumns<Definition, ModelName extends ModelNames<Definition>> = { readonly [FieldName in keyof BuiltModelColumnMappings<Definition, ModelName> & string as BuiltModelColumnMappings<Definition, ModelName>[FieldName]['column']]: ModelStorageColumn<Definition, ModelName, FieldName> };
590
590
  type BuiltStorageTables<Definition> = { readonly [ModelName in ModelNames<Definition> as BuiltModelTableName<Definition, ModelName>]: {
591
591
  readonly columns: BuiltStorageTableColumns<Definition, ModelName>;
592
592
  readonly uniques: ReadonlyArray<{
@@ -617,7 +617,7 @@ type BuiltStorage<Definition> = {
617
617
  readonly tables: BuiltStorageTables<Definition>;
618
618
  readonly types: DefinitionTypes<Definition>;
619
619
  };
620
- type FieldOutputType<Definition, ModelName$1 extends ModelNames<Definition>, FieldName$1 extends ModelFieldNames<Definition, ModelName$1>> = ModelStorageColumn<Definition, ModelName$1, FieldName$1> extends infer Col ? Col extends {
620
+ type FieldOutputType<Definition, ModelName extends ModelNames<Definition>, FieldName extends ModelFieldNames<Definition, ModelName>> = ModelStorageColumn<Definition, ModelName, FieldName> extends infer Col ? Col extends {
621
621
  readonly codecId: infer Id extends string;
622
622
  } ? Id extends keyof CodecTypesFromDefinition<Definition> ? CodecTypesFromDefinition<Definition>[Id] extends {
623
623
  readonly output: infer O;
@@ -640,7 +640,7 @@ interface FieldNode {
640
640
  readonly descriptor: ColumnTypeDescriptor;
641
641
  readonly nullable: boolean;
642
642
  readonly default?: ColumnDefault;
643
- readonly executionDefault?: ExecutionMutationDefaultValue;
643
+ readonly executionDefaults?: ExecutionMutationDefaultPhases$1;
644
644
  readonly many?: boolean;
645
645
  }
646
646
  interface PrimaryKeyNode {
@@ -693,7 +693,7 @@ interface ValueObjectFieldNode {
693
693
  readonly valueObjectName: string;
694
694
  readonly nullable: boolean;
695
695
  readonly default?: ColumnDefault;
696
- readonly executionDefault?: ExecutionMutationDefaultValue;
696
+ readonly executionDefaults?: ExecutionMutationDefaultPhases$1;
697
697
  readonly many?: boolean;
698
698
  }
699
699
  interface ValueObjectNode {