bun-query-builder 0.1.2 → 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 (43) hide show
  1. package/dist/actions/benchmark.d.ts +12 -0
  2. package/dist/actions/cache.d.ts +6 -0
  3. package/dist/actions/console.d.ts +2 -0
  4. package/dist/actions/data.d.ts +15 -0
  5. package/dist/actions/db-info.d.ts +17 -0
  6. package/dist/actions/db-optimize.d.ts +11 -0
  7. package/dist/actions/db-wipe.d.ts +10 -0
  8. package/dist/actions/file.d.ts +2 -1
  9. package/dist/actions/index.d.ts +25 -8
  10. package/dist/actions/inspect.d.ts +24 -0
  11. package/dist/actions/introspect.d.ts +2 -1
  12. package/dist/actions/make-model.d.ts +7 -0
  13. package/dist/actions/migrate-generate.d.ts +5 -0
  14. package/dist/actions/migrate-rollback.d.ts +6 -0
  15. package/dist/actions/migrate-status.d.ts +9 -0
  16. package/dist/actions/migrate.d.ts +13 -3
  17. package/dist/actions/model-show.d.ts +20 -0
  18. package/dist/actions/query-explain-all.d.ts +14 -0
  19. package/dist/actions/relation-diagram.d.ts +11 -0
  20. package/dist/actions/seed.d.ts +8 -0
  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 +16 -0
  24. package/dist/actions/wait-ready.d.ts +2 -1
  25. package/dist/client.d.ts +230 -158
  26. package/dist/config.d.ts +2 -1
  27. package/dist/db.d.ts +10 -0
  28. package/dist/drivers/index.d.ts +12 -0
  29. package/dist/drivers/mysql.d.ts +187 -0
  30. package/dist/drivers/postgres.d.ts +173 -0
  31. package/dist/drivers/sqlite.d.ts +175 -0
  32. package/dist/factory.d.ts +3 -6
  33. package/dist/index.d.ts +11 -9
  34. package/dist/index.js +5444 -869
  35. package/dist/loader.d.ts +3 -2
  36. package/dist/meta.d.ts +10 -2
  37. package/dist/migrations.d.ts +43 -43
  38. package/dist/schema.d.ts +36 -177
  39. package/dist/seeder.d.ts +21 -0
  40. package/dist/types.d.ts +60 -143
  41. package/package.json +18 -27
  42. package/LICENSE.md +0 -21
  43. package/README.md +0 -150
@@ -0,0 +1,12 @@
1
+ export declare interface BenchmarkOptions {
2
+ operations?: string
3
+ 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>;
@@ -0,0 +1,6 @@
1
+ export declare function cacheClear(): Promise<void>;
2
+ export declare function cacheStats(): Promise<void>;
3
+ export declare interface CacheConfigOptions {
4
+ size?: number
5
+ }
6
+ export declare function cacheConfig(options: CacheConfigOptions = {}): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function startConsole(): Promise<void>;
2
+ export declare function tinker(): Promise<void>;
@@ -0,0 +1,15 @@
1
+ export declare interface ExportOptions {
2
+ format?: 'json' | 'csv' | 'sql'
3
+ output?: string
4
+ limit?: number
5
+ }
6
+ export declare interface ImportOptions {
7
+ format?: 'json' | 'csv'
8
+ truncate?: boolean
9
+ }
10
+ export declare interface DumpOptions {
11
+ tables?: string
12
+ 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>;
@@ -0,0 +1,17 @@
1
+ import type { SupportedDialect } from '@/types';
2
+
3
+ export declare interface TableInfo {
4
+ name: string
5
+ rowCount: number
6
+ columns?: number
7
+ indexes?: number
8
+ }
9
+ export declare interface DatabaseInfo {
10
+ dialect: SupportedDialect
11
+ database: string
12
+ tables: TableInfo[]
13
+ totalTables: number
14
+ totalRows: number
15
+ }
16
+ export declare function dbInfo(): Promise<DatabaseInfo>;
17
+ export declare function dbStats(): Promise<DatabaseInfo>;
@@ -0,0 +1,11 @@
1
+ import type { SupportedDialect } from '@/types';
2
+
3
+ export declare interface OptimizeOptions {
4
+ dialect?: SupportedDialect
5
+ aggressive?: boolean
6
+ tables?: string[]
7
+ verbose?: boolean
8
+ }
9
+ export declare function dbOptimize(options: OptimizeOptions = {}): Promise<void>;
10
+
11
+ export { dbOptimize as optimizeDatabase }
@@ -0,0 +1,10 @@
1
+ import type { SupportedDialect } from '@/types';
2
+
3
+ export declare interface WipeOptions {
4
+ dialect?: SupportedDialect
5
+ force?: boolean
6
+ verbose?: boolean
7
+ }
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,8 +1,25 @@
1
- export { explain } from './explain';
2
- export { file } from './file';
3
- export { introspect } from './introspect';
4
- export { executeMigration, generateMigration } from './migrate';
5
- export { ping } from './ping';
6
- export { sql } from './sql';
7
- export { unsafe } from './unsafe';
8
- 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'
@@ -0,0 +1,24 @@
1
+ export declare interface ColumnInfo {
2
+ name: string
3
+ type: string
4
+ nullable: boolean
5
+ default: any
6
+ isPrimaryKey?: boolean
7
+ isForeignKey?: boolean
8
+ }
9
+ export declare interface IndexInfo {
10
+ name: string
11
+ columns: string[]
12
+ unique: boolean
13
+ }
14
+ export declare interface TableInspection {
15
+ tableName: string
16
+ rowCount: number
17
+ columns: ColumnInfo[]
18
+ indexes: IndexInfo[]
19
+ }
20
+ export declare interface InspectOptions {
21
+ 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>;
@@ -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;
@@ -0,0 +1,7 @@
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ export declare interface MakeModelOptions {
3
+ table?: string
4
+ dir?: string
5
+ timestamps?: boolean
6
+ }
7
+ export declare function makeModel(name: string, options: MakeModelOptions = {}): Promise<void>;
@@ -0,0 +1,5 @@
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 }
@@ -0,0 +1,6 @@
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ declare function getSqlDirectory(workspaceRoot?: string): string;
3
+ export declare interface RollbackOptions {
4
+ steps?: number
5
+ }
6
+ export declare function migrateRollback(options: RollbackOptions = {}): Promise<void>;
@@ -0,0 +1,9 @@
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ declare function getSqlDirectory(workspaceRoot?: string): string;
3
+ export declare interface MigrationStatus {
4
+ file: string
5
+ status: 'executed' | 'pending' | 'transient'
6
+ executedAt?: string
7
+ }
8
+ export declare function migrateStatus(): Promise<MigrationStatus[]>;
9
+ export declare function migrateList(): Promise<MigrationStatus[]>;
@@ -1,3 +1,13 @@
1
- import type { GenerateMigrationResult, MigrateOptions } from '../types';
2
- export declare function generateMigration(dir: string, opts?: MigrateOptions): Promise<GenerateMigrationResult>;
3
- export declare function executeMigration(migration: GenerateMigrationResult): Promise<boolean>;
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>;
@@ -0,0 +1,20 @@
1
+ export declare interface ModelShowOptions {
2
+ dir?: string
3
+ verbose?: boolean
4
+ json?: boolean
5
+ }
6
+ export declare interface ModelDetails {
7
+ name: string
8
+ table: string
9
+ primaryKey: string
10
+ attributes: Record<string, any>
11
+ relations?: Record<string, any>
12
+ scopes?: Record<string, any>
13
+ hooks?: string[]
14
+ indexes?: any[]
15
+ timestamps?: boolean
16
+ softDeletes?: boolean
17
+ }
18
+ export declare function modelShow(modelName: string, options: ModelShowOptions = {}): Promise<ModelDetails | void>;
19
+
20
+ export { modelShow as showModel }
@@ -0,0 +1,14 @@
1
+ export declare interface ExplainAllOptions {
2
+ verbose?: boolean
3
+ json?: boolean
4
+ format?: 'text' | 'json'
5
+ }
6
+ export declare interface ExplainResult {
7
+ file: string
8
+ query: string
9
+ plan: any[]
10
+ error?: string
11
+ }
12
+ export declare function queryExplainAll(path: string, options: ExplainAllOptions = {}): Promise<ExplainResult[]>;
13
+
14
+ export { queryExplainAll as explainAllQueries }
@@ -0,0 +1,11 @@
1
+ export declare interface DiagramOptions {
2
+ dir?: string
3
+ format?: 'mermaid' | 'dot'
4
+ output?: string
5
+ verbose?: boolean
6
+ }
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 }
@@ -0,0 +1,8 @@
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>;
7
+ export declare function makeSeeder(name: string): 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;
@@ -0,0 +1,16 @@
1
+ declare function findWorkspaceRoot(startPath: string): string;
2
+ export declare interface ValidationIssue {
3
+ type: 'missing_table' | 'extra_table' | 'missing_column' | 'extra_column' | 'type_mismatch'
4
+ severity: 'error' | 'warning'
5
+ table?: string
6
+ column?: string
7
+ expected?: string
8
+ actual?: string
9
+ message: string
10
+ }
11
+ export declare interface ValidationResult {
12
+ valid: boolean
13
+ issues: ValidationIssue[]
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;