drizzle-docs-generator 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +59 -15
- package/README.md +55 -11
- package/dist/adapter/types.d.ts +40 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/adapter/v0-adapter.d.ts +73 -0
- package/dist/adapter/v0-adapter.d.ts.map +1 -0
- package/dist/adapter/v0-adapter.js +136 -0
- package/dist/adapter/v0-adapter.js.map +1 -0
- package/dist/adapter/v1-adapter.d.ts +40 -0
- package/dist/adapter/v1-adapter.d.ts.map +1 -0
- package/dist/adapter/v1-adapter.js +83 -0
- package/dist/adapter/v1-adapter.js.map +1 -0
- package/dist/cli/index.js +194 -71
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/integration-test-utils.d.ts +19 -0
- package/dist/cli/integration-test-utils.d.ts.map +1 -0
- package/dist/formatter/dbml-builder.d.ts +29 -0
- package/dist/formatter/dbml-builder.d.ts.map +1 -0
- package/dist/formatter/dbml-builder.js +39 -0
- package/dist/formatter/dbml-builder.js.map +1 -0
- package/dist/formatter/dbml.d.ts +81 -0
- package/dist/formatter/dbml.d.ts.map +1 -0
- package/dist/formatter/dbml.js +163 -0
- package/dist/formatter/dbml.js.map +1 -0
- package/dist/formatter/markdown.d.ts +126 -0
- package/dist/formatter/markdown.d.ts.map +1 -0
- package/dist/formatter/markdown.js +235 -0
- package/dist/formatter/markdown.js.map +1 -0
- package/dist/formatter/mermaid.d.ts +102 -0
- package/dist/formatter/mermaid.d.ts.map +1 -0
- package/dist/formatter/mermaid.js +177 -0
- package/dist/formatter/mermaid.js.map +1 -0
- package/dist/formatter/types.d.ts +37 -0
- package/dist/formatter/types.d.ts.map +1 -0
- package/dist/generator/common.d.ts +115 -208
- package/dist/generator/common.d.ts.map +1 -1
- package/dist/generator/common.js +260 -479
- package/dist/generator/common.js.map +1 -1
- package/dist/generator/mysql.js +3 -3
- package/dist/generator/pg.d.ts +8 -7
- package/dist/generator/pg.d.ts.map +1 -1
- package/dist/generator/pg.js +29 -31
- package/dist/generator/pg.js.map +1 -1
- package/dist/generator/sqlite.js +3 -3
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -18
- package/dist/index.js.map +1 -1
- package/dist/test-utils/cli-runner.d.ts +4 -1
- package/dist/test-utils/cli-runner.d.ts.map +1 -1
- package/dist/test-utils/dbml-validator.d.ts +29 -0
- package/dist/test-utils/dbml-validator.d.ts.map +1 -1
- package/dist/types.d.ts +128 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/generator/index.d.ts +0 -15
- package/dist/generator/index.d.ts.map +0 -1
- package/dist/parser/index.d.ts +0 -5
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/test-utils/index.d.ts +0 -7
- package/dist/test-utils/index.d.ts.map +0 -1
|
@@ -1,67 +1,77 @@
|
|
|
1
1
|
import { AnyColumn, Table } from 'drizzle-orm';
|
|
2
2
|
import { TableRelationalConfig } from 'drizzle-orm/relations';
|
|
3
|
-
import { GeneratedRef, GenerateOptions } from '../types';
|
|
3
|
+
import { GeneratedRef, GenerateOptions, IntermediateSchema, TableDefinition, ColumnDefinition, IndexDefinition, ConstraintDefinition, RelationDefinition, EnumDefinition, DatabaseType } from '../types';
|
|
4
4
|
import { SchemaComments } from '../parser/comments';
|
|
5
5
|
import { SchemaRelations } from '../parser/relations';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* This is a simplified type - the actual structure is more complex
|
|
7
|
+
* Configuration for different database dialects
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
export interface DialectConfig {
|
|
10
|
+
escapeName: (name: string) => string;
|
|
11
|
+
isIncrement: (column: AnyColumn) => boolean;
|
|
12
|
+
}
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* Configuration for an index definition
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* Decrease the indentation level by one (minimum 0)
|
|
27
|
-
* @returns This instance for method chaining
|
|
28
|
-
*/
|
|
29
|
-
dedent(): this;
|
|
30
|
-
/**
|
|
31
|
-
* Add a line with the current indentation level
|
|
32
|
-
* @param content - The content to add (empty string adds a blank line)
|
|
33
|
-
* @returns This instance for method chaining
|
|
34
|
-
*/
|
|
35
|
-
line(content?: string): this;
|
|
36
|
-
/**
|
|
37
|
-
* Build the final DBML string from all added lines
|
|
38
|
-
* @returns The complete DBML content as a string
|
|
39
|
-
*/
|
|
40
|
-
build(): string;
|
|
16
|
+
interface IndexConfig {
|
|
17
|
+
config: {
|
|
18
|
+
columns: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
}>;
|
|
21
|
+
name?: string;
|
|
22
|
+
unique: boolean;
|
|
23
|
+
using?: string;
|
|
24
|
+
};
|
|
41
25
|
}
|
|
42
26
|
/**
|
|
43
|
-
* Configuration for
|
|
27
|
+
* Configuration for a primary key constraint
|
|
44
28
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
interface PrimaryKeyConfig {
|
|
30
|
+
columns: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
}>;
|
|
33
|
+
name?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for a unique constraint
|
|
37
|
+
*/
|
|
38
|
+
interface UniqueConstraintConfig {
|
|
39
|
+
columns: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
}>;
|
|
42
|
+
name?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for a foreign key constraint
|
|
46
|
+
*/
|
|
47
|
+
export interface ForeignKeyConfig {
|
|
48
|
+
reference: () => {
|
|
49
|
+
columns: Array<{
|
|
50
|
+
name: string;
|
|
51
|
+
}>;
|
|
52
|
+
foreignColumns: Array<{
|
|
53
|
+
name: string;
|
|
54
|
+
}>;
|
|
55
|
+
foreignTable: Table;
|
|
56
|
+
};
|
|
57
|
+
name?: string;
|
|
58
|
+
onDelete?: string;
|
|
59
|
+
onUpdate?: string;
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
62
|
* Table configuration extracted from Drizzle tables
|
|
51
|
-
* Using 'any' types for dialect-agnostic handling
|
|
52
63
|
*/
|
|
53
64
|
export interface TableConfig {
|
|
54
|
-
indexes:
|
|
55
|
-
primaryKeys:
|
|
56
|
-
uniqueConstraints:
|
|
57
|
-
foreignKeys:
|
|
65
|
+
indexes: IndexConfig[];
|
|
66
|
+
primaryKeys: PrimaryKeyConfig[];
|
|
67
|
+
uniqueConstraints: UniqueConstraintConfig[];
|
|
68
|
+
foreignKeys: ForeignKeyConfig[];
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* Base generator class for DBML generation
|
|
61
72
|
*/
|
|
62
73
|
export declare abstract class BaseGenerator<TSchema extends Record<string, unknown> = Record<string, unknown>> {
|
|
63
74
|
protected schema: TSchema;
|
|
64
|
-
protected relational: boolean;
|
|
65
75
|
protected generatedRefs: GeneratedRef[];
|
|
66
76
|
protected comments: SchemaComments | undefined;
|
|
67
77
|
protected parsedRelations: SchemaRelations | undefined;
|
|
@@ -69,7 +79,7 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
69
79
|
protected abstract dialectConfig: DialectConfig;
|
|
70
80
|
/**
|
|
71
81
|
* Create a new generator instance
|
|
72
|
-
* @param options - Configuration options including schema,
|
|
82
|
+
* @param options - Configuration options including schema, source code, and comments
|
|
73
83
|
*/
|
|
74
84
|
constructor(options: GenerateOptions<TSchema>);
|
|
75
85
|
/**
|
|
@@ -102,24 +112,6 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
102
112
|
* @returns True if value is a Drizzle table
|
|
103
113
|
*/
|
|
104
114
|
protected isTable(value: unknown): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Get all v0 relations from schema (legacy relations() API)
|
|
107
|
-
*
|
|
108
|
-
* Extracts legacy relations defined using the old relations() API.
|
|
109
|
-
* These are identified by having 'table' and 'config' properties.
|
|
110
|
-
*
|
|
111
|
-
* @returns Array of legacy relation objects
|
|
112
|
-
*/
|
|
113
|
-
protected getV0Relations(): LegacyRelations[];
|
|
114
|
-
/**
|
|
115
|
-
* Check if a value is a Drizzle v0 relations object (from relations())
|
|
116
|
-
*
|
|
117
|
-
* Validates the legacy relations() format by checking for 'table' and 'config' properties.
|
|
118
|
-
*
|
|
119
|
-
* @param value - The value to check
|
|
120
|
-
* @returns True if value is a legacy relations object
|
|
121
|
-
*/
|
|
122
|
-
protected isV0Relations(value: unknown): boolean;
|
|
123
115
|
/**
|
|
124
116
|
* Check if a value is a v1 relation entry (from defineRelations())
|
|
125
117
|
*
|
|
@@ -149,16 +141,6 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
149
141
|
* @returns True if value is a full defineRelations() result
|
|
150
142
|
*/
|
|
151
143
|
protected isV1DefineRelationsResult(value: unknown): boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Generate a table definition in DBML format
|
|
154
|
-
*
|
|
155
|
-
* Creates the complete table definition including columns, indexes, constraints,
|
|
156
|
-
* and table-level comments. Also collects foreign keys if not in relational mode.
|
|
157
|
-
*
|
|
158
|
-
* @param dbml - The DBML builder to add the table to
|
|
159
|
-
* @param table - The Drizzle table to generate
|
|
160
|
-
*/
|
|
161
|
-
protected generateTable(dbml: DbmlBuilder, table: Table): void;
|
|
162
144
|
/**
|
|
163
145
|
* Get table configuration from a Drizzle table
|
|
164
146
|
*
|
|
@@ -170,41 +152,13 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
170
152
|
*/
|
|
171
153
|
protected getTableConfig(table: Table): TableConfig | undefined;
|
|
172
154
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* Creates a column line with type and attributes (primary key, not null, unique, etc.)
|
|
176
|
-
* and includes column-level comments if available.
|
|
177
|
-
*
|
|
178
|
-
* @param dbml - The DBML builder to add the column to
|
|
179
|
-
* @param column - The Drizzle column to generate
|
|
180
|
-
* @param tableName - Optional table name for looking up comments
|
|
181
|
-
*/
|
|
182
|
-
protected generateColumn(dbml: DbmlBuilder, column: AnyColumn, tableName?: string): void;
|
|
183
|
-
/**
|
|
184
|
-
* Get the SQL type for a column
|
|
185
|
-
*
|
|
186
|
-
* @param column - The column to get the SQL type from
|
|
187
|
-
* @returns The SQL type string (e.g., "varchar", "integer")
|
|
188
|
-
*/
|
|
189
|
-
protected getColumnType(column: AnyColumn): string;
|
|
190
|
-
/**
|
|
191
|
-
* Get column attributes for DBML
|
|
192
|
-
*
|
|
193
|
-
* Extracts attributes like primary key, not null, unique, increment, default value,
|
|
194
|
-
* and note from the column. Uses column metadata and comments if available.
|
|
195
|
-
*
|
|
196
|
-
* @param column - The column to get attributes from
|
|
197
|
-
* @param tableName - Optional table name for looking up comments
|
|
198
|
-
* @returns Array of attribute strings for DBML format
|
|
199
|
-
*/
|
|
200
|
-
protected getColumnAttributes(column: AnyColumn, tableName?: string): string[];
|
|
201
|
-
/**
|
|
202
|
-
* Format attributes into a string
|
|
155
|
+
* Map Drizzle's internal table config to our typed TableConfig
|
|
203
156
|
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
157
|
+
* Note: Drizzle ORM's columns type is `SQL<unknown> | IndexedColumn` union,
|
|
158
|
+
* so we use `{ name?: string }` and cast to access the name property.
|
|
159
|
+
* This is unavoidable due to Drizzle's internal type structure.
|
|
206
160
|
*/
|
|
207
|
-
|
|
161
|
+
private mapTableConfig;
|
|
208
162
|
/**
|
|
209
163
|
* Get the default value for a column
|
|
210
164
|
*
|
|
@@ -215,16 +169,6 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
215
169
|
* @returns Formatted default value string or undefined
|
|
216
170
|
*/
|
|
217
171
|
protected getDefaultValue(column: AnyColumn): string | undefined;
|
|
218
|
-
/**
|
|
219
|
-
* Generate indexes block from table configuration
|
|
220
|
-
*
|
|
221
|
-
* Creates the indexes block containing primary keys, unique constraints,
|
|
222
|
-
* and regular indexes with their respective attributes.
|
|
223
|
-
*
|
|
224
|
-
* @param dbml - The DBML builder to add the indexes block to
|
|
225
|
-
* @param tableConfig - The table configuration containing index information
|
|
226
|
-
*/
|
|
227
|
-
protected generateIndexesBlock(dbml: DbmlBuilder, tableConfig: TableConfig): void;
|
|
228
172
|
/**
|
|
229
173
|
* Collect foreign keys from table configuration
|
|
230
174
|
*
|
|
@@ -234,7 +178,7 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
234
178
|
* @param tableName - The name of the source table
|
|
235
179
|
* @param foreignKeys - Array of foreign key definitions from table config
|
|
236
180
|
*/
|
|
237
|
-
protected collectForeignKeysFromConfig(tableName: string, foreignKeys:
|
|
181
|
+
protected collectForeignKeysFromConfig(tableName: string, foreignKeys: ForeignKeyConfig[]): void;
|
|
238
182
|
/**
|
|
239
183
|
* Parse a foreign key into a GeneratedRef
|
|
240
184
|
*
|
|
@@ -243,141 +187,104 @@ export declare abstract class BaseGenerator<TSchema extends Record<string, unkno
|
|
|
243
187
|
*
|
|
244
188
|
* @param tableName - The name of the source table
|
|
245
189
|
* @param fk - The foreign key definition to parse
|
|
246
|
-
* @returns GeneratedRef object
|
|
190
|
+
* @returns GeneratedRef object
|
|
247
191
|
*/
|
|
248
|
-
protected parseForeignKey(tableName: string, fk:
|
|
192
|
+
protected parseForeignKey(tableName: string, fk: ForeignKeyConfig): GeneratedRef;
|
|
249
193
|
/**
|
|
250
|
-
*
|
|
194
|
+
* Detect if relation definitions are present in the schema
|
|
251
195
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
196
|
+
* Checks for both v1 (defineRelations()) and v0 (relations()) API usage.
|
|
197
|
+
* Returns true if any relation definitions are found.
|
|
254
198
|
*
|
|
255
|
-
* @returns
|
|
199
|
+
* @returns True if relations are defined, false otherwise
|
|
256
200
|
*/
|
|
257
|
-
|
|
201
|
+
private hasRelationDefinitions;
|
|
258
202
|
/**
|
|
259
|
-
*
|
|
203
|
+
* Create the appropriate relation adapter based on schema contents
|
|
260
204
|
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
205
|
+
* Detects whether v1 or v0 relations are present and returns the
|
|
206
|
+
* corresponding adapter implementation.
|
|
263
207
|
*
|
|
264
|
-
* @
|
|
265
|
-
* @returns Map of property names to column names
|
|
208
|
+
* @returns RelationAdapter instance (V1RelationAdapter or V0RelationAdapter)
|
|
266
209
|
*/
|
|
267
|
-
|
|
210
|
+
private createRelationAdapter;
|
|
268
211
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
* Used to detect one-to-one relationships by checking if both tables
|
|
272
|
-
* have one() relations pointing to each other.
|
|
212
|
+
* Convert a UnifiedRelation to a RelationDefinition
|
|
273
213
|
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* @param sourceFields - The source table's field names
|
|
277
|
-
* @param targetReferences - The target table's reference column names
|
|
278
|
-
* @returns True if a reverse one() relation exists
|
|
279
|
-
*/
|
|
280
|
-
protected hasReverseOneRelation(sourceTable: string, targetTable: string, sourceFields: string[], targetReferences: string[]): boolean;
|
|
281
|
-
/**
|
|
282
|
-
* Helper to check if two arrays are equal
|
|
214
|
+
* Maps the unified relation format from adapters to the intermediate
|
|
215
|
+
* schema's RelationDefinition format.
|
|
283
216
|
*
|
|
284
|
-
* @param
|
|
285
|
-
* @
|
|
286
|
-
* @returns True if arrays have same length and same elements in order
|
|
217
|
+
* @param unified - The unified relation from adapter
|
|
218
|
+
* @returns RelationDefinition for intermediate schema
|
|
287
219
|
*/
|
|
288
|
-
private
|
|
220
|
+
private unifiedRelationToDefinition;
|
|
289
221
|
/**
|
|
290
|
-
*
|
|
222
|
+
* Convert the Drizzle schema to an intermediate schema representation
|
|
291
223
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
224
|
+
* Creates a database-agnostic intermediate representation that can be
|
|
225
|
+
* used to generate various output formats (DBML, Markdown, JSON, etc.)
|
|
294
226
|
*
|
|
295
|
-
*
|
|
227
|
+
* @returns The intermediate schema representation
|
|
296
228
|
*/
|
|
297
|
-
|
|
229
|
+
toIntermediateSchema(): IntermediateSchema;
|
|
298
230
|
/**
|
|
299
|
-
*
|
|
231
|
+
* Determine the database type from a Drizzle table
|
|
300
232
|
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* DBML Ref lines. Detects one-to-one relationships with bidirectional checks.
|
|
304
|
-
*
|
|
305
|
-
* @param entries - Array of v1 relation entries from defineRelations()
|
|
233
|
+
* @param table - The table to check (can be undefined for empty schemas)
|
|
234
|
+
* @returns The database type
|
|
306
235
|
*/
|
|
307
|
-
protected
|
|
236
|
+
protected getDatabaseType(table: Table | undefined): DatabaseType;
|
|
308
237
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* Detects one-to-one relationships by checking if the target table
|
|
312
|
-
* has a matching One relation pointing back to the source table.
|
|
238
|
+
* Convert a Drizzle table to a TableDefinition
|
|
313
239
|
*
|
|
314
|
-
* @param
|
|
315
|
-
* @
|
|
316
|
-
* @param toTableName - The expected target table of the reverse relation
|
|
317
|
-
* @param fromColumns - The expected source columns of the reverse relation
|
|
318
|
-
* @param toColumns - The expected target columns of the reverse relation
|
|
319
|
-
* @returns True if a matching reverse One relation exists
|
|
240
|
+
* @param table - The Drizzle table to convert
|
|
241
|
+
* @returns The table definition
|
|
320
242
|
*/
|
|
321
|
-
protected
|
|
243
|
+
protected tableToDefinition(table: Table): TableDefinition;
|
|
322
244
|
/**
|
|
323
|
-
*
|
|
245
|
+
* Convert a Drizzle column to a ColumnDefinition
|
|
324
246
|
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* @
|
|
328
|
-
* @param relation - The relation object
|
|
329
|
-
* @returns A unique key string for the relation
|
|
247
|
+
* @param column - The Drizzle column to convert
|
|
248
|
+
* @param tableName - The name of the table containing the column
|
|
249
|
+
* @returns The column definition
|
|
330
250
|
*/
|
|
331
|
-
protected
|
|
251
|
+
protected columnToDefinition(column: AnyColumn, tableName: string): ColumnDefinition;
|
|
332
252
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* Extracts relation information from a legacy relation object and converts
|
|
336
|
-
* it to a GeneratedRef for DBML output.
|
|
253
|
+
* Extract index definitions from table config
|
|
337
254
|
*
|
|
338
|
-
* @param
|
|
339
|
-
* @
|
|
340
|
-
* @returns GeneratedRef object or undefined if parsing fails
|
|
255
|
+
* @param tableConfig - The table configuration
|
|
256
|
+
* @returns Array of index definitions
|
|
341
257
|
*/
|
|
342
|
-
protected
|
|
258
|
+
protected extractIndexDefinitions(tableConfig: TableConfig | undefined): IndexDefinition[];
|
|
343
259
|
/**
|
|
344
|
-
*
|
|
260
|
+
* Extract constraint definitions from table config
|
|
345
261
|
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* @param dbml - The DBML builder to add the reference to
|
|
350
|
-
* @param ref - The reference definition to generate
|
|
262
|
+
* @param tableConfig - The table configuration
|
|
263
|
+
* @returns Array of constraint definitions
|
|
351
264
|
*/
|
|
352
|
-
protected
|
|
265
|
+
protected extractConstraintDefinitions(tableConfig: TableConfig | undefined): ConstraintDefinition[];
|
|
353
266
|
/**
|
|
354
|
-
*
|
|
267
|
+
* Parse a foreign key into a ConstraintDefinition
|
|
355
268
|
*
|
|
356
|
-
* @param
|
|
357
|
-
* @returns
|
|
269
|
+
* @param fk - The foreign key definition
|
|
270
|
+
* @returns ConstraintDefinition
|
|
358
271
|
*/
|
|
359
|
-
protected
|
|
272
|
+
protected parseForeignKeyForConstraint(fk: ForeignKeyConfig): ConstraintDefinition;
|
|
360
273
|
/**
|
|
361
|
-
*
|
|
274
|
+
* Convert a GeneratedRef to a RelationDefinition
|
|
362
275
|
*
|
|
363
|
-
* @param
|
|
364
|
-
* @returns
|
|
276
|
+
* @param ref - The generated reference
|
|
277
|
+
* @returns The relation definition
|
|
365
278
|
*/
|
|
366
|
-
protected
|
|
279
|
+
protected refToRelationDefinition(ref: GeneratedRef): RelationDefinition;
|
|
367
280
|
/**
|
|
368
|
-
*
|
|
281
|
+
* Collect enum definitions from the schema
|
|
369
282
|
*
|
|
370
|
-
*
|
|
371
|
-
* @returns Array of column names in the primary key
|
|
372
|
-
*/
|
|
373
|
-
protected getPrimaryKeyColumns(pk: unknown): string[];
|
|
374
|
-
/**
|
|
375
|
-
* Get column names from a unique constraint
|
|
283
|
+
* Override in subclasses for dialect-specific enum handling (e.g., PostgreSQL)
|
|
376
284
|
*
|
|
377
|
-
* @
|
|
378
|
-
* @returns Array of column names in the unique constraint
|
|
285
|
+
* @returns Array of enum definitions (empty by default)
|
|
379
286
|
*/
|
|
380
|
-
protected
|
|
287
|
+
protected collectEnumDefinitions(): EnumDefinition[];
|
|
381
288
|
}
|
|
382
289
|
/**
|
|
383
290
|
* Write DBML content to a file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/generator/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/generator/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,KAAK,EAKX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAQnE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,YAAY,EAEb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAmB,KAAK,cAAc,EAAE,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