uql-orm 0.84.0 → 0.86.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/dist/http/handler.d.ts
CHANGED
|
@@ -44,8 +44,11 @@ export type HookContext<E extends object, Ctx = unknown> = {
|
|
|
44
44
|
export type Hook<Ctx = unknown> = <E extends object>(ctx: HookContext<E, Ctx>) => void | Promise<void>;
|
|
45
45
|
export type ResponseHook<Ctx = unknown> = <E extends object>(ctx: HookContext<E, Ctx>, envelope: RequestSuccessResponse<unknown>) => void | Promise<void>;
|
|
46
46
|
export type RequestHandlerOptions<Ctx = unknown> = {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The entities served, and the only ones a request reaches, through a relation too: nothing is served
|
|
49
|
+
* by being defined, so an entity holding secrets (a session's token) stays off the wire unless named.
|
|
50
|
+
*/
|
|
51
|
+
include: readonly Type<object>[];
|
|
49
52
|
/** The URL segment an entity is addressed by, its kebab-cased class name by default; the browser client takes the same option. */
|
|
50
53
|
entityPath?: (entity: Type<unknown>) => string;
|
|
51
54
|
/**
|
package/dist/http/handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { withContext } from '../context/context.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getMeta, soleIdOf } from '../entity/index.js';
|
|
3
3
|
import { whereIds, whereWith } from '../util/dialect.util.js';
|
|
4
4
|
import { UqlUsageError } from '../util/uqlError.js';
|
|
5
5
|
import { CRUD_ROUTES, entityPath, matchRoute, } from './contract.js';
|
|
@@ -10,14 +10,11 @@ function tableOf(entity) {
|
|
|
10
10
|
return `${entity.name} (${meta.schema ? `${meta.schema}.${meta.name}` : meta.name})`;
|
|
11
11
|
}
|
|
12
12
|
export function createRequestHandler(opts) {
|
|
13
|
-
const { include
|
|
13
|
+
const { include: entities, pre, preSave, preFilter, post, getContext, pool } = opts;
|
|
14
14
|
const pathOf = opts.entityPath ?? entityPath;
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
if (!entities.length) {
|
|
20
|
-
throw new UqlUsageError('no entities for the uql middleware');
|
|
15
|
+
// Refused rather than defaulted to every entity defined, which would serve whatever one registers.
|
|
16
|
+
if (!entities?.length) {
|
|
17
|
+
throw new UqlUsageError("name the entities the handler serves in 'include': it serves those alone");
|
|
21
18
|
}
|
|
22
19
|
// All of them at once, so fixing the first collision does not just reveal the next.
|
|
23
20
|
const byPath = Map.groupBy(entities, pathOf);
|
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.86.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
package/skills/uql-orm/SKILL.md
CHANGED
|
@@ -119,7 +119,8 @@ const users = await pool.findMany(User, {
|
|
|
119
119
|
- A result is narrowed to what the query selected and populated: reading an unselected field is a compile error.
|
|
120
120
|
Name that shape with `QueryFindResult<User, 'id' | 'email'>` rather than widening the query.
|
|
121
121
|
- `$populate` loads relations in the same statement. Nothing is lazy: a relation not populated is not there.
|
|
122
|
-
- A query is plain data, so it can be built dynamically, stored, or sent from a browser to `uql-orm/http
|
|
122
|
+
- A query is plain data, so it can be built dynamically, stored, or sent from a browser to `uql-orm/http`,
|
|
123
|
+
whose handler serves only the entities its required `include` names.
|
|
123
124
|
- Methods: `findMany`, `findOne`, `findOneById`, `findManyAndCount`, `findManyStream`, `count`, `exists`,
|
|
124
125
|
`aggregate`, `insertOne`, `insertMany`, `updateOneById`, `updateMany`, `saveOne`, `saveMany`, `upsertOne`,
|
|
125
126
|
`upsertMany`, `deleteOneById`, `deleteMany`. Each takes the entity class first.
|