uql-orm 0.66.0 → 0.67.1
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/dist/browser/querier/httpQuerier.js +1 -8
- package/dist/browser/uql-browser.min.js.map +5 -5
- package/dist/bunSql/bunSql.util.d.ts +2 -6
- package/dist/bunSql/bunSql.util.js +2 -6
- package/dist/bunSql/bunSqlQuerier.d.ts +2 -5
- package/dist/bunSql/bunSqlQuerier.js +2 -5
- package/dist/cockroachdb/cockroachDialect.d.ts +4 -13
- package/dist/cockroachdb/cockroachDialect.js +4 -13
- package/dist/context/context.browser.js +2 -10
- package/dist/context/context.d.ts +4 -17
- package/dist/context/context.js +4 -17
- package/dist/dialect/abstractDialect.d.ts +4 -19
- package/dist/dialect/abstractDialect.js +2 -20
- package/dist/dialect/abstractSqlDialect.d.ts +47 -212
- package/dist/dialect/abstractSqlDialect.js +68 -222
- package/dist/dialect/aliases.d.ts +2 -12
- package/dist/dialect/aliases.js +4 -12
- package/dist/dialect/hydrateColumn.d.ts +2 -6
- package/dist/dialect/hydrateColumn.js +3 -13
- package/dist/dialect/jsonArrayElemMatchUtils.d.ts +1 -7
- package/dist/dialect/jsonArrayElemMatchUtils.js +1 -7
- package/dist/dialect/jsonSql.d.ts +6 -27
- package/dist/dialect/jsonSql.js +6 -27
- package/dist/dialect/mergeSqlDialect.d.ts +4 -22
- package/dist/dialect/mergeSqlDialect.js +4 -22
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +11 -37
- package/dist/dialect/mysqlLikeSqlDialect.js +35 -51
- package/dist/dialect/pgLikeSqlDialect.d.ts +8 -22
- package/dist/dialect/pgLikeSqlDialect.js +36 -39
- package/dist/dialect/queryContext.d.ts +4 -22
- package/dist/dialect/queryContext.js +4 -22
- package/dist/dialect/queryJoins.d.ts +3 -12
- package/dist/dialect/queryJoins.js +3 -12
- package/dist/dialect/vectorCast.d.ts +2 -12
- package/dist/dialect/vectorCast.js +3 -19
- package/dist/dialect/vectorSqlDialect.d.ts +8 -38
- package/dist/dialect/vectorSqlDialect.js +7 -38
- package/dist/entity/decorator/bag.d.ts +6 -19
- package/dist/entity/decorator/bag.js +6 -22
- package/dist/entity/decorator/entity.d.ts +2 -7
- package/dist/entity/decorator/entity.js +2 -7
- package/dist/entity/decorator/members.d.ts +7 -30
- package/dist/entity/decorator/members.js +3 -12
- package/dist/entity/metadata/definition.d.ts +2 -18
- package/dist/entity/metadata/definition.js +6 -28
- package/dist/http/handler.d.ts +2 -14
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/libsql/libsqlDialect.d.ts +1 -8
- package/dist/libsql/libsqlDialect.js +1 -8
- package/dist/maria/mariaDialect.d.ts +3 -5
- package/dist/maria/mariaDialect.js +5 -5
- package/dist/maria/mariadbQuerier.js +2 -2
- package/dist/maria/mariadbQuerierPool.js +1 -6
- package/dist/migrate/builder/migrationBuilder.js +3 -19
- package/dist/migrate/builder/splitSqlStatements.d.ts +1 -14
- package/dist/migrate/builder/splitSqlStatements.js +2 -22
- package/dist/migrate/builder/types.d.ts +2 -15
- package/dist/migrate/cli-config.js +2 -11
- package/dist/migrate/cli.js +2 -7
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -15
- package/dist/migrate/codegen/entityCodeGenerator.js +15 -44
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +1 -8
- package/dist/migrate/codegen/fieldOptionsSource.js +3 -22
- package/dist/migrate/ddl/indexDdl.d.ts +2 -5
- package/dist/migrate/ddl/indexDdl.js +2 -5
- package/dist/migrate/ddl/pgIndexDdl.d.ts +3 -13
- package/dist/migrate/ddl/pgIndexDdl.js +3 -13
- package/dist/migrate/generator/definitionToNode.d.ts +2 -9
- package/dist/migrate/generator/definitionToNode.js +3 -17
- package/dist/migrate/generator/indexNodeToSchema.d.ts +2 -3
- package/dist/migrate/generator/indexNodeToSchema.js +2 -3
- package/dist/migrate/generator/mongoCommand.d.ts +1 -8
- package/dist/migrate/generator/mongoSchemaGenerator.d.ts +1 -8
- package/dist/migrate/generator/mongoSchemaGenerator.js +1 -8
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +6 -26
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +9 -41
- package/dist/migrate/introspection/baseSqlIntrospector.js +0 -1
- package/dist/migrate/introspection/mongoIntrospector.d.ts +3 -1
- package/dist/migrate/introspection/mongoIntrospector.js +48 -46
- package/dist/migrate/introspection/mssqlIntrospector.d.ts +4 -4
- package/dist/migrate/introspection/mssqlIntrospector.js +18 -27
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +7 -2
- package/dist/migrate/introspection/mysqlIntrospector.js +16 -14
- package/dist/migrate/introspection/postgresIntrospector.d.ts +24 -9
- package/dist/migrate/introspection/postgresIntrospector.js +68 -59
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +1 -1
- package/dist/migrate/introspection/sqliteIntrospector.js +8 -10
- package/dist/migrate/migrator.d.ts +9 -53
- package/dist/migrate/migrator.js +32 -65
- package/dist/migrate/schemaGenerator.d.ts +16 -66
- package/dist/migrate/schemaGenerator.js +21 -74
- package/dist/mongo/mongoDialect.d.ts +21 -53
- package/dist/mongo/mongoDialect.js +25 -70
- package/dist/mongo/mongodbQuerier.d.ts +5 -8
- package/dist/mongo/mongodbQuerier.js +31 -65
- package/dist/mssql/mssqlDialect.d.ts +8 -34
- package/dist/mssql/mssqlDialect.js +37 -51
- package/dist/mssql/mssqlQuerier.d.ts +37 -4
- package/dist/mssql/mssqlQuerier.js +2 -2
- package/dist/mssql/mssqlWireTypes.d.ts +2 -14
- package/dist/mssql/mssqlWireTypes.js +2 -14
- package/dist/nestjs/uqlModule.js +2 -7
- package/dist/pglite/pgliteQuerier.d.ts +1 -9
- package/dist/pglite/pgliteQuerierPool.d.ts +4 -26
- package/dist/pglite/pgliteQuerierPool.js +3 -18
- package/dist/postgres/abstractPgQuerierPool.d.ts +1 -8
- package/dist/postgres/abstractPgQuerierPool.js +1 -8
- package/dist/postgres/pgNumericTypes.d.ts +3 -26
- package/dist/postgres/pgNumericTypes.js +3 -26
- package/dist/postgres/postgresDialect.d.ts +4 -10
- package/dist/postgres/postgresDialect.js +4 -10
- package/dist/querier/abstractQuerier.d.ts +35 -103
- package/dist/querier/abstractQuerier.js +105 -201
- package/dist/querier/abstractSharedHandleQuerierPool.d.ts +3 -17
- package/dist/querier/abstractSharedHandleQuerierPool.js +3 -17
- package/dist/querier/abstractSqlQuerier.d.ts +15 -36
- package/dist/querier/abstractSqlQuerier.js +49 -131
- package/dist/schema/canonicalType.d.ts +3 -21
- package/dist/schema/canonicalType.js +22 -67
- package/dist/schema/dependencyGraph.d.ts +2 -8
- package/dist/schema/dependencyGraph.js +2 -32
- package/dist/schema/index.d.ts +1 -25
- package/dist/schema/index.js +0 -26
- package/dist/schema/indexColumns.d.ts +1 -8
- package/dist/schema/indexColumns.js +1 -8
- package/dist/schema/indexDifferences.d.ts +7 -40
- package/dist/schema/indexDifferences.js +6 -31
- package/dist/schema/schemaAST.d.ts +8 -175
- package/dist/schema/schemaAST.js +13 -365
- package/dist/schema/schemaASTBuilder.d.ts +2 -24
- package/dist/schema/schemaASTBuilder.js +2 -30
- package/dist/schema/schemaASTDiffer.d.ts +6 -46
- package/dist/schema/schemaASTDiffer.js +8 -56
- package/dist/schema/types.d.ts +5 -61
- package/dist/schema/types.js +3 -6
- package/dist/sqlite/abstractSqliteQuerier.d.ts +1 -8
- package/dist/sqlite/localSqliteQuerierPool.d.ts +1 -7
- package/dist/sqlite/localSqliteQuerierPool.js +1 -7
- package/dist/sqlite/nodeSqliteQuerierPool.d.ts +2 -7
- package/dist/sqlite/nodeSqliteQuerierPool.js +2 -7
- package/dist/sqlite/sqliteDialect.d.ts +5 -20
- package/dist/sqlite/sqliteDialect.js +29 -35
- package/dist/turso/tursoDialect.d.ts +4 -6
- package/dist/turso/tursoDialect.js +4 -6
- package/dist/turso/tursoLocalQuerierPool.d.ts +1 -7
- package/dist/turso/tursoLocalQuerierPool.js +1 -7
- package/dist/turso/tursoQuerierPool.d.ts +2 -6
- package/dist/turso/tursoQuerierPool.js +2 -6
- package/dist/turso/tursoSessionQuerier.d.ts +1 -7
- package/dist/turso/tursoSessionQuerier.js +1 -7
- package/dist/type/dialect.d.ts +42 -94
- package/dist/type/dialect.js +3 -13
- package/dist/type/entity.d.ts +163 -534
- package/dist/type/entity.js +26 -9
- package/dist/type/logger.d.ts +2 -14
- package/dist/type/migration.d.ts +9 -38
- package/dist/type/querier.d.ts +9 -28
- package/dist/type/querierPool.d.ts +4 -26
- package/dist/type/query.d.ts +19 -73
- package/dist/type/query.js +2 -7
- package/dist/type/queryAggregate.d.ts +18 -98
- package/dist/type/queryRaw.d.ts +1 -8
- package/dist/type/queryRaw.js +1 -8
- package/dist/type/queryWhere.d.ts +13 -61
- package/dist/type/universalQuerier.d.ts +18 -105
- package/dist/type/utility.d.ts +12 -24
- package/dist/type/vector.d.ts +8 -38
- package/dist/type/vector.js +1 -1
- package/dist/type/wire.d.ts +2 -5
- package/dist/util/dialect.util.d.ts +9 -27
- package/dist/util/dialect.util.js +10 -27
- package/dist/util/field.util.d.ts +2 -31
- package/dist/util/field.util.js +3 -43
- package/dist/util/fieldOption.util.d.ts +7 -15
- package/dist/util/fieldOption.util.js +1 -1
- package/dist/util/filters.util.d.ts +2 -5
- package/dist/util/filters.util.js +2 -5
- package/dist/util/logger.d.ts +2 -6
- package/dist/util/logger.js +2 -6
- package/dist/util/object.util.d.ts +2 -6
- package/dist/util/object.util.js +1 -5
- package/dist/util/raw.d.ts +3 -23
- package/dist/util/relationQuery.util.d.ts +3 -14
- package/dist/util/relationQuery.util.js +3 -14
- package/dist/util/rowKey.util.d.ts +2 -10
- package/dist/util/rowKey.util.js +2 -10
- package/dist/util/sql.util.d.ts +6 -37
- package/dist/util/sql.util.js +13 -73
- package/dist/util/sqlLiteral.d.ts +2 -13
- package/dist/util/sqlLiteral.js +8 -13
- package/dist/util/string.util.js +0 -2
- package/package.json +4 -4
|
@@ -1,51 +1,18 @@
|
|
|
1
1
|
import type { IndexNode } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* What an introspector can report about an index, and so all that diffing may compare. Anything it
|
|
4
|
-
* cannot report is skipped: the entity declares it, the database never mentions it, and no migration
|
|
5
|
-
* could ever make the two agree.
|
|
6
|
-
*
|
|
7
|
-
* Deliberately separate from the dialect's `IndexFeature`, which says what an engine can *emit* and
|
|
8
|
-
* rejects outright. The two look alike and are not: Postgres emits an expression index and reads one
|
|
9
|
-
* back, MySQL emits one it cannot describe afterwards.
|
|
10
|
-
*/
|
|
2
|
+
/** What an introspector reports about an index, and so all a diff may compare; apart from `IndexFeature`, what an engine emits. */
|
|
11
3
|
export type IndexFacet = 'order' | 'nulls' | 'opsClass' | 'accessMethod' | 'include';
|
|
12
4
|
/**
|
|
13
|
-
* Whether the table
|
|
14
|
-
*
|
|
15
|
-
* Its shape, never its name: the table's indexes were named by whoever created them, so an index
|
|
16
|
-
* that is already there must not be created a second time under a name we happen to prefer. A
|
|
17
|
-
* derived name is no handle at all - the convention can change, an engine silently truncates one
|
|
18
|
-
* past its identifier limit, and SQLite reports names it made up.
|
|
19
|
-
*
|
|
20
|
-
* Uniqueness counts, because a unique index and a plain one over the same columns enforce different
|
|
21
|
-
* things and no engine can alter one into the other. An index over an expression or a JSON path has
|
|
22
|
-
* no comparable columns - engines reprint SQL text from their parse tree, the same reason
|
|
23
|
-
* {@link describeIndexDifferences} leaves those entries alone - so it falls back to its name.
|
|
5
|
+
* Whether the table has this index already, by shape rather than name, uniqueness included. An index
|
|
6
|
+
* over an expression, whose text the engine reprints, falls back to its name.
|
|
24
7
|
*/
|
|
25
8
|
export declare function indexSignature(index: Pick<IndexNode, 'name' | 'entries' | 'unique'>): string;
|
|
26
9
|
/**
|
|
27
|
-
* A constraint name without its kind marker
|
|
28
|
-
*
|
|
29
|
-
* What pairs two sides of a *report*: an index whose uniqueness or columns changed is one index that
|
|
30
|
-
* differs, not one dropped and another created, and only a handle independent of its shape can say
|
|
31
|
-
* so. Stripping the marker is what lets `idx_User_email`, named before the convention moved it to
|
|
32
|
-
* the end, recognise the `User__email_idx` derived for it now, so upgrading reports no drift.
|
|
33
|
-
*
|
|
34
|
-
* Exactly one marker, and the trailing one first. Stripping both ends would eat a leading marker
|
|
35
|
-
* that belongs to the *table* - an index over `pk_registry` is not a primary key - leaving it unable
|
|
36
|
-
* to pair with its own older name. The separator is levelled last, since only one convention doubles
|
|
37
|
-
* it.
|
|
10
|
+
* A constraint name without its kind marker, pairing an index with its older spelling
|
|
11
|
+
* (`idx_User_email` with `User__email_idx`). Only one marker, the trailing one first.
|
|
38
12
|
*/
|
|
39
13
|
export declare function indexNameStem(name: string): string;
|
|
40
14
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Only what both sides can state *structurally* is compared. SQL text is not: a database reprints an
|
|
44
|
-
* expression and a predicate from its parse tree, so `status IN ('a','b')` reads back as
|
|
45
|
-
* `status = ANY (ARRAY['a'::text, 'b'::text])`, `LIKE` as `~~`, and a date literal with its time zone
|
|
46
|
-
* spelled out. Folding that back needs a SQL parser, and every near-miss reports drift that no
|
|
47
|
-
* migration can settle. So a partial index's predicate is never compared, and an index over an
|
|
48
|
-
* expression - a `raw()` one, or a JSON path, which the engines report as an expression too - has
|
|
49
|
-
* its entries left alone while the rest of it still compares.
|
|
15
|
+
* What two indexes differ by, comparing only what both sides state structurally: an expression, a JSON
|
|
16
|
+
* path or a predicate is reprinted by the engine, so never compared.
|
|
50
17
|
*/
|
|
51
18
|
export declare function describeIndexDifferences(source: IndexNode, target: IndexNode, facets: ReadonlySet<IndexFacet>): string[];
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Whether the table
|
|
3
|
-
*
|
|
4
|
-
* Its shape, never its name: the table's indexes were named by whoever created them, so an index
|
|
5
|
-
* that is already there must not be created a second time under a name we happen to prefer. A
|
|
6
|
-
* derived name is no handle at all - the convention can change, an engine silently truncates one
|
|
7
|
-
* past its identifier limit, and SQLite reports names it made up.
|
|
8
|
-
*
|
|
9
|
-
* Uniqueness counts, because a unique index and a plain one over the same columns enforce different
|
|
10
|
-
* things and no engine can alter one into the other. An index over an expression or a JSON path has
|
|
11
|
-
* no comparable columns - engines reprint SQL text from their parse tree, the same reason
|
|
12
|
-
* {@link describeIndexDifferences} leaves those entries alone - so it falls back to its name.
|
|
2
|
+
* Whether the table has this index already, by shape rather than name, uniqueness included. An index
|
|
3
|
+
* over an expression, whose text the engine reprints, falls back to its name.
|
|
13
4
|
*/
|
|
14
5
|
export function indexSignature(index) {
|
|
15
6
|
const comparable = !index.entries.some((entry) => entry.expression || entry.jsonPath || entry.jsonArray);
|
|
@@ -19,17 +10,8 @@ export function indexSignature(index) {
|
|
|
19
10
|
return `${index.unique ? 'unique' : 'plain'}(${identity})`;
|
|
20
11
|
}
|
|
21
12
|
/**
|
|
22
|
-
* A constraint name without its kind marker
|
|
23
|
-
*
|
|
24
|
-
* What pairs two sides of a *report*: an index whose uniqueness or columns changed is one index that
|
|
25
|
-
* differs, not one dropped and another created, and only a handle independent of its shape can say
|
|
26
|
-
* so. Stripping the marker is what lets `idx_User_email`, named before the convention moved it to
|
|
27
|
-
* the end, recognise the `User__email_idx` derived for it now, so upgrading reports no drift.
|
|
28
|
-
*
|
|
29
|
-
* Exactly one marker, and the trailing one first. Stripping both ends would eat a leading marker
|
|
30
|
-
* that belongs to the *table* - an index over `pk_registry` is not a primary key - leaving it unable
|
|
31
|
-
* to pair with its own older name. The separator is levelled last, since only one convention doubles
|
|
32
|
-
* it.
|
|
13
|
+
* A constraint name without its kind marker, pairing an index with its older spelling
|
|
14
|
+
* (`idx_User_email` with `User__email_idx`). Only one marker, the trailing one first.
|
|
33
15
|
*/
|
|
34
16
|
export function indexNameStem(name) {
|
|
35
17
|
const withoutSuffix = name.replace(KIND_SUFFIX, '');
|
|
@@ -45,15 +27,8 @@ const KIND_SUFFIX = /_(?:idx|fk|ck|pk|uk|uq)$/i;
|
|
|
45
27
|
*/
|
|
46
28
|
const KIND_PREFIX = /^(?:idx|fk|ck|pk|uk|uq)_/i;
|
|
47
29
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* Only what both sides can state *structurally* is compared. SQL text is not: a database reprints an
|
|
51
|
-
* expression and a predicate from its parse tree, so `status IN ('a','b')` reads back as
|
|
52
|
-
* `status = ANY (ARRAY['a'::text, 'b'::text])`, `LIKE` as `~~`, and a date literal with its time zone
|
|
53
|
-
* spelled out. Folding that back needs a SQL parser, and every near-miss reports drift that no
|
|
54
|
-
* migration can settle. So a partial index's predicate is never compared, and an index over an
|
|
55
|
-
* expression - a `raw()` one, or a JSON path, which the engines report as an expression too - has
|
|
56
|
-
* its entries left alone while the rest of it still compares.
|
|
30
|
+
* What two indexes differ by, comparing only what both sides state structurally: an expression, a JSON
|
|
31
|
+
* path or a predicate is reprinted by the engine, so never compared.
|
|
57
32
|
*/
|
|
58
33
|
export function describeIndexDifferences(source, target, facets) {
|
|
59
34
|
const differences = [];
|
|
@@ -1,187 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* The main class for working with schema graphs.
|
|
5
|
-
* Provides graph operations like navigation, validation, and topological sorting.
|
|
6
|
-
*/
|
|
7
|
-
import type { ColumnNode, IndexNode, SchemaAST as ISchemaAST, RelationshipNode, RelationshipType, TableNode, ValidationError } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* A table node with its collections empty, ready to be filled. Six places build one, and the fields
|
|
10
|
-
* that are pure boilerplate are exactly the ones a new field gets forgotten in: {@link TableNode.schema}
|
|
11
|
-
* was added and `SchemaAST.clone` kept rebuilding nodes without it.
|
|
12
|
-
*/
|
|
1
|
+
import type { IndexNode, RelationshipNode, TableNode } from './types.js';
|
|
2
|
+
/** A table node with its collections empty, ready to be filled. */
|
|
13
3
|
export declare function createTableNode(name: string, schema?: string, comment?: string): TableNode;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* Enables:
|
|
18
|
-
* - Graph navigation (dependencies, dependents)
|
|
19
|
-
* - Circular dependency detection
|
|
20
|
-
* - Topological sorting for correct DDL order
|
|
21
|
-
* - Smart relation inference
|
|
22
|
-
* - Schema validation
|
|
23
|
-
*/
|
|
24
|
-
export declare class SchemaAST implements ISchemaAST {
|
|
4
|
+
/** A database schema as a graph: tables, the foreign keys between them, and their indexes. */
|
|
5
|
+
export declare class SchemaAST {
|
|
25
6
|
readonly tables: Map<string, TableNode>;
|
|
26
7
|
readonly relationships: RelationshipNode[];
|
|
27
8
|
readonly indexes: IndexNode[];
|
|
28
|
-
/**
|
|
29
|
-
* Get a table by the name it is keyed under: schema-qualified where it has one, so two tables of
|
|
30
|
-
* the same name in different schemas stay distinct. Build the key with `qualifyName`.
|
|
31
|
-
*/
|
|
9
|
+
/** A table by the key it is stored under: schema-qualified where it has one (see `qualifyName`). */
|
|
32
10
|
getTable(name: string): TableNode | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Add a table to the schema.
|
|
35
|
-
*/
|
|
36
11
|
addTable(table: TableNode): void;
|
|
37
|
-
/**
|
|
38
|
-
* Remove a table from the schema.
|
|
39
|
-
*/
|
|
40
|
-
removeTable(name: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Get all table nodes.
|
|
43
|
-
*/
|
|
44
12
|
getTables(): TableNode[];
|
|
45
|
-
/**
|
|
46
|
-
* Get all table names.
|
|
47
|
-
*/
|
|
48
|
-
getTableNames(): string[];
|
|
49
|
-
/**
|
|
50
|
-
* Get all tables that depend on this table (have FKs pointing to it).
|
|
51
|
-
* These are tables that reference this table's primary key.
|
|
52
|
-
*/
|
|
53
|
-
getDependentTables(table: TableNode): TableNode[];
|
|
54
|
-
/**
|
|
55
|
-
* Get all tables this table depends on (has FKs to).
|
|
56
|
-
* These are tables that this table references.
|
|
57
|
-
*/
|
|
58
|
-
getDependencies(table: TableNode): TableNode[];
|
|
59
|
-
/**
|
|
60
|
-
* Get the relationship between two tables (if any).
|
|
61
|
-
*/
|
|
62
|
-
getRelationship(from: TableNode, to: TableNode): RelationshipNode | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Get all relationships for a table.
|
|
65
|
-
*/
|
|
66
|
-
getTableRelationships(table: TableNode): RelationshipNode[];
|
|
67
|
-
/**
|
|
68
|
-
* Get the column that a foreign key column references.
|
|
69
|
-
*/
|
|
70
|
-
getReferencedColumn(fkColumn: ColumnNode): ColumnNode | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Detect circular foreign key dependencies.
|
|
73
|
-
* Returns arrays of tables that form cycles.
|
|
74
|
-
*/
|
|
75
|
-
detectCircularDependencies(): TableNode[][];
|
|
76
|
-
/**
|
|
77
|
-
* Check if there are any circular dependencies.
|
|
78
|
-
*/
|
|
79
|
-
hasCircularDependencies(): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Get tables in correct order for CREATE (dependencies first).
|
|
82
|
-
* Tables with no dependencies come first, then tables that depend on them, etc.
|
|
83
|
-
*/
|
|
13
|
+
/** Tables in `CREATE` order, each after the tables it references. */
|
|
84
14
|
getCreateOrder(): TableNode[];
|
|
85
|
-
/**
|
|
86
|
-
* Get tables in correct order for DROP (dependents first).
|
|
87
|
-
* Tables that depend on others come first, then the tables they depend on.
|
|
88
|
-
*/
|
|
15
|
+
/** Tables in `DROP` order, each before the tables it references. */
|
|
89
16
|
getDropOrder(): TableNode[];
|
|
90
|
-
/**
|
|
91
|
-
* Validate schema integrity.
|
|
92
|
-
* Checks for:
|
|
93
|
-
* - Missing FK targets
|
|
94
|
-
* - Circular dependencies
|
|
95
|
-
* - Orphan columns
|
|
96
|
-
* - Duplicate indexes
|
|
97
|
-
*/
|
|
98
|
-
validate(): ValidationError[];
|
|
99
|
-
/**
|
|
100
|
-
* Check if the schema is valid (no validation errors).
|
|
101
|
-
*/
|
|
102
|
-
isValid(): boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Check if a table looks like a junction table (ManyToMany through).
|
|
105
|
-
* Junction tables typically have:
|
|
106
|
-
* - Exactly 2 foreign keys
|
|
107
|
-
* - Few other columns (id, maybe timestamps)
|
|
108
|
-
* - Primary key might be composite of the FKs
|
|
109
|
-
*/
|
|
110
|
-
isJunctionTable(table: TableNode): boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Infer relation type from schema structure.
|
|
113
|
-
*/
|
|
114
|
-
inferRelationType(rel: RelationshipNode): RelationshipType;
|
|
115
|
-
/**
|
|
116
|
-
* Get the inverse relation type.
|
|
117
|
-
*/
|
|
118
|
-
getInverseRelationType(type: RelationshipType): RelationshipType;
|
|
119
|
-
/**
|
|
120
|
-
* Add an index to the schema.
|
|
121
|
-
*/
|
|
122
17
|
addIndex(index: IndexNode): void;
|
|
123
|
-
/**
|
|
124
|
-
* Get all indexes for a table.
|
|
125
|
-
*/
|
|
126
|
-
getTableIndexes(tableName: string): IndexNode[];
|
|
127
|
-
/**
|
|
128
|
-
* Find an index by name.
|
|
129
|
-
*/
|
|
130
|
-
getIndex(name: string): IndexNode | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Add a relationship to the schema.
|
|
133
|
-
*/
|
|
18
|
+
/** Adds a foreign key, linking it from both tables and both column sets. */
|
|
134
19
|
addRelationship(rel: RelationshipNode): void;
|
|
135
|
-
/**
|
|
136
|
-
* Remove a relationship from the schema.
|
|
137
|
-
*/
|
|
138
|
-
removeRelationship(name: string): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Create a deep clone of this schema.
|
|
141
|
-
*/
|
|
142
|
-
clone(): SchemaAST;
|
|
143
|
-
/**
|
|
144
|
-
* Get statistics about the schema.
|
|
145
|
-
*/
|
|
146
|
-
getStats(): {
|
|
147
|
-
tableCount: number;
|
|
148
|
-
columnCount: number;
|
|
149
|
-
relationshipCount: number;
|
|
150
|
-
indexCount: number;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* The schema as a plain object, for serialization and debugging. The graph links are what is left
|
|
154
|
-
* out - they are cycles, and nothing else is: listing the fields to keep instead dropped every
|
|
155
|
-
* option a column had gained since, `defaultValue` and `enum` included.
|
|
156
|
-
*/
|
|
157
|
-
toJSON(): {
|
|
158
|
-
tables: {
|
|
159
|
-
name: string;
|
|
160
|
-
columns: {
|
|
161
|
-
name: string;
|
|
162
|
-
type: import("./types.js").CanonicalType;
|
|
163
|
-
nullable: boolean;
|
|
164
|
-
defaultValue?: unknown;
|
|
165
|
-
isPrimaryKey: boolean;
|
|
166
|
-
isAutoIncrement: boolean;
|
|
167
|
-
isUnique: boolean;
|
|
168
|
-
enum?: import("./types.js").EnumValues;
|
|
169
|
-
generatedAs?: string;
|
|
170
|
-
comment?: string;
|
|
171
|
-
}[];
|
|
172
|
-
indexes: {
|
|
173
|
-
name: string;
|
|
174
|
-
columns: string[];
|
|
175
|
-
unique: boolean;
|
|
176
|
-
}[];
|
|
177
|
-
}[];
|
|
178
|
-
relationships: {
|
|
179
|
-
name: string;
|
|
180
|
-
type: RelationshipType;
|
|
181
|
-
from: string;
|
|
182
|
-
to: string;
|
|
183
|
-
onDelete: import("./types.js").ForeignKeyAction | undefined;
|
|
184
|
-
onUpdate: import("./types.js").ForeignKeyAction | undefined;
|
|
185
|
-
}[];
|
|
186
|
-
};
|
|
187
20
|
}
|