uql-orm 0.89.0 → 0.91.0
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 +6 -6
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +3 -3
- package/dist/entity/decorator/members.d.ts +3 -3
- package/dist/entity/decorator/members.js +1 -1
- package/dist/migrate/acquireQuerierForMigrations.d.ts +3 -3
- package/dist/migrate/acquireQuerierForMigrations.js +3 -6
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +15 -4
- package/dist/migrate/codegen/entityCodeGenerator.js +84 -47
- package/dist/migrate/codegen/entityTypes.js +37 -6
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +4 -2
- package/dist/migrate/codegen/fieldOptionsSource.js +20 -8
- package/dist/migrate/codegen/migrationFile.d.ts +4 -0
- package/dist/migrate/codegen/migrationFile.js +4 -2
- package/dist/migrate/index.d.ts +1 -2
- package/dist/migrate/index.js +0 -2
- package/dist/migrate/introspection/index.d.ts +0 -1
- package/dist/migrate/introspection/index.js +0 -1
- package/dist/migrate/introspection/registry.js +1 -1
- package/dist/migrate/migrationTarget.js +6 -5
- package/dist/mongo/index.d.ts +4 -1
- package/dist/mongo/index.js +4 -1
- package/dist/{migrate/generator → mongo}/mongoCommand.js +1 -1
- package/dist/{migrate/introspection → mongo}/mongoIntrospector.d.ts +3 -3
- package/dist/{migrate/introspection → mongo}/mongoIntrospector.js +4 -4
- package/dist/{migrate/storage/mongoStorage.d.ts → mongo/mongoMigrationStorage.d.ts} +2 -1
- package/dist/{migrate/storage/mongoStorage.js → mongo/mongoMigrationStorage.js} +2 -2
- package/dist/mongo/mongoQuerier.d.ts +18 -0
- package/dist/mongo/mongoQuerier.js +13 -0
- package/dist/{migrate/generator → mongo}/mongoSchemaGenerator.d.ts +4 -4
- package/dist/{migrate/generator → mongo}/mongoSchemaGenerator.js +14 -14
- package/dist/mongo/mongodbQuerier.d.ts +2 -1
- package/dist/type/entity.d.ts +42 -11
- package/dist/type/migratorDialect.d.ts +8 -3
- package/dist/type/querier.d.ts +0 -15
- package/dist/type/querier.js +0 -7
- package/dist/type/queryRaw.d.ts +5 -3
- package/dist/type/queryRaw.js +2 -0
- package/dist/type/utility.d.ts +9 -3
- package/dist/util/dialect.util.d.ts +2 -10
- package/package.json +6 -6
- package/skills/uql-orm/SKILL.md +4 -3
- /package/dist/{migrate/generator → mongo}/mongoCommand.d.ts +0 -0
package/dist/type/queryRaw.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export type QueryRawFn = (opts: QueryRawRenderOptions) => unknown;
|
|
|
33
33
|
export declare const RAW_VALUE: unique symbol;
|
|
34
34
|
export declare const RAW_ALIAS: unique symbol;
|
|
35
35
|
export declare const RAW_TEXT: unique symbol;
|
|
36
|
+
/** Keys the phantom a ref or an aggregate carries its value type in, which no value ever fills. */
|
|
37
|
+
export declare const RAW_VALUE_TYPE: unique symbol;
|
|
36
38
|
export declare class QueryRaw {
|
|
37
39
|
readonly [RAW_VALUE]: QueryRawFn;
|
|
38
40
|
readonly [RAW_ALIAS]?: string;
|
|
@@ -55,7 +57,7 @@ export declare class QueryRaw {
|
|
|
55
57
|
*/
|
|
56
58
|
export declare class ColumnRef<K extends string = string, V = unknown> extends QueryRaw {
|
|
57
59
|
readonly key: K;
|
|
58
|
-
readonly
|
|
60
|
+
readonly [RAW_VALUE_TYPE]?: V;
|
|
59
61
|
constructor(key: K, value: QueryRawFn);
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
@@ -63,7 +65,7 @@ export declare class ColumnRef<K extends string = string, V = unknown> extends Q
|
|
|
63
65
|
* holding one, nullability aside. `Raw` is what the transport carries, so the wire's `never` stays one.
|
|
64
66
|
*/
|
|
65
67
|
export type RawFor<Raw, V> = Raw & {
|
|
66
|
-
readonly
|
|
68
|
+
readonly [RAW_VALUE_TYPE]?: V | null;
|
|
67
69
|
};
|
|
68
70
|
/**
|
|
69
71
|
* A relation aggregate as SQL, read off a `computed` field's refs: `(user) => user.resources.count()`.
|
|
@@ -77,7 +79,7 @@ export type RawFor<Raw, V> = Raw & {
|
|
|
77
79
|
export declare class RelationAggregate<V = unknown, Storable extends boolean = boolean> extends QueryRaw {
|
|
78
80
|
/** What it reads, kept beside the SQL so a read decodes the value the way the target's field does. */
|
|
79
81
|
readonly spec: RelationAggregateSpec;
|
|
80
|
-
readonly
|
|
82
|
+
readonly [RAW_VALUE_TYPE]?: V;
|
|
81
83
|
private readonly __storable;
|
|
82
84
|
constructor(
|
|
83
85
|
/** What it reads, kept beside the SQL so a read decodes the value the way the target's field does. */
|
package/dist/type/queryRaw.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export const RAW_VALUE = Symbol('rawValue');
|
|
2
2
|
export const RAW_ALIAS = Symbol('rawAlias');
|
|
3
3
|
export const RAW_TEXT = Symbol('rawText');
|
|
4
|
+
/** Keys the phantom a ref or an aggregate carries its value type in, which no value ever fills. */
|
|
5
|
+
export const RAW_VALUE_TYPE = Symbol('rawValueType');
|
|
4
6
|
export class QueryRaw {
|
|
5
7
|
[RAW_VALUE];
|
|
6
8
|
[RAW_ALIAS];
|
package/dist/type/utility.d.ts
CHANGED
|
@@ -20,9 +20,14 @@ export type PrimaryKey = string | number | bigint;
|
|
|
20
20
|
* Brands a JSON field, `settings?: Json<{ isArchived?: boolean }>`, so it reads as a field rather than a
|
|
21
21
|
* relation; `Json<T>[]` is a list of documents.
|
|
22
22
|
*/
|
|
23
|
-
export type Json<T = unknown> = T &
|
|
24
|
-
|
|
25
|
-
}
|
|
23
|
+
export type Json<T = unknown> = T & JsonBrand;
|
|
24
|
+
declare const json: unique symbol;
|
|
25
|
+
/** The marker {@link Json} adds: a symbol key, so no string key, path or autocomplete shows it. */
|
|
26
|
+
export interface JsonBrand {
|
|
27
|
+
readonly [json]?: never;
|
|
28
|
+
}
|
|
29
|
+
/** Whether `T` carries the {@link Json} brand: a primitive matches `Json<infer P>` too, so the key is what tells. */
|
|
30
|
+
export type IsJson<T> = typeof json extends keyof T ? true : false;
|
|
26
31
|
export type ExpandScalar<T> = T extends Date ? Date | string : T;
|
|
27
32
|
/**
|
|
28
33
|
* A raw database result row before entity mapping.
|
|
@@ -75,3 +80,4 @@ export type Unpacked<T> = T extends readonly (infer U)[] ? U : T extends (...arg
|
|
|
75
80
|
* each is load-bearing for.
|
|
76
81
|
*/
|
|
77
82
|
export type IsMany<V> = [NonNullable<V>] extends [readonly unknown[]] ? true : false;
|
|
83
|
+
export {};
|
|
@@ -14,20 +14,12 @@ export declare function insertShapeOf<E>(meta: EntityMeta<E>, record: EntityData
|
|
|
14
14
|
* whether or not it was filled yet. A record missing one writes its default.
|
|
15
15
|
*/
|
|
16
16
|
export declare function getInsertFieldKeys<E>(meta: EntityMeta<E>, payloads: EntityData<E>[]): FieldKey<E>[];
|
|
17
|
-
export declare function getFieldCallbackValue(val: OnFieldCallback): string | number | bigint | boolean | Date | QueryRaw | readonly
|
|
18
|
-
readonly __json?: never;
|
|
19
|
-
}[] | readonly number[] | Uint8Array<ArrayBufferLike> | {
|
|
20
|
-
readonly __json?: never;
|
|
21
|
-
};
|
|
17
|
+
export declare function getFieldCallbackValue(val: OnFieldCallback): string | number | bigint | boolean | Date | import("../type/utility.js").JsonBrand | QueryRaw | readonly import("../type/utility.js").JsonBrand[] | readonly number[] | Uint8Array<ArrayBufferLike>;
|
|
22
18
|
/**
|
|
23
19
|
* Resolves the value stamped on the soft-delete field when deleting a row.
|
|
24
20
|
* `true` stamps the current timestamp (`new Date()`); any other marker is an {@link OnFieldCallback}.
|
|
25
21
|
*/
|
|
26
|
-
export declare function getSoftDeleteValue(field: FieldOptions): string | number | bigint | boolean | Date | QueryRaw | readonly
|
|
27
|
-
readonly __json?: never;
|
|
28
|
-
}[] | readonly number[] | Uint8Array<ArrayBufferLike> | {
|
|
29
|
-
readonly __json?: never;
|
|
30
|
-
};
|
|
22
|
+
export declare function getSoftDeleteValue(field: FieldOptions): string | number | bigint | boolean | Date | import("../type/utility.js").JsonBrand | QueryRaw | readonly import("../type/utility.js").JsonBrand[] | readonly number[] | Uint8Array<ArrayBufferLike>;
|
|
31
23
|
/** Fills each field `callbackKey` generates on `payload` in place, where the caller left it unset. */
|
|
32
24
|
export declare function fillOnFields<E, R extends EntityData<E> | UpdatePayload<E>>(meta: EntityMeta<E>, payload: R | R[], callbackKey: CallbackKey): R[];
|
|
33
25
|
/**
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
4
|
"description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Deno, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.91.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
|
@@ -136,9 +136,9 @@
|
|
|
136
136
|
"@electric-sql/pglite-pgvector": "0.0.9",
|
|
137
137
|
"@libsql/client": "^0.18.0",
|
|
138
138
|
"@neondatabase/serverless": "^1.1.0",
|
|
139
|
-
"@nestjs/common": "^12.1.
|
|
140
|
-
"@nestjs/core": "^12.1.
|
|
141
|
-
"@nestjs/testing": "^12.1.
|
|
139
|
+
"@nestjs/common": "^12.1.1",
|
|
140
|
+
"@nestjs/core": "^12.1.1",
|
|
141
|
+
"@nestjs/testing": "^12.1.1",
|
|
142
142
|
"@tursodatabase/database": "^0.7.2",
|
|
143
143
|
"@tursodatabase/serverless": "^1.4.0",
|
|
144
144
|
"@types/better-sqlite3": "^9.6.0",
|
|
@@ -149,14 +149,14 @@
|
|
|
149
149
|
"better-sqlite3": "^13.0.3",
|
|
150
150
|
"express": "^5.2.1",
|
|
151
151
|
"mariadb": "^3.5.4",
|
|
152
|
-
"mongodb": "^7.
|
|
152
|
+
"mongodb": "^7.7.0",
|
|
153
153
|
"mssql": "^12",
|
|
154
154
|
"mysql2": "^3.24.4",
|
|
155
155
|
"pg": "^8.23.0",
|
|
156
156
|
"pg-query-stream": "^4.17.0",
|
|
157
157
|
"rxjs": "^7.8.2",
|
|
158
158
|
"sqlite-vec": "^0.1.9",
|
|
159
|
-
"ws": "^8.
|
|
159
|
+
"ws": "^8.22.0"
|
|
160
160
|
},
|
|
161
161
|
"author": "Roger Padilla",
|
|
162
162
|
"repository": {
|
package/skills/uql-orm/SKILL.md
CHANGED
|
@@ -49,10 +49,10 @@ import { Entity, Field, Id, ManyToOne, OneToMany } from 'uql-orm';
|
|
|
49
49
|
@Entity()
|
|
50
50
|
export class User {
|
|
51
51
|
@Id({ type: 'uuid', onInsert: () => crypto.randomUUID() })
|
|
52
|
-
id
|
|
52
|
+
id!: string;
|
|
53
53
|
|
|
54
54
|
@Field({ type: String, unique: true, nullable: false })
|
|
55
|
-
email
|
|
55
|
+
email!: string;
|
|
56
56
|
|
|
57
57
|
@OneToMany({ entity: () => Post, mappedBy: (post) => post.author })
|
|
58
58
|
posts?: Post[];
|
|
@@ -61,7 +61,7 @@ export class User {
|
|
|
61
61
|
@Entity()
|
|
62
62
|
export class Post {
|
|
63
63
|
@Id({ type: Number })
|
|
64
|
-
id
|
|
64
|
+
id!: number;
|
|
65
65
|
|
|
66
66
|
@Field({ type: String })
|
|
67
67
|
title?: string | null;
|
|
@@ -76,6 +76,7 @@ export class Post {
|
|
|
76
76
|
|
|
77
77
|
- Every `@Field` states its `type` (`String`, `Number`, `Boolean`, `Date` (an instant, bound and read as UTC on every engine; `TIMESTAMPTZ` on Postgres and CockroachDB, `DATETIME(3)` on MySQL and MariaDB; `precision` sets its fractional-second digits), `BigInt`, or a column type such as `'uuid'`, `'text'`, `'jsonb'`), except a foreign key, which takes `references` and inherits the target key's type.
|
|
78
78
|
- A column is nullable unless it says `nullable: false`, and its property must admit `null` to match: `title?: string | null`. A property typed without `| null` on a nullable column is a compile error.
|
|
79
|
+
- Declare a `nullable: false` column `!` (`email!: string`): reads have it and inserts must name it, except a single-column key and a `version`, which uql fills. One `onInsert` or a `defaultValue` fills is `Filled<T>` (`createdAt!: Filled<Date>`): reads have it, inserts may leave it out. Declare `?` the rest an insert may leave out: a nullable, `eager: false` or `computed` field, and relations.
|
|
79
80
|
- An engine's own column type is a `raw` constant, ``columnType: raw`tsvector` ``, rendered verbatim and carrying its own `length`/`precision`: never a bare string.
|
|
80
81
|
- Members are named by callbacks, never by strings: `mappedBy: (post) => post.author`, `references: (post) => post.authorId`.
|
|
81
82
|
- `@ManyToMany({ entity: () => Tag, through: () => PostTag })` names its junction entity.
|
|
File without changes
|