drizzle-multitenant 1.2.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { C as Config } from './types-BhK96FPC.js';
1
+ import { C as Config } from './types-CGqsPe2Q.js';
2
2
  import { Pool } from 'pg';
3
3
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
4
4
 
@@ -305,6 +305,35 @@ interface MigratorConfig {
305
305
  * @default "name"
306
306
  */
307
307
  defaultFormat?: TableFormat;
308
+ /**
309
+ * Path to shared schema migrations folder
310
+ * If provided, enables shared schema migration support
311
+ */
312
+ sharedMigrationsFolder?: string;
313
+ /**
314
+ * Table name for tracking shared migrations
315
+ * @default "__drizzle_shared_migrations"
316
+ */
317
+ sharedMigrationsTable?: string;
318
+ /**
319
+ * Hooks for shared schema migrations
320
+ */
321
+ sharedHooks?: SharedMigrationHooks;
322
+ /**
323
+ * Table format for tracking shared schema migrations
324
+ * Independent from tenant tableFormat, allowing different formats per schema type
325
+ * - "auto": Auto-detect existing format, use sharedDefaultFormat for new tables
326
+ * - "name": Use filename (drizzle-multitenant native)
327
+ * - "hash": Use SHA-256 hash
328
+ * - "drizzle-kit": Exact drizzle-kit format (hash + bigint timestamp)
329
+ * @default "auto"
330
+ */
331
+ sharedTableFormat?: 'auto' | TableFormat;
332
+ /**
333
+ * When using "auto" for sharedTableFormat and no table exists, which format to create
334
+ * @default "name"
335
+ */
336
+ sharedDefaultFormat?: TableFormat;
308
337
  }
309
338
  /**
310
339
  * Migrate options
@@ -608,6 +637,104 @@ interface SchemaDriftOptions {
608
637
  onProgress?: (tenantId: string, status: 'starting' | 'introspecting' | 'comparing' | 'completed' | 'failed') => void;
609
638
  }
610
639
 
640
+ /**
641
+ * Migration status for the shared schema (public)
642
+ */
643
+ interface SharedMigrationStatus {
644
+ /** Schema name (usually 'public') */
645
+ schemaName: string;
646
+ /** Number of applied migrations */
647
+ appliedCount: number;
648
+ /** Number of pending migrations */
649
+ pendingCount: number;
650
+ /** Names of pending migrations */
651
+ pendingMigrations: string[];
652
+ /** Overall status */
653
+ status: 'ok' | 'behind' | 'error';
654
+ /** Error message if status is 'error' */
655
+ error?: string;
656
+ /** Detected table format */
657
+ format: TableFormat | null;
658
+ }
659
+ /**
660
+ * Migration result for the shared schema
661
+ */
662
+ interface SharedMigrationResult {
663
+ /** Schema name (usually 'public') */
664
+ schemaName: string;
665
+ /** Whether migration was successful */
666
+ success: boolean;
667
+ /** List of applied migration names */
668
+ appliedMigrations: string[];
669
+ /** Error message if failed */
670
+ error?: string;
671
+ /** Duration in milliseconds */
672
+ durationMs: number;
673
+ /** Table format used */
674
+ format?: TableFormat;
675
+ }
676
+ /**
677
+ * Shared migration configuration (extends MigratorConfig)
678
+ */
679
+ interface SharedMigratorConfig {
680
+ /** Path to shared schema migrations folder */
681
+ sharedMigrationsFolder: string;
682
+ /** Table name for tracking shared migrations (default: '__drizzle_shared_migrations') */
683
+ sharedMigrationsTable?: string;
684
+ /** Migration hooks for shared schema */
685
+ hooks?: SharedMigrationHooks;
686
+ /**
687
+ * Table format for tracking migrations
688
+ * @default "auto"
689
+ */
690
+ tableFormat?: 'auto' | TableFormat;
691
+ /**
692
+ * Default format when creating new table
693
+ * @default "name"
694
+ */
695
+ defaultFormat?: TableFormat;
696
+ }
697
+ /**
698
+ * Hooks for shared schema migrations
699
+ */
700
+ interface SharedMigrationHooks {
701
+ /** Called before starting shared migration */
702
+ beforeMigration?: () => void | Promise<void>;
703
+ /** Called after shared migration completes */
704
+ afterMigration?: (result: SharedMigrationResult) => void | Promise<void>;
705
+ /** Called before applying a specific migration */
706
+ beforeApply?: (migrationName: string) => void | Promise<void>;
707
+ /** Called after applying a specific migration */
708
+ afterApply?: (migrationName: string, durationMs: number) => void | Promise<void>;
709
+ }
710
+ /**
711
+ * Options for shared migration operations
712
+ */
713
+ interface SharedMigrateOptions {
714
+ /** Dry run mode - show what would be applied without executing */
715
+ dryRun?: boolean;
716
+ /** Progress callback */
717
+ onProgress?: (status: 'starting' | 'migrating' | 'completed' | 'failed', migrationName?: string) => void;
718
+ }
719
+ /**
720
+ * Seed function signature for shared schema
721
+ * Called with the shared database instance
722
+ */
723
+ type SharedSeedFunction<TSchema extends Record<string, unknown> = Record<string, unknown>> = (db: PostgresJsDatabase<TSchema>) => Promise<void>;
724
+ /**
725
+ * Result of shared schema seeding
726
+ */
727
+ interface SharedSeedResult {
728
+ /** Schema name (usually 'public') */
729
+ schemaName: string;
730
+ /** Whether seeding was successful */
731
+ success: boolean;
732
+ /** Error message if failed */
733
+ error?: string;
734
+ /** Duration in milliseconds */
735
+ durationMs: number;
736
+ }
737
+
611
738
  /**
612
739
  * Parallel migration engine for multi-tenant applications
613
740
  */
@@ -621,6 +748,8 @@ declare class Migrator<TTenantSchema extends Record<string, unknown>, TSharedSch
621
748
  private readonly migrationExecutor;
622
749
  private readonly batchExecutor;
623
750
  private readonly cloner;
751
+ private readonly sharedMigrationExecutor;
752
+ private readonly sharedSeeder;
624
753
  constructor(tenantConfig: Config<TTenantSchema, TSharedSchema>, migratorConfig: MigratorConfig);
625
754
  /**
626
755
  * Migrate all tenants in parallel
@@ -769,6 +898,69 @@ declare class Migrator<TTenantSchema extends Record<string, unknown>, TSharedSch
769
898
  * Seed specific tenants with initial data
770
899
  */
771
900
  seedTenants(tenantIds: string[], seedFn: SeedFunction<TTenantSchema>, options?: SeedOptions): Promise<SeedResults>;
901
+ /**
902
+ * Check if shared schema seeding is available
903
+ *
904
+ * @returns True if shared schema is configured
905
+ */
906
+ hasSharedSeeding(): boolean;
907
+ /**
908
+ * Seed the shared schema with initial data
909
+ *
910
+ * Seeds the public/shared schema with common data like plans, roles, permissions.
911
+ * Must have schemas.shared configured in the tenant config.
912
+ *
913
+ * @example
914
+ * ```typescript
915
+ * if (migrator.hasSharedSeeding()) {
916
+ * const result = await migrator.seedShared(async (db) => {
917
+ * await db.insert(plans).values([
918
+ * { id: 'free', name: 'Free', price: 0 },
919
+ * { id: 'pro', name: 'Pro', price: 29 },
920
+ * { id: 'enterprise', name: 'Enterprise', price: 99 },
921
+ * ]).onConflictDoNothing();
922
+ *
923
+ * await db.insert(roles).values([
924
+ * { name: 'admin', permissions: ['*'] },
925
+ * { name: 'user', permissions: ['read'] },
926
+ * ]).onConflictDoNothing();
927
+ * });
928
+ *
929
+ * if (result.success) {
930
+ * console.log(`Seeded shared schema in ${result.durationMs}ms`);
931
+ * }
932
+ * }
933
+ * ```
934
+ */
935
+ seedShared(seedFn: SharedSeedFunction<TSharedSchema>): Promise<SharedSeedResult>;
936
+ /**
937
+ * Seed shared schema first, then all tenants
938
+ *
939
+ * Convenience method for the common pattern of seeding shared tables
940
+ * before tenant tables.
941
+ *
942
+ * @example
943
+ * ```typescript
944
+ * const result = await migrator.seedAllWithShared(
945
+ * async (db) => {
946
+ * await db.insert(plans).values([{ id: 'free', name: 'Free' }]);
947
+ * },
948
+ * async (db, tenantId) => {
949
+ * await db.insert(roles).values([{ name: 'admin' }]);
950
+ * },
951
+ * { concurrency: 10 }
952
+ * );
953
+ *
954
+ * if (result.shared.success) {
955
+ * console.log('Shared seeding completed');
956
+ * }
957
+ * console.log(`Tenants: ${result.tenants.succeeded}/${result.tenants.total}`);
958
+ * ```
959
+ */
960
+ seedAllWithShared(sharedSeedFn: SharedSeedFunction<TSharedSchema>, tenantSeedFn: SeedFunction<TTenantSchema>, options?: SeedOptions): Promise<{
961
+ shared: SharedSeedResult;
962
+ tenants: SeedResults;
963
+ }>;
772
964
  /**
773
965
  * Load migration files from the migrations folder
774
966
  */
@@ -780,6 +972,75 @@ declare class Migrator<TTenantSchema extends Record<string, unknown>, TSharedSch
780
972
  * Note: This method is shared with SyncManager and MigrationExecutor via dependency injection.
781
973
  */
782
974
  private getOrDetectFormat;
975
+ /**
976
+ * Load shared migration files from the shared migrations folder
977
+ */
978
+ private loadSharedMigrations;
979
+ /**
980
+ * Get or detect the format for the shared schema
981
+ *
982
+ * Uses sharedTableFormat/sharedDefaultFormat if configured,
983
+ * otherwise falls back to tableFormat/defaultFormat for backwards compatibility.
984
+ */
985
+ private getOrDetectSharedFormat;
986
+ /**
987
+ * Check if shared schema migrations are configured
988
+ *
989
+ * @returns True if sharedMigrationsFolder is configured and exists
990
+ */
991
+ hasSharedMigrations(): boolean;
992
+ /**
993
+ * Migrate the shared schema (public)
994
+ *
995
+ * Applies pending migrations to the shared/public schema.
996
+ * Must have sharedMigrationsFolder configured.
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * if (migrator.hasSharedMigrations()) {
1001
+ * const result = await migrator.migrateShared();
1002
+ * console.log(`Applied ${result.appliedMigrations.length} shared migrations`);
1003
+ * }
1004
+ * ```
1005
+ */
1006
+ migrateShared(options?: SharedMigrateOptions): Promise<SharedMigrationResult>;
1007
+ /**
1008
+ * Get migration status for the shared schema
1009
+ *
1010
+ * @returns Status with applied/pending counts
1011
+ */
1012
+ getSharedStatus(): Promise<SharedMigrationStatus>;
1013
+ /**
1014
+ * Mark shared schema migrations as applied without executing SQL
1015
+ *
1016
+ * Useful for syncing tracking state with already-applied migrations.
1017
+ */
1018
+ markSharedAsApplied(options?: {
1019
+ onProgress?: SharedMigrateOptions['onProgress'];
1020
+ }): Promise<SharedMigrationResult>;
1021
+ /**
1022
+ * Migrate shared schema first, then all tenants
1023
+ *
1024
+ * Convenience method for the common pattern of migrating shared tables
1025
+ * before tenant tables.
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * const result = await migrator.migrateAllWithShared({
1030
+ * concurrency: 10,
1031
+ * onProgress: (tenantId, status) => console.log(`${tenantId}: ${status}`),
1032
+ * });
1033
+ *
1034
+ * console.log(`Shared: ${result.shared.appliedMigrations.length} applied`);
1035
+ * console.log(`Tenants: ${result.tenants.succeeded}/${result.tenants.total} succeeded`);
1036
+ * ```
1037
+ */
1038
+ migrateAllWithShared(options?: MigrateOptions & {
1039
+ sharedOptions?: SharedMigrateOptions;
1040
+ }): Promise<{
1041
+ shared: SharedMigrationResult;
1042
+ tenants: MigrationResults;
1043
+ }>;
783
1044
  /**
784
1045
  * Detect schema drift across all tenants
785
1046
  * Compares each tenant's schema against a reference tenant (first tenant by default)
@@ -821,4 +1082,4 @@ declare class Migrator<TTenantSchema extends Record<string, unknown>, TSharedSch
821
1082
  */
822
1083
  declare function createMigrator<TTenantSchema extends Record<string, unknown>, TSharedSchema extends Record<string, unknown>>(tenantConfig: Config<TTenantSchema, TSharedSchema>, migratorConfig: MigratorConfig): Migrator<TTenantSchema, TSharedSchema>;
823
1084
 
824
- export { type AppliedMigration as A, type TableFormat as B, type CreateTenantOptions as C, type DropTenantOptions as D, type ColumnInfo as E, type ConstraintInfo as F, type TableSchema as G, type TenantSchema as H, type IndexInfo as I, type ColumnDrift as J, type IndexDrift as K, type ConstraintDrift as L, Migrator as M, type TableDrift as N, type TenantSchemaDrift as O, type SchemaDriftStatus as P, type SchemaDriftOptions as Q, type CloneProgressCallback as R, type SeedFunction as S, type TenantMigrationResult as T, type CloneProgressStatus as U, type AnonymizeOptions as V, type AnonymizeRules as W, type AnonymizeValue as X, type MigratorConfig as a, type MigrationFile as b, createMigrator as c, type MigrateOptions as d, type MigrationResults as e, type TenantMigrationStatus as f, type MigrationHooks as g, type MigrationProgressCallback as h, type MigrationErrorHandler as i, type SeedOptions as j, type TenantSeedResult as k, type SeedResults as l, type DetectedFormat as m, type SyncStatus as n, type TenantSyncStatus as o, type TenantSyncResult as p, type SyncOptions as q, type SyncResults as r, type ClonerConfig as s, type ClonerDependencies as t, type CloneTenantOptions as u, type CloneTenantResult as v, detectTableFormat as w, getFormatConfig as x, DEFAULT_FORMAT as y, DRIZZLE_KIT_FORMAT as z };
1085
+ export { type AnonymizeRules as $, type AppliedMigration as A, type SharedMigrationStatus as B, type CreateTenantOptions as C, type DropTenantOptions as D, detectTableFormat as E, getFormatConfig as F, DEFAULT_FORMAT as G, DRIZZLE_KIT_FORMAT as H, type TableFormat as I, type ColumnInfo as J, type IndexInfo as K, type ConstraintInfo as L, Migrator as M, type TableSchema as N, type TenantSchema as O, type ColumnDrift as P, type IndexDrift as Q, type ConstraintDrift as R, type SeedFunction as S, type TenantMigrationResult as T, type TableDrift as U, type TenantSchemaDrift as V, type SchemaDriftStatus as W, type SchemaDriftOptions as X, type CloneProgressCallback as Y, type CloneProgressStatus as Z, type AnonymizeOptions as _, type MigratorConfig as a, type AnonymizeValue as a0, type SharedMigratorConfig as a1, type SharedMigrationHooks as a2, type MigrationFile as b, createMigrator as c, type MigrateOptions as d, type MigrationResults as e, type TenantMigrationStatus as f, type MigrationHooks as g, type MigrationProgressCallback as h, type MigrationErrorHandler as i, type SeedOptions as j, type TenantSeedResult as k, type SeedResults as l, type SharedSeedFunction as m, type SharedSeedResult as n, type DetectedFormat as o, type SyncStatus as p, type TenantSyncStatus as q, type TenantSyncResult as r, type SyncOptions as s, type SyncResults as t, type ClonerConfig as u, type ClonerDependencies as v, type CloneTenantOptions as w, type CloneTenantResult as x, type SharedMigrateOptions as y, type SharedMigrationResult as z };
@@ -0,0 +1,330 @@
1
+ /**
2
+ * Scaffold module types
3
+ *
4
+ * @module scaffold/types
5
+ */
6
+ /**
7
+ * Type of scaffold to generate
8
+ */
9
+ type ScaffoldType = 'tenant' | 'shared';
10
+ /**
11
+ * Kind of scaffold template
12
+ */
13
+ type ScaffoldKind = 'schema' | 'seed' | 'migration';
14
+ /**
15
+ * Options for scaffolding a schema
16
+ */
17
+ interface ScaffoldSchemaOptions {
18
+ /** Name of the schema/table (e.g., "orders", "products") */
19
+ name: string;
20
+ /** Type of schema (tenant or shared) */
21
+ type: ScaffoldType;
22
+ /** Output directory for the schema file */
23
+ outputDir?: string;
24
+ /** Whether to include example columns */
25
+ includeExample?: boolean;
26
+ /** Whether to include timestamps (createdAt, updatedAt) */
27
+ includeTimestamps?: boolean;
28
+ /** Whether to include soft delete (deletedAt) */
29
+ includeSoftDelete?: boolean;
30
+ /** Whether to use UUID for primary key (default: true) */
31
+ useUuid?: boolean;
32
+ }
33
+ /**
34
+ * Options for scaffolding a seed
35
+ */
36
+ interface ScaffoldSeedOptions {
37
+ /** Name of the seed file (e.g., "initial", "demo-data") */
38
+ name: string;
39
+ /** Type of seed (tenant or shared) */
40
+ type: ScaffoldType;
41
+ /** Output directory for the seed file */
42
+ outputDir?: string;
43
+ /** Optional table name to seed */
44
+ tableName?: string;
45
+ }
46
+ /**
47
+ * Options for scaffolding a migration
48
+ */
49
+ interface ScaffoldMigrationOptions {
50
+ /** Name of the migration (e.g., "add-orders", "create-users") */
51
+ name: string;
52
+ /** Type of migration (tenant or shared) */
53
+ type: ScaffoldType;
54
+ /** Output directory for the migration file */
55
+ outputDir?: string;
56
+ /** Migration template type */
57
+ template?: MigrationTemplate;
58
+ }
59
+ /**
60
+ * Available migration templates
61
+ */
62
+ type MigrationTemplate = 'create-table' | 'add-column' | 'add-index' | 'add-foreign-key' | 'blank';
63
+ /**
64
+ * Result of a scaffold operation
65
+ */
66
+ interface ScaffoldResult {
67
+ /** Whether the operation was successful */
68
+ success: boolean;
69
+ /** Path to the generated file */
70
+ filePath: string;
71
+ /** Name of the generated file */
72
+ fileName: string;
73
+ /** Type of scaffold generated */
74
+ kind: ScaffoldKind;
75
+ /** Tenant or shared */
76
+ type: ScaffoldType;
77
+ /** Optional error message if failed */
78
+ error?: string;
79
+ }
80
+ /**
81
+ * Template context for schema generation
82
+ */
83
+ interface SchemaTemplateContext {
84
+ /** Table name in snake_case */
85
+ tableName: string;
86
+ /** Table name in PascalCase */
87
+ tableNamePascal: string;
88
+ /** Table name in camelCase */
89
+ tableNameCamel: string;
90
+ /** Schema type (tenant or shared) */
91
+ type: ScaffoldType;
92
+ /** Whether to include timestamps */
93
+ includeTimestamps: boolean;
94
+ /** Whether to include soft delete */
95
+ includeSoftDelete: boolean;
96
+ /** Whether to use UUID for primary key */
97
+ useUuid: boolean;
98
+ /** Whether to include example columns */
99
+ includeExample: boolean;
100
+ }
101
+ /**
102
+ * Template context for seed generation
103
+ */
104
+ interface SeedTemplateContext {
105
+ /** Seed function name in camelCase */
106
+ seedName: string;
107
+ /** Table name (optional) */
108
+ tableName?: string;
109
+ /** Schema type (tenant or shared) */
110
+ type: ScaffoldType;
111
+ }
112
+ /**
113
+ * Template context for migration generation
114
+ */
115
+ interface MigrationTemplateContext {
116
+ /** Migration name for comments */
117
+ migrationName: string;
118
+ /** Schema type (tenant or shared) */
119
+ type: ScaffoldType;
120
+ /** Template type */
121
+ template: MigrationTemplate;
122
+ /** Table name (derived from migration name) */
123
+ tableName?: string;
124
+ }
125
+ /**
126
+ * Generated file output
127
+ */
128
+ interface GeneratedFile {
129
+ /** File path relative to project root */
130
+ path: string;
131
+ /** File content */
132
+ content: string;
133
+ }
134
+ /**
135
+ * Scaffold configuration from tenant.config.ts
136
+ */
137
+ interface ScaffoldConfig {
138
+ /** Schema output directory */
139
+ schemaDir?: string;
140
+ /** Seed output directory */
141
+ seedDir?: string;
142
+ /** Migrations folder */
143
+ migrationsFolder?: string;
144
+ /** Shared migrations folder */
145
+ sharedMigrationsFolder?: string;
146
+ }
147
+
148
+ /**
149
+ * Scaffold generator
150
+ *
151
+ * Orchestrates the generation of schema, seed, and migration files.
152
+ *
153
+ * @module scaffold/generator
154
+ */
155
+
156
+ /**
157
+ * Convert a name to various case formats
158
+ */
159
+ declare function toCase(name: string): {
160
+ snake: string;
161
+ pascal: string;
162
+ camel: string;
163
+ };
164
+ /**
165
+ * Default output directories
166
+ */
167
+ declare const DEFAULT_DIRS: {
168
+ readonly schemaDir: "src/db/schema";
169
+ readonly seedDir: "drizzle/seeds";
170
+ readonly tenantMigrationsDir: "drizzle/tenant-migrations";
171
+ readonly sharedMigrationsDir: "drizzle/shared-migrations";
172
+ };
173
+ /**
174
+ * Scaffold a new Drizzle schema file
175
+ *
176
+ * @param options - Scaffold options
177
+ * @returns Result of the scaffold operation
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const result = await scaffoldSchema({
182
+ * name: 'orders',
183
+ * type: 'tenant',
184
+ * includeTimestamps: true,
185
+ * });
186
+ *
187
+ * if (result.success) {
188
+ * console.log(`Created: ${result.filePath}`);
189
+ * }
190
+ * ```
191
+ */
192
+ declare function scaffoldSchema(options: ScaffoldSchemaOptions): Promise<ScaffoldResult>;
193
+ /**
194
+ * Scaffold a new seed file
195
+ *
196
+ * @param options - Scaffold options
197
+ * @returns Result of the scaffold operation
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const result = await scaffoldSeed({
202
+ * name: 'initial',
203
+ * type: 'tenant',
204
+ * tableName: 'users',
205
+ * });
206
+ * ```
207
+ */
208
+ declare function scaffoldSeed(options: ScaffoldSeedOptions): Promise<ScaffoldResult>;
209
+ /**
210
+ * Scaffold a new migration file
211
+ *
212
+ * @param options - Scaffold options
213
+ * @returns Result of the scaffold operation
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const result = await scaffoldMigration({
218
+ * name: 'add-orders',
219
+ * type: 'tenant',
220
+ * template: 'create-table',
221
+ * });
222
+ * ```
223
+ */
224
+ declare function scaffoldMigration(options: ScaffoldMigrationOptions): Promise<ScaffoldResult>;
225
+ /**
226
+ * Get available migration templates
227
+ */
228
+ declare function getMigrationTemplates(): Array<{
229
+ value: MigrationTemplate;
230
+ label: string;
231
+ description: string;
232
+ }>;
233
+
234
+ /**
235
+ * Schema template generator
236
+ *
237
+ * @module scaffold/templates/schema-template
238
+ */
239
+
240
+ /**
241
+ * Generate a Drizzle schema file content
242
+ *
243
+ * @param context - Template context
244
+ * @returns Generated TypeScript code for the schema
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const content = generateSchemaTemplate({
249
+ * tableName: 'orders',
250
+ * tableNamePascal: 'Orders',
251
+ * tableNameCamel: 'orders',
252
+ * type: 'tenant',
253
+ * includeTimestamps: true,
254
+ * includeSoftDelete: false,
255
+ * useUuid: true,
256
+ * includeExample: true,
257
+ * });
258
+ * ```
259
+ */
260
+ declare function generateSchemaTemplate(context: SchemaTemplateContext): string;
261
+
262
+ /**
263
+ * Seed template generator
264
+ *
265
+ * @module scaffold/templates/seed-template
266
+ */
267
+
268
+ /**
269
+ * Generate a seed file content
270
+ *
271
+ * @param context - Template context
272
+ * @returns Generated TypeScript code for the seed
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * const content = generateSeedTemplate({
277
+ * seedName: 'initialData',
278
+ * type: 'tenant',
279
+ * tableName: 'users',
280
+ * });
281
+ * ```
282
+ */
283
+ declare function generateSeedTemplate(context: SeedTemplateContext): string;
284
+
285
+ /**
286
+ * Migration template generator
287
+ *
288
+ * @module scaffold/templates/migration-template
289
+ */
290
+
291
+ /**
292
+ * Generate a SQL migration file content
293
+ *
294
+ * @param context - Template context
295
+ * @returns Generated SQL migration content
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const content = generateMigrationTemplate({
300
+ * migrationName: 'add-orders',
301
+ * type: 'tenant',
302
+ * template: 'create-table',
303
+ * tableName: 'orders',
304
+ * });
305
+ * ```
306
+ */
307
+ declare function generateMigrationTemplate(context: MigrationTemplateContext): string;
308
+ /**
309
+ * Infer table name from migration name
310
+ *
311
+ * @param migrationName - Name of the migration
312
+ * @returns Inferred table name or undefined
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * inferTableName('add-orders') // 'orders'
317
+ * inferTableName('create-user-profiles') // 'user_profiles'
318
+ * inferTableName('add-index-to-users') // 'users'
319
+ * ```
320
+ */
321
+ declare function inferTableName(migrationName: string): string | undefined;
322
+ /**
323
+ * Determine the best template based on migration name
324
+ *
325
+ * @param migrationName - Name of the migration
326
+ * @returns Suggested template type
327
+ */
328
+ declare function inferMigrationTemplate(migrationName: string): MigrationTemplate;
329
+
330
+ export { DEFAULT_DIRS, type GeneratedFile, type MigrationTemplate, type MigrationTemplateContext, type ScaffoldConfig, type ScaffoldKind, type ScaffoldMigrationOptions, type ScaffoldResult, type ScaffoldSchemaOptions, type ScaffoldSeedOptions, type ScaffoldType, type SchemaTemplateContext, type SeedTemplateContext, generateMigrationTemplate, generateSchemaTemplate, generateSeedTemplate, getMigrationTemplates, inferMigrationTemplate, inferTableName, scaffoldMigration, scaffoldSchema, scaffoldSeed, toCase };