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,8 +1,8 @@
1
- import { m as DetectedFormat, S as SeedFunction, k as TenantSeedResult, j as SeedOptions, l as SeedResults, n as SyncStatus, b as MigrationFile, o as TenantSyncStatus, p as TenantSyncResult, q as SyncOptions, r as SyncResults, d as MigrateOptions, e as MigrationResults, g as MigrationHooks, h as MigrationProgressCallback, i as MigrationErrorHandler, T as TenantMigrationResult, f as TenantMigrationStatus, s as ClonerConfig, t as ClonerDependencies, u as CloneTenantOptions, v as CloneTenantResult } from '../migrator-BDgFzSh8.js';
2
- export { V as AnonymizeOptions, W as AnonymizeRules, X as AnonymizeValue, A as AppliedMigration, R as CloneProgressCallback, U as CloneProgressStatus, J as ColumnDrift, E as ColumnInfo, L as ConstraintDrift, F as ConstraintInfo, C as CreateTenantOptions, y as DEFAULT_FORMAT, z as DRIZZLE_KIT_FORMAT, D as DropTenantOptions, K as IndexDrift, I as IndexInfo, M as Migrator, a as MigratorConfig, Q as SchemaDriftOptions, P as SchemaDriftStatus, N as TableDrift, B as TableFormat, G as TableSchema, H as TenantSchema, O as TenantSchemaDrift, c as createMigrator, w as detectTableFormat, x as getFormatConfig } from '../migrator-BDgFzSh8.js';
1
+ import { o as DetectedFormat, S as SeedFunction, k as TenantSeedResult, j as SeedOptions, l as SeedResults, p as SyncStatus, b as MigrationFile, q as TenantSyncStatus, r as TenantSyncResult, s as SyncOptions, t as SyncResults, d as MigrateOptions, e as MigrationResults, g as MigrationHooks, h as MigrationProgressCallback, i as MigrationErrorHandler, T as TenantMigrationResult, f as TenantMigrationStatus, u as ClonerConfig, v as ClonerDependencies, w as CloneTenantOptions, x as CloneTenantResult, y as SharedMigrateOptions, z as SharedMigrationResult, B as SharedMigrationStatus } from '../migrator-C7FtsZ0H.js';
2
+ export { _ as AnonymizeOptions, $ as AnonymizeRules, a0 as AnonymizeValue, A as AppliedMigration, Y as CloneProgressCallback, Z as CloneProgressStatus, P as ColumnDrift, J as ColumnInfo, R as ConstraintDrift, L as ConstraintInfo, C as CreateTenantOptions, G as DEFAULT_FORMAT, H as DRIZZLE_KIT_FORMAT, D as DropTenantOptions, Q as IndexDrift, K as IndexInfo, M as Migrator, a as MigratorConfig, X as SchemaDriftOptions, W as SchemaDriftStatus, a2 as SharedMigrationHooks, a1 as SharedMigratorConfig, m as SharedSeedFunction, n as SharedSeedResult, U as TableDrift, I as TableFormat, N as TableSchema, O as TenantSchema, V as TenantSchemaDrift, c as createMigrator, E as detectTableFormat, F as getFormatConfig } from '../migrator-C7FtsZ0H.js';
3
3
  import * as pg from 'pg';
4
4
  import { Pool } from 'pg';
5
- import { C as Config } from '../types-BhK96FPC.js';
5
+ import { C as Config } from '../types-CGqsPe2Q.js';
6
6
  import 'drizzle-orm/postgres-js';
7
7
  import 'drizzle-orm/node-postgres';
8
8
 
@@ -1106,4 +1106,116 @@ declare class Cloner {
1106
1106
  */
1107
1107
  declare function createCloner(config: ClonerConfig, dependencies: ClonerDependencies): Cloner;
1108
1108
 
1109
- export { BatchExecutor, type BatchExecutorConfig, type BatchMigrateOptions, CloneTenantOptions, CloneTenantResult, Cloner, ClonerConfig, ClonerDependencies, type CreateSchemaOptions, DetectedFormat, type DropSchemaOptions, MigrateOptions, type MigrateTenantOptions, MigrationErrorHandler, MigrationExecutor, type MigrationExecutorConfig, type MigrationExecutorDependencies, MigrationFile, MigrationHooks, MigrationProgressCallback, MigrationResults, SchemaManager, SeedFunction, SeedOptions, SeedResults, Seeder, type SeederConfig, type SeederDependencies, SyncManager, type SyncManagerConfig, type SyncManagerDependencies, SyncOptions, SyncResults, SyncStatus, TenantMigrationResult, TenantMigrationStatus, TenantSeedResult, TenantSyncResult, TenantSyncStatus, createBatchExecutor, createCloner, createMigrationExecutor, createSchemaManager, createSeeder, createSyncManager };
1109
+ /**
1110
+ * Configuration for SharedMigrationExecutor
1111
+ */
1112
+ interface SharedMigrationExecutorConfig {
1113
+ /** Schema name for shared tables (default: 'public') */
1114
+ schemaName?: string;
1115
+ /** Table name for tracking migrations */
1116
+ migrationsTable: string;
1117
+ /** Hooks for migration events */
1118
+ hooks?: {
1119
+ beforeMigration?: () => void | Promise<void>;
1120
+ afterMigration?: (migrationName: string, durationMs: number) => void | Promise<void>;
1121
+ };
1122
+ }
1123
+ /**
1124
+ * Dependencies for SharedMigrationExecutor
1125
+ */
1126
+ interface SharedMigrationExecutorDependencies {
1127
+ /** Create a database pool for the shared schema */
1128
+ createPool: () => Promise<Pool>;
1129
+ /** Check if migrations table exists */
1130
+ migrationsTableExists: (pool: Pool, schemaName: string) => Promise<boolean>;
1131
+ /** Ensure migrations table exists with correct format */
1132
+ ensureMigrationsTable: (pool: Pool, schemaName: string, format: DetectedFormat) => Promise<void>;
1133
+ /** Get or detect migration table format */
1134
+ getOrDetectFormat: (pool: Pool, schemaName: string) => Promise<DetectedFormat>;
1135
+ /** Load migrations from disk */
1136
+ loadMigrations: () => Promise<MigrationFile[]>;
1137
+ }
1138
+
1139
+ /**
1140
+ * Executor for shared schema migrations
1141
+ *
1142
+ * Handles migrations for the shared/public schema, separate from tenant schemas.
1143
+ * Used for tables that are shared across all tenants (e.g., plans, roles, permissions).
1144
+ *
1145
+ * @example
1146
+ * ```typescript
1147
+ * const executor = new SharedMigrationExecutor(config, dependencies);
1148
+ *
1149
+ * // Get status
1150
+ * const status = await executor.getStatus();
1151
+ * console.log(`Pending: ${status.pendingCount}`);
1152
+ *
1153
+ * // Apply migrations
1154
+ * const result = await executor.migrate();
1155
+ * console.log(`Applied: ${result.appliedMigrations.length}`);
1156
+ * ```
1157
+ */
1158
+ declare class SharedMigrationExecutor {
1159
+ private readonly config;
1160
+ private readonly deps;
1161
+ private readonly schemaName;
1162
+ constructor(config: SharedMigrationExecutorConfig, deps: SharedMigrationExecutorDependencies);
1163
+ /**
1164
+ * Apply pending migrations to the shared schema
1165
+ *
1166
+ * @param options - Migration options (dryRun, onProgress)
1167
+ * @returns Migration result with applied migrations
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * const result = await executor.migrate({
1172
+ * dryRun: false,
1173
+ * onProgress: (status, name) => console.log(`${status}: ${name}`),
1174
+ * });
1175
+ *
1176
+ * if (result.success) {
1177
+ * console.log(`Applied ${result.appliedMigrations.length} migrations`);
1178
+ * }
1179
+ * ```
1180
+ */
1181
+ migrate(options?: SharedMigrateOptions): Promise<SharedMigrationResult>;
1182
+ /**
1183
+ * Mark migrations as applied without executing SQL
1184
+ *
1185
+ * Useful for syncing tracking state with already-applied migrations.
1186
+ *
1187
+ * @param options - Options with progress callback
1188
+ * @returns Result with list of marked migrations
1189
+ */
1190
+ markAsApplied(options?: {
1191
+ onProgress?: SharedMigrateOptions['onProgress'];
1192
+ }): Promise<SharedMigrationResult>;
1193
+ /**
1194
+ * Get migration status for the shared schema
1195
+ *
1196
+ * @returns Status with applied/pending counts
1197
+ */
1198
+ getStatus(): Promise<SharedMigrationStatus>;
1199
+ /**
1200
+ * Get list of applied migrations
1201
+ */
1202
+ private getAppliedMigrations;
1203
+ /**
1204
+ * Check if a migration has been applied
1205
+ */
1206
+ private isMigrationApplied;
1207
+ /**
1208
+ * Apply a migration (execute SQL + record)
1209
+ */
1210
+ private applyMigration;
1211
+ /**
1212
+ * Record a migration as applied without executing SQL
1213
+ */
1214
+ private recordMigration;
1215
+ }
1216
+ /**
1217
+ * Factory function to create a SharedMigrationExecutor
1218
+ */
1219
+ declare function createSharedMigrationExecutor(config: SharedMigrationExecutorConfig, dependencies: SharedMigrationExecutorDependencies): SharedMigrationExecutor;
1220
+
1221
+ export { BatchExecutor, type BatchExecutorConfig, type BatchMigrateOptions, CloneTenantOptions, CloneTenantResult, Cloner, ClonerConfig, ClonerDependencies, type CreateSchemaOptions, DetectedFormat, type DropSchemaOptions, MigrateOptions, type MigrateTenantOptions, MigrationErrorHandler, MigrationExecutor, type MigrationExecutorConfig, type MigrationExecutorDependencies, MigrationFile, MigrationHooks, MigrationProgressCallback, MigrationResults, SchemaManager, SeedFunction, SeedOptions, SeedResults, Seeder, type SeederConfig, type SeederDependencies, SharedMigrateOptions, SharedMigrationExecutor, type SharedMigrationExecutorConfig, type SharedMigrationExecutorDependencies, SharedMigrationResult, SharedMigrationStatus, SyncManager, type SyncManagerConfig, type SyncManagerDependencies, SyncOptions, SyncResults, SyncStatus, TenantMigrationResult, TenantMigrationStatus, TenantSeedResult, TenantSyncResult, TenantSyncStatus, createBatchExecutor, createCloner, createMigrationExecutor, createSchemaManager, createSeeder, createSharedMigrationExecutor, createSyncManager };