@prisma-next/contract-authoring 0.3.0-dev.135 → 0.3.0-dev.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,50 +1,44 @@
1
1
  # @prisma-next/contract-authoring
2
2
 
3
- **Status:** Phase 2 - Target-agnostic contract authoring core extracted
3
+ **Status:** Shared descriptor types for family-specific contract authoring
4
4
 
5
- This package contains the target-agnostic contract authoring builder core for Prisma Next.
5
+ This package holds the small, target-neutral descriptor vocabulary shared by Prisma Next authoring surfaces, targets, extensions, and ID helpers.
6
6
 
7
7
  ## Overview
8
8
 
9
- This package provides generic builder primitives that can be composed with target-family specific types (e.g., SQL) to create contract authoring surfaces. It is part of the authoring ring and depends only on `@prisma-next/contract` and core packages.
9
+ `@prisma-next/contract-authoring` is not the active TypeScript contract DSL. It exists to give multiple packages a common way to describe authored storage details without depending on SQL-specific packages.
10
10
 
11
11
  ## Responsibilities
12
12
 
13
- - **Generic Builder Core**: Provides target-agnostic builder state types and builder classes (`TableBuilder`, `ModelBuilder`, `ContractBuilder`)
14
- - **State Management**: Manages builder state for tables, columns, models, and relations without target-specific logic
15
- - **Storage Type State**: Captures target-agnostic storage type entries and column `typeRef` metadata for family-specific composition
16
- - **Type Helpers**: Provides generic type-level helpers for transforming builder states into contract structures
17
- - **Composition Surface**: Enables target-family specific packages (e.g., `@prisma-next/sql-contract-ts`) to compose generic core with family-specific types
18
- - **Defaults**: Reuses shared contract `ColumnDefault` for db-agnostic defaults (literal, function, and client-generated descriptors)
19
- - **Foreign Keys Configuration**: Provides a `foreignKeys()` method on the base `ContractBuilder` to configure FK constraint and index emission behavior
13
+ - **Column descriptors**: `ColumnTypeDescriptor` captures a codec ID, native type, and optional `typeParams` / `typeRef`
14
+ - **Index descriptors**: `IndexDef` captures index column lists plus optional `name`, `using`, and `config`
15
+ - **Foreign key defaults**: `ForeignKeyDefaultsState` captures default FK materialization choices shared by authoring surfaces
16
+ - **Shared authoring vocabulary**: Gives target-family packages such as `@prisma-next/sql-contract-ts` a target-neutral descriptor layer
20
17
 
21
18
  ## Package Status
22
19
 
23
- This package was created in Phase 2 of the contract authoring extraction. It contains the extracted target-neutral builder core from `@prisma-next/sql-contract-ts`. The SQL layer (`@prisma-next/sql-contract-ts`) composes this generic core with SQL-specific types.
20
+ This package is the extracted shared descriptor layer from the contract authoring split. The current SQL TypeScript authoring implementation lives in `@prisma-next/sql-contract-ts`.
24
21
 
25
22
  ## Architecture
26
23
 
27
- - **Builder state types**: Generic state types (`ColumnBuilderState`, `TableBuilderState`, `ModelBuilderState`, `ContractBuilderState`) that don't reference any target-family specific types
28
- - **Builder classes**: Generic builder classes (`TableBuilder`, `ModelBuilder`, `ContractBuilder`) that handle state management
29
- - **Type helpers**: Generic type-level helpers for transforming builder states into contract structures
30
- - **No target-specific logic**: This package must remain target-family agnostic and cannot import from `@prisma-next/sql-*` or other family-specific modules
24
+ - **No builders or lowering**: This package does not own `defineContract`, `field`, `model`, `rel`, or any lowering pipeline
25
+ - **No target-specific logic**: It must remain target-family agnostic and cannot import from `@prisma-next/sql-*` or other family-specific modules
26
+ - **Shared by multiple layers**: SQL authoring, target packs, extension packs, and ID helpers all consume these types
31
27
 
32
28
  ## Dependencies
33
29
 
34
- - `@prisma-next/contract` - Core contract types
35
- - `ts-toolbelt` - Type utilities
30
+ - Runtime dependencies: none
36
31
 
37
32
  ## Exports
38
33
 
39
- - Builder state types: `ColumnBuilderState`, `TableBuilderState`, `ModelBuilderState`, `ContractBuilderState`, `ForeignKeysConfigState`, `RelationDefinition`, `ColumnBuilder`
40
- - Builder classes: `TableBuilder`, `ModelBuilder`, `ContractBuilder`
41
- - Type helpers: `BuildStorageColumn`, `BuildStorage`, `BuildModels`, extract helpers, `Mutable`
42
- - Factory function: `defineContract()` (generic)
34
+ - `ColumnTypeDescriptor`
35
+ - `IndexDef`
36
+ - `ForeignKeyDefaultsState`
43
37
 
44
38
  ## Usage
45
39
 
46
- This package is intended for use by target-family specific authoring packages (e.g., `@prisma-next/sql-contract-ts`). End users should import from the target-family specific packages, not directly from this package.
40
+ This package is intended for internal composition. End-user contract authoring code should import from the family-specific surface, such as `@prisma-next/sql-contract-ts`, rather than from this package directly.
47
41
 
48
42
  ## See Also
49
43
 
50
- - `@prisma-next/sql-contract-ts` - SQL-specific contract authoring surface that composes this generic core
44
+ - `@prisma-next/sql-contract-ts` - SQL TypeScript contract authoring surface
package/dist/index.d.mts CHANGED
@@ -1,311 +1,20 @@
1
- import { ColumnDefault, DomainField, DomainRelation, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
2
- import { TargetPackRef } from "@prisma-next/contract/framework-components";
3
-
4
- //#region src/builder-state.d.ts
5
-
6
- /**
7
- * Duplicated from sql-contract to avoid cross-layer dependency
8
- * (framework authoring cannot depend on the SQL domain's contract package).
9
- */
10
- type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
11
- /**
12
- * Column type descriptor containing both codec ID and native type.
13
- * Used when defining columns with descriptor objects instead of string IDs.
14
- *
15
- * For parameterized types (e.g., `vector(1536)`), the `typeParams` field
16
- * carries codec-owned parameters that affect both TypeScript type generation
17
- * and native DDL output.
18
- */
1
+ //#region src/descriptors.d.ts
19
2
  type ColumnTypeDescriptor<TCodecId extends string = string> = {
20
3
  readonly codecId: TCodecId;
21
4
  readonly nativeType: string;
22
5
  readonly typeParams?: Record<string, unknown>;
23
6
  readonly typeRef?: string;
24
7
  };
25
- /**
26
- * Base column properties shared by all column states.
27
- */
28
- type ColumnBuilderStateBase<Name extends string, Type extends string> = {
29
- readonly name: Name;
30
- readonly type: Type;
31
- readonly nativeType: string;
32
- readonly typeParams?: Record<string, unknown>;
33
- readonly typeRef?: string;
34
- };
35
- type StorageTypeInstanceState = {
36
- readonly codecId: string;
37
- readonly nativeType: string;
38
- readonly typeParams: Record<string, unknown>;
39
- };
40
- /**
41
- * Column builder state.
42
- *
43
- * Both nullable and non-nullable columns can define defaults to match database behavior.
44
- */
45
- type ColumnBuilderState<Name extends string, Nullable extends boolean, Type extends string> = ColumnBuilderStateBase<Name, Type> & (Nullable extends true ? {
46
- readonly nullable: true;
47
- readonly default?: ColumnDefault;
48
- } : {
49
- readonly nullable: false;
50
- readonly default?: ColumnDefault;
51
- readonly executionDefault?: ExecutionMutationDefaultValue;
52
- });
53
- /**
54
- * Unique constraint definition for table builder.
55
- */
56
- interface UniqueConstraintDef {
57
- readonly columns: readonly string[];
58
- readonly name?: string;
59
- }
60
- /**
61
- * Index definition for table builder.
62
- */
63
8
  interface IndexDef {
64
9
  readonly columns: readonly string[];
65
10
  readonly name?: string;
66
- /**
67
- * Optional index access method. Extension-specific methods are represented
68
- * as strings and interpreted by the owning extension package.
69
- */
70
11
  readonly using?: string;
71
- /**
72
- * Optional extension-owned index configuration payload.
73
- */
74
12
  readonly config?: Record<string, unknown>;
75
13
  }
76
- /**
77
- * Options for configuring a foreign key's name and referential actions.
78
- */
79
- type ForeignKeyOptions = {
80
- readonly name?: string;
81
- readonly onDelete?: ReferentialAction;
82
- readonly onUpdate?: ReferentialAction;
83
- };
84
- /**
85
- * Foreign key definition for table builder.
86
- */
87
- interface ForeignKeyDef extends ForeignKeyOptions {
88
- readonly columns: readonly string[];
89
- readonly references: {
90
- readonly table: string;
91
- readonly columns: readonly string[];
92
- };
93
- readonly constraint?: boolean;
94
- readonly index?: boolean;
95
- }
96
- interface TableBuilderState<Name extends string, Columns extends Record<string, ColumnBuilderState<string, boolean, string>>, PrimaryKey extends readonly string[] | undefined> {
97
- readonly name: Name;
98
- readonly columns: Columns;
99
- readonly primaryKey?: PrimaryKey;
100
- readonly primaryKeyName?: string;
101
- readonly uniques: readonly UniqueConstraintDef[];
102
- readonly indexes: readonly IndexDef[];
103
- readonly foreignKeys: readonly ForeignKeyDef[];
104
- }
105
- type RelationDefinition = {
106
- readonly to: string;
107
- readonly cardinality: '1:1' | '1:N' | 'N:1' | 'N:M';
108
- readonly on: {
109
- readonly parentCols: readonly string[];
110
- readonly childCols: readonly string[];
111
- };
112
- readonly through?: {
113
- readonly table: string;
114
- readonly parentCols: readonly string[];
115
- readonly childCols: readonly string[];
116
- };
117
- };
118
- interface ModelBuilderState<Name extends string, Table extends string, Fields extends Record<string, string>, Relations extends Record<string, RelationDefinition>> {
119
- readonly name: Name;
120
- readonly table: Table;
121
- readonly fields: Fields;
122
- readonly relations: Relations;
123
- }
124
14
  interface ForeignKeyDefaultsState {
125
15
  readonly constraint: boolean;
126
16
  readonly index: boolean;
127
17
  }
128
- 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>>>, StorageHash extends string | undefined = string | undefined, ExtensionPacks extends Record<string, unknown> | undefined = undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined> {
129
- readonly target?: Target;
130
- readonly tables: Tables;
131
- readonly models: Models;
132
- readonly storageHash?: StorageHash;
133
- readonly extensionPacks?: ExtensionPacks;
134
- readonly capabilities?: Capabilities;
135
- readonly storageTypes?: Record<string, StorageTypeInstanceState>;
136
- readonly foreignKeyDefaults?: ForeignKeyDefaultsState;
137
- /**
138
- * Array of extension pack namespace identifiers (e.g., ['pgvector', 'postgis']).
139
- * Populated when extension packs are registered during contract building.
140
- * Used to track which extension packs are included in the contract.
141
- * Can be undefined or empty if no extension packs are registered.
142
- * Namespace format matches the extension pack ID (e.g., 'pgvector', not 'pgvector@1.0.0').
143
- */
144
- readonly extensionNamespaces?: readonly string[];
145
- }
146
- interface ColumnBuilder<Name extends string, Nullable extends boolean, Type extends string> {
147
- nullable<Value extends boolean>(value?: Value): ColumnBuilder<Name, Value, Type>;
148
- type<Id extends string>(id: Id): ColumnBuilder<Name, Nullable, Id>;
149
- build(): ColumnBuilderState<Name, Nullable, Type>;
150
- }
151
- //#endregion
152
- //#region src/model-builder.d.ts
153
- declare class ModelBuilder<Name extends string, Table extends string, Fields extends Record<string, string> = Record<never, never>, Relations extends Record<string, RelationDefinition> = Record<never, never>> {
154
- private readonly _name;
155
- private readonly _table;
156
- private readonly _fields;
157
- private readonly _relations;
158
- constructor(name: Name, table: Table, fields?: Fields, relations?: Relations);
159
- field<FieldName extends string, ColumnName extends string>(fieldName: FieldName, columnName: ColumnName): ModelBuilder<Name, Table, Fields & Record<FieldName, ColumnName>, Relations>;
160
- relation<RelationName extends string, ToModel extends string, ToTable extends string>(name: RelationName, options: {
161
- toModel: ToModel;
162
- toTable: ToTable;
163
- cardinality: '1:1' | '1:N' | 'N:1';
164
- on: {
165
- parentTable: Table;
166
- parentColumns: readonly string[];
167
- childTable: ToTable;
168
- childColumns: readonly string[];
169
- };
170
- }): ModelBuilder<Name, Table, Fields, Relations & Record<RelationName, RelationDefinition>>;
171
- relation<RelationName extends string, ToModel extends string, ToTable extends string, JunctionTable extends string>(name: RelationName, options: {
172
- toModel: ToModel;
173
- toTable: ToTable;
174
- cardinality: 'N:M';
175
- through: {
176
- table: JunctionTable;
177
- parentColumns: readonly string[];
178
- childColumns: readonly string[];
179
- };
180
- on: {
181
- parentTable: Table;
182
- parentColumns: readonly string[];
183
- childTable: JunctionTable;
184
- childColumns: readonly string[];
185
- };
186
- }): ModelBuilder<Name, Table, Fields, Relations & Record<RelationName, RelationDefinition>>;
187
- build(): ModelBuilderState<Name, Table, Fields, Relations>;
188
- }
189
- //#endregion
190
- //#region src/table-builder.d.ts
191
- /**
192
- * Column options for nullable columns.
193
- */
194
- interface NullableColumnOptions<Descriptor extends ColumnTypeDescriptor> {
195
- type: Descriptor;
196
- nullable: true;
197
- typeParams?: Record<string, unknown>;
198
- default?: ColumnDefault;
199
- }
200
- /**
201
- * Column options for non-nullable columns.
202
- * Non-nullable columns can optionally have a default value.
203
- */
204
- interface NonNullableColumnOptions<Descriptor extends ColumnTypeDescriptor> {
205
- type: Descriptor;
206
- nullable?: false;
207
- typeParams?: Record<string, unknown>;
208
- default?: ColumnDefault;
209
- }
210
- type GeneratedColumnOptions<Descriptor extends ColumnTypeDescriptor> = Omit<NonNullableColumnOptions<Descriptor>, 'default' | 'nullable'> & {
211
- /**
212
- * Generated columns are always non-nullable and use mutation-time defaults
213
- * that the runtime injects when the column is omitted from insert input.
214
- */
215
- nullable?: false;
216
- generated: ExecutionMutationDefaultValue;
217
- };
218
- type IndexOptions = {
219
- readonly name?: string;
220
- readonly using?: string;
221
- readonly config?: Record<string, unknown>;
222
- };
223
- /**
224
- * Creates a new table builder with the given name.
225
- * This is the preferred way to create a TableBuilder - it ensures
226
- * type parameters are inferred correctly without unsafe casts.
227
- */
228
- declare function createTable<Name extends string>(name: Name): TableBuilder<Name>;
229
- /**
230
- * Builder for defining table structure with type-safe chaining.
231
- * Use `createTable(name)` to create instances.
232
- */
233
- declare class TableBuilder<Name extends string, Columns extends Record<string, ColumnBuilderState<string, boolean, string>> = Record<never, ColumnBuilderState<string, boolean, string>>, PrimaryKey extends readonly string[] | undefined = undefined> {
234
- private readonly _state;
235
- /** @internal Use createTable() instead */
236
- constructor(name: Name, columns: Columns, primaryKey: PrimaryKey, primaryKeyName: string | undefined, uniques: readonly UniqueConstraintDef[], indexes: readonly IndexDef[], foreignKeys: readonly ForeignKeyDef[]);
237
- private get _name();
238
- private get _columns();
239
- private get _primaryKey();
240
- /** Add a nullable column to the table. */
241
- column<ColName extends string, Descriptor extends ColumnTypeDescriptor>(name: ColName, options: NullableColumnOptions<Descriptor>): TableBuilder<Name, Columns & Record<ColName, ColumnBuilderState<ColName, true, Descriptor['codecId']>>, PrimaryKey>;
242
- /**
243
- * Add a non-nullable column to the table.
244
- * Non-nullable columns can optionally have a default value.
245
- */
246
- column<ColName extends string, Descriptor extends ColumnTypeDescriptor>(name: ColName, options: NonNullableColumnOptions<Descriptor>): TableBuilder<Name, Columns & Record<ColName, ColumnBuilderState<ColName, false, Descriptor['codecId']>>, PrimaryKey>;
247
- generated<ColName extends string, Descriptor extends ColumnTypeDescriptor>(name: ColName, options: GeneratedColumnOptions<Descriptor>): TableBuilder<Name, Columns & Record<ColName, ColumnBuilderState<ColName, false, Descriptor['codecId']>>, PrimaryKey>;
248
- private columnInternal;
249
- primaryKey<PK extends readonly string[]>(columns: PK, name?: string): TableBuilder<Name, Columns, PK>;
250
- unique(columns: readonly string[], name?: string): TableBuilder<Name, Columns, PrimaryKey>;
251
- index(columns: readonly string[], name?: string): TableBuilder<Name, Columns, PrimaryKey>;
252
- index(columns: readonly string[], options?: IndexOptions): TableBuilder<Name, Columns, PrimaryKey>;
253
- index(indexDef: IndexDef): TableBuilder<Name, Columns, PrimaryKey>;
254
- foreignKey(columns: readonly string[], references: {
255
- table: string;
256
- columns: readonly string[];
257
- }, opts?: string | (ForeignKeyOptions & {
258
- constraint?: boolean;
259
- index?: boolean;
260
- })): TableBuilder<Name, Columns, PrimaryKey>;
261
- build(): TableBuilderState<Name, Columns, PrimaryKey>;
262
- }
263
- //#endregion
264
- //#region src/contract-builder.d.ts
265
- 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>, StorageHash extends string | undefined = undefined, ExtensionPacks extends Record<string, unknown> | undefined = undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined> {
266
- protected readonly state: ContractBuilderState<Target, Tables, Models, StorageHash, ExtensionPacks, Capabilities>;
267
- constructor(state?: ContractBuilderState<Target, Tables, Models, StorageHash, ExtensionPacks, Capabilities>);
268
- target<T extends string>(packRef: TargetPackRef<string, T>): ContractBuilder<T, Tables, Models, StorageHash, ExtensionPacks, Capabilities>;
269
- capabilities<C extends Record<string, Record<string, boolean>>>(capabilities: C): ContractBuilder<Target, Tables, Models, StorageHash, ExtensionPacks, C>;
270
- 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, StorageHash, ExtensionPacks, Capabilities>;
271
- 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<never, never>, Record<never, never>>) => M | undefined): ContractBuilder<Target, Tables, Models & Record<ModelName, ReturnType<M['build']>>, StorageHash, ExtensionPacks, Capabilities>;
272
- storageHash<H extends string>(hash: H): ContractBuilder<Target, Tables, Models, H, ExtensionPacks, Capabilities>;
273
- foreignKeyDefaults(config: ForeignKeyDefaultsState): ContractBuilder<Target, Tables, Models, StorageHash, ExtensionPacks, Capabilities>;
274
- }
275
- declare function defineContract(): ContractBuilder;
276
- //#endregion
277
- //#region src/types.d.ts
278
- type BuildStorageColumn<Nullable extends boolean, Type extends string> = {
279
- readonly nativeType: string;
280
- readonly codecId: Type;
281
- readonly nullable: Nullable;
282
- readonly typeParams?: Record<string, unknown>;
283
- readonly typeRef?: string;
284
- readonly default?: ColumnDefault;
285
- };
286
- type ExtractColumns<T extends TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>> = T extends TableBuilderState<string, infer C, readonly string[] | undefined> ? C : never;
287
- type ExtractPrimaryKey<T extends TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>> = T extends TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, infer PK> ? PK : never;
288
- type BuildStorage<Tables extends Record<string, TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>>> = {
289
- readonly tables: { readonly [K in keyof Tables]: {
290
- readonly columns: { readonly [ColK in keyof ExtractColumns<Tables[K]>]: ExtractColumns<Tables[K]>[ColK] extends ColumnBuilderState<string, infer Null, infer TType> ? BuildStorageColumn<Null & boolean, TType> : never };
291
- } };
292
- };
293
- type BuildStorageTables<Tables extends Record<string, TableBuilderState<string, Record<string, ColumnBuilderState<string, boolean, string>>, readonly string[] | undefined>>> = { readonly [K in keyof Tables]: {
294
- readonly columns: { readonly [ColK in keyof ExtractColumns<Tables[K]>]: ExtractColumns<Tables[K]>[ColK] extends ColumnBuilderState<string, infer Null, infer TType> ? BuildStorageColumn<Null & boolean, TType> : never };
295
- } };
296
- type Mutable<T> = { -readonly [K in keyof T]-?: T[K] };
297
- type BuildModelFields<Fields extends Record<string, string>> = { readonly [K in keyof Fields]: {
298
- readonly column: Fields[K];
299
- } };
300
- type ExtractModelFields<T extends ModelBuilderState<string, string, Record<string, string>, Record<string, RelationDefinition>>> = T extends ModelBuilderState<string, string, infer F, Record<string, RelationDefinition>> ? F : never;
301
- type BuildModels<Models extends Record<string, ModelBuilderState<string, string, Record<string, string>, Record<string, RelationDefinition>>>> = { readonly [K in keyof Models]: {
302
- readonly storage: {
303
- readonly table: Models[K]['table'];
304
- readonly fields: BuildModelFields<ExtractModelFields<Models[K]>>;
305
- };
306
- readonly fields: Record<string, DomainField>;
307
- readonly relations: Record<string, DomainRelation>;
308
- } };
309
18
  //#endregion
310
- export { type BuildModelFields, type BuildModels, type BuildStorage, type BuildStorageColumn, type BuildStorageTables, type ColumnBuilder, type ColumnBuilderState, type ColumnTypeDescriptor, ContractBuilder, type ContractBuilderState, type ExtractColumns, type ExtractModelFields, type ExtractPrimaryKey, type ForeignKeyDef, type ForeignKeyDefaultsState, type ForeignKeyOptions, type IndexDef, ModelBuilder, type ModelBuilderState, type Mutable, type RelationDefinition, TableBuilder, type TableBuilderState, type UniqueConstraintDef, createTable, defineContract };
19
+ export { type ColumnTypeDescriptor, type ForeignKeyDefaultsState, type IndexDef };
311
20
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/builder-state.ts","../src/model-builder.ts","../src/table-builder.ts","../src/contract-builder.ts","../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAMA;AAUY,KAVA,iBAAA,GAUoB,UAAA,GAAA,UACZ,GAEI,SAAM,GAAA,SAAA,GAAA,YAAA;AAE5B;;;;;AAaF;AAWA;;AAIiC,KAjCrB,oBAiCqB,CAAA,iBAAA,MAAA,GAAA,MAAA,CAAA,GAAA;EAA7B,SAAA,OAAA,EAhCgB,QAgChB;EACD,SAAA,UAAA,EAAA,MAAA;EACiD,SAAA,UAAA,CAAA,EAhC5B,MAgC4B,CAAA,MAAA,EAAA,OAAA,CAAA;EAGzB,SAAA,OAAA,CAAA,EAAA,MAAA;CACS;;AAMpC;AAQA;AAiBA,KA5DK,sBA4DwB,CAAA,aAEP,MAAA,EAAA,aACA,MAAA,CAAA,GAAA;EAML,SAAA,IAAA,EApEA,IAoEc;EAUd,SAAA,IAAA,EA7EA,IA6EA;EAEgB,SAAA,UAAA,EAAA,MAAA;EAAf,SAAA,UAAA,CAAA,EA7EM,MA6EN,CAAA,MAAA,EAAA,OAAA,CAAA;EAGD,SAAA,OAAA,CAAA,EAAA,MAAA;CACG;AACI,KA9EZ,wBAAA,GA8EY;EAEK,SAAA,OAAA,EAAA,MAAA;EACA,SAAA,UAAA,EAAA,MAAA;EACI,SAAA,UAAA,EA/EV,MA+EU,CAAA,MAAA,EAAA,OAAA,CAAA;CAAa;AAG9C;AAcA;;;;AAMiB,KA9FL,kBA8FK,CAAA,aAAA,MAAA,EAAA,iBAAA,OAAA,EAAA,aAAA,MAAA,CAAA,GA1Fb,sBA0Fa,CA1FU,IA0FV,EA1FgB,IA0FhB,CAAA,GAAA,CAzFd,QAyFc,SAAA,IAAA,GAAA;EACC,SAAA,QAAA,EAAA,IAAA;EACC,SAAA,OAAA,CAAA,EA1FiC,aA0FjC;C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2BzC,CI3BgD,CJ2BhD,CAAA,CAAA,CAAA;EACC,CAAA;EACG,SAAA,MAAA,EI3BD,MJ2BC,CAAA,MAAA,EI3Bc,WJ2Bd,CAAA;EAAS,SAAA,SAAA,EI1BP,MJ0BO,CAAA,MAAA,EI1BQ,cJ0BR,CAAA;AAGd,CAAA,EAKjB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/descriptors.ts"],"sourcesContent":[],"mappings":";KAAY;EAAA,SAAA,OAAA,EACQ,QADY;EAOf,SAAA,UAAQ,EAAA,MAIL;EAGH,SAAA,UAAA,CAAA,EAXO,MAWgB,CAAA,MAAA,EAAA,OAAA,CAAA;;;UAPvB,QAAA;;;;oBAIG;;UAGH,uBAAA"}
package/dist/index.mjs CHANGED
@@ -1,237 +1 @@
1
- import { ifDefined } from "@prisma-next/utils/defined";
2
-
3
- //#region src/model-builder.ts
4
- var ModelBuilder = class ModelBuilder {
5
- _name;
6
- _table;
7
- _fields;
8
- _relations;
9
- constructor(name, table, fields = {}, relations = {}) {
10
- this._name = name;
11
- this._table = table;
12
- this._fields = fields;
13
- this._relations = relations;
14
- }
15
- field(fieldName, columnName) {
16
- return new ModelBuilder(this._name, this._table, {
17
- ...this._fields,
18
- [fieldName]: columnName
19
- }, this._relations);
20
- }
21
- relation(name, options) {
22
- if (options.on.parentTable !== this._table) throw new Error(`Relation "${name}" parentTable "${options.on.parentTable}" does not match model table "${this._table}"`);
23
- if (options.cardinality === "N:M") {
24
- if (!options.through) throw new Error(`Relation "${name}" with cardinality "N:M" requires through field`);
25
- if (options.on.childTable !== options.through.table) throw new Error(`Relation "${name}" childTable "${options.on.childTable}" does not match through.table "${options.through.table}"`);
26
- } else if (options.on.childTable !== options.toTable) throw new Error(`Relation "${name}" childTable "${options.on.childTable}" does not match toTable "${options.toTable}"`);
27
- const relationDef = {
28
- to: options.toModel,
29
- cardinality: options.cardinality,
30
- on: {
31
- parentCols: options.on.parentColumns,
32
- childCols: options.on.childColumns
33
- },
34
- ...options.through ? { through: {
35
- table: options.through.table,
36
- parentCols: options.through.parentColumns,
37
- childCols: options.through.childColumns
38
- } } : void 0
39
- };
40
- return new ModelBuilder(this._name, this._table, this._fields, {
41
- ...this._relations,
42
- [name]: relationDef
43
- });
44
- }
45
- build() {
46
- return {
47
- name: this._name,
48
- table: this._table,
49
- fields: this._fields,
50
- relations: this._relations
51
- };
52
- }
53
- };
54
-
55
- //#endregion
56
- //#region src/table-builder.ts
57
- function isIndexDef(value) {
58
- return !Array.isArray(value);
59
- }
60
- /**
61
- * Creates a new table builder with the given name.
62
- * This is the preferred way to create a TableBuilder - it ensures
63
- * type parameters are inferred correctly without unsafe casts.
64
- */
65
- function createTable(name) {
66
- return new TableBuilder(name, {}, void 0, void 0, [], [], []);
67
- }
68
- /**
69
- * Builder for defining table structure with type-safe chaining.
70
- * Use `createTable(name)` to create instances.
71
- */
72
- var TableBuilder = class TableBuilder {
73
- _state;
74
- /** @internal Use createTable() instead */
75
- constructor(name, columns, primaryKey, primaryKeyName, uniques, indexes, foreignKeys) {
76
- this._state = {
77
- name,
78
- columns,
79
- primaryKey,
80
- primaryKeyName,
81
- uniques,
82
- indexes,
83
- foreignKeys
84
- };
85
- }
86
- get _name() {
87
- return this._state.name;
88
- }
89
- get _columns() {
90
- return this._state.columns;
91
- }
92
- get _primaryKey() {
93
- return this._state.primaryKey;
94
- }
95
- /**
96
- * Implementation of the column method.
97
- */
98
- column(name, options) {
99
- return this.columnInternal(name, options);
100
- }
101
- generated(name, options) {
102
- const { generated, ...columnOptions } = options;
103
- return this.columnInternal(name, columnOptions, generated);
104
- }
105
- columnInternal(name, options, executionDefault) {
106
- const nullable = options.nullable ?? false;
107
- const { codecId, nativeType, typeParams: descriptorTypeParams, typeRef } = options.type;
108
- const columnState = {
109
- name,
110
- nullable,
111
- type: codecId,
112
- nativeType,
113
- ...ifDefined("typeParams", options.typeParams ?? descriptorTypeParams),
114
- ...ifDefined("typeRef", typeRef),
115
- ...ifDefined("default", "default" in options ? options.default : void 0),
116
- ...ifDefined("executionDefault", executionDefault)
117
- };
118
- const newColumns = {
119
- ...this._columns,
120
- [name]: columnState
121
- };
122
- return new TableBuilder(this._state.name, newColumns, this._state.primaryKey, this._state.primaryKeyName, this._state.uniques, this._state.indexes, this._state.foreignKeys);
123
- }
124
- primaryKey(columns, name) {
125
- return new TableBuilder(this._state.name, this._state.columns, columns, name, this._state.uniques, this._state.indexes, this._state.foreignKeys);
126
- }
127
- unique(columns, name) {
128
- const constraint = name ? {
129
- columns,
130
- name
131
- } : { columns };
132
- return new TableBuilder(this._state.name, this._state.columns, this._state.primaryKey, this._state.primaryKeyName, [...this._state.uniques, constraint], this._state.indexes, this._state.foreignKeys);
133
- }
134
- index(columnsOrIndexDef, nameOrOptions) {
135
- const indexDef = isIndexDef(columnsOrIndexDef) ? columnsOrIndexDef : {
136
- columns: columnsOrIndexDef,
137
- ...typeof nameOrOptions === "string" ? { name: nameOrOptions } : {},
138
- ...typeof nameOrOptions === "object" && nameOrOptions !== null ? {
139
- ...nameOrOptions.name !== void 0 ? { name: nameOrOptions.name } : {},
140
- ...nameOrOptions.using !== void 0 ? { using: nameOrOptions.using } : {},
141
- ...nameOrOptions.config !== void 0 ? { config: nameOrOptions.config } : {}
142
- } : {}
143
- };
144
- return new TableBuilder(this._state.name, this._state.columns, this._state.primaryKey, this._state.primaryKeyName, this._state.uniques, [...this._state.indexes, indexDef], this._state.foreignKeys);
145
- }
146
- foreignKey(columns, references, opts) {
147
- const resolved = typeof opts === "string" ? { name: opts } : opts;
148
- const fkDef = {
149
- columns,
150
- references,
151
- ...ifDefined("name", resolved?.name),
152
- ...ifDefined("onDelete", resolved?.onDelete),
153
- ...ifDefined("onUpdate", resolved?.onUpdate),
154
- ...ifDefined("constraint", resolved?.constraint),
155
- ...ifDefined("index", resolved?.index)
156
- };
157
- return new TableBuilder(this._state.name, this._state.columns, this._state.primaryKey, this._state.primaryKeyName, this._state.uniques, this._state.indexes, [...this._state.foreignKeys, fkDef]);
158
- }
159
- build() {
160
- return {
161
- name: this._name,
162
- columns: this._columns,
163
- ...this._primaryKey !== void 0 ? { primaryKey: this._primaryKey } : {},
164
- ...this._state.primaryKeyName !== void 0 ? { primaryKeyName: this._state.primaryKeyName } : {},
165
- uniques: this._state.uniques,
166
- indexes: this._state.indexes,
167
- foreignKeys: this._state.foreignKeys
168
- };
169
- }
170
- };
171
-
172
- //#endregion
173
- //#region src/contract-builder.ts
174
- var ContractBuilder = class ContractBuilder {
175
- state;
176
- constructor(state) {
177
- this.state = state ?? {
178
- tables: {},
179
- models: {}
180
- };
181
- }
182
- target(packRef) {
183
- return new ContractBuilder({
184
- ...this.state,
185
- target: packRef.targetId
186
- });
187
- }
188
- capabilities(capabilities) {
189
- return new ContractBuilder({
190
- ...this.state,
191
- capabilities
192
- });
193
- }
194
- table(name, callback) {
195
- const tableBuilder = createTable(name);
196
- const result = callback(tableBuilder);
197
- const tableState = (result instanceof TableBuilder ? result : tableBuilder).build();
198
- return new ContractBuilder({
199
- ...this.state,
200
- tables: {
201
- ...this.state.tables,
202
- [name]: tableState
203
- }
204
- });
205
- }
206
- model(name, table, callback) {
207
- const modelBuilder = new ModelBuilder(name, table);
208
- const result = callback(modelBuilder);
209
- const modelState = (result instanceof ModelBuilder ? result : modelBuilder).build();
210
- return new ContractBuilder({
211
- ...this.state,
212
- models: {
213
- ...this.state.models,
214
- [name]: modelState
215
- }
216
- });
217
- }
218
- storageHash(hash) {
219
- return new ContractBuilder({
220
- ...this.state,
221
- storageHash: hash
222
- });
223
- }
224
- foreignKeyDefaults(config) {
225
- return new ContractBuilder({
226
- ...this.state,
227
- foreignKeyDefaults: config
228
- });
229
- }
230
- };
231
- function defineContract() {
232
- return new ContractBuilder();
233
- }
234
-
235
- //#endregion
236
- export { ContractBuilder, ModelBuilder, TableBuilder, createTable, defineContract };
237
- //# sourceMappingURL=index.mjs.map
1
+ export { };