uql-orm 0.33.0 → 0.34.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/bunSql/bunSqlQuerierPool.js +2 -1
- package/dist/cockroachdb/crdbQuerierPool.js +2 -1
- package/dist/d1/d1QuerierPool.js +2 -1
- package/dist/dialect/abstractDialect.d.ts +27 -3
- package/dist/dialect/abstractDialect.js +34 -4
- package/dist/dialect/abstractSqlDialect.d.ts +27 -1
- package/dist/dialect/abstractSqlDialect.js +74 -36
- package/dist/dialect/mysqlLikeSqlDialect.js +1 -0
- package/dist/dialect/pgLikeSqlDialect.js +1 -0
- package/dist/entity/metadata/definition.js +9 -0
- package/dist/http/handler.js +16 -1
- package/dist/libsql/libsqlQuerierPool.js +2 -1
- package/dist/maria/mariadbQuerierPool.js +2 -1
- package/dist/migrate/builder/migrationBuilder.js +3 -1
- package/dist/migrate/builder/tableBuilder.js +2 -1
- package/dist/migrate/generator/definitionToNode.js +3 -3
- package/dist/migrate/generator/mongoSchemaGenerator.js +7 -6
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +12 -1
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +16 -2
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +7 -1
- package/dist/migrate/introspection/baseSqlIntrospector.js +11 -12
- package/dist/migrate/introspection/mongoIntrospector.js +0 -1
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +1 -0
- package/dist/migrate/introspection/mysqlIntrospector.js +8 -6
- package/dist/migrate/introspection/postgresIntrospector.d.ts +1 -0
- package/dist/migrate/introspection/postgresIntrospector.js +6 -5
- package/dist/migrate/migrator.d.ts +10 -1
- package/dist/migrate/migrator.js +30 -8
- package/dist/migrate/schemaGenerator.d.ts +16 -6
- package/dist/migrate/schemaGenerator.js +53 -24
- package/dist/mongo/mongoDialect.js +5 -4
- package/dist/mongo/mongodbQuerierPool.js +2 -1
- package/dist/mysql/mysql2QuerierPool.js +2 -1
- package/dist/neon/neonQuerierPool.js +2 -1
- package/dist/pglite/pgliteQuerierPool.js +2 -1
- package/dist/postgres/pgQuerierPool.js +2 -1
- package/dist/schema/schemaAST.d.ts +8 -1
- package/dist/schema/schemaAST.js +22 -13
- package/dist/schema/schemaASTBuilder.d.ts +5 -3
- package/dist/schema/schemaASTBuilder.js +24 -31
- package/dist/schema/types.d.ts +10 -3
- package/dist/sqlite/localSqliteQuerierPool.js +2 -1
- package/dist/sqlite/sqliteDialect.js +2 -1
- package/dist/turso/tursoLocalQuerierPool.js +2 -1
- package/dist/turso/tursoQuerierPool.js +2 -1
- package/dist/type/dialect.d.ts +6 -0
- package/dist/type/entity.d.ts +7 -0
- package/dist/type/migration.d.ts +16 -2
- package/dist/type/querier.d.ts +5 -0
- package/dist/util/sql.util.d.ts +17 -0
- package/dist/util/sql.util.js +23 -0
- package/package.json +1 -1
package/dist/type/entity.d.ts
CHANGED
|
@@ -577,6 +577,8 @@ export type EntityIndexMeta = {
|
|
|
577
577
|
export type EntityMeta<E> = {
|
|
578
578
|
readonly entity: Type<E>;
|
|
579
579
|
name?: string;
|
|
580
|
+
/** Set only when the entity named one; unset defers to the pool where it is used. See `AbstractDialect.resolveSchema`. */
|
|
581
|
+
schema?: string;
|
|
580
582
|
id: IdKey<E>;
|
|
581
583
|
softDelete?: FieldKey<E>;
|
|
582
584
|
/** Named, default-on `$where` filters applied to every query unless bypassed. */
|
|
@@ -605,6 +607,11 @@ export type EntityMeta<E> = {
|
|
|
605
607
|
*/
|
|
606
608
|
export type EntityOptions<E = unknown> = {
|
|
607
609
|
readonly name?: string;
|
|
610
|
+
/**
|
|
611
|
+
* The schema (in MySQL terms, database) this table lives in, pinning it whichever pool reads it;
|
|
612
|
+
* unset follows the pool's own. Not in `name`: a dotted `name` is rejected.
|
|
613
|
+
*/
|
|
614
|
+
readonly schema?: string;
|
|
608
615
|
/** Named, default-on `$where` filters (soft-delete is auto-registered from `@Field({ softDelete })`). */
|
|
609
616
|
readonly filters?: Record<string, FilterOptions<E>>;
|
|
610
617
|
/** Scalar fields; use `isId: true` on exactly one field for the primary key. */
|
package/dist/type/migration.d.ts
CHANGED
|
@@ -168,7 +168,13 @@ export interface ForeignKeySchema {
|
|
|
168
168
|
* Represents a difference between current and desired schema
|
|
169
169
|
*/
|
|
170
170
|
export interface SchemaDiff {
|
|
171
|
+
/** Qualified where the table has a schema, since it is also the key the table is found under. */
|
|
171
172
|
readonly tableName: string;
|
|
173
|
+
/**
|
|
174
|
+
* The schema {@link tableName} is in, carried separately for the identifiers that live in it
|
|
175
|
+
* rather than name it: a Postgres index is dropped as `schema.index`, never `schema.table`.
|
|
176
|
+
*/
|
|
177
|
+
readonly schema?: string;
|
|
172
178
|
readonly type: 'create' | 'alter' | 'drop';
|
|
173
179
|
readonly columnsToAdd?: ColumnSchema[];
|
|
174
180
|
readonly columnsToAlter?: {
|
|
@@ -243,9 +249,17 @@ export interface SchemaGenerator {
|
|
|
243
249
|
*/
|
|
244
250
|
diffSchema<E>(entity: Type<E>, currentTable: TableNode | undefined): SchemaDiff | undefined;
|
|
245
251
|
/**
|
|
246
|
-
*
|
|
252
|
+
* The table's key: {@link resolveTableAlias} behind {@link resolveSchema}, which is how a
|
|
253
|
+
* `SchemaAST` stores it and how a diff finds it again.
|
|
254
|
+
*/
|
|
255
|
+
resolveTableName<E>(meta: EntityMeta<E>): string;
|
|
256
|
+
/**
|
|
257
|
+
* The table's own name, unqualified. What a derived index or constraint name is built from, since
|
|
258
|
+
* those are single identifiers.
|
|
247
259
|
*/
|
|
248
|
-
|
|
260
|
+
resolveTableAlias<E>(meta: EntityMeta<E>): string;
|
|
261
|
+
/** The schema the table lives in, `undefined` where nothing named one. */
|
|
262
|
+
resolveSchema<E>(meta: EntityMeta<E>): string | undefined;
|
|
249
263
|
/**
|
|
250
264
|
* Resolve column name using field options and naming strategy
|
|
251
265
|
*/
|
package/dist/type/querier.d.ts
CHANGED
|
@@ -164,5 +164,10 @@ export type ExtraOptions = {
|
|
|
164
164
|
/** Threshold in milliseconds - queries exceeding this are logged as slow. */
|
|
165
165
|
readonly slowQuery?: number;
|
|
166
166
|
readonly namingStrategy?: NamingStrategy;
|
|
167
|
+
/**
|
|
168
|
+
* Default schema (in MySQL terms, database) for entities naming none; unset leaves them
|
|
169
|
+
* unqualified. `@Entity({ schema })` overrides it.
|
|
170
|
+
*/
|
|
171
|
+
readonly schema?: string;
|
|
167
172
|
readonly listeners?: readonly QuerierListener[];
|
|
168
173
|
};
|
package/dist/util/sql.util.d.ts
CHANGED
|
@@ -9,6 +9,23 @@ export declare function unflatObject<T extends object>(row: RawRow, attrsPaths:
|
|
|
9
9
|
export declare function obtainAttrsPaths<T extends object>(row: T): {
|
|
10
10
|
[k: string]: string[];
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* A name behind its namespace, or bare where there is none: the one place the two are joined, so a
|
|
14
|
+
* table's key, its statement operand and its escaped form cannot spell it differently. Never the
|
|
15
|
+
* seed for a derived identifier - an index or constraint name is a single identifier, and
|
|
16
|
+
* `idx_sales.Order_total` is a syntax error.
|
|
17
|
+
*/
|
|
18
|
+
export declare function qualifyName(name: string, schema?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* The name a derived index or constraint gets when nothing named it: `idx_Order_total`.
|
|
21
|
+
*
|
|
22
|
+
* One owner, because it is a rule two layers apply and a third has to match: the entity AST derives
|
|
23
|
+
* it, the DDL generator falls back to it, and a diff compares what the database reports against it.
|
|
24
|
+
* `table` is the table's own name, never qualified - the result is a single identifier.
|
|
25
|
+
*/
|
|
26
|
+
export declare function derivedIndexName(table: string, columns: readonly string[]): string;
|
|
27
|
+
/** The constraint name a foreign key gets when nothing named it: `fk_Order_customerId`. */
|
|
28
|
+
export declare function derivedForeignKeyName(table: string, columns: readonly string[]): string;
|
|
12
29
|
/**
|
|
13
30
|
* Escape a SQL identifier (table name, column name, etc.)
|
|
14
31
|
* @param val the identifier to escape
|
package/dist/util/sql.util.js
CHANGED
|
@@ -48,6 +48,29 @@ export function obtainAttrsPaths(row) {
|
|
|
48
48
|
}
|
|
49
49
|
return paths;
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A name behind its namespace, or bare where there is none: the one place the two are joined, so a
|
|
53
|
+
* table's key, its statement operand and its escaped form cannot spell it differently. Never the
|
|
54
|
+
* seed for a derived identifier - an index or constraint name is a single identifier, and
|
|
55
|
+
* `idx_sales.Order_total` is a syntax error.
|
|
56
|
+
*/
|
|
57
|
+
export function qualifyName(name, schema) {
|
|
58
|
+
return schema ? `${schema}.${name}` : name;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The name a derived index or constraint gets when nothing named it: `idx_Order_total`.
|
|
62
|
+
*
|
|
63
|
+
* One owner, because it is a rule two layers apply and a third has to match: the entity AST derives
|
|
64
|
+
* it, the DDL generator falls back to it, and a diff compares what the database reports against it.
|
|
65
|
+
* `table` is the table's own name, never qualified - the result is a single identifier.
|
|
66
|
+
*/
|
|
67
|
+
export function derivedIndexName(table, columns) {
|
|
68
|
+
return `idx_${table}_${columns.join('_')}`;
|
|
69
|
+
}
|
|
70
|
+
/** The constraint name a foreign key gets when nothing named it: `fk_Order_customerId`. */
|
|
71
|
+
export function derivedForeignKeyName(table, columns) {
|
|
72
|
+
return `fk_${table}_${columns.join('_')}`;
|
|
73
|
+
}
|
|
51
74
|
/**
|
|
52
75
|
* Escape a SQL identifier (table name, column name, etc.)
|
|
53
76
|
* @param val the identifier to escape
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
4
|
"description": "JSON-native TypeScript ORM for Node.js, Bun and Deno. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.34.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|