@prisma-next/contract-authoring 0.3.0-dev.9 → 0.3.0-dev.91

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,5 +1,91 @@
1
- import type { ColumnBuilderState, ColumnTypeDescriptor, TableBuilderState } from './builder-state';
1
+ import type { ColumnDefault, ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
2
+ import { ifDefined } from '@prisma-next/utils/defined';
3
+ import type {
4
+ ColumnBuilderState,
5
+ ColumnTypeDescriptor,
6
+ ForeignKeyDef,
7
+ ForeignKeyOptions,
8
+ IndexDef,
9
+ TableBuilderState,
10
+ UniqueConstraintDef,
11
+ } from './builder-state';
2
12
 
13
+ /**
14
+ * Column options for nullable columns.
15
+ */
16
+ interface NullableColumnOptions<Descriptor extends ColumnTypeDescriptor> {
17
+ type: Descriptor;
18
+ nullable: true;
19
+ typeParams?: Record<string, unknown>;
20
+ default?: ColumnDefault;
21
+ }
22
+
23
+ /**
24
+ * Column options for non-nullable columns.
25
+ * Non-nullable columns can optionally have a default value.
26
+ */
27
+ interface NonNullableColumnOptions<Descriptor extends ColumnTypeDescriptor> {
28
+ type: Descriptor;
29
+ nullable?: false;
30
+ typeParams?: Record<string, unknown>;
31
+ default?: ColumnDefault;
32
+ }
33
+
34
+ type GeneratedColumnOptions<Descriptor extends ColumnTypeDescriptor> = Omit<
35
+ NonNullableColumnOptions<Descriptor>,
36
+ 'default' | 'nullable'
37
+ > & {
38
+ /**
39
+ * Generated columns are always non-nullable and use mutation-time defaults
40
+ * that the runtime injects when the column is omitted from insert input.
41
+ */
42
+ nullable?: false;
43
+ generated: ExecutionMutationDefaultValue;
44
+ };
45
+
46
+ /** Column options for any column nullability. */
47
+ type ColumnOptions<Descriptor extends ColumnTypeDescriptor> =
48
+ | NullableColumnOptions<Descriptor>
49
+ | NonNullableColumnOptions<Descriptor>;
50
+
51
+ type NullableFromOptions<TOptions> = TOptions extends { nullable: true } ? true : false;
52
+ type IndexOptions = {
53
+ readonly name?: string;
54
+ readonly using?: string;
55
+ readonly config?: Record<string, unknown>;
56
+ };
57
+
58
+ function isIndexDef(value: readonly string[] | IndexDef): value is IndexDef {
59
+ return !Array.isArray(value);
60
+ }
61
+
62
+ interface TableBuilderInternalState<
63
+ Name extends string,
64
+ Columns extends Record<string, ColumnBuilderState<string, boolean, string>>,
65
+ PrimaryKey extends readonly string[] | undefined,
66
+ > {
67
+ readonly name: Name;
68
+ readonly columns: Columns;
69
+ readonly primaryKey: PrimaryKey;
70
+ readonly primaryKeyName: string | undefined;
71
+ readonly uniques: readonly UniqueConstraintDef[];
72
+ readonly indexes: readonly IndexDef[];
73
+ readonly foreignKeys: readonly ForeignKeyDef[];
74
+ }
75
+
76
+ /**
77
+ * Creates a new table builder with the given name.
78
+ * This is the preferred way to create a TableBuilder - it ensures
79
+ * type parameters are inferred correctly without unsafe casts.
80
+ */
81
+ export function createTable<Name extends string>(name: Name): TableBuilder<Name> {
82
+ return new TableBuilder(name, {}, undefined, undefined, [], [], []);
83
+ }
84
+
85
+ /**
86
+ * Builder for defining table structure with type-safe chaining.
87
+ * Use `createTable(name)` to create instances.
88
+ */
3
89
  export class TableBuilder<
4
90
  Name extends string,
5
91
  Columns extends Record<string, ColumnBuilderState<string, boolean, string>> = Record<
@@ -8,76 +94,224 @@ export class TableBuilder<
8
94
  >,
9
95
  PrimaryKey extends readonly string[] | undefined = undefined,
10
96
  > {
11
- private readonly _name: Name;
12
- private readonly _columns: Columns;
13
- private readonly _primaryKey: PrimaryKey;
14
-
15
- constructor(name: Name, columns: Columns = {} as Columns, primaryKey?: PrimaryKey) {
16
- this._name = name;
17
- this._columns = columns;
18
- this._primaryKey = primaryKey as PrimaryKey;
97
+ private readonly _state: TableBuilderInternalState<Name, Columns, PrimaryKey>;
98
+
99
+ /** @internal Use createTable() instead */
100
+ constructor(
101
+ name: Name,
102
+ columns: Columns,
103
+ primaryKey: PrimaryKey,
104
+ primaryKeyName: string | undefined,
105
+ uniques: readonly UniqueConstraintDef[],
106
+ indexes: readonly IndexDef[],
107
+ foreignKeys: readonly ForeignKeyDef[],
108
+ ) {
109
+ this._state = {
110
+ name,
111
+ columns,
112
+ primaryKey,
113
+ primaryKeyName,
114
+ uniques,
115
+ indexes,
116
+ foreignKeys,
117
+ };
118
+ }
119
+
120
+ private get _name(): Name {
121
+ return this._state.name;
122
+ }
123
+
124
+ private get _columns(): Columns {
125
+ return this._state.columns;
126
+ }
127
+
128
+ private get _primaryKey(): PrimaryKey {
129
+ return this._state.primaryKey;
130
+ }
131
+
132
+ /** Add a nullable column to the table. */
133
+ column<ColName extends string, Descriptor extends ColumnTypeDescriptor>(
134
+ name: ColName,
135
+ options: NullableColumnOptions<Descriptor>,
136
+ ): TableBuilder<
137
+ Name,
138
+ Columns & Record<ColName, ColumnBuilderState<ColName, true, Descriptor['codecId']>>,
139
+ PrimaryKey
140
+ >;
141
+
142
+ /**
143
+ * Add a non-nullable column to the table.
144
+ * Non-nullable columns can optionally have a default value.
145
+ */
146
+ column<ColName extends string, Descriptor extends ColumnTypeDescriptor>(
147
+ name: ColName,
148
+ options: NonNullableColumnOptions<Descriptor>,
149
+ ): TableBuilder<
150
+ Name,
151
+ Columns & Record<ColName, ColumnBuilderState<ColName, false, Descriptor['codecId']>>,
152
+ PrimaryKey
153
+ >;
154
+
155
+ /**
156
+ * Implementation of the column method.
157
+ */
158
+ column<ColName extends string, Descriptor extends ColumnTypeDescriptor>(
159
+ name: ColName,
160
+ options: ColumnOptions<Descriptor>,
161
+ ): TableBuilder<
162
+ Name,
163
+ Columns & Record<ColName, ColumnBuilderState<ColName, boolean, Descriptor['codecId']>>,
164
+ PrimaryKey
165
+ > {
166
+ return this.columnInternal(name, options);
167
+ }
168
+
169
+ generated<ColName extends string, Descriptor extends ColumnTypeDescriptor>(
170
+ name: ColName,
171
+ options: GeneratedColumnOptions<Descriptor>,
172
+ ): TableBuilder<
173
+ Name,
174
+ Columns & Record<ColName, ColumnBuilderState<ColName, false, Descriptor['codecId']>>,
175
+ PrimaryKey
176
+ > {
177
+ const { generated, ...columnOptions } = options;
178
+ return this.columnInternal(name, columnOptions, generated);
19
179
  }
20
180
 
21
- column<
181
+ private columnInternal<
22
182
  ColName extends string,
23
183
  Descriptor extends ColumnTypeDescriptor,
24
- Nullable extends boolean | undefined = undefined,
184
+ Options extends ColumnOptions<Descriptor>,
25
185
  >(
26
186
  name: ColName,
27
- options: {
28
- type: Descriptor;
29
- nullable?: Nullable;
30
- },
187
+ options: Options,
188
+ executionDefault?: ExecutionMutationDefaultValue,
31
189
  ): TableBuilder<
32
190
  Name,
33
191
  Columns &
34
192
  Record<
35
193
  ColName,
36
- ColumnBuilderState<ColName, Nullable extends true ? true : false, Descriptor['codecId']>
194
+ ColumnBuilderState<ColName, NullableFromOptions<Options>, Descriptor['codecId']>
37
195
  >,
38
196
  PrimaryKey
39
197
  > {
40
- const nullable = (options.nullable ?? false) as Nullable extends true ? true : false;
41
- const { codecId, nativeType } = options.type;
198
+ const nullable = options.nullable ?? false;
199
+ const { codecId, nativeType, typeParams: descriptorTypeParams, typeRef } = options.type;
200
+ const typeParams = options.typeParams ?? descriptorTypeParams;
42
201
 
43
202
  const columnState = {
44
203
  name,
45
204
  nullable,
46
205
  type: codecId,
47
206
  nativeType,
48
- } as ColumnBuilderState<ColName, Nullable extends true ? true : false, Descriptor['codecId']>;
207
+ ...ifDefined('typeParams', typeParams),
208
+ ...ifDefined('typeRef', typeRef),
209
+ ...ifDefined('default', 'default' in options ? options.default : undefined),
210
+ ...ifDefined('executionDefault', executionDefault),
211
+ } as ColumnBuilderState<ColName, NullableFromOptions<Options>, Descriptor['codecId']>;
212
+ const newColumns = { ...this._columns, [name]: columnState } as Columns &
213
+ Record<
214
+ ColName,
215
+ ColumnBuilderState<ColName, NullableFromOptions<Options>, Descriptor['codecId']>
216
+ >;
49
217
  return new TableBuilder(
50
- this._name,
51
- { ...this._columns, [name]: columnState } as Columns &
52
- Record<
53
- ColName,
54
- ColumnBuilderState<ColName, Nullable extends true ? true : false, Descriptor['codecId']>
55
- >,
56
- this._primaryKey,
218
+ this._state.name,
219
+ newColumns,
220
+ this._state.primaryKey,
221
+ this._state.primaryKeyName,
222
+ this._state.uniques,
223
+ this._state.indexes,
224
+ this._state.foreignKeys,
57
225
  );
58
226
  }
59
227
 
60
228
  primaryKey<PK extends readonly string[]>(
61
229
  columns: PK,
62
- _name?: string,
230
+ name?: string,
63
231
  ): TableBuilder<Name, Columns, PK> {
64
- return new TableBuilder(this._name, this._columns, columns);
232
+ return new TableBuilder(
233
+ this._state.name,
234
+ this._state.columns,
235
+ columns,
236
+ name,
237
+ this._state.uniques,
238
+ this._state.indexes,
239
+ this._state.foreignKeys,
240
+ );
65
241
  }
66
242
 
67
- unique(_columns: readonly string[], _name?: string): TableBuilder<Name, Columns, PrimaryKey> {
68
- return this;
243
+ unique(columns: readonly string[], name?: string): TableBuilder<Name, Columns, PrimaryKey> {
244
+ const constraint: UniqueConstraintDef = name ? { columns, name } : { columns };
245
+ return new TableBuilder(
246
+ this._state.name,
247
+ this._state.columns,
248
+ this._state.primaryKey,
249
+ this._state.primaryKeyName,
250
+ [...this._state.uniques, constraint],
251
+ this._state.indexes,
252
+ this._state.foreignKeys,
253
+ );
69
254
  }
70
255
 
71
- index(_columns: readonly string[], _name?: string): TableBuilder<Name, Columns, PrimaryKey> {
72
- return this;
256
+ index(columns: readonly string[], name?: string): TableBuilder<Name, Columns, PrimaryKey>;
257
+ index(
258
+ columns: readonly string[],
259
+ options?: IndexOptions,
260
+ ): TableBuilder<Name, Columns, PrimaryKey>;
261
+ index(indexDef: IndexDef): TableBuilder<Name, Columns, PrimaryKey>;
262
+ index(
263
+ columnsOrIndexDef: readonly string[] | IndexDef,
264
+ nameOrOptions?: string | IndexOptions,
265
+ ): TableBuilder<Name, Columns, PrimaryKey> {
266
+ const indexDef: IndexDef = isIndexDef(columnsOrIndexDef)
267
+ ? columnsOrIndexDef
268
+ : {
269
+ columns: columnsOrIndexDef,
270
+ ...(typeof nameOrOptions === 'string' ? { name: nameOrOptions } : {}),
271
+ ...(typeof nameOrOptions === 'object' && nameOrOptions !== null
272
+ ? {
273
+ ...(nameOrOptions.name !== undefined ? { name: nameOrOptions.name } : {}),
274
+ ...(nameOrOptions.using !== undefined ? { using: nameOrOptions.using } : {}),
275
+ ...(nameOrOptions.config !== undefined ? { config: nameOrOptions.config } : {}),
276
+ }
277
+ : {}),
278
+ };
279
+
280
+ return new TableBuilder(
281
+ this._state.name,
282
+ this._state.columns,
283
+ this._state.primaryKey,
284
+ this._state.primaryKeyName,
285
+ this._state.uniques,
286
+ [...this._state.indexes, indexDef],
287
+ this._state.foreignKeys,
288
+ );
73
289
  }
74
290
 
75
291
  foreignKey(
76
- _columns: readonly string[],
77
- _references: { table: string; columns: readonly string[] },
78
- _name?: string,
292
+ columns: readonly string[],
293
+ references: { table: string; columns: readonly string[] },
294
+ opts?: string | (ForeignKeyOptions & { constraint?: boolean; index?: boolean }),
79
295
  ): TableBuilder<Name, Columns, PrimaryKey> {
80
- return this;
296
+ const resolved = typeof opts === 'string' ? { name: opts } : opts;
297
+ const fkDef: ForeignKeyDef = {
298
+ columns,
299
+ references,
300
+ ...ifDefined('name', resolved?.name),
301
+ ...ifDefined('onDelete', resolved?.onDelete),
302
+ ...ifDefined('onUpdate', resolved?.onUpdate),
303
+ ...ifDefined('constraint', resolved?.constraint),
304
+ ...ifDefined('index', resolved?.index),
305
+ };
306
+ return new TableBuilder(
307
+ this._state.name,
308
+ this._state.columns,
309
+ this._state.primaryKey,
310
+ this._state.primaryKeyName,
311
+ this._state.uniques,
312
+ this._state.indexes,
313
+ [...this._state.foreignKeys, fkDef],
314
+ );
81
315
  }
82
316
 
83
317
  build(): TableBuilderState<Name, Columns, PrimaryKey> {
@@ -85,6 +319,12 @@ export class TableBuilder<
85
319
  name: this._name,
86
320
  columns: this._columns,
87
321
  ...(this._primaryKey !== undefined ? { primaryKey: this._primaryKey } : {}),
322
+ ...(this._state.primaryKeyName !== undefined
323
+ ? { primaryKeyName: this._state.primaryKeyName }
324
+ : {}),
325
+ uniques: this._state.uniques,
326
+ indexes: this._state.indexes,
327
+ foreignKeys: this._state.foreignKeys,
88
328
  } as TableBuilderState<Name, Columns, PrimaryKey>;
89
329
  }
90
330
  }
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ColumnDefault } from '@prisma-next/contract/types';
1
2
  import type {
2
3
  ColumnBuilderState,
3
4
  ModelBuilderState,
@@ -9,6 +10,9 @@ export type BuildStorageColumn<Nullable extends boolean, Type extends string> =
9
10
  readonly nativeType: string;
10
11
  readonly codecId: Type;
11
12
  readonly nullable: Nullable;
13
+ readonly typeParams?: Record<string, unknown>;
14
+ readonly typeRef?: string;
15
+ readonly default?: ColumnDefault;
12
16
  };
13
17
 
14
18
  export type ExtractColumns<
@@ -25,13 +29,14 @@ export type ExtractPrimaryKey<
25
29
  Record<string, ColumnBuilderState<string, boolean, string>>,
26
30
  readonly string[] | undefined
27
31
  >,
28
- > = T extends TableBuilderState<
29
- string,
30
- Record<string, ColumnBuilderState<string, boolean, string>>,
31
- infer PK
32
- >
33
- ? PK
34
- : never;
32
+ > =
33
+ T extends TableBuilderState<
34
+ string,
35
+ Record<string, ColumnBuilderState<string, boolean, string>>,
36
+ infer PK
37
+ >
38
+ ? PK
39
+ : never;
35
40
 
36
41
  export type BuildStorage<
37
42
  Tables extends Record<
@@ -92,9 +97,10 @@ export type ExtractModelFields<
92
97
  Record<string, string>,
93
98
  Record<string, RelationDefinition>
94
99
  >,
95
- > = T extends ModelBuilderState<string, string, infer F, Record<string, RelationDefinition>>
96
- ? F
97
- : never;
100
+ > =
101
+ T extends ModelBuilderState<string, string, infer F, Record<string, RelationDefinition>>
102
+ ? F
103
+ : never;
98
104
 
99
105
  export type ExtractModelRelations<
100
106
  T extends ModelBuilderState<
@@ -1,60 +0,0 @@
1
- /**
2
- * Column type descriptor containing both codec ID and native type.
3
- * Used when defining columns with descriptor objects instead of string IDs.
4
- */
5
- export type ColumnTypeDescriptor = {
6
- readonly codecId: string;
7
- readonly nativeType: string;
8
- };
9
- export interface ColumnBuilderState<Name extends string, Nullable extends boolean, Type extends string> {
10
- readonly name: Name;
11
- readonly nullable: Nullable;
12
- readonly type: Type;
13
- readonly nativeType: string;
14
- }
15
- export interface TableBuilderState<Name extends string, Columns extends Record<string, ColumnBuilderState<string, boolean, string>>, PrimaryKey extends readonly string[] | undefined> {
16
- readonly name: Name;
17
- readonly columns: Columns;
18
- readonly primaryKey?: PrimaryKey;
19
- }
20
- export type RelationDefinition = {
21
- readonly to: string;
22
- readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
23
- readonly on: {
24
- readonly parentCols: readonly string[];
25
- readonly childCols: readonly string[];
26
- };
27
- readonly through?: {
28
- readonly table: string;
29
- readonly parentCols: readonly string[];
30
- readonly childCols: readonly string[];
31
- };
32
- };
33
- export interface ModelBuilderState<Name extends string, Table extends string, Fields extends Record<string, string>, Relations extends Record<string, RelationDefinition>> {
34
- readonly name: Name;
35
- readonly table: Table;
36
- readonly fields: Fields;
37
- readonly relations: Relations;
38
- }
39
- export interface ContractBuilderState<Target extends string | undefined = string | undefined, Tables extends Record<string, TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>> = Record<never, TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>>, Models extends Record<string, ModelBuilderState<string, string, Record<string, string>, Record<string, RelationDefinition>>> = Record<never, ModelBuilderState<string, string, Record<string, string>, Record<string, RelationDefinition>>>, CoreHash extends string | undefined = string | undefined, ExtensionPacks extends Record<string, unknown> | undefined = undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined> {
40
- readonly target?: Target;
41
- readonly tables: Tables;
42
- readonly models: Models;
43
- readonly coreHash?: CoreHash;
44
- readonly extensionPacks?: ExtensionPacks;
45
- readonly capabilities?: Capabilities;
46
- /**
47
- * Array of extension pack namespace identifiers (e.g., ['pgvector', 'postgis']).
48
- * Populated when extension packs are registered during contract building.
49
- * Used to track which extension packs are included in the contract.
50
- * Can be undefined or empty if no extension packs are registered.
51
- * Namespace format matches the extension pack ID (e.g., 'pgvector', not 'pgvector@1.0.0').
52
- */
53
- readonly extensionNamespaces?: readonly string[];
54
- }
55
- export interface ColumnBuilder<Name extends string, Nullable extends boolean, Type extends string> {
56
- nullable<Value extends boolean>(value?: Value): ColumnBuilder<Name, Value, Type>;
57
- type<Id extends string>(id: Id): ColumnBuilder<Name, Nullable, Id>;
58
- build(): ColumnBuilderState<Name, Nullable, Type>;
59
- }
60
- //# sourceMappingURL=builder-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builder-state.d.ts","sourceRoot":"","sources":["../src/builder-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,kBAAkB,CACjC,IAAI,SAAS,MAAM,EACnB,QAAQ,SAAS,OAAO,EACxB,IAAI,SAAS,MAAM;IAEnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB,CAChC,IAAI,SAAS,MAAM,EACnB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAC3E,UAAU,SAAS,SAAS,MAAM,EAAE,GAAG,SAAS;IAEhD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC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SAAS,OAAO,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjF,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACnE,KAAK,IAAI,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;CACnD"}
@@ -1,15 +0,0 @@
1
- import type { TargetPackRef } from '@prisma-next/contract/framework-components';
2
- import type { ColumnBuilderState, ContractBuilderState, ModelBuilderState, RelationDefinition, TableBuilderState } from './builder-state';
3
- import { ModelBuilder } from './model-builder';
4
- import { TableBuilder } from './table-builder';
5
- export declare class ContractBuilder<Target extends string | undefined = undefined, Tables extends Record<string, TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>> = Record<never, never>, Models extends Record<string, ModelBuilderState<string, string, Record<string, string>, Record<string, RelationDefinition>>> = Record<never, never>, CoreHash extends string | undefined = undefined, ExtensionPacks extends Record<string, unknown> | undefined = undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined> {
6
- protected readonly state: ContractBuilderState<Target, Tables, Models, CoreHash, ExtensionPacks, Capabilities>;
7
- constructor(state?: ContractBuilderState<Target, Tables, Models, CoreHash, ExtensionPacks, Capabilities>);
8
- target<T extends string>(packRef: TargetPackRef<string, T>): ContractBuilder<T, Tables, Models, CoreHash, ExtensionPacks, Capabilities>;
9
- capabilities<C extends Record<string, Record<string, boolean>>>(capabilities: C): ContractBuilder<Target, Tables, Models, CoreHash, ExtensionPacks, C>;
10
- table<TableName extends string, T extends TableBuilder<TableName, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>>(name: TableName, callback: (t: TableBuilder<TableName>) => T | undefined): ContractBuilder<Target, Tables & Record<TableName, ReturnType<T['build']>>, Models, CoreHash, ExtensionPacks, Capabilities>;
11
- model<ModelName extends string, TableName extends string, M extends ModelBuilder<ModelName, TableName, Record<string, string>, Record<string, RelationDefinition>>>(name: ModelName, table: TableName, callback: (m: ModelBuilder<ModelName, TableName, Record<string, string>, Record<never, never>>) => M | undefined): ContractBuilder<Target, Tables, Models & Record<ModelName, ReturnType<M['build']>>, CoreHash, ExtensionPacks, Capabilities>;
12
- coreHash<H extends string>(hash: H): ContractBuilder<Target, Tables, Models, H, ExtensionPacks, Capabilities>;
13
- }
14
- export declare function defineContract(): ContractBuilder;
15
- //# sourceMappingURL=contract-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-builder.d.ts","sourceRoot":"","sources":["../src/contract-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAAa,eAAe,CAC1B,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAC7C,MAAM,SAAS,MAAM,CACnB,MAAM,EACN,iBAAiB,CACf,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAC3D,SAAS,MAAM,EAAE,GAAG,SAAS,CAC9B,CACF,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACxB,MAAM,SAAS,MAAM,CACnB,MAAM,EACN,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAC9F,GAAG,MAAM,CAAC,KAAK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ACN,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAClD,MAAM,EACN,QAAQ,EACR,cAAc,EACd,YAAY,CACb;IAoBD,KAAK,CACH,SAAS,SAAS,MAAM,EACxB,SAAS,SAAS,MAAM,EACxB,CAAC,SAAS,YAAY,CACpB,SAAS,EACT,SAAS,EACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACtB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CACnC,EAED,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CACR,CAAC,EAAE,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,KAChF,CAAC,GAAG,SAAS,GACjB,eAAe,CAChB,MAAM,EACN,MAAM,EACN,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAClD,QAAQ,EACR,cAAc,EACd,YAAY,CACb;IAoBD,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvB,IAAI,EAAE,CAAC,GACN,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,YAAY,CAAC;CAM5E;AAED,wBAAgB,cAAc,IAAI,eAAe,CAEhD"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export type { ColumnBuilder, ColumnBuilderState, ColumnTypeDescriptor, ContractBuilderState, ModelBuilderState, RelationDefinition, TableBuilderState, } from './builder-state';
2
- export { ContractBuilder, defineContract } from './contract-builder';
3
- export { ModelBuilder } from './model-builder';
4
- export { TableBuilder } from './table-builder';
5
- export type { BuildModelFields, BuildModels, BuildRelations, BuildStorage, BuildStorageColumn, BuildStorageTables, ExtractColumns, ExtractModelFields, ExtractModelRelations, ExtractPrimaryKey, Mutable, } from './types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,OAAO,GACR,MAAM,SAAS,CAAC"}