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.
- package/README.md +28 -8
- package/dist/cli/index.js +1809 -5949
- package/dist/{context-Vki959ri.d.ts → context-BBLPNjmk.d.ts} +1 -1
- package/dist/cross-schema/index.js +1 -426
- package/dist/export/index.d.ts +395 -0
- package/dist/export/index.js +9 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +34 -4745
- package/dist/integrations/express.d.ts +3 -3
- package/dist/integrations/express.js +1 -110
- package/dist/integrations/fastify.d.ts +3 -3
- package/dist/integrations/fastify.js +1 -236
- package/dist/integrations/hono.js +0 -3
- package/dist/integrations/nestjs/index.d.ts +1 -1
- package/dist/integrations/nestjs/index.js +3 -11006
- package/dist/lint/index.d.ts +475 -0
- package/dist/lint/index.js +5 -0
- package/dist/metrics/index.d.ts +530 -0
- package/dist/metrics/index.js +3 -0
- package/dist/migrator/index.d.ts +116 -4
- package/dist/migrator/index.js +34 -2990
- package/dist/{migrator-BDgFzSh8.d.ts → migrator-C7FtsZ0H.d.ts} +263 -2
- package/dist/scaffold/index.d.ts +330 -0
- package/dist/scaffold/index.js +277 -0
- package/dist/{types-BhK96FPC.d.ts → types-CGqsPe2Q.d.ts} +49 -1
- package/package.json +18 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cross-schema/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/express.js.map +0 -1
- package/dist/integrations/fastify.js.map +0 -1
- package/dist/integrations/hono.js.map +0 -1
- package/dist/integrations/nestjs/index.js.map +0 -1
- package/dist/migrator/index.js.map +0 -1
package/dist/migrator/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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-
|
|
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
|
-
|
|
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 };
|