metal-orm 1.0.11 → 1.0.13
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 +21 -18
- package/dist/decorators/index.cjs +317 -34
- 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 +317 -34
- package/dist/decorators/index.js.map +1 -1
- package/dist/index.cjs +1965 -267
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +273 -23
- package/dist/index.d.ts +273 -23
- package/dist/index.js +1947 -267
- package/dist/index.js.map +1 -1
- package/dist/{select-654m4qy8.d.cts → select-CCp1oz9p.d.cts} +254 -4
- package/dist/{select-654m4qy8.d.ts → select-CCp1oz9p.d.ts} +254 -4
- package/package.json +3 -2
- package/src/core/ast/query.ts +40 -22
- 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/abstract.ts +122 -37
- package/src/core/dialect/base/sql-dialect.ts +204 -0
- package/src/core/dialect/mssql/index.ts +125 -80
- package/src/core/dialect/mysql/index.ts +18 -112
- package/src/core/dialect/postgres/index.ts +29 -126
- package/src/core/dialect/sqlite/index.ts +28 -129
- package/src/index.ts +4 -0
- package/src/orm/execute.ts +25 -16
- package/src/orm/orm-context.ts +60 -55
- package/src/orm/query-logger.ts +38 -0
- package/src/orm/relations/belongs-to.ts +42 -26
- package/src/orm/relations/has-many.ts +41 -25
- package/src/orm/relations/many-to-many.ts +43 -27
- package/src/orm/unit-of-work.ts +60 -23
- package/src/query-builder/hydration-manager.ts +229 -25
- package/src/query-builder/query-ast-service.ts +27 -12
- package/src/query-builder/select-query-state.ts +24 -12
- package/src/query-builder/select.ts +58 -14
- 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.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-CCp1oz9p.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, an as QueryLogEntry, ao as QueryLogger, 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-CCp1oz9p.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Converts a primitive or existing operand into an operand node
|
|
@@ -341,10 +341,60 @@ 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
|
+
/**
|
|
361
|
+
* Compiles a single SELECT (no set operations, no CTE prefix).
|
|
362
|
+
*/
|
|
363
|
+
private compileSelectCore;
|
|
364
|
+
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
365
|
+
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
366
|
+
/**
|
|
367
|
+
* Default RETURNING compilation: no support.
|
|
368
|
+
*/
|
|
369
|
+
protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
|
|
370
|
+
protected formatReturningColumns(returning: ColumnNode[]): string;
|
|
371
|
+
/**
|
|
372
|
+
* DISTINCT clause. Override for DISTINCT ON support.
|
|
373
|
+
*/
|
|
374
|
+
protected compileDistinct(ast: SelectQueryNode): string;
|
|
375
|
+
protected compileSelectColumns(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
376
|
+
protected compileFrom(ast: SelectQueryNode['from']): string;
|
|
377
|
+
protected compileTableName(table: {
|
|
378
|
+
name: string;
|
|
379
|
+
schema?: string;
|
|
380
|
+
}): string;
|
|
381
|
+
protected compileJoins(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
382
|
+
protected compileGroupBy(ast: SelectQueryNode): string;
|
|
383
|
+
protected compileHaving(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
384
|
+
protected compileOrderBy(ast: SelectQueryNode): string;
|
|
385
|
+
/**
|
|
386
|
+
* Default LIMIT/OFFSET pagination clause.
|
|
387
|
+
*/
|
|
388
|
+
protected compilePagination(ast: SelectQueryNode, _orderByClause: string): string;
|
|
389
|
+
protected compileCtes(ast: SelectQueryNode, ctx: CompilerContext): string;
|
|
390
|
+
protected stripTrailingSemicolon(sql: string): string;
|
|
391
|
+
protected wrapSetOperand(sql: string): string;
|
|
392
|
+
}
|
|
393
|
+
|
|
344
394
|
/**
|
|
345
395
|
* MySQL dialect implementation
|
|
346
396
|
*/
|
|
347
|
-
declare class MySqlDialect extends
|
|
397
|
+
declare class MySqlDialect extends SqlDialectBase {
|
|
348
398
|
/**
|
|
349
399
|
* Creates a new MySqlDialect instance
|
|
350
400
|
*/
|
|
@@ -361,16 +411,6 @@ declare class MySqlDialect extends Dialect {
|
|
|
361
411
|
* @returns MySQL JSON path expression
|
|
362
412
|
*/
|
|
363
413
|
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
414
|
}
|
|
375
415
|
|
|
376
416
|
/**
|
|
@@ -409,12 +449,17 @@ declare class SqlServerDialect extends Dialect {
|
|
|
409
449
|
protected compileInsertAst(ast: InsertQueryNode, ctx: CompilerContext): string;
|
|
410
450
|
protected compileUpdateAst(ast: UpdateQueryNode, ctx: CompilerContext): string;
|
|
411
451
|
protected compileDeleteAst(ast: DeleteQueryNode, ctx: CompilerContext): string;
|
|
452
|
+
private compileSelectCore;
|
|
453
|
+
private compileOrderBy;
|
|
454
|
+
private compilePagination;
|
|
455
|
+
private compileCtes;
|
|
456
|
+
private wrapSetOperand;
|
|
412
457
|
}
|
|
413
458
|
|
|
414
459
|
/**
|
|
415
460
|
* SQLite dialect implementation
|
|
416
461
|
*/
|
|
417
|
-
declare class SqliteDialect extends
|
|
462
|
+
declare class SqliteDialect extends SqlDialectBase {
|
|
418
463
|
/**
|
|
419
464
|
* Creates a new SqliteDialect instance
|
|
420
465
|
*/
|
|
@@ -431,18 +476,220 @@ declare class SqliteDialect extends Dialect {
|
|
|
431
476
|
* @returns SQLite JSON path expression
|
|
432
477
|
*/
|
|
433
478
|
protected compileJsonPath(node: JsonPathNode): string;
|
|
479
|
+
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
480
|
+
supportsReturning(): boolean;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* PostgreSQL dialect implementation
|
|
485
|
+
*/
|
|
486
|
+
declare class PostgresDialect extends SqlDialectBase {
|
|
434
487
|
/**
|
|
435
|
-
*
|
|
436
|
-
* @param ast - Query AST
|
|
437
|
-
* @param ctx - Compiler context
|
|
438
|
-
* @returns SQLite SQL string
|
|
488
|
+
* Creates a new PostgresDialect instance
|
|
439
489
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
490
|
+
constructor();
|
|
491
|
+
/**
|
|
492
|
+
* Quotes an identifier using PostgreSQL double-quote syntax
|
|
493
|
+
* @param id - Identifier to quote
|
|
494
|
+
* @returns Quoted identifier
|
|
495
|
+
*/
|
|
496
|
+
quoteIdentifier(id: string): string;
|
|
497
|
+
/**
|
|
498
|
+
* Compiles JSON path expression using PostgreSQL syntax
|
|
499
|
+
* @param node - JSON path node
|
|
500
|
+
* @returns PostgreSQL JSON path expression
|
|
501
|
+
*/
|
|
502
|
+
protected compileJsonPath(node: JsonPathNode): string;
|
|
444
503
|
protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
|
|
504
|
+
supportsReturning(): boolean;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
interface DatabaseColumn {
|
|
508
|
+
name: string;
|
|
509
|
+
type: string;
|
|
510
|
+
notNull?: boolean;
|
|
511
|
+
default?: unknown;
|
|
512
|
+
autoIncrement?: boolean;
|
|
513
|
+
generated?: 'always' | 'byDefault';
|
|
514
|
+
unique?: boolean | string;
|
|
515
|
+
references?: ForeignKeyReference;
|
|
516
|
+
check?: string;
|
|
517
|
+
}
|
|
518
|
+
interface DatabaseIndex {
|
|
519
|
+
name: string;
|
|
520
|
+
columns: IndexColumn[];
|
|
521
|
+
unique?: boolean;
|
|
522
|
+
where?: string;
|
|
523
|
+
}
|
|
524
|
+
interface DatabaseCheck {
|
|
525
|
+
name?: string;
|
|
526
|
+
expression: string;
|
|
527
|
+
}
|
|
528
|
+
interface DatabaseTable {
|
|
529
|
+
name: string;
|
|
530
|
+
schema?: string;
|
|
531
|
+
columns: DatabaseColumn[];
|
|
532
|
+
primaryKey?: string[];
|
|
533
|
+
indexes?: DatabaseIndex[];
|
|
534
|
+
checks?: DatabaseCheck[];
|
|
535
|
+
}
|
|
536
|
+
interface DatabaseSchema {
|
|
537
|
+
tables: DatabaseTable[];
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
type TableLike = {
|
|
541
|
+
name: string;
|
|
542
|
+
schema?: string;
|
|
543
|
+
};
|
|
544
|
+
/**
|
|
545
|
+
* Common behavior for schema dialects (DDL).
|
|
546
|
+
* Concrete dialects only override the small surface area instead of reimplementing everything.
|
|
547
|
+
*/
|
|
548
|
+
declare abstract class BaseSchemaDialect implements SchemaDialect {
|
|
549
|
+
abstract name: DialectName;
|
|
550
|
+
abstract quoteIdentifier(id: string): string;
|
|
551
|
+
abstract renderColumnType(column: ColumnDef): string;
|
|
552
|
+
abstract renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
553
|
+
abstract renderIndex(table: TableDef, index: IndexDef): string;
|
|
554
|
+
supportsPartialIndexes(): boolean;
|
|
555
|
+
formatTableName(table: TableLike): string;
|
|
556
|
+
renderDefault(value: unknown, _column: ColumnDef): string;
|
|
557
|
+
renderReference(ref: ForeignKeyReference, _table: TableDef): string;
|
|
558
|
+
renderTableOptions(_table: TableDef): string | undefined;
|
|
559
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
560
|
+
abstract dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
561
|
+
abstract dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
562
|
+
warnDropColumn(_table: DatabaseTable, _column: string): string | undefined;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
declare class PostgresSchemaDialect extends BaseSchemaDialect {
|
|
566
|
+
name: DialectName;
|
|
567
|
+
quoteIdentifier(id: string): string;
|
|
568
|
+
renderColumnType(column: ColumnDef): string;
|
|
569
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
570
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
571
|
+
supportsPartialIndexes(): boolean;
|
|
572
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
573
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
declare class MySqlSchemaDialect extends BaseSchemaDialect {
|
|
577
|
+
name: DialectName;
|
|
578
|
+
quoteIdentifier(id: string): string;
|
|
579
|
+
renderColumnType(column: ColumnDef): string;
|
|
580
|
+
renderDefault(value: unknown): string;
|
|
581
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
582
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
583
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
584
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
585
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
declare class SQLiteSchemaDialect extends BaseSchemaDialect {
|
|
589
|
+
name: DialectName;
|
|
590
|
+
quoteIdentifier(id: string): string;
|
|
591
|
+
renderColumnType(column: ColumnDef): string;
|
|
592
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
593
|
+
preferInlinePkAutoincrement(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
594
|
+
renderDefault(value: unknown): string;
|
|
595
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
596
|
+
dropColumnSql(_table: DatabaseTable, _column: string): string[];
|
|
597
|
+
dropIndexSql(_table: DatabaseTable, index: string): string[];
|
|
598
|
+
warnDropColumn(table: DatabaseTable, column: string): string | undefined;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
declare class MSSqlSchemaDialect extends BaseSchemaDialect {
|
|
602
|
+
name: DialectName;
|
|
603
|
+
quoteIdentifier(id: string): string;
|
|
604
|
+
renderColumnType(column: ColumnDef): string;
|
|
605
|
+
renderDefault(value: unknown): string;
|
|
606
|
+
renderAutoIncrement(column: ColumnDef): string | undefined;
|
|
607
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
608
|
+
supportsPartialIndexes(): boolean;
|
|
609
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
610
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
type DialectName = 'postgres' | 'mysql' | 'sqlite' | 'mssql';
|
|
614
|
+
interface SchemaDialect {
|
|
615
|
+
name: DialectName;
|
|
616
|
+
quoteIdentifier(id: string): string;
|
|
617
|
+
formatTableName(table: TableDef | DatabaseTable): string;
|
|
618
|
+
renderColumnType(column: ColumnDef): string;
|
|
619
|
+
renderDefault(value: unknown, column: ColumnDef): string;
|
|
620
|
+
renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
621
|
+
renderReference(ref: ForeignKeyReference, table: TableDef): string;
|
|
622
|
+
renderIndex(table: TableDef, index: IndexDef): string;
|
|
623
|
+
renderTableOptions(table: TableDef): string | undefined;
|
|
624
|
+
supportsPartialIndexes(): boolean;
|
|
625
|
+
preferInlinePkAutoincrement?(column: ColumnDef, table: TableDef, pk: string[]): boolean;
|
|
626
|
+
dropColumnSql(table: DatabaseTable, column: string): string[];
|
|
627
|
+
dropIndexSql(table: DatabaseTable, index: string): string[];
|
|
628
|
+
dropTableSql(table: DatabaseTable): string[];
|
|
629
|
+
warnDropColumn?(table: DatabaseTable, column: string): string | undefined;
|
|
630
|
+
}
|
|
631
|
+
interface SchemaGenerateResult {
|
|
632
|
+
tableSql: string;
|
|
633
|
+
indexSql: string[];
|
|
634
|
+
}
|
|
635
|
+
declare const escapeLiteral: (value: string) => string;
|
|
636
|
+
declare const formatLiteral: (value: unknown, dialect: DialectName) => string;
|
|
637
|
+
declare const resolvePrimaryKey: (table: TableDef) => string[];
|
|
638
|
+
declare const quoteQualified: (dialect: SchemaDialect, identifier: string) => string;
|
|
639
|
+
declare const renderIndexColumns: (dialect: SchemaDialect, columns: (string | IndexColumn)[]) => string;
|
|
640
|
+
declare const deriveIndexName: (table: TableDef, index: IndexDef) => string;
|
|
641
|
+
interface RenderColumnOptions {
|
|
642
|
+
includePrimary?: boolean;
|
|
643
|
+
}
|
|
644
|
+
declare const renderColumnDefinition: (table: TableDef, col: ColumnDef, dialect: SchemaDialect, options?: RenderColumnOptions) => {
|
|
645
|
+
sql: string;
|
|
646
|
+
inlinePrimary: boolean;
|
|
647
|
+
};
|
|
648
|
+
declare const generateCreateTableSql: (table: TableDef, dialect: SchemaDialect) => SchemaGenerateResult;
|
|
649
|
+
declare const generateSchemaSql: (tables: TableDef[], dialect: SchemaDialect) => string[];
|
|
650
|
+
|
|
651
|
+
type SchemaChangeKind = 'createTable' | 'dropTable' | 'addColumn' | 'dropColumn' | 'alterColumn' | 'addIndex' | 'dropIndex';
|
|
652
|
+
interface SchemaChange {
|
|
653
|
+
kind: SchemaChangeKind;
|
|
654
|
+
table: string;
|
|
655
|
+
description: string;
|
|
656
|
+
statements: string[];
|
|
657
|
+
safe: boolean;
|
|
658
|
+
}
|
|
659
|
+
interface SchemaPlan {
|
|
660
|
+
changes: SchemaChange[];
|
|
661
|
+
warnings: string[];
|
|
662
|
+
}
|
|
663
|
+
interface SchemaDiffOptions {
|
|
664
|
+
/** Allow destructive operations (drops) */
|
|
665
|
+
allowDestructive?: boolean;
|
|
445
666
|
}
|
|
667
|
+
declare const diffSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, options?: SchemaDiffOptions) => SchemaPlan;
|
|
668
|
+
interface SynchronizeOptions extends SchemaDiffOptions {
|
|
669
|
+
dryRun?: boolean;
|
|
670
|
+
}
|
|
671
|
+
declare const synchronizeSchema: (expectedTables: TableDef[], actualSchema: DatabaseSchema, dialect: SchemaDialect, executor: DbExecutor, options?: SynchronizeOptions) => Promise<SchemaPlan>;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Dialect-agnostic options for schema introspection.
|
|
675
|
+
*/
|
|
676
|
+
interface IntrospectOptions {
|
|
677
|
+
/** Dialect-specific schema/catalog. Postgres: schema; MySQL: database; MSSQL: schema. */
|
|
678
|
+
schema?: string;
|
|
679
|
+
includeTables?: string[];
|
|
680
|
+
excludeTables?: string[];
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Strategy interface implemented per dialect to introspect an existing database schema.
|
|
684
|
+
*/
|
|
685
|
+
interface SchemaIntrospector {
|
|
686
|
+
introspect(executor: DbExecutor, options: IntrospectOptions): Promise<DatabaseSchema>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Introspects an existing database schema using the dialect-specific strategy.
|
|
691
|
+
*/
|
|
692
|
+
declare const introspectSchema: (executor: DbExecutor, dialect: DialectName, options?: IntrospectOptions) => Promise<DatabaseSchema>;
|
|
446
693
|
|
|
447
694
|
/**
|
|
448
695
|
* Browser-compatible implementation of AsyncLocalStorage
|
|
@@ -647,6 +894,7 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
647
894
|
clear(): void;
|
|
648
895
|
private get relationKey();
|
|
649
896
|
private hydrateFromCache;
|
|
897
|
+
toJSON(): TChild[];
|
|
650
898
|
}
|
|
651
899
|
|
|
652
900
|
type Rows$1 = Record<string, any>;
|
|
@@ -668,6 +916,7 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
|
|
|
668
916
|
set(data: Partial<TParent> | TParent | null): TParent | null;
|
|
669
917
|
private get relationKey();
|
|
670
918
|
private populateFromHydrationCache;
|
|
919
|
+
toJSON(): TParent | null;
|
|
671
920
|
}
|
|
672
921
|
|
|
673
922
|
type Rows = Record<string, any>[];
|
|
@@ -694,8 +943,9 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
|
|
|
694
943
|
private get relationKey();
|
|
695
944
|
private get targetKey();
|
|
696
945
|
private hydrateFromCache;
|
|
946
|
+
toJSON(): TTarget[];
|
|
697
947
|
}
|
|
698
948
|
|
|
699
949
|
declare function executeHydrated<TTable extends TableDef>(ctx: OrmContext, qb: SelectQueryBuilder<any, TTable>): Promise<Entity<TTable>[]>;
|
|
700
950
|
|
|
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 };
|
|
951
|
+
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 };
|