@famgia/omnify-laravel 0.0.1

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.
@@ -0,0 +1,402 @@
1
+ import { PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
2
+
3
+ /**
4
+ * @famgia/omnify-laravel - Migration Types
5
+ *
6
+ * Types for Laravel migration generation.
7
+ */
8
+ /**
9
+ * Laravel migration file structure.
10
+ */
11
+ interface MigrationFile {
12
+ /** File name with timestamp prefix */
13
+ readonly fileName: string;
14
+ /** Migration class name */
15
+ readonly className: string;
16
+ /** Full file content */
17
+ readonly content: string;
18
+ /** Tables affected */
19
+ readonly tables: readonly string[];
20
+ /** Whether this is a create or alter migration */
21
+ readonly type: 'create' | 'alter' | 'drop';
22
+ }
23
+ /**
24
+ * Migration generation options.
25
+ */
26
+ interface MigrationOptions {
27
+ /** Output directory for migrations */
28
+ readonly outputDir?: string | undefined;
29
+ /** Timestamp prefix (defaults to current time) */
30
+ readonly timestamp?: string | undefined;
31
+ /** Whether to generate down migration */
32
+ readonly generateDown?: boolean | undefined;
33
+ /** Database connection name */
34
+ readonly connection?: string | undefined;
35
+ }
36
+ /**
37
+ * Schema Builder column method.
38
+ */
39
+ interface ColumnMethod {
40
+ /** Column name */
41
+ readonly name: string;
42
+ /** Method name (e.g., 'string', 'integer', 'boolean') */
43
+ readonly method: string;
44
+ /** Method arguments */
45
+ readonly args: readonly (string | number | boolean)[];
46
+ /** Chained modifiers (e.g., nullable(), unique(), default()) */
47
+ readonly modifiers: readonly ColumnModifier[];
48
+ }
49
+ /**
50
+ * Column modifier (chained method).
51
+ */
52
+ interface ColumnModifier {
53
+ /** Modifier method name */
54
+ readonly method: string;
55
+ /** Modifier arguments */
56
+ readonly args?: readonly (string | number | boolean)[] | undefined;
57
+ }
58
+ /**
59
+ * Foreign key definition for Schema Builder.
60
+ */
61
+ interface ForeignKeyDefinition {
62
+ /** Local column(s) */
63
+ readonly columns: readonly string[];
64
+ /** Referenced table */
65
+ readonly references: string;
66
+ /** Referenced column(s) */
67
+ readonly on: readonly string[];
68
+ /** ON DELETE action */
69
+ readonly onDelete?: string | undefined;
70
+ /** ON UPDATE action */
71
+ readonly onUpdate?: string | undefined;
72
+ }
73
+ /**
74
+ * Index definition for Schema Builder.
75
+ */
76
+ interface IndexDefinition {
77
+ /** Index name */
78
+ readonly name?: string | undefined;
79
+ /** Columns in the index */
80
+ readonly columns: readonly string[];
81
+ /** Whether this is a unique index */
82
+ readonly unique: boolean;
83
+ }
84
+ /**
85
+ * Table blueprint for Schema Builder.
86
+ */
87
+ interface TableBlueprint {
88
+ /** Table name */
89
+ readonly tableName: string;
90
+ /** Column definitions */
91
+ readonly columns: readonly ColumnMethod[];
92
+ /** Primary key column(s) */
93
+ readonly primaryKey?: readonly string[] | undefined;
94
+ /** Foreign key constraints */
95
+ readonly foreignKeys: readonly ForeignKeyDefinition[];
96
+ /** Index definitions */
97
+ readonly indexes: readonly IndexDefinition[];
98
+ }
99
+ /**
100
+ * Migration operation (up or down).
101
+ */
102
+ interface MigrationOperation {
103
+ /** Operation type */
104
+ readonly type: 'create' | 'table' | 'drop' | 'dropIfExists';
105
+ /** Table name */
106
+ readonly tableName: string;
107
+ /** Blueprint (for create/table operations) */
108
+ readonly blueprint?: TableBlueprint | undefined;
109
+ }
110
+ /**
111
+ * Complete migration definition.
112
+ */
113
+ interface MigrationDefinition {
114
+ /** Migration class name */
115
+ readonly className: string;
116
+ /** UP operations */
117
+ readonly up: readonly MigrationOperation[];
118
+ /** DOWN operations */
119
+ readonly down: readonly MigrationOperation[];
120
+ /** Database connection */
121
+ readonly connection?: string | undefined;
122
+ }
123
+
124
+ /**
125
+ * @famgia/omnify-laravel - Schema Builder Converter
126
+ *
127
+ * Converts SQL types and operations to Laravel Schema Builder methods.
128
+ */
129
+
130
+ /**
131
+ * Converts a property name to snake_case column name.
132
+ */
133
+ declare function toColumnName(propertyName: string): string;
134
+ /**
135
+ * Converts schema name to snake_case plural table name.
136
+ */
137
+ declare function toTableName(schemaName: string): string;
138
+ /**
139
+ * Converts a property to Laravel column method.
140
+ */
141
+ declare function propertyToColumnMethod(propertyName: string, property: PropertyDefinition): ColumnMethod | null;
142
+ /**
143
+ * Generates primary key column method.
144
+ */
145
+ declare function generatePrimaryKeyColumn(pkType?: 'Int' | 'BigInt' | 'Uuid' | 'String'): ColumnMethod;
146
+ /**
147
+ * Generates timestamp columns.
148
+ */
149
+ declare function generateTimestampColumns(): ColumnMethod[];
150
+ /**
151
+ * Generates soft delete column.
152
+ */
153
+ declare function generateSoftDeleteColumn(): ColumnMethod;
154
+ /**
155
+ * Generates foreign key column and constraint from association.
156
+ */
157
+ declare function generateForeignKey(propertyName: string, property: PropertyDefinition, allSchemas: SchemaCollection): {
158
+ column: ColumnMethod;
159
+ foreignKey: ForeignKeyDefinition;
160
+ index: IndexDefinition;
161
+ } | null;
162
+ /**
163
+ * Generates table blueprint from schema.
164
+ */
165
+ declare function schemaToBlueprint(schema: LoadedSchema, allSchemas: SchemaCollection): TableBlueprint;
166
+ /**
167
+ * Formats a column method to PHP code.
168
+ */
169
+ declare function formatColumnMethod(column: ColumnMethod): string;
170
+ /**
171
+ * Formats a foreign key to PHP code.
172
+ */
173
+ declare function formatForeignKey(fk: ForeignKeyDefinition): string;
174
+ /**
175
+ * Formats an index to PHP code.
176
+ */
177
+ declare function formatIndex(index: IndexDefinition): string;
178
+
179
+ /**
180
+ * @famgia/omnify-laravel - Migration Generator
181
+ *
182
+ * Generates Laravel migration files from schemas.
183
+ */
184
+
185
+ /**
186
+ * Generates migrations for all schemas.
187
+ */
188
+ declare function generateMigrations(schemas: SchemaCollection, options?: MigrationOptions): MigrationFile[];
189
+ /**
190
+ * Generates migration from a single schema.
191
+ */
192
+ declare function generateMigrationFromSchema(schema: LoadedSchema, allSchemas: SchemaCollection, options?: MigrationOptions): MigrationFile;
193
+ /**
194
+ * Generates drop migration for a table.
195
+ */
196
+ declare function generateDropMigrationForTable(tableName: string, options?: MigrationOptions): MigrationFile;
197
+ /**
198
+ * Formats migration content for writing to file.
199
+ */
200
+ declare function formatMigrationFile(migration: MigrationFile): string;
201
+ /**
202
+ * Gets the output path for a migration file.
203
+ */
204
+ declare function getMigrationPath(migration: MigrationFile, outputDir?: string): string;
205
+
206
+ /**
207
+ * @famgia/omnify-laravel - TypeScript Types
208
+ *
209
+ * Types for TypeScript code generation.
210
+ */
211
+ /**
212
+ * Generated TypeScript file.
213
+ */
214
+ interface TypeScriptFile {
215
+ /** File name */
216
+ readonly fileName: string;
217
+ /** Full file content */
218
+ readonly content: string;
219
+ /** Types defined in this file */
220
+ readonly types: readonly string[];
221
+ }
222
+ /**
223
+ * TypeScript generation options.
224
+ */
225
+ interface TypeScriptOptions {
226
+ /** Output directory for TypeScript files */
227
+ readonly outputDir?: string | undefined;
228
+ /** Whether to generate a single file or multiple files */
229
+ readonly singleFile?: boolean | undefined;
230
+ /** File name for single file output */
231
+ readonly fileName?: string | undefined;
232
+ /** Whether to export as default */
233
+ readonly exportDefault?: boolean | undefined;
234
+ /** Whether to include readonly modifiers */
235
+ readonly readonly?: boolean | undefined;
236
+ /** Whether to use strict null checks compatible types */
237
+ readonly strictNullChecks?: boolean | undefined;
238
+ }
239
+ /**
240
+ * TypeScript property definition.
241
+ */
242
+ interface TSProperty {
243
+ /** Property name */
244
+ readonly name: string;
245
+ /** TypeScript type */
246
+ readonly type: string;
247
+ /** Whether the property is optional */
248
+ readonly optional: boolean;
249
+ /** Whether the property is readonly */
250
+ readonly readonly: boolean;
251
+ /** JSDoc comment */
252
+ readonly comment?: string | undefined;
253
+ }
254
+ /**
255
+ * TypeScript interface definition.
256
+ */
257
+ interface TSInterface {
258
+ /** Interface name */
259
+ readonly name: string;
260
+ /** Properties */
261
+ readonly properties: readonly TSProperty[];
262
+ /** Extended interfaces */
263
+ readonly extends?: readonly string[] | undefined;
264
+ /** JSDoc comment */
265
+ readonly comment?: string | undefined;
266
+ }
267
+ /**
268
+ * TypeScript enum definition.
269
+ */
270
+ interface TSEnum {
271
+ /** Enum name */
272
+ readonly name: string;
273
+ /** Enum values */
274
+ readonly values: readonly TSEnumValue[];
275
+ /** JSDoc comment */
276
+ readonly comment?: string | undefined;
277
+ }
278
+ /**
279
+ * TypeScript enum value.
280
+ */
281
+ interface TSEnumValue {
282
+ /** Value name */
283
+ readonly name: string;
284
+ /** Value (string or number) */
285
+ readonly value: string | number;
286
+ }
287
+ /**
288
+ * TypeScript type alias definition.
289
+ */
290
+ interface TSTypeAlias {
291
+ /** Type name */
292
+ readonly name: string;
293
+ /** Type definition */
294
+ readonly type: string;
295
+ /** JSDoc comment */
296
+ readonly comment?: string | undefined;
297
+ }
298
+
299
+ /**
300
+ * @famgia/omnify-laravel - TypeScript Interface Generator
301
+ *
302
+ * Generates TypeScript interfaces from schemas.
303
+ */
304
+
305
+ /**
306
+ * Converts property name to TypeScript property name.
307
+ * Preserves camelCase.
308
+ */
309
+ declare function toPropertyName(name: string): string;
310
+ /**
311
+ * Converts schema name to TypeScript interface name.
312
+ * Preserves PascalCase.
313
+ */
314
+ declare function toInterfaceName(schemaName: string): string;
315
+ /**
316
+ * Gets TypeScript type for a property.
317
+ */
318
+ declare function getPropertyType(property: PropertyDefinition, _allSchemas: SchemaCollection): string;
319
+ /**
320
+ * Converts a property to TypeScript property definition.
321
+ */
322
+ declare function propertyToTSProperty(propertyName: string, property: PropertyDefinition, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSProperty;
323
+ /**
324
+ * Generates TypeScript interface from schema.
325
+ */
326
+ declare function schemaToInterface(schema: LoadedSchema, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSInterface;
327
+ /**
328
+ * Formats a TypeScript property.
329
+ */
330
+ declare function formatProperty(property: TSProperty): string;
331
+ /**
332
+ * Formats a TypeScript interface.
333
+ */
334
+ declare function formatInterface(iface: TSInterface): string;
335
+ /**
336
+ * Generates interfaces for all schemas.
337
+ */
338
+ declare function generateInterfaces(schemas: SchemaCollection, options?: TypeScriptOptions): TSInterface[];
339
+
340
+ /**
341
+ * @famgia/omnify-laravel - TypeScript Enum Generator
342
+ *
343
+ * Generates TypeScript enums from schema enum definitions.
344
+ */
345
+
346
+ /**
347
+ * Converts enum value to valid TypeScript enum member name.
348
+ */
349
+ declare function toEnumMemberName(value: string): string;
350
+ /**
351
+ * Converts schema name to TypeScript enum name.
352
+ */
353
+ declare function toEnumName(schemaName: string): string;
354
+ /**
355
+ * Generates TypeScript enum from schema enum.
356
+ */
357
+ declare function schemaToEnum(schema: LoadedSchema): TSEnum | null;
358
+ /**
359
+ * Generates enums for all enum schemas.
360
+ */
361
+ declare function generateEnums(schemas: SchemaCollection): TSEnum[];
362
+ /**
363
+ * Formats a TypeScript enum.
364
+ */
365
+ declare function formatEnum(enumDef: TSEnum): string;
366
+ /**
367
+ * Generates a union type alias as an alternative to enum.
368
+ */
369
+ declare function enumToUnionType(enumDef: TSEnum): TSTypeAlias;
370
+ /**
371
+ * Formats a TypeScript type alias.
372
+ */
373
+ declare function formatTypeAlias(alias: TSTypeAlias): string;
374
+ /**
375
+ * Extracts inline enums from properties for type generation.
376
+ */
377
+ declare function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[];
378
+
379
+ /**
380
+ * @famgia/omnify-laravel - TypeScript Generator
381
+ *
382
+ * Main TypeScript code generator combining interfaces, enums, and types.
383
+ */
384
+
385
+ /**
386
+ * Generates all TypeScript code as a single file.
387
+ */
388
+ declare function generateTypeScriptFile(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile;
389
+ /**
390
+ * Generates TypeScript code as multiple files.
391
+ */
392
+ declare function generateTypeScriptFiles(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
393
+ /**
394
+ * Generates TypeScript types with configurable output.
395
+ */
396
+ declare function generateTypeScript(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
397
+ /**
398
+ * Gets output path for a TypeScript file.
399
+ */
400
+ declare function getTypeScriptPath(file: TypeScriptFile, outputDir?: string): string;
401
+
402
+ export { type ColumnMethod, type ColumnModifier, type ForeignKeyDefinition, type IndexDefinition, type MigrationDefinition, type MigrationFile, type MigrationOperation, type MigrationOptions, type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TableBlueprint, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatColumnMethod, formatEnum, formatForeignKey, formatIndex, formatInterface, formatMigrationFile, formatProperty, formatTypeAlias, generateDropMigrationForTable, generateEnums, generateForeignKey, generateInterfaces, generateMigrationFromSchema, generateMigrations, generatePrimaryKeyColumn, generateSoftDeleteColumn, generateTimestampColumns, generateTypeScript, generateTypeScriptFile, generateTypeScriptFiles, getMigrationPath, getPropertyType, getTypeScriptPath, propertyToColumnMethod, propertyToTSProperty, schemaToBlueprint, schemaToEnum, schemaToInterface, toColumnName, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName, toTableName };