bun-query-builder 0.1.5 → 0.1.6

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 +9 -5
  2. package/dist/actions/cache.d.ts +2 -14
  3. package/dist/actions/console.d.ts +0 -6
  4. package/dist/actions/data.d.ts +3 -13
  5. package/dist/actions/db-info.d.ts +4 -9
  6. package/dist/actions/db-optimize.d.ts +4 -5
  7. package/dist/actions/db-wipe.d.ts +4 -5
  8. package/dist/actions/file.d.ts +2 -1
  9. package/dist/actions/index.d.ts +25 -25
  10. package/dist/actions/inspect.d.ts +3 -9
  11. package/dist/actions/introspect.d.ts +2 -1
  12. package/dist/actions/make-model.d.ts +3 -5
  13. package/dist/actions/migrate-generate.d.ts +4 -5
  14. package/dist/actions/migrate-rollback.d.ts +4 -11
  15. package/dist/actions/migrate-status.d.ts +5 -9
  16. package/dist/actions/migrate.d.ts +13 -21
  17. package/dist/actions/model-show.d.ts +3 -5
  18. package/dist/actions/query-explain-all.d.ts +3 -5
  19. package/dist/actions/relation-diagram.d.ts +5 -5
  20. package/dist/actions/seed.d.ts +7 -17
  21. package/dist/actions/sql.d.ts +2 -1
  22. package/dist/actions/unsafe.d.ts +2 -1
  23. package/dist/actions/validate.d.ts +4 -9
  24. package/dist/actions/wait-ready.d.ts +2 -1
  25. package/dist/client.d.ts +199 -189
  26. package/dist/config.d.ts +2 -1
  27. package/dist/db.d.ts +8 -9
  28. package/dist/drivers/index.d.ts +8 -6
  29. package/dist/drivers/mysql.d.ts +169 -19
  30. package/dist/drivers/postgres.d.ts +155 -19
  31. package/dist/drivers/sqlite.d.ts +157 -19
  32. package/dist/factory.d.ts +3 -6
  33. package/dist/index.d.ts +11 -11
  34. package/dist/index.js +48 -51
  35. package/dist/loader.d.ts +3 -2
  36. package/dist/meta.d.ts +3 -2
  37. package/dist/migrations.d.ts +42 -47
  38. package/dist/schema.d.ts +30 -177
  39. package/dist/seeder.d.ts +12 -17
  40. package/dist/types.d.ts +42 -143
  41. package/package.json +4 -3
@@ -1,8 +1,12 @@
1
- /**
2
- * Run performance benchmarks
3
- */
4
- export declare function runBenchmark(options?: BenchmarkOptions): Promise<void>;
5
1
  export declare interface BenchmarkOptions {
6
2
  operations?: string
7
3
  iterations?: number
8
- }
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>;
@@ -1,18 +1,6 @@
1
- /**
2
- * Clear the query cache
3
- */
4
1
  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
- */
11
2
  export declare function cacheStats(): Promise<void>;
12
- /**
13
- * Configure query cache settings
14
- */
15
- export declare function cacheConfig(options?: CacheConfigOptions): Promise<void>;
16
3
  export declare interface CacheConfigOptions {
17
4
  size?: number
18
- }
5
+ }
6
+ export declare function cacheConfig(options: CacheConfigOptions = {}): Promise<void>;
@@ -1,8 +1,2 @@
1
- /**
2
- * Start an interactive REPL for running queries
3
- */
4
1
  export declare function startConsole(): Promise<void>;
5
- /**
6
- * Tinker - alias for startConsole
7
- */
8
2
  export declare function tinker(): Promise<void>;
@@ -1,15 +1,3 @@
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>;
13
1
  export declare interface ExportOptions {
14
2
  format?: 'json' | 'csv' | 'sql'
15
3
  output?: string
@@ -22,4 +10,6 @@ export declare interface ImportOptions {
22
10
  export declare interface DumpOptions {
23
11
  tables?: string
24
12
  output?: string
25
- }
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>;
@@ -1,12 +1,5 @@
1
1
  import type { SupportedDialect } from '@/types';
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>;
2
+
10
3
  export declare interface TableInfo {
11
4
  name: string
12
5
  rowCount: number
@@ -19,4 +12,6 @@ export declare interface DatabaseInfo {
19
12
  tables: TableInfo[]
20
13
  totalTables: number
21
14
  totalRows: number
22
- }
15
+ }
16
+ export declare function dbInfo(): Promise<DatabaseInfo>;
17
+ export declare function dbStats(): Promise<DatabaseInfo>;
@@ -1,12 +1,11 @@
1
1
  import type { SupportedDialect } from '@/types';
2
- /**
3
- * Optimize database tables (VACUUM, ANALYZE, OPTIMIZE)
4
- */
5
- export declare function dbOptimize(options?: OptimizeOptions): Promise<void>;
2
+
6
3
  export declare interface OptimizeOptions {
7
4
  dialect?: SupportedDialect
8
5
  aggressive?: boolean
9
6
  tables?: string[]
10
7
  verbose?: boolean
11
8
  }
12
- export { dbOptimize as optimizeDatabase };
9
+ export declare function dbOptimize(options: OptimizeOptions = {}): Promise<void>;
10
+
11
+ export { dbOptimize as optimizeDatabase }
@@ -1,11 +1,10 @@
1
1
  import type { SupportedDialect } from '@/types';
2
- /**
3
- * Drop all tables in the database
4
- */
5
- export declare function dbWipe(options?: WipeOptions): Promise<void>;
2
+
6
3
  export declare interface WipeOptions {
7
4
  dialect?: SupportedDialect
8
5
  force?: boolean
9
6
  verbose?: boolean
10
7
  }
11
- export { dbWipe as wipeDatabase };
8
+ export declare function dbWipe(options: WipeOptions = {}): Promise<void>;
9
+
10
+ export { dbWipe as wipeDatabase }
@@ -1,2 +1,3 @@
1
1
  import type { FileOptions } from '../types';
2
- export declare function file(path: string, opts?: FileOptions): void;
2
+
3
+ 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,11 +1,3 @@
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>;
9
1
  export declare interface ColumnInfo {
10
2
  name: string
11
3
  type: string
@@ -27,4 +19,6 @@ export declare interface TableInspection {
27
19
  }
28
20
  export declare interface InspectOptions {
29
21
  verbose?: boolean
30
- }
22
+ }
23
+ export declare function inspectTable(tableName: string, options: InspectOptions = {}): Promise<TableInspection>;
24
+ export declare function tableInfo(tableName: string, options: InspectOptions = {}): Promise<TableInspection>;
@@ -1,2 +1,3 @@
1
1
  import type { IntrospectOptions } from '../types';
2
- export declare function introspect(dir: string, _opts?: IntrospectOptions): void;
2
+
3
+ export declare function introspect(dir: string, _opts: IntrospectOptions = {}): void;
@@ -1,9 +1,7 @@
1
- /**
2
- * Generate a new model file
3
- */
4
- export declare function makeModel(name: string, options?: MakeModelOptions): Promise<void>;
1
+ declare function findWorkspaceRoot(startPath: string): string;
5
2
  export declare interface MakeModelOptions {
6
3
  table?: string
7
4
  dir?: string
8
5
  timestamps?: boolean
9
- }
6
+ }
7
+ export declare function makeModel(name: string, options: MakeModelOptions = {}): Promise<void>;
@@ -1,6 +1,5 @@
1
1
  import type { GenerateMigrationResult, MigrateOptions } from '@/types';
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 };
2
+
3
+ export declare function migrateGenerate(dir?: string, opts: MigrateOptions = {}): Promise<GenerateMigrationResult>;
4
+
5
+ export { migrateGenerate as generateMigration }
@@ -1,13 +1,6 @@
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>;
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ declare function getSqlDirectory(workspaceRoot?: string): string;
11
3
  export declare interface RollbackOptions {
12
4
  steps?: number
13
- }
5
+ }
6
+ export declare function migrateRollback(options: RollbackOptions = {}): Promise<void>;
@@ -1,13 +1,9 @@
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[]>;
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ declare function getSqlDirectory(workspaceRoot?: string): string;
9
3
  export declare interface MigrationStatus {
10
4
  file: string
11
5
  status: 'executed' | 'pending' | 'transient'
12
6
  executedAt?: string
13
- }
7
+ }
8
+ export declare function migrateStatus(): Promise<MigrationStatus[]>;
9
+ export declare function migrateList(): Promise<MigrationStatus[]>;
@@ -1,21 +1,13 @@
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>;
18
- export declare function executeMigration(): Promise<boolean>;
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
+ 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>;
6
+ 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>;
@@ -1,7 +1,3 @@
1
- /**
2
- * Show detailed information about a specific model
3
- */
4
- export declare function modelShow(modelName: string, options?: ModelShowOptions): Promise<ModelDetails | void>;
5
1
  export declare interface ModelShowOptions {
6
2
  dir?: string
7
3
  verbose?: boolean
@@ -19,4 +15,6 @@ export declare interface ModelDetails {
19
15
  timestamps?: boolean
20
16
  softDeletes?: boolean
21
17
  }
22
- export { modelShow as showModel };
18
+ export declare function modelShow(modelName: string, options: ModelShowOptions = {}): Promise<ModelDetails | void>;
19
+
20
+ export { modelShow as showModel }
@@ -1,7 +1,3 @@
1
- /**
2
- * Run EXPLAIN on all SQL files in a directory
3
- */
4
- export declare function queryExplainAll(path: string, options?: ExplainAllOptions): Promise<ExplainResult[]>;
5
1
  export declare interface ExplainAllOptions {
6
2
  verbose?: boolean
7
3
  json?: boolean
@@ -13,4 +9,6 @@ export declare interface ExplainResult {
13
9
  plan: any[]
14
10
  error?: string
15
11
  }
16
- export { queryExplainAll as explainAllQueries };
12
+ export declare function queryExplainAll(path: string, options: ExplainAllOptions = {}): Promise<ExplainResult[]>;
13
+
14
+ 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>;
5
1
  export declare interface DiagramOptions {
6
2
  dir?: string
7
3
  format?: 'mermaid' | 'dot'
8
4
  output?: string
9
5
  verbose?: boolean
10
6
  }
11
- export { relationDiagram as generateDiagram };
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 }
@@ -1,18 +1,8 @@
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
- */
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>;
13
7
  export declare function makeSeeder(name: string): 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>;
8
+ export declare function freshDatabase(options: { seedersDir?: string, modelsDir?: string, verbose?: boolean } = {}): Promise<void>;
@@ -1,2 +1,3 @@
1
1
  import type { SqlOptions } from '../types';
2
- export declare function sql(dir: string, table: string, opts?: SqlOptions): void;
2
+
3
+ export declare function sql(dir: string, table: string, opts: SqlOptions = {}): void;
@@ -1,2 +1,3 @@
1
1
  import type { UnsafeOptions } from '../types';
2
- export declare function unsafe(sql: string, opts?: UnsafeOptions): void;
2
+
3
+ export declare function unsafe(sql: string, opts: UnsafeOptions = {}): void;
@@ -1,11 +1,4 @@
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>;
1
+ declare function findWorkspaceRoot(startPath: string): string;
9
2
  export declare interface ValidationIssue {
10
3
  type: 'missing_table' | 'extra_table' | 'missing_column' | 'extra_column' | 'type_mismatch'
11
4
  severity: 'error' | 'warning'
@@ -18,4 +11,6 @@ export declare interface ValidationIssue {
18
11
  export declare interface ValidationResult {
19
12
  valid: boolean
20
13
  issues: ValidationIssue[]
21
- }
14
+ }
15
+ export declare function validateSchema(dir?: string): Promise<ValidationResult>;
16
+ export declare function checkSchema(dir?: string): Promise<ValidationResult>;
@@ -1,2 +1,3 @@
1
1
  import type { WaitReadyOptions } from '../types';
2
- export declare function waitReady(opts?: WaitReadyOptions): void;
2
+
3
+ export declare function waitReady(opts: WaitReadyOptions = {}): void;