uql-orm 0.29.0 → 0.31.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 +11 -3
- package/dist/browser/querier/httpQuerier.d.ts +5 -5
- package/dist/browser/uql-browser.min.js.map +2 -2
- package/dist/dialect/abstractSqlDialect.d.ts +6 -4
- package/dist/dialect/abstractSqlDialect.js +29 -29
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +3 -1
- package/dist/dialect/mysqlLikeSqlDialect.js +9 -0
- package/dist/dialect/vectorSqlDialect.js +8 -1
- package/dist/mongo/mongoDialect.d.ts +3 -3
- package/dist/mongo/mongoDialect.js +17 -9
- package/dist/mongo/mongodbQuerier.d.ts +4 -4
- package/dist/pglite/index.d.ts +3 -0
- package/dist/pglite/index.js +3 -0
- package/dist/pglite/pgliteDialect.d.ts +14 -0
- package/dist/pglite/pgliteDialect.js +14 -0
- package/dist/pglite/pgliteQuerier.d.ts +36 -0
- package/dist/pglite/pgliteQuerier.js +30 -0
- package/dist/pglite/pgliteQuerierPool.d.ts +36 -0
- package/dist/pglite/pgliteQuerierPool.js +36 -0
- package/dist/querier/abstractQuerier.d.ts +19 -8
- package/dist/querier/abstractQuerier.js +61 -25
- package/dist/querier/abstractQuerierPool.d.ts +7 -7
- package/dist/querier/abstractSharedHandleQuerierPool.d.ts +42 -0
- package/dist/querier/abstractSharedHandleQuerierPool.js +48 -0
- package/dist/querier/abstractSqlQuerier.d.ts +6 -4
- package/dist/querier/abstractSqlQuerier.js +31 -9
- package/dist/sqlite/localSqliteQuerierPool.d.ts +8 -11
- package/dist/sqlite/localSqliteQuerierPool.js +8 -15
- package/dist/turso/tursoLocalQuerierPool.d.ts +5 -11
- package/dist/turso/tursoLocalQuerierPool.js +4 -14
- package/dist/type/entity.d.ts +41 -16
- package/dist/type/querier.d.ts +14 -8
- package/dist/type/query.d.ts +27 -14
- package/dist/type/queryAggregate.d.ts +67 -24
- package/dist/type/queryWhere.d.ts +8 -5
- package/dist/type/universalQuerier.d.ts +15 -13
- package/dist/type/utility.d.ts +7 -0
- package/dist/util/dialect.util.d.ts +26 -4
- package/dist/util/dialect.util.js +42 -0
- package/package.json +13 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type CascadeType, type EntityMeta, type FieldKey, type FieldOptions, type JsonUpdateOp, type OnFieldCallback, type QueryAggMap, type QueryAggregateOp, type QueryExclude, type QueryGroupMap, type QueryOptions, QueryRaw, type QuerySelect, type QuerySelectValue, type QuerySizeComparisonOps, type QueryVectorSearch, type QueryWhere, type QueryWhereMap, type RelationKey } from '../type/index.js';
|
|
1
|
+
import { type CascadeType, type EntityData, type EntityMeta, type FieldKey, type FieldOptions, type JsonUpdateOp, type OnFieldCallback, type QueryAggMap, type QueryAggregateOp, type QueryExclude, type QueryGroupMap, type QueryOptions, QueryRaw, type QuerySelect, type QuerySelectValue, type QuerySizeComparisonOps, type QueryVectorSearch, type QueryWhere, type QueryWhereMap, type RelationKey } from '../type/index.js';
|
|
2
2
|
export type CallbackKey = keyof Pick<FieldOptions, 'onInsert' | 'onUpdate'>;
|
|
3
|
-
export declare function filterFieldKeys<E>(meta: EntityMeta<E>, payload: E
|
|
3
|
+
export declare function filterFieldKeys<E>(meta: EntityMeta<E>, payload: EntityData<E>, callbackKey: CallbackKey): FieldKey<E>[];
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the columns of an INSERT statement: the union of the persistable fields provided by
|
|
6
6
|
* any record (in first-seen order), plus every `onInsert` field. Records missing one of these
|
|
@@ -13,7 +13,7 @@ export declare function filterFieldKeys<E>(meta: EntityMeta<E>, payload: E, call
|
|
|
13
13
|
* has run {@link fillOnFields} first (it stamps them on every record, but the querier's
|
|
14
14
|
* chunk-size estimate inspects the raw payload).
|
|
15
15
|
*/
|
|
16
|
-
export declare function getInsertFieldKeys<E>(meta: EntityMeta<E>, payloads: E[]): FieldKey<E>[];
|
|
16
|
+
export declare function getInsertFieldKeys<E>(meta: EntityMeta<E>, payloads: EntityData<E>[]): FieldKey<E>[];
|
|
17
17
|
export declare function getFieldCallbackValue(val: OnFieldCallback): string | number | bigint | boolean | Date | QueryRaw | readonly {
|
|
18
18
|
readonly __json?: never;
|
|
19
19
|
}[] | readonly number[] | Uint8Array<ArrayBufferLike> | {
|
|
@@ -28,7 +28,7 @@ export declare function getSoftDeleteValue(field: FieldOptions): string | number
|
|
|
28
28
|
}[] | readonly number[] | Uint8Array<ArrayBufferLike> | {
|
|
29
29
|
readonly __json?: never;
|
|
30
30
|
};
|
|
31
|
-
export declare function fillOnFields<E>(meta: EntityMeta<E>, payload: E | E[], callbackKey: CallbackKey): E[];
|
|
31
|
+
export declare function fillOnFields<E>(meta: EntityMeta<E>, payload: EntityData<E> | EntityData<E>[], callbackKey: CallbackKey): EntityData<E>[];
|
|
32
32
|
/**
|
|
33
33
|
* The relation keys present in `payload` whose cascade configuration allows `action`. Only
|
|
34
34
|
* `payload`'s keys are read, so any keys-bearing object works (an entity, an update payload,
|
|
@@ -100,3 +100,25 @@ export declare function parseRelationSize(val: unknown): number | QuerySizeCompa
|
|
|
100
100
|
* entries consumable by any dialect. Grouped columns come first, then computed columns.
|
|
101
101
|
*/
|
|
102
102
|
export declare function parseGroupMap<E>(group?: QueryGroupMap<E>, agg?: QueryAggMap<E>): ParsedGroupEntry[];
|
|
103
|
+
/**
|
|
104
|
+
* Whether `value` is a map of comparison operators rather than a value to compare against. Only a
|
|
105
|
+
* plain object qualifies: `Date`, `QueryRaw`, `Uint8Array` and arrays are all `typeof 'object'`, and
|
|
106
|
+
* reading their keys as operators drops the condition (a `Date` has none) or throws on an array's
|
|
107
|
+
* indices. Shared by the SQL and MongoDB builders, whose `$where` and `$having` all face this.
|
|
108
|
+
*/
|
|
109
|
+
export declare function isOperatorMap(value: unknown): value is Record<string, unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* A page operand, checked before it reaches an engine. These arrive from page arithmetic and from
|
|
112
|
+
* REST query strings (`parseQueryParams` yields `NaN` for a non-numeric one), and each engine's own
|
|
113
|
+
* complaint names neither the clause nor the value - or, for `$limit: 0`, quietly means something
|
|
114
|
+
* else. Shared so every backend rejects the same input.
|
|
115
|
+
*/
|
|
116
|
+
export declare function assertNonNegativeInteger(value: number, clause: string): number;
|
|
117
|
+
/**
|
|
118
|
+
* Rejects a `$having`/`$sort` key naming something an aggregate does not emit. Its rows are its
|
|
119
|
+
* `$group` columns and its `$agg` aliases; anything else is a value that is not there. Shared so
|
|
120
|
+
* SQL and MongoDB refuse the same query with the same words.
|
|
121
|
+
*/
|
|
122
|
+
export declare function throwUnknownAggregateColumn(key: string, clause: string): never;
|
|
123
|
+
/** {@link throwUnknownAggregateColumn} over every key of a clause, for backends that check up front. */
|
|
124
|
+
export declare function assertAggregateColumns(clauseMap: object | undefined, emitted: ReadonlySet<string>, clause: string): void;
|
|
@@ -301,3 +301,45 @@ export function parseGroupMap(group, agg) {
|
|
|
301
301
|
}
|
|
302
302
|
return entries;
|
|
303
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Whether `value` is a map of comparison operators rather than a value to compare against. Only a
|
|
306
|
+
* plain object qualifies: `Date`, `QueryRaw`, `Uint8Array` and arrays are all `typeof 'object'`, and
|
|
307
|
+
* reading their keys as operators drops the condition (a `Date` has none) or throws on an array's
|
|
308
|
+
* indices. Shared by the SQL and MongoDB builders, whose `$where` and `$having` all face this.
|
|
309
|
+
*/
|
|
310
|
+
export function isOperatorMap(value) {
|
|
311
|
+
return (typeof value === 'object' &&
|
|
312
|
+
value !== null &&
|
|
313
|
+
!Array.isArray(value) &&
|
|
314
|
+
!(value instanceof Date) &&
|
|
315
|
+
!(value instanceof Uint8Array) &&
|
|
316
|
+
!(value instanceof QueryRaw));
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* A page operand, checked before it reaches an engine. These arrive from page arithmetic and from
|
|
320
|
+
* REST query strings (`parseQueryParams` yields `NaN` for a non-numeric one), and each engine's own
|
|
321
|
+
* complaint names neither the clause nor the value - or, for `$limit: 0`, quietly means something
|
|
322
|
+
* else. Shared so every backend rejects the same input.
|
|
323
|
+
*/
|
|
324
|
+
export function assertNonNegativeInteger(value, clause) {
|
|
325
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
326
|
+
throw new TypeError(`${clause} must be a non-negative integer, got ${value}`);
|
|
327
|
+
}
|
|
328
|
+
return value;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Rejects a `$having`/`$sort` key naming something an aggregate does not emit. Its rows are its
|
|
332
|
+
* `$group` columns and its `$agg` aliases; anything else is a value that is not there. Shared so
|
|
333
|
+
* SQL and MongoDB refuse the same query with the same words.
|
|
334
|
+
*/
|
|
335
|
+
export function throwUnknownAggregateColumn(key, clause) {
|
|
336
|
+
throw new TypeError(`cannot ${clause} by '${key}': it is neither a $group column nor an $agg alias`);
|
|
337
|
+
}
|
|
338
|
+
/** {@link throwUnknownAggregateColumn} over every key of a clause, for backends that check up front. */
|
|
339
|
+
export function assertAggregateColumns(clauseMap, emitted, clause) {
|
|
340
|
+
for (const key of getKeys(clauseMap ?? {})) {
|
|
341
|
+
if (!emitted.has(key)) {
|
|
342
|
+
throwUnknownAggregateColumn(key, clause);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uql-orm",
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
|
-
"description": "JSON-native TypeScript ORM for Node.js, Bun and Deno. Supports PostgreSQL, MySQL, MariaDB, SQLite, CockroachDB, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
|
|
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.31.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"./turso": "./dist/turso/index.js",
|
|
48
48
|
"./turso/local": "./dist/turso/local.js",
|
|
49
49
|
"./neon": "./dist/neon/index.js",
|
|
50
|
+
"./pglite": "./dist/pglite/index.js",
|
|
50
51
|
"./d1": "./dist/d1/index.js",
|
|
51
52
|
"./bunSql": "./dist/bunSql/index.js",
|
|
52
53
|
"./package.json": "./package.json"
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
"clean": "rimraf dist .tsconfig.tsbuildinfo"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
|
68
|
+
"@electric-sql/pglite": ">=0.5.0",
|
|
67
69
|
"@libsql/client": ">=0.6.0",
|
|
68
70
|
"@neondatabase/serverless": ">=0.9.0",
|
|
69
71
|
"@nestjs/common": ">=10.0.0",
|
|
@@ -80,6 +82,9 @@
|
|
|
80
82
|
"rxjs": ">=7.0.0"
|
|
81
83
|
},
|
|
82
84
|
"peerDependenciesMeta": {
|
|
85
|
+
"@electric-sql/pglite": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
83
88
|
"@libsql/client": {
|
|
84
89
|
"optional": true
|
|
85
90
|
},
|
|
@@ -124,6 +129,8 @@
|
|
|
124
129
|
}
|
|
125
130
|
},
|
|
126
131
|
"devDependencies": {
|
|
132
|
+
"@electric-sql/pglite": "0.5.7",
|
|
133
|
+
"@electric-sql/pglite-pgvector": "0.0.8",
|
|
127
134
|
"@libsql/client": "^0.17.4",
|
|
128
135
|
"@neondatabase/serverless": "^1.1.0",
|
|
129
136
|
"@nestjs/common": "^11.2.1",
|
|
@@ -133,13 +140,13 @@
|
|
|
133
140
|
"@tursodatabase/serverless": "^1.4.0",
|
|
134
141
|
"@types/better-sqlite3": "^9.6.0",
|
|
135
142
|
"@types/express": "^5.0.6",
|
|
136
|
-
"@types/pg": "^8.
|
|
143
|
+
"@types/pg": "^8.23.1",
|
|
137
144
|
"@types/ws": "^8.18.1",
|
|
138
145
|
"better-sqlite3": "^13.0.3",
|
|
139
146
|
"express": "^5.2.1",
|
|
140
147
|
"mariadb": "^3.5.3",
|
|
141
148
|
"mongodb": "^7.5.0",
|
|
142
|
-
"mysql2": "^3.23.
|
|
149
|
+
"mysql2": "^3.23.4",
|
|
143
150
|
"pg": "^8.23.0",
|
|
144
151
|
"pg-query-stream": "^4.17.0",
|
|
145
152
|
"rxjs": "^7.8.2",
|
|
@@ -172,6 +179,8 @@
|
|
|
172
179
|
"postgres",
|
|
173
180
|
"postgresql",
|
|
174
181
|
"pg",
|
|
182
|
+
"pglite",
|
|
183
|
+
"wasm",
|
|
175
184
|
"mysql",
|
|
176
185
|
"mariadb",
|
|
177
186
|
"sqlite",
|