metal-orm 1.0.11 → 1.0.12
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 +4 -3
- package/dist/decorators/index.cjs +15 -2
- package/dist/decorators/index.cjs.map +1 -1
- package/dist/decorators/index.d.cts +1 -1
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +15 -2
- package/dist/decorators/index.js.map +1 -1
- package/dist/index.cjs +1394 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +257 -23
- package/dist/index.d.ts +257 -23
- package/dist/index.js +1376 -149
- package/dist/index.js.map +1 -1
- package/dist/{select-654m4qy8.d.cts → select-BKlr2ivY.d.cts} +141 -4
- package/dist/{select-654m4qy8.d.ts → select-BKlr2ivY.d.ts} +141 -4
- package/package.json +1 -1
- package/src/core/ddl/dialects/base-schema-dialect.ts +48 -0
- package/src/core/ddl/dialects/index.ts +5 -0
- package/src/core/ddl/dialects/mssql-schema-dialect.ts +97 -0
- package/src/core/ddl/dialects/mysql-schema-dialect.ts +109 -0
- package/src/core/ddl/dialects/postgres-schema-dialect.ts +99 -0
- package/src/core/ddl/dialects/sqlite-schema-dialect.ts +103 -0
- package/src/core/ddl/introspect/mssql.ts +149 -0
- package/src/core/ddl/introspect/mysql.ts +99 -0
- package/src/core/ddl/introspect/postgres.ts +154 -0
- package/src/core/ddl/introspect/sqlite.ts +66 -0
- package/src/core/ddl/introspect/types.ts +19 -0
- package/src/core/ddl/introspect/utils.ts +27 -0
- package/src/core/ddl/schema-diff.ts +179 -0
- package/src/core/ddl/schema-generator.ts +229 -0
- package/src/core/ddl/schema-introspect.ts +32 -0
- package/src/core/ddl/schema-types.ts +39 -0
- package/src/core/dialect/base/sql-dialect.ts +161 -0
- package/src/core/dialect/mysql/index.ts +18 -112
- package/src/core/dialect/postgres/index.ts +30 -126
- package/src/core/dialect/sqlite/index.ts +29 -129
- package/src/index.ts +4 -0
- package/src/schema/column.ts +206 -27
- package/src/schema/table.ts +89 -32
- package/src/schema/types.ts +8 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, H as HydrationPlan, R as RelationMap,
|
|
2
|
-
export {
|
|
1
|
+
import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-BKlr2ivY.cjs';
|
|
2
|
+
export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-BKlr2ivY.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Converts a primitive or existing operand into an operand node
|
|
@@ -341,10 +341,54 @@ declare class DeleteQueryBuilder<T> {
|
|
|
341
341
|
getAST(): DeleteQueryNode;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Shared SQL compiler for dialects with standard LIMIT/OFFSET pagination.
|
|
346
|
+
* Concrete dialects override only the minimal hooks (identifier quoting,
|
|
347
|
+
* JSON path, placeholders, RETURNING support) instead of re-implementing
|
|
348
|
+
* the entire compile pipeline.
|
|
349
|
+
*/
|
|
350
|
+
declare abstract class SqlDialectBase extends Dialect {
|
|
351
|
+
/**
|
|
352
|
+
* Quotes an identifier (dialect-specific).
|
|
353
|
+
*/
|
|
354
|
+
abstract quoteIdentifier(id: string): string;
|
|
355
|
+
/**
|
|
356
|
+
* Compiles SELECT query AST to SQL using common rules.
|
|
357
|
+
*/
|
|
358
|
+
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
359
|
+
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
360
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
361
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
362
|
+
/**
|
|
363
|
+
* Default RETURNING compilation: no support.
|
|
364
|
+
*/
|
|
365
|
+
protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
|
|
366
|
+
/**
|
|
367
|
+
* DISTINCT clause. Override for DISTINCT ON support.
|
|
368
|
+
*/
|
|
369
|
+
protected compileDistinct(ast: SelectQueryNode): string;
|
|
370
|
+
protected compileSelectColumns(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
371
|
+
protected compileFrom(ast: SelectQueryNode['from']): string;
|
|
372
|
+
protected compileTableName(table: {
|
|
373
|
+
name: string;
|
|
374
|
+
schema?: string;
|
|
375
|
+
}): string;
|
|
376
|
+
protected compileJoins(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
377
|
+
protected compileGroupBy(ast: SelectQueryNode): string;
|
|
378
|
+
protected compileHaving(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
379
|
+
protected compileOrderBy(ast: SelectQueryNode): string;
|
|
380
|
+
/**
|
|
381
|
+
* Default LIMIT/OFFSET pagination clause.
|
|
382
|
+
*/
|
|
383
|
+
protected compilePagination(ast: SelectQueryNode, _orderByClause: string): string;
|
|
384
|
+
protected compileCtes(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
385
|
+
protected stripTrailingSemicolon(sql: string): string;
|
|
386
|
+
}
|
|
387
|
+
|
|
344
388
|
/**
|
|
345
389
|
* MySQL dialect implementation
|
|
346
390
|
*/
|
|
347
|
-
declare class MySqlDialect extends
|
|
391
|
+
declare class MySqlDialect extends SqlDialectBase {
|
|
348
392
|
/**
|
|
349
393
|
* Creates a new MySqlDialect instance
|
|
350
394
|
*/
|
|
@@ -361,16 +405,6 @@ declare class MySqlDialect extends Dialect {
|
|
|
361
405
|
* @returns MySQL JSON path expression
|
|
362
406
|
*/
|
|
363
407
|
protected compileJsonPath(node: JsonPathNode): string;
|
|
364
|
-
/**
|
|
365
|
-
* Compiles SELECT query AST to MySQL SQL
|
|
366
|
-
* @param ast - Query AST
|
|
367
|
-
* @param ctx - Compiler context
|
|
368
|
-
* @returns MySQL SQL string
|
|
369
|
-
*/
|
|
370
|
-
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
371
|
-
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
372
|
-
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
373
|
-
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
374
408
|
}
|
|
375
409
|
|
|
376
410
|
/**
|
|
@@ -414,7 +448,7 @@ declare class SqlServerDialect extends Dialect {
|
|
|
414
448
|
/**
|
|
415
449
|
* SQLite dialect implementation
|
|
416
450
|
*/
|
|
417
|
-
declare class SqliteDialect extends
|
|
451
|
+
declare class SqliteDialect extends SqlDialectBase {
|
|
418
452
|
/**
|
|
419
453
|
* Creates a new SqliteDialect instance
|
|
420
454
|
*/
|
|
@@ -431,19 +465,219 @@ declare class SqliteDialect extends Dialect {
|
|
|
431
465
|
* @returns SQLite JSON path expression
|
|
432
466
|
*/
|
|
433
467
|
protected compileJsonPath(node: JsonPathNode): string;
|
|
468
|
+
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* PostgreSQL dialect implementation
|
|
473
|
+
*/
|
|
474
|
+
declare class PostgresDialect extends SqlDialectBase {
|
|
434
475
|
/**
|
|
435
|
-
*
|
|
436
|
-
* @param ast - Query AST
|
|
437
|
-
* @param ctx - Compiler context
|
|
438
|
-
* @returns SQLite SQL string
|
|
476
|
+
* Creates a new PostgresDialect instance
|
|
439
477
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
478
|
+
constructor();
|
|
479
|
+
/**
|
|
480
|
+
* Quotes an identifier using PostgreSQL double-quote syntax
|
|
481
|
+
* @param id - Identifier to quote
|
|
482
|
+
* @returns Quoted identifier
|
|
483
|
+
*/
|
|
484
|
+
quoteIdentifier(id: string): string;
|
|
485
|
+
/**
|
|
486
|
+
* Compiles JSON path expression using PostgreSQL syntax
|
|
487
|
+
* @param node - JSON path node
|
|
488
|
+
* @returns PostgreSQL JSON path expression
|
|
489
|
+
*/
|
|
490
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
444
491
|
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
445
492
|
}
|
|
446
493
|
|
|
494
|
+
interface DatabaseColumn {
|
|
495
|
+
name: string;
|
|
496
|
+
type: string;
|
|
497
|
+
notNull?: boolean;
|
|
498
|
+
default?: unknown;
|
|
499
|
+
autoIncrement?: boolean;
|
|
500
|
+
generated?: 'always' | 'byDefault';
|
|
501
|
+
unique?: boolean | string;
|
|
502
|
+
references?: ForeignKeyReference;
|
|
503
|
+
check?: string;
|
|
504
|
+
}
|
|
505
|
+
interface DatabaseIndex {
|
|
506
|
+
name: string;
|
|
507
|
+
columns: IndexColumn[];
|
|
508
|
+
unique?: boolean;
|
|
509
|
+
where?: string;
|
|
510
|
+
}
|
|
511
|
+
interface DatabaseCheck {
|
|
512
|
+
name?: string;
|
|
513
|
+
expression: string;
|
|
514
|
+
}
|
|
515
|
+
interface DatabaseTable {
|
|
516
|
+
name: string;
|
|
517
|
+
schema?: string;
|
|
518
|
+
columns: DatabaseColumn[];
|
|
519
|
+
primaryKey?: string[];
|
|
520
|
+
indexes?: DatabaseIndex[];
|
|
521
|
+
checks?: DatabaseCheck[];
|
|
522
|
+
}
|
|
523
|
+
interface DatabaseSchema {
|
|
524
|
+
tables: DatabaseTable[];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
type TableLike = {
|
|
528
|
+
name: string;
|
|
529
|
+
schema?: string;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Common behavior for schema dialects (DDL).
|
|
533
|
+
* Concrete dialects only override the small surface area instead of reimplementing everything.
|
|
534
|
+
*/
|
|
535
|
+
declare abstract class BaseSchemaDialect implements SchemaDialect {
|
|
536
|
+
abstract name: DialectName;
|
|
537
|
+
abstract quoteIdentifier(id: string): string;
|
|
538
|
+
abstract renderColumnType(column: ColumnDef): string;
|
|
539
|
+
abstract renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
540
|
+
abstract renderIndex(table: TableDef, index: IndexDef): string;
|
|
541
|
+
supportsPartialIndexes(): boolean;
|
|
542
|
+
formatTableName(table: TableLike): string;
|
|
543
|
+
renderDefault(value: unknown, _column: ColumnDef): string;
|
|
544
|
+
renderReference(ref: ForeignKeyReference, _table: TableDef): string;
|
|
545
|
+
renderTableOptions(_table: TableDef): string | undefined;
|
|
546
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
547
|
+
abstract dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
548
|
+
abstract dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
549
|
+
warnDropColumn(_table: DatabaseTable, _column: string): string | undefined;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
declare class PostgresSchemaDialect extends BaseSchemaDialect {
|
|
553
|
+
name: DialectName;
|
|
554
|
+
quoteIdentifier(id: string): string;
|
|
555
|
+
renderColumnType(column: ColumnDef): string;
|
|
556
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
557
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
558
|
+
supportsPartialIndexes(): boolean;
|
|
559
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
560
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
declare class MySqlSchemaDialect extends BaseSchemaDialect {
|
|
564
|
+
name: DialectName;
|
|
565
|
+
quoteIdentifier(id: string): string;
|
|
566
|
+
renderColumnType(column: ColumnDef): string;
|
|
567
|
+
renderDefault(value: unknown): string;
|
|
568
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
569
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
570
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
571
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
572
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
declare class SQLiteSchemaDialect extends BaseSchemaDialect {
|
|
576
|
+
name: DialectName;
|
|
577
|
+
quoteIdentifier(id: string): string;
|
|
578
|
+
renderColumnType(column: ColumnDef): string;
|
|
579
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
580
|
+
preferInlinePkAutoincrement(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
581
|
+
renderDefault(value: unknown): string;
|
|
582
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
583
|
+
dropColumnSql(_table: DatabaseTable, _column: string): string[];
|
|
584
|
+
dropIndexSql(_table: DatabaseTable, index: string): string[];
|
|
585
|
+
warnDropColumn(table: DatabaseTable, column: string): string | undefined;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
declare class MSSqlSchemaDialect extends BaseSchemaDialect {
|
|
589
|
+
name: DialectName;
|
|
590
|
+
quoteIdentifier(id: string): string;
|
|
591
|
+
renderColumnType(column: ColumnDef): string;
|
|
592
|
+
renderDefault(value: unknown): string;
|
|
593
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
594
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
595
|
+
supportsPartialIndexes(): boolean;
|
|
596
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
597
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
type DialectName = 'postgres' | 'mysql' | 'sqlite' | 'mssql';
|
|
601
|
+
interface SchemaDialect {
|
|
602
|
+
name: DialectName;
|
|
603
|
+
quoteIdentifier(id: string): string;
|
|
604
|
+
formatTableName(table: TableDef | DatabaseTable): string;
|
|
605
|
+
renderColumnType(column: ColumnDef): string;
|
|
606
|
+
renderDefault(value: unknown, column: ColumnDef): string;
|
|
607
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
608
|
+
renderReference(ref: ForeignKeyReference, table: TableDef): string;
|
|
609
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
610
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
611
|
+
supportsPartialIndexes(): boolean;
|
|
612
|
+
preferInlinePkAutoincrement?(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
613
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
614
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
615
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
616
|
+
warnDropColumn?(table: DatabaseTable, column: string): string | undefined;
|
|
617
|
+
}
|
|
618
|
+
interface SchemaGenerateResult {
|
|
619
|
+
tableSql: string;
|
|
620
|
+
indexSql: string[];
|
|
621
|
+
}
|
|
622
|
+
declare const escapeLiteral: (value: string) => string;
|
|
623
|
+
declare const formatLiteral: (value: unknown, dialect: DialectName) => string;
|
|
624
|
+
declare const resolvePrimaryKey: (table: TableDef) => string[];
|
|
625
|
+
declare const quoteQualified: (dialect: SchemaDialect, identifier: string) => string;
|
|
626
|
+
declare const renderIndexColumns: (dialect: SchemaDialect, columns: (string | IndexColumn)[]) => string;
|
|
627
|
+
declare const deriveIndexName: (table: TableDef, index: IndexDef) => string;
|
|
628
|
+
interface RenderColumnOptions {
|
|
629
|
+
includePrimary?: boolean;
|
|
630
|
+
}
|
|
631
|
+
declare const renderColumnDefinition: (table: TableDef, col: ColumnDef, dialect: SchemaDialect, options?: RenderColumnOptions) => {
|
|
632
|
+
sql: string;
|
|
633
|
+
inlinePrimary: boolean;
|
|
634
|
+
};
|
|
635
|
+
declare const generateCreateTableSql: (table: TableDef, dialect: SchemaDialect) => SchemaGenerateResult;
|
|
636
|
+
declare const generateSchemaSql: (tables: TableDef[], dialect: SchemaDialect) => string[];
|
|
637
|
+
|
|
638
|
+
type SchemaChangeKind = 'createTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'alterColumn' | 'addIndex' | 'dropIndex';
|
|
639
|
+
interface SchemaChange {
|
|
640
|
+
kind: SchemaChangeKind;
|
|
641
|
+
table: string;
|
|
642
|
+
description: string;
|
|
643
|
+
statements: string[];
|
|
644
|
+
safe: boolean;
|
|
645
|
+
}
|
|
646
|
+
interface SchemaPlan {
|
|
647
|
+
changes: SchemaChange[];
|
|
648
|
+
warnings: string[];
|
|
649
|
+
}
|
|
650
|
+
interface SchemaDiffOptions {
|
|
651
|
+
/** Allow destructive operations (drops) */
|
|
652
|
+
allowDestructive?: boolean;
|
|
653
|
+
}
|
|
654
|
+
declare const diffSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, options?: SchemaDiffOptions) => SchemaPlan;
|
|
655
|
+
interface SynchronizeOptions extends SchemaDiffOptions {
|
|
656
|
+
dryRun?: boolean;
|
|
657
|
+
}
|
|
658
|
+
declare const synchronizeSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, executor: DbExecutor, options?: SynchronizeOptions) => Promise<SchemaPlan>;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Dialect-agnostic options for schema introspection.
|
|
662
|
+
*/
|
|
663
|
+
interface IntrospectOptions {
|
|
664
|
+
/** Dialect-specific schema/catalog. Postgres: schema; MySQL: database; MSSQL: schema. */
|
|
665
|
+
schema?: string;
|
|
666
|
+
includeTables?: string[];
|
|
667
|
+
excludeTables?: string[];
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Strategy interface implemented per dialect to introspect an existing database schema.
|
|
671
|
+
*/
|
|
672
|
+
interface SchemaIntrospector {
|
|
673
|
+
introspect(executor: DbExecutor, options: IntrospectOptions): Promise<DatabaseSchema>;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Introspects an existing database schema using the dialect-specific strategy.
|
|
678
|
+
*/
|
|
679
|
+
declare const introspectSchema: (executor: DbExecutor, dialect: DialectName, options?: IntrospectOptions) => Promise<DatabaseSchema>;
|
|
680
|
+
|
|
447
681
|
/**
|
|
448
682
|
* Browser-compatible implementation of AsyncLocalStorage
|
|
449
683
|
* Provides a simple in-memory store for browser environments
|
|
@@ -698,4 +932,4 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
|
|
|
698
932
|
|
|
699
933
|
declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;
|
|
700
934
|
|
|
701
|
-
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, ColumnNode, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, Entity, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, FunctionNode, HasManyCollection, HasManyRelation, InExpressionNode, InsertQueryBuilder, JsonPathNode, LiteralNode, LogicalExpressionNode, ManyToManyCollection, MySqlDialect, NullExpressionNode, OperandNode, type OperandVisitor, OrmContext, RelationMap, ScalarSubqueryNode, SelectQueryBuilder, SqlServerDialect, SqliteDialect, TableDef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, and, avg, between, caseWhen, columnOperand, count, createEntityFromRow, createEntityProxy, denseRank, eq, executeHydrated, exists, firstValue, gt, gte, hydrateRows, inList, isNotNull, isNull, jsonPath, lag, lastValue, lead, like, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, lt, lte, neq, notBetween, notExists, notInList, notLike, ntile, or, rank, rowNumber, sum, valueToOperand, visitExpression, visitOperand, windowFunction };
|
|
935
|
+
export { AsyncLocalStorage, BaseSchemaDialect, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, ColumnNode, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, HasManyCollection, HasManyRelation, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, LogicalExpressionNode, MSSqlSchemaDialect, ManyToManyCollection, MySqlDialect, MySqlSchemaDialect, NullExpressionNode, OperandNode, type OperandVisitor, OrmContext, PostgresDialect, PostgresSchemaDialect, RelationMap, type RenderColumnOptions, SQLiteSchemaDialect, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDialect, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, SqliteDialect, type SynchronizeOptions, TableDef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, and, avg, between, caseWhen, columnOperand, count, createEntityFromRow, createEntityProxy, denseRank, deriveIndexName, diffSchema, eq, escapeLiteral, executeHydrated, exists, firstValue, formatLiteral, generateCreateTableSql, generateSchemaSql, gt, gte, hydrateRows, inList, introspectSchema, isNotNull, isNull, jsonPath, lag, lastValue, lead, like, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, lt, lte, neq, notBetween, notExists, notInList, notLike, ntile, or, quoteQualified, rank, renderColumnDefinition, renderIndexColumns, resolvePrimaryKey, rowNumber, sum, synchronizeSchema, valueToOperand, visitExpression, visitOperand, windowFunction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, H as HydrationPlan, R as RelationMap,
|
|
2
|
-
export {
|
|
1
|
+
import { O as OperandNode, C as ColumnDef, a as ColumnNode, B as BinaryExpressionNode, E as ExpressionNode, L as LogicalExpressionNode, N as NullExpressionNode, b as LiteralNode, I as InExpressionNode, c as BetweenExpressionNode, J as JsonPathNode, d as CaseExpressionNode, S as SelectQueryNode, e as ExistsExpressionNode, W as WindowFunctionNode, f as OrderDirection, F as FunctionNode, g as ScalarSubqueryNode, T as TableDef, h as InsertQueryNode, i as InsertCompiler, j as CompiledQuery, U as UpdateQueryNode, k as UpdateCompiler, D as DeleteQueryNode, l as DeleteCompiler, m as Dialect, n as CompilerContext, o as ForeignKeyReference, p as IndexColumn, q as IndexDef, r as DbExecutor, H as HydrationPlan, R as RelationMap, s as OrmContext, t as Entity, u as HasManyRelation, v as BelongsToRelation, w as BelongsToManyRelation, x as HasManyCollection, y as BelongsToReference, M as ManyToManyCollection, z as SelectQueryBuilder } from './select-BKlr2ivY.js';
|
|
2
|
+
export { a0 as CascadeMode, A as CheckConstraint, a5 as ColumnToTs, Q as ColumnType, Y as DefaultValue, al as DomainEventHandler, af as EntityStatus, aj as HasDomainEvents, a6 as InferRow, am as OrmContextOptions, ak as OrmInterceptor, ag as QueryResult, X as RawDefaultValue, V as ReferentialAction, ai as RelationChange, a1 as RelationDef, ah as RelationKey, _ as RelationKinds, $ as RelationType, K as TableHooks, G as TableOptions, ae as addDomainEvent, a3 as belongsTo, a4 as belongsToMany, Z as col, a7 as createColumn, a8 as createLiteral, P as defineTable, a2 as hasMany, ab as isCaseExpressionNode, ad as isExpressionSelectionNode, aa as isFunctionNode, a9 as isOperandNode, ac as isWindowFunctionNode } from './select-BKlr2ivY.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Converts a primitive or existing operand into an operand node
|
|
@@ -341,10 +341,54 @@ declare class DeleteQueryBuilder<T> {
|
|
|
341
341
|
getAST(): DeleteQueryNode;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Shared SQL compiler for dialects with standard LIMIT/OFFSET pagination.
|
|
346
|
+
* Concrete dialects override only the minimal hooks (identifier quoting,
|
|
347
|
+
* JSON path, placeholders, RETURNING support) instead of re-implementing
|
|
348
|
+
* the entire compile pipeline.
|
|
349
|
+
*/
|
|
350
|
+
declare abstract class SqlDialectBase extends Dialect {
|
|
351
|
+
/**
|
|
352
|
+
* Quotes an identifier (dialect-specific).
|
|
353
|
+
*/
|
|
354
|
+
abstract quoteIdentifier(id: string): string;
|
|
355
|
+
/**
|
|
356
|
+
* Compiles SELECT query AST to SQL using common rules.
|
|
357
|
+
*/
|
|
358
|
+
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
359
|
+
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
360
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
361
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
362
|
+
/**
|
|
363
|
+
* Default RETURNING compilation: no support.
|
|
364
|
+
*/
|
|
365
|
+
protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
|
|
366
|
+
/**
|
|
367
|
+
* DISTINCT clause. Override for DISTINCT ON support.
|
|
368
|
+
*/
|
|
369
|
+
protected compileDistinct(ast: SelectQueryNode): string;
|
|
370
|
+
protected compileSelectColumns(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
371
|
+
protected compileFrom(ast: SelectQueryNode['from']): string;
|
|
372
|
+
protected compileTableName(table: {
|
|
373
|
+
name: string;
|
|
374
|
+
schema?: string;
|
|
375
|
+
}): string;
|
|
376
|
+
protected compileJoins(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
377
|
+
protected compileGroupBy(ast: SelectQueryNode): string;
|
|
378
|
+
protected compileHaving(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
379
|
+
protected compileOrderBy(ast: SelectQueryNode): string;
|
|
380
|
+
/**
|
|
381
|
+
* Default LIMIT/OFFSET pagination clause.
|
|
382
|
+
*/
|
|
383
|
+
protected compilePagination(ast: SelectQueryNode, _orderByClause: string): string;
|
|
384
|
+
protected compileCtes(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
385
|
+
protected stripTrailingSemicolon(sql: string): string;
|
|
386
|
+
}
|
|
387
|
+
|
|
344
388
|
/**
|
|
345
389
|
* MySQL dialect implementation
|
|
346
390
|
*/
|
|
347
|
-
declare class MySqlDialect extends
|
|
391
|
+
declare class MySqlDialect extends SqlDialectBase {
|
|
348
392
|
/**
|
|
349
393
|
* Creates a new MySqlDialect instance
|
|
350
394
|
*/
|
|
@@ -361,16 +405,6 @@ declare class MySqlDialect extends Dialect {
|
|
|
361
405
|
* @returns MySQL JSON path expression
|
|
362
406
|
*/
|
|
363
407
|
protected compileJsonPath(node: JsonPathNode): string;
|
|
364
|
-
/**
|
|
365
|
-
* Compiles SELECT query AST to MySQL SQL
|
|
366
|
-
* @param ast - Query AST
|
|
367
|
-
* @param ctx - Compiler context
|
|
368
|
-
* @returns MySQL SQL string
|
|
369
|
-
*/
|
|
370
|
-
protected compileSelectAst(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
371
|
-
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
372
|
-
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
373
|
-
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
374
408
|
}
|
|
375
409
|
|
|
376
410
|
/**
|
|
@@ -414,7 +448,7 @@ declare class SqlServerDialect extends Dialect {
|
|
|
414
448
|
/**
|
|
415
449
|
* SQLite dialect implementation
|
|
416
450
|
*/
|
|
417
|
-
declare class SqliteDialect extends
|
|
451
|
+
declare class SqliteDialect extends SqlDialectBase {
|
|
418
452
|
/**
|
|
419
453
|
* Creates a new SqliteDialect instance
|
|
420
454
|
*/
|
|
@@ -431,19 +465,219 @@ declare class SqliteDialect extends Dialect {
|
|
|
431
465
|
* @returns SQLite JSON path expression
|
|
432
466
|
*/
|
|
433
467
|
protected compileJsonPath(node: JsonPathNode): string;
|
|
468
|
+
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* PostgreSQL dialect implementation
|
|
473
|
+
*/
|
|
474
|
+
declare class PostgresDialect extends SqlDialectBase {
|
|
434
475
|
/**
|
|
435
|
-
*
|
|
436
|
-
* @param ast - Query AST
|
|
437
|
-
* @param ctx - Compiler context
|
|
438
|
-
* @returns SQLite SQL string
|
|
476
|
+
* Creates a new PostgresDialect instance
|
|
439
477
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
478
|
+
constructor();
|
|
479
|
+
/**
|
|
480
|
+
* Quotes an identifier using PostgreSQL double-quote syntax
|
|
481
|
+
* @param id - Identifier to quote
|
|
482
|
+
* @returns Quoted identifier
|
|
483
|
+
*/
|
|
484
|
+
quoteIdentifier(id: string): string;
|
|
485
|
+
/**
|
|
486
|
+
* Compiles JSON path expression using PostgreSQL syntax
|
|
487
|
+
* @param node - JSON path node
|
|
488
|
+
* @returns PostgreSQL JSON path expression
|
|
489
|
+
*/
|
|
490
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
444
491
|
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
445
492
|
}
|
|
446
493
|
|
|
494
|
+
interface DatabaseColumn {
|
|
495
|
+
name: string;
|
|
496
|
+
type: string;
|
|
497
|
+
notNull?: boolean;
|
|
498
|
+
default?: unknown;
|
|
499
|
+
autoIncrement?: boolean;
|
|
500
|
+
generated?: 'always' | 'byDefault';
|
|
501
|
+
unique?: boolean | string;
|
|
502
|
+
references?: ForeignKeyReference;
|
|
503
|
+
check?: string;
|
|
504
|
+
}
|
|
505
|
+
interface DatabaseIndex {
|
|
506
|
+
name: string;
|
|
507
|
+
columns: IndexColumn[];
|
|
508
|
+
unique?: boolean;
|
|
509
|
+
where?: string;
|
|
510
|
+
}
|
|
511
|
+
interface DatabaseCheck {
|
|
512
|
+
name?: string;
|
|
513
|
+
expression: string;
|
|
514
|
+
}
|
|
515
|
+
interface DatabaseTable {
|
|
516
|
+
name: string;
|
|
517
|
+
schema?: string;
|
|
518
|
+
columns: DatabaseColumn[];
|
|
519
|
+
primaryKey?: string[];
|
|
520
|
+
indexes?: DatabaseIndex[];
|
|
521
|
+
checks?: DatabaseCheck[];
|
|
522
|
+
}
|
|
523
|
+
interface DatabaseSchema {
|
|
524
|
+
tables: DatabaseTable[];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
type TableLike = {
|
|
528
|
+
name: string;
|
|
529
|
+
schema?: string;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Common behavior for schema dialects (DDL).
|
|
533
|
+
* Concrete dialects only override the small surface area instead of reimplementing everything.
|
|
534
|
+
*/
|
|
535
|
+
declare abstract class BaseSchemaDialect implements SchemaDialect {
|
|
536
|
+
abstract name: DialectName;
|
|
537
|
+
abstract quoteIdentifier(id: string): string;
|
|
538
|
+
abstract renderColumnType(column: ColumnDef): string;
|
|
539
|
+
abstract renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
540
|
+
abstract renderIndex(table: TableDef, index: IndexDef): string;
|
|
541
|
+
supportsPartialIndexes(): boolean;
|
|
542
|
+
formatTableName(table: TableLike): string;
|
|
543
|
+
renderDefault(value: unknown, _column: ColumnDef): string;
|
|
544
|
+
renderReference(ref: ForeignKeyReference, _table: TableDef): string;
|
|
545
|
+
renderTableOptions(_table: TableDef): string | undefined;
|
|
546
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
547
|
+
abstract dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
548
|
+
abstract dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
549
|
+
warnDropColumn(_table: DatabaseTable, _column: string): string | undefined;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
declare class PostgresSchemaDialect extends BaseSchemaDialect {
|
|
553
|
+
name: DialectName;
|
|
554
|
+
quoteIdentifier(id: string): string;
|
|
555
|
+
renderColumnType(column: ColumnDef): string;
|
|
556
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
557
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
558
|
+
supportsPartialIndexes(): boolean;
|
|
559
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
560
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
declare class MySqlSchemaDialect extends BaseSchemaDialect {
|
|
564
|
+
name: DialectName;
|
|
565
|
+
quoteIdentifier(id: string): string;
|
|
566
|
+
renderColumnType(column: ColumnDef): string;
|
|
567
|
+
renderDefault(value: unknown): string;
|
|
568
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
569
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
570
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
571
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
572
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
declare class SQLiteSchemaDialect extends BaseSchemaDialect {
|
|
576
|
+
name: DialectName;
|
|
577
|
+
quoteIdentifier(id: string): string;
|
|
578
|
+
renderColumnType(column: ColumnDef): string;
|
|
579
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
580
|
+
preferInlinePkAutoincrement(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
581
|
+
renderDefault(value: unknown): string;
|
|
582
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
583
|
+
dropColumnSql(_table: DatabaseTable, _column: string): string[];
|
|
584
|
+
dropIndexSql(_table: DatabaseTable, index: string): string[];
|
|
585
|
+
warnDropColumn(table: DatabaseTable, column: string): string | undefined;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
declare class MSSqlSchemaDialect extends BaseSchemaDialect {
|
|
589
|
+
name: DialectName;
|
|
590
|
+
quoteIdentifier(id: string): string;
|
|
591
|
+
renderColumnType(column: ColumnDef): string;
|
|
592
|
+
renderDefault(value: unknown): string;
|
|
593
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
594
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
595
|
+
supportsPartialIndexes(): boolean;
|
|
596
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
597
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
type DialectName = 'postgres' | 'mysql' | 'sqlite' | 'mssql';
|
|
601
|
+
interface SchemaDialect {
|
|
602
|
+
name: DialectName;
|
|
603
|
+
quoteIdentifier(id: string): string;
|
|
604
|
+
formatTableName(table: TableDef | DatabaseTable): string;
|
|
605
|
+
renderColumnType(column: ColumnDef): string;
|
|
606
|
+
renderDefault(value: unknown, column: ColumnDef): string;
|
|
607
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
608
|
+
renderReference(ref: ForeignKeyReference, table: TableDef): string;
|
|
609
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
610
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
611
|
+
supportsPartialIndexes(): boolean;
|
|
612
|
+
preferInlinePkAutoincrement?(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
613
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
614
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
615
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
616
|
+
warnDropColumn?(table: DatabaseTable, column: string): string | undefined;
|
|
617
|
+
}
|
|
618
|
+
interface SchemaGenerateResult {
|
|
619
|
+
tableSql: string;
|
|
620
|
+
indexSql: string[];
|
|
621
|
+
}
|
|
622
|
+
declare const escapeLiteral: (value: string) => string;
|
|
623
|
+
declare const formatLiteral: (value: unknown, dialect: DialectName) => string;
|
|
624
|
+
declare const resolvePrimaryKey: (table: TableDef) => string[];
|
|
625
|
+
declare const quoteQualified: (dialect: SchemaDialect, identifier: string) => string;
|
|
626
|
+
declare const renderIndexColumns: (dialect: SchemaDialect, columns: (string | IndexColumn)[]) => string;
|
|
627
|
+
declare const deriveIndexName: (table: TableDef, index: IndexDef) => string;
|
|
628
|
+
interface RenderColumnOptions {
|
|
629
|
+
includePrimary?: boolean;
|
|
630
|
+
}
|
|
631
|
+
declare const renderColumnDefinition: (table: TableDef, col: ColumnDef, dialect: SchemaDialect, options?: RenderColumnOptions) => {
|
|
632
|
+
sql: string;
|
|
633
|
+
inlinePrimary: boolean;
|
|
634
|
+
};
|
|
635
|
+
declare const generateCreateTableSql: (table: TableDef, dialect: SchemaDialect) => SchemaGenerateResult;
|
|
636
|
+
declare const generateSchemaSql: (tables: TableDef[], dialect: SchemaDialect) => string[];
|
|
637
|
+
|
|
638
|
+
type SchemaChangeKind = 'createTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'alterColumn' | 'addIndex' | 'dropIndex';
|
|
639
|
+
interface SchemaChange {
|
|
640
|
+
kind: SchemaChangeKind;
|
|
641
|
+
table: string;
|
|
642
|
+
description: string;
|
|
643
|
+
statements: string[];
|
|
644
|
+
safe: boolean;
|
|
645
|
+
}
|
|
646
|
+
interface SchemaPlan {
|
|
647
|
+
changes: SchemaChange[];
|
|
648
|
+
warnings: string[];
|
|
649
|
+
}
|
|
650
|
+
interface SchemaDiffOptions {
|
|
651
|
+
/** Allow destructive operations (drops) */
|
|
652
|
+
allowDestructive?: boolean;
|
|
653
|
+
}
|
|
654
|
+
declare const diffSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, options?: SchemaDiffOptions) => SchemaPlan;
|
|
655
|
+
interface SynchronizeOptions extends SchemaDiffOptions {
|
|
656
|
+
dryRun?: boolean;
|
|
657
|
+
}
|
|
658
|
+
declare const synchronizeSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, executor: DbExecutor, options?: SynchronizeOptions) => Promise<SchemaPlan>;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Dialect-agnostic options for schema introspection.
|
|
662
|
+
*/
|
|
663
|
+
interface IntrospectOptions {
|
|
664
|
+
/** Dialect-specific schema/catalog. Postgres: schema; MySQL: database; MSSQL: schema. */
|
|
665
|
+
schema?: string;
|
|
666
|
+
includeTables?: string[];
|
|
667
|
+
excludeTables?: string[];
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Strategy interface implemented per dialect to introspect an existing database schema.
|
|
671
|
+
*/
|
|
672
|
+
interface SchemaIntrospector {
|
|
673
|
+
introspect(executor: DbExecutor, options: IntrospectOptions): Promise<DatabaseSchema>;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Introspects an existing database schema using the dialect-specific strategy.
|
|
678
|
+
*/
|
|
679
|
+
declare const introspectSchema: (executor: DbExecutor, dialect: DialectName, options?: IntrospectOptions) => Promise<DatabaseSchema>;
|
|
680
|
+
|
|
447
681
|
/**
|
|
448
682
|
* Browser-compatible implementation of AsyncLocalStorage
|
|
449
683
|
* Provides a simple in-memory store for browser environments
|
|
@@ -698,4 +932,4 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
|
|
|
698
932
|
|
|
699
933
|
declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;
|
|
700
934
|
|
|
701
|
-
export { AsyncLocalStorage, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, ColumnNode, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, Entity, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, FunctionNode, HasManyCollection, HasManyRelation, InExpressionNode, InsertQueryBuilder, JsonPathNode, LiteralNode, LogicalExpressionNode, ManyToManyCollection, MySqlDialect, NullExpressionNode, OperandNode, type OperandVisitor, OrmContext, RelationMap, ScalarSubqueryNode, SelectQueryBuilder, SqlServerDialect, SqliteDialect, TableDef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, and, avg, between, caseWhen, columnOperand, count, createEntityFromRow, createEntityProxy, denseRank, eq, executeHydrated, exists, firstValue, gt, gte, hydrateRows, inList, isNotNull, isNull, jsonPath, lag, lastValue, lead, like, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, lt, lte, neq, notBetween, notExists, notInList, notLike, ntile, or, rank, rowNumber, sum, valueToOperand, visitExpression, visitOperand, windowFunction };
|
|
935
|
+
export { AsyncLocalStorage, BaseSchemaDialect, BelongsToManyRelation, BelongsToReference, BelongsToRelation, BetweenExpressionNode, BinaryExpressionNode, CaseExpressionNode, ColumnDef, ColumnNode, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, DbExecutor, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, DeleteQueryBuilder, type DialectName, Entity, ExistsExpressionNode, ExpressionNode, type ExpressionVisitor, ForeignKeyReference, FunctionNode, HasManyCollection, HasManyRelation, InExpressionNode, IndexColumn, IndexDef, InsertQueryBuilder, type IntrospectOptions, JsonPathNode, LiteralNode, LogicalExpressionNode, MSSqlSchemaDialect, ManyToManyCollection, MySqlDialect, MySqlSchemaDialect, NullExpressionNode, OperandNode, type OperandVisitor, OrmContext, PostgresDialect, PostgresSchemaDialect, RelationMap, type RenderColumnOptions, SQLiteSchemaDialect, ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDialect, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, SqlServerDialect, SqliteDialect, type SynchronizeOptions, TableDef, TypeScriptGenerator, UpdateQueryBuilder, WindowFunctionNode, and, avg, between, caseWhen, columnOperand, count, createEntityFromRow, createEntityProxy, denseRank, deriveIndexName, diffSchema, eq, escapeLiteral, executeHydrated, exists, firstValue, formatLiteral, generateCreateTableSql, generateSchemaSql, gt, gte, hydrateRows, inList, introspectSchema, isNotNull, isNull, jsonPath, lag, lastValue, lead, like, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, lt, lte, neq, notBetween, notExists, notInList, notLike, ntile, or, quoteQualified, rank, renderColumnDefinition, renderIndexColumns, resolvePrimaryKey, rowNumber, sum, synchronizeSchema, valueToOperand, visitExpression, visitOperand, windowFunction };
|