bun-query-builder 0.1.7 → 0.1.9

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.
Files changed (41) hide show
  1. package/dist/actions/benchmark.d.ts +5 -9
  2. package/dist/actions/cache.d.ts +14 -2
  3. package/dist/actions/console.d.ts +6 -0
  4. package/dist/actions/data.d.ts +13 -3
  5. package/dist/actions/db-info.d.ts +9 -4
  6. package/dist/actions/db-optimize.d.ts +5 -4
  7. package/dist/actions/db-wipe.d.ts +5 -4
  8. package/dist/actions/file.d.ts +1 -2
  9. package/dist/actions/index.d.ts +25 -25
  10. package/dist/actions/inspect.d.ts +9 -3
  11. package/dist/actions/introspect.d.ts +1 -2
  12. package/dist/actions/make-model.d.ts +5 -3
  13. package/dist/actions/migrate-generate.d.ts +5 -4
  14. package/dist/actions/migrate-rollback.d.ts +11 -4
  15. package/dist/actions/migrate-status.d.ts +9 -5
  16. package/dist/actions/migrate.d.ts +20 -12
  17. package/dist/actions/model-show.d.ts +5 -3
  18. package/dist/actions/query-explain-all.d.ts +5 -3
  19. package/dist/actions/relation-diagram.d.ts +5 -5
  20. package/dist/actions/seed.d.ts +17 -7
  21. package/dist/actions/sql.d.ts +1 -2
  22. package/dist/actions/unsafe.d.ts +1 -2
  23. package/dist/actions/validate.d.ts +9 -4
  24. package/dist/actions/wait-ready.d.ts +1 -2
  25. package/dist/client.d.ts +189 -199
  26. package/dist/config.d.ts +1 -2
  27. package/dist/db.d.ts +9 -8
  28. package/dist/drivers/index.d.ts +6 -8
  29. package/dist/drivers/mysql.d.ts +19 -169
  30. package/dist/drivers/postgres.d.ts +19 -155
  31. package/dist/drivers/sqlite.d.ts +19 -157
  32. package/dist/factory.d.ts +6 -3
  33. package/dist/index.d.ts +11 -11
  34. package/dist/index.js +5 -4
  35. package/dist/loader.d.ts +2 -3
  36. package/dist/meta.d.ts +2 -3
  37. package/dist/migrations.d.ts +47 -42
  38. package/dist/schema.d.ts +177 -30
  39. package/dist/seeder.d.ts +17 -12
  40. package/dist/types.d.ts +143 -42
  41. package/package.json +2 -2
@@ -1,12 +1,8 @@
1
+ /**
2
+ * Run performance benchmarks
3
+ */
4
+ export declare function runBenchmark(options?: BenchmarkOptions): Promise<void>;
1
5
  export declare interface BenchmarkOptions {
2
6
  operations?: string
3
7
  iterations?: number
4
- }
5
- declare interface BenchmarkResult {
6
- operation: string
7
- avgTime: number
8
- minTime: number
9
- maxTime: number
10
- iterations: number
11
- }
12
- export declare function runBenchmark(options: BenchmarkOptions = {}): Promise<void>;
8
+ }
@@ -1,6 +1,18 @@
1
+ /**
2
+ * Clear the query cache
3
+ */
1
4
  export declare function cacheClear(): Promise<void>;
5
+ /**
6
+ * Show cache statistics and configuration
7
+ *
8
+ * Note: The current cache implementation doesn't track detailed statistics.
9
+ * This command shows the current configuration.
10
+ */
2
11
  export declare function cacheStats(): Promise<void>;
12
+ /**
13
+ * Configure query cache settings
14
+ */
15
+ export declare function cacheConfig(options?: CacheConfigOptions): Promise<void>;
3
16
  export declare interface CacheConfigOptions {
4
17
  size?: number
5
- }
6
- export declare function cacheConfig(options: CacheConfigOptions = {}): Promise<void>;
18
+ }
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Start an interactive REPL for running queries
3
+ */
1
4
  export declare function startConsole(): Promise<void>;
5
+ /**
6
+ * Tinker - alias for startConsole
7
+ */
2
8
  export declare function tinker(): Promise<void>;
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Export data from a table
3
+ */
4
+ export declare function exportData(tableName: string, options?: ExportOptions): Promise<void>;
5
+ /**
6
+ * Import data into a table
7
+ */
8
+ export declare function importData(tableName: string, filePath: string, options?: ImportOptions): Promise<void>;
9
+ /**
10
+ * Dump database or specific tables to SQL
11
+ */
12
+ export declare function dumpDatabase(options?: DumpOptions): Promise<void>;
1
13
  export declare interface ExportOptions {
2
14
  format?: 'json' | 'csv' | 'sql'
3
15
  output?: string
@@ -10,6 +22,4 @@ export declare interface ImportOptions {
10
22
  export declare interface DumpOptions {
11
23
  tables?: string
12
24
  output?: string
13
- }
14
- export declare function exportData(tableName: string, options: ExportOptions = {}): Promise<void>;
15
- export declare function importData(tableName: string, filePath: string, options: ImportOptions = {}): Promise<void>;
25
+ }
@@ -1,5 +1,12 @@
1
1
  import type { SupportedDialect } from '@/types';
2
-
2
+ /**
3
+ * Get database information and statistics
4
+ */
5
+ export declare function dbInfo(): Promise<DatabaseInfo>;
6
+ /**
7
+ * Get database statistics (alias for dbInfo)
8
+ */
9
+ export declare function dbStats(): Promise<DatabaseInfo>;
3
10
  export declare interface TableInfo {
4
11
  name: string
5
12
  rowCount: number
@@ -12,6 +19,4 @@ export declare interface DatabaseInfo {
12
19
  tables: TableInfo[]
13
20
  totalTables: number
14
21
  totalRows: number
15
- }
16
- export declare function dbInfo(): Promise<DatabaseInfo>;
17
- export declare function dbStats(): Promise<DatabaseInfo>;
22
+ }
@@ -1,11 +1,12 @@
1
1
  import type { SupportedDialect } from '@/types';
2
-
2
+ /**
3
+ * Optimize database tables (VACUUM, ANALYZE, OPTIMIZE)
4
+ */
5
+ export declare function dbOptimize(options?: OptimizeOptions): Promise<void>;
3
6
  export declare interface OptimizeOptions {
4
7
  dialect?: SupportedDialect
5
8
  aggressive?: boolean
6
9
  tables?: string[]
7
10
  verbose?: boolean
8
11
  }
9
- export declare function dbOptimize(options: OptimizeOptions = {}): Promise<void>;
10
-
11
- export { dbOptimize as optimizeDatabase }
12
+ export { dbOptimize as optimizeDatabase };
@@ -1,10 +1,11 @@
1
1
  import type { SupportedDialect } from '@/types';
2
-
2
+ /**
3
+ * Drop all tables in the database
4
+ */
5
+ export declare function dbWipe(options?: WipeOptions): Promise<void>;
3
6
  export declare interface WipeOptions {
4
7
  dialect?: SupportedDialect
5
8
  force?: boolean
6
9
  verbose?: boolean
7
10
  }
8
- export declare function dbWipe(options: WipeOptions = {}): Promise<void>;
9
-
10
- export { dbWipe as wipeDatabase }
11
+ export { dbWipe as wipeDatabase };
@@ -1,3 +1,2 @@
1
1
  import type { FileOptions } from '../types';
2
-
3
- export declare function file(path: string, opts: FileOptions = {}): void;
2
+ export declare function file(path: string, opts?: FileOptions): void;
@@ -1,25 +1,25 @@
1
- export { runBenchmark } from './benchmark'
2
- export { cacheClear, cacheConfig, cacheStats } from './cache'
3
- export { startConsole, tinker } from './console'
4
- export { dumpDatabase, exportData, importData } from './data'
5
- export { dbInfo, dbStats } from './db-info'
6
- export { dbOptimize, optimizeDatabase } from './db-optimize'
7
- export { dbWipe, wipeDatabase } from './db-wipe'
8
- export { explain } from './explain'
9
- export { file } from './file'
10
- export { inspectTable, tableInfo } from './inspect'
11
- export { introspect } from './introspect'
12
- export { makeModel } from './make-model'
13
- export { executeMigration, generateMigration, resetDatabase } from './migrate'
14
- export { migrateGenerate } from './migrate-generate'
15
- export { migrateRollback } from './migrate-rollback'
16
- export { migrateList, migrateStatus } from './migrate-status'
17
- export { modelShow, showModel } from './model-show'
18
- export { ping } from './ping'
19
- export { explainAllQueries, queryExplainAll } from './query-explain-all'
20
- export { generateDiagram, relationDiagram } from './relation-diagram'
21
- export { freshDatabase, makeSeeder, runSeeder, runSeeders } from './seed'
22
- export { sql } from './sql'
23
- export { unsafe } from './unsafe'
24
- export { checkSchema, validateSchema } from './validate'
25
- export { waitReady } from './wait-ready'
1
+ export { runBenchmark } from './benchmark';
2
+ export { cacheClear, cacheConfig, cacheStats } from './cache';
3
+ export { startConsole, tinker } from './console';
4
+ export { dumpDatabase, exportData, importData } from './data';
5
+ export { dbInfo, dbStats } from './db-info';
6
+ export { dbOptimize, optimizeDatabase } from './db-optimize';
7
+ export { dbWipe, wipeDatabase } from './db-wipe';
8
+ export { explain } from './explain';
9
+ export { file } from './file';
10
+ export { inspectTable, tableInfo } from './inspect';
11
+ export { introspect } from './introspect';
12
+ export { makeModel } from './make-model';
13
+ export { executeMigration, generateMigration, resetDatabase } from './migrate';
14
+ export { migrateGenerate } from './migrate-generate';
15
+ export { migrateRollback } from './migrate-rollback';
16
+ export { migrateList, migrateStatus } from './migrate-status';
17
+ export { modelShow, showModel } from './model-show';
18
+ export { ping } from './ping';
19
+ export { explainAllQueries, queryExplainAll } from './query-explain-all';
20
+ export { generateDiagram, relationDiagram } from './relation-diagram';
21
+ export { freshDatabase, makeSeeder, runSeeder, runSeeders } from './seed';
22
+ export { sql } from './sql';
23
+ export { unsafe } from './unsafe';
24
+ export { checkSchema, validateSchema } from './validate';
25
+ export { waitReady } from './wait-ready';
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Inspect a table's structure, indexes, and statistics
3
+ */
4
+ export declare function inspectTable(tableName: string, options?: InspectOptions): Promise<TableInspection>;
5
+ /**
6
+ * Alias for inspectTable
7
+ */
8
+ export declare function tableInfo(tableName: string, options?: InspectOptions): Promise<TableInspection>;
1
9
  export declare interface ColumnInfo {
2
10
  name: string
3
11
  type: string
@@ -19,6 +27,4 @@ export declare interface TableInspection {
19
27
  }
20
28
  export declare interface InspectOptions {
21
29
  verbose?: boolean
22
- }
23
- export declare function inspectTable(tableName: string, options: InspectOptions = {}): Promise<TableInspection>;
24
- export declare function tableInfo(tableName: string, options: InspectOptions = {}): Promise<TableInspection>;
30
+ }
@@ -1,3 +1,2 @@
1
1
  import type { IntrospectOptions } from '../types';
2
-
3
- export declare function introspect(dir: string, _opts: IntrospectOptions = {}): void;
2
+ export declare function introspect(dir: string, _opts?: IntrospectOptions): void;
@@ -1,7 +1,9 @@
1
- declare function findWorkspaceRoot(startPath: string): string;
1
+ /**
2
+ * Generate a new model file
3
+ */
4
+ export declare function makeModel(name: string, options?: MakeModelOptions): Promise<void>;
2
5
  export declare interface MakeModelOptions {
3
6
  table?: string
4
7
  dir?: string
5
8
  timestamps?: boolean
6
- }
7
- export declare function makeModel(name: string, options: MakeModelOptions = {}): Promise<void>;
9
+ }
@@ -1,5 +1,6 @@
1
1
  import type { GenerateMigrationResult, MigrateOptions } from '@/types';
2
-
3
- export declare function migrateGenerate(dir?: string, opts: MigrateOptions = {}): Promise<GenerateMigrationResult>;
4
-
5
- export { migrateGenerate as generateMigration }
2
+ /**
3
+ * Generate migration files from model changes (alias for generateMigration)
4
+ */
5
+ export declare function migrateGenerate(dir?: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
6
+ export { migrateGenerate as generateMigration };
@@ -1,6 +1,13 @@
1
- declare function findWorkspaceRoot(startPath: string): string;
2
- declare function getSqlDirectory(workspaceRoot?: string): string;
1
+ /**
2
+ * Rollback migrations
3
+ *
4
+ * Note: This removes migration entries from the migrations table.
5
+ * Since migrations are auto-generated from models, you should:
6
+ * 1. Revert your model changes
7
+ * 2. Run rollback to remove migration records
8
+ * 3. Generate fresh migrations
9
+ */
10
+ export declare function migrateRollback(options?: RollbackOptions): Promise<void>;
3
11
  export declare interface RollbackOptions {
4
12
  steps?: number
5
- }
6
- export declare function migrateRollback(options: RollbackOptions = {}): Promise<void>;
13
+ }
@@ -1,9 +1,13 @@
1
- declare function findWorkspaceRoot(startPath: string): string;
2
- declare function getSqlDirectory(workspaceRoot?: string): string;
1
+ /**
2
+ * Get migration status - shows which migrations have been executed and which are pending
3
+ */
4
+ export declare function migrateStatus(): Promise<MigrationStatus[]>;
5
+ /**
6
+ * List all migrations (alias for status)
7
+ */
8
+ export declare function migrateList(): Promise<MigrationStatus[]>;
3
9
  export declare interface MigrationStatus {
4
10
  file: string
5
11
  status: 'executed' | 'pending' | 'transient'
6
12
  executedAt?: string
7
- }
8
- export declare function migrateStatus(): Promise<MigrationStatus[]>;
9
- export declare function migrateList(): Promise<MigrationStatus[]>;
13
+ }
@@ -1,13 +1,21 @@
1
- import type { GenerateMigrationResult, MigrateOptions, SupportedDialect } from '@/types';
2
-
3
- declare function getWorkspaceRoot(): string;
4
- declare function ensureSqlDirectory(workspaceRoot?: string): string;
5
- export declare function generateMigration(dir?: string, opts: MigrateOptions = {}): Promise<GenerateMigrationResult>;
1
+ import type { GenerateMigrationResult, MigrateOptions } from '@/types';
2
+ /**
3
+ * Generate migration files by comparing old models (from generated/) with new models (from source).
4
+ *
5
+ * Workflow:
6
+ * 1. Loads previous model state from the 'generated/' directory (old model copies)
7
+ * 2. Loads current models from the source directory
8
+ * 3. Compares both to detect all changes:
9
+ * - Dropped tables, columns, indexes
10
+ * - New tables, columns, indexes
11
+ * - Modified columns (type changes, etc.)
12
+ * 4. Generates SQL migration files for all detected changes
13
+ * 5. Copies current models to 'generated/' for next comparison
14
+ *
15
+ * This follows Laravel's migration philosophy where model changes drive schema changes.
16
+ */
17
+ export declare function generateMigration(dir?: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
6
18
  export declare function executeMigration(dir?: string): Promise<boolean>;
7
- export declare function resetDatabase(dir?: string, opts: MigrateOptions = {}): Promise<boolean>;
8
- export declare function deleteMigrationFiles(dir?: string, workspaceRoot?: string, opts: MigrateOptions = {}): Promise<void>;
9
- export declare function copyModelsToGenerated(dir?: string, workspaceRoot?: string): Promise<void>;
10
- declare function getSqlDirectory(workspaceRoot?: string): string;
11
- declare function createMigrationsTable(qb: any, dialect: SupportedDialect): Promise<void>;
12
- declare function getExecutedMigrations(qb: any, dialect: SupportedDialect): Promise<string[]>;
13
- declare function recordMigration(qb: any, migrationFile: string, dialect: SupportedDialect): Promise<void>;
19
+ export declare function resetDatabase(dir?: string, opts?: MigrateOptions): Promise<boolean>;
20
+ export declare function deleteMigrationFiles(dir?: string, workspaceRoot?: string, opts?: MigrateOptions): Promise<void>;
21
+ export declare function copyModelsToGenerated(dir?: string, workspaceRoot?: string): Promise<void>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Show detailed information about a specific model
3
+ */
4
+ export declare function modelShow(modelName: string, options?: ModelShowOptions): Promise<ModelDetails | void>;
1
5
  export declare interface ModelShowOptions {
2
6
  dir?: string
3
7
  verbose?: boolean
@@ -15,6 +19,4 @@ export declare interface ModelDetails {
15
19
  timestamps?: boolean
16
20
  softDeletes?: boolean
17
21
  }
18
- export declare function modelShow(modelName: string, options: ModelShowOptions = {}): Promise<ModelDetails | void>;
19
-
20
- export { modelShow as showModel }
22
+ export { modelShow as showModel };
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Run EXPLAIN on all SQL files in a directory
3
+ */
4
+ export declare function queryExplainAll(path: string, options?: ExplainAllOptions): Promise<ExplainResult[]>;
1
5
  export declare interface ExplainAllOptions {
2
6
  verbose?: boolean
3
7
  json?: boolean
@@ -9,6 +13,4 @@ export declare interface ExplainResult {
9
13
  plan: any[]
10
14
  error?: string
11
15
  }
12
- export declare function queryExplainAll(path: string, options: ExplainAllOptions = {}): Promise<ExplainResult[]>;
13
-
14
- export { queryExplainAll as explainAllQueries }
16
+ export { queryExplainAll as explainAllQueries };
@@ -1,11 +1,11 @@
1
+ /**
2
+ * Generate relationship diagram from models
3
+ */
4
+ export declare function relationDiagram(options?: DiagramOptions): Promise<string>;
1
5
  export declare interface DiagramOptions {
2
6
  dir?: string
3
7
  format?: 'mermaid' | 'dot'
4
8
  output?: string
5
9
  verbose?: boolean
6
10
  }
7
- export declare function relationDiagram(options: DiagramOptions = {}): Promise<string>;
8
- declare function generateMermaidDiagram(models: Record<string, any>): string;
9
- declare function generateDotDiagram(models: Record<string, any>): string;
10
-
11
- export { relationDiagram as generateDiagram }
11
+ export { relationDiagram as generateDiagram };
@@ -1,8 +1,18 @@
1
- import type { RunSeederOptions, Seeder, SeederConfig } from '@/seeder';
2
-
3
- declare function findWorkspaceRoot(startPath: string): string;
4
- declare function loadSeeders(seedersDir: string): Promise<Array<{ name: string, instance: Seeder }>>;
5
- export declare function runSeeders(config: SeederConfig = {}): Promise<void>;
6
- export declare function runSeeder(className: string, options: RunSeederOptions = {}): Promise<void>;
1
+ import type { RunSeederOptions, SeederConfig } from '@/seeder';
2
+ /**
3
+ * Run all seeders from a directory
4
+ */
5
+ export declare function runSeeders(config?: SeederConfig): Promise<void>;
6
+ /**
7
+ * Run a specific seeder by class name
8
+ */
9
+ export declare function runSeeder(className: string, options?: RunSeederOptions): Promise<void>;
10
+ /**
11
+ * Generate a new seeder file
12
+ */
7
13
  export declare function makeSeeder(name: string): Promise<void>;
8
- export declare function freshDatabase(options: { seedersDir?: string, modelsDir?: string, verbose?: boolean } = {}): Promise<void>;
14
+ /**
15
+ * Refresh database and run all seeders
16
+ * This will drop all tables and re-run migrations and seeders
17
+ */
18
+ export declare function freshDatabase(options?: { seedersDir?: string, modelsDir?: string, verbose?: boolean }): Promise<void>;
@@ -1,3 +1,2 @@
1
1
  import type { SqlOptions } from '../types';
2
-
3
- export declare function sql(dir: string, table: string, opts: SqlOptions = {}): void;
2
+ export declare function sql(dir: string, table: string, opts?: SqlOptions): void;
@@ -1,3 +1,2 @@
1
1
  import type { UnsafeOptions } from '../types';
2
-
3
- export declare function unsafe(sql: string, opts: UnsafeOptions = {}): void;
2
+ export declare function unsafe(sql: string, opts?: UnsafeOptions): void;
@@ -1,4 +1,11 @@
1
- declare function findWorkspaceRoot(startPath: string): string;
1
+ /**
2
+ * Validate that models match the database schema
3
+ */
4
+ export declare function validateSchema(dir?: string): Promise<ValidationResult>;
5
+ /**
6
+ * Check schema (alias for validateSchema)
7
+ */
8
+ export declare function checkSchema(dir?: string): Promise<ValidationResult>;
2
9
  export declare interface ValidationIssue {
3
10
  type: 'missing_table' | 'extra_table' | 'missing_column' | 'extra_column' | 'type_mismatch'
4
11
  severity: 'error' | 'warning'
@@ -11,6 +18,4 @@ export declare interface ValidationIssue {
11
18
  export declare interface ValidationResult {
12
19
  valid: boolean
13
20
  issues: ValidationIssue[]
14
- }
15
- export declare function validateSchema(dir?: string): Promise<ValidationResult>;
16
- export declare function checkSchema(dir?: string): Promise<ValidationResult>;
21
+ }
@@ -1,3 +1,2 @@
1
1
  import type { WaitReadyOptions } from '../types';
2
-
3
- export declare function waitReady(opts: WaitReadyOptions = {}): void;
2
+ export declare function waitReady(opts?: WaitReadyOptions): void;