@fitzzero/quickdraw-core 5.1.1 → 5.1.3
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 +1308 -219
- package/dist/{admin-DKwkIh5i.d.ts → admin-CS7JB_UH.d.ts} +2 -2
- package/dist/{adminSchemas-2DUA_hZ8.d.ts → adminSchemas-29cGgrg5.d.ts} +6 -4
- package/dist/{auth-BhWqdyb-.d.ts → auth-DtdYjrZ9.d.ts} +51 -21
- package/dist/{caller-CXTFswBO.d.ts → caller-BTwGl7vm.d.ts} +296 -33
- package/dist/chunk-2FDSKLBO.js +82 -0
- package/dist/chunk-2FDSKLBO.js.map +1 -0
- package/dist/{chunk-RT6OILOI.js → chunk-4D2DOGAW.js} +2 -14
- package/dist/chunk-4D2DOGAW.js.map +1 -0
- package/dist/{chunk-OECZPRPW.js → chunk-64I6MYBC.js} +162 -775
- package/dist/chunk-64I6MYBC.js.map +1 -0
- package/dist/chunk-7473HK24.js +17 -0
- package/dist/chunk-7473HK24.js.map +1 -0
- package/dist/chunk-7Y5ROPXL.js +33 -0
- package/dist/chunk-7Y5ROPXL.js.map +1 -0
- package/dist/chunk-A2RBQD66.js +7 -0
- package/dist/chunk-A2RBQD66.js.map +1 -0
- package/dist/chunk-AK23XSWD.js +16 -0
- package/dist/chunk-AK23XSWD.js.map +1 -0
- package/dist/chunk-ASAMUGHG.js +651 -0
- package/dist/chunk-ASAMUGHG.js.map +1 -0
- package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
- package/dist/chunk-CYE4UBOB.js.map +1 -0
- package/dist/chunk-DKE6QO26.js +136 -0
- package/dist/chunk-DKE6QO26.js.map +1 -0
- package/dist/chunk-DNP65TD5.js +832 -0
- package/dist/chunk-DNP65TD5.js.map +1 -0
- package/dist/{chunk-H23KEFBA.js → chunk-DUBU3BB3.js} +30 -1
- package/dist/chunk-DUBU3BB3.js.map +1 -0
- package/dist/chunk-GYLWEJHW.js +19 -0
- package/dist/chunk-GYLWEJHW.js.map +1 -0
- package/dist/{chunk-SHEGLZEP.js → chunk-I3JCFS7H.js} +34 -13
- package/dist/chunk-I3JCFS7H.js.map +1 -0
- package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
- package/dist/chunk-IIQ3WMJK.js.map +1 -0
- package/dist/{chunk-RZTP4IEW.js → chunk-JVTONQFI.js} +6339 -4226
- package/dist/chunk-JVTONQFI.js.map +1 -0
- package/dist/{chunk-QEKVYG5F.js → chunk-KKQANRLG.js} +2 -2
- package/dist/chunk-KKQANRLG.js.map +1 -0
- package/dist/{chunk-CDKG4TFA.js → chunk-MPQAT55F.js} +38 -205
- package/dist/chunk-MPQAT55F.js.map +1 -0
- package/dist/chunk-NO4M6PO5.js +101 -0
- package/dist/chunk-NO4M6PO5.js.map +1 -0
- package/dist/{chunk-TBMKJ26R.js → chunk-NW6U45HX.js} +3 -1
- package/dist/chunk-NW6U45HX.js.map +1 -0
- package/dist/chunk-NX2V6SIL.js +202 -0
- package/dist/chunk-NX2V6SIL.js.map +1 -0
- package/dist/{chunk-ZIVPHYRG.js → chunk-NZHA4TZD.js} +72 -175
- package/dist/chunk-NZHA4TZD.js.map +1 -0
- package/dist/{chunk-2PWMUVC7.js → chunk-OCZJ4EYV.js} +518 -27
- package/dist/chunk-OCZJ4EYV.js.map +1 -0
- package/dist/{chunk-REX5YPHX.js → chunk-PHCURHC7.js} +76 -21
- package/dist/chunk-PHCURHC7.js.map +1 -0
- package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
- package/dist/chunk-Q4OGQM5I.js.map +1 -0
- package/dist/chunk-QSU47XEX.js +13 -0
- package/dist/chunk-QSU47XEX.js.map +1 -0
- package/dist/{chunk-DD4SKCNO.js → chunk-RZXJTDH5.js} +13 -2
- package/dist/chunk-RZXJTDH5.js.map +1 -0
- package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
- package/dist/chunk-SN3OZVEQ.js.map +1 -0
- package/dist/{chunk-4DIQHASK.js → chunk-SQ5VUG77.js} +28 -8
- package/dist/chunk-SQ5VUG77.js.map +1 -0
- package/dist/chunk-STH5DLQP.js +1192 -0
- package/dist/chunk-STH5DLQP.js.map +1 -0
- package/dist/{chunk-QCHKWIRS.js → chunk-VZFJTKIW.js} +13 -13
- package/dist/{chunk-QCHKWIRS.js.map → chunk-VZFJTKIW.js.map} +1 -1
- package/dist/{chunk-VSQBHPWH.js → chunk-X4ZU4QH5.js} +54 -22
- package/dist/chunk-X4ZU4QH5.js.map +1 -0
- package/dist/chunk-XD7SRDUY.js +188 -0
- package/dist/chunk-XD7SRDUY.js.map +1 -0
- package/dist/chunk-XH2IZVLT.js +62 -0
- package/dist/chunk-XH2IZVLT.js.map +1 -0
- package/dist/chunk-Z7I6SONO.js +825 -0
- package/dist/chunk-Z7I6SONO.js.map +1 -0
- package/dist/cli/quickdraw-docs.js +132 -112
- package/dist/cli/quickdraw-docs.js.map +1 -1
- package/dist/client/core.d.ts +387 -0
- package/dist/client/core.js +109 -0
- package/dist/client/index.d.ts +52 -203
- package/dist/client/index.js +59 -218
- package/dist/client/index.js.map +1 -1
- package/dist/{clientTypes-Bc-G8n-U.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
- package/dist/{connection-Cr1BU07W.d.ts → connection-2EeQ_Et0.d.ts} +22 -11
- package/dist/{createServer-CP9eDHZZ.d.ts → createServer-Bx5HOcYK.d.ts} +67 -17
- package/dist/{createTestApp-UKVGEmOf.d.ts → createTestApp-DAMANT79.d.ts} +46 -13
- package/dist/{envelope-Cp3YcVxC.d.ts → envelope-BMBaxppV.d.ts} +216 -10
- package/dist/{http-Djj2Inuu.d.ts → http-YzLAar3w.d.ts} +76 -60
- package/dist/index.d.ts +8 -7
- package/dist/index.js +82 -25
- package/dist/index.js.map +1 -1
- package/dist/{infer-Teo1xpsd.d.ts → infer-Br62cnyW.d.ts} +82 -11
- package/dist/logger-Yz93KzdV.d.ts +30 -0
- package/dist/{metrics-BdBu5o8G.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
- package/dist/origins-kvpxnVcW.d.ts +8 -0
- package/dist/parser.js +2 -1
- package/dist/prisma/index.d.ts +14 -7
- package/dist/prisma/index.js +279 -70
- package/dist/prisma/index.js.map +1 -1
- package/dist/{rateLimit-ZMIZJUZF.js → rateLimit-5RKBFLUR.js} +2 -2
- package/dist/rateLimit-5RKBFLUR.js.map +1 -0
- package/dist/remote-N7OUAGOW.js +15 -0
- package/dist/remote-N7OUAGOW.js.map +1 -0
- package/dist/server/auth/index.d.ts +82 -33
- package/dist/server/auth/index.js +277 -270
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/express/index.d.ts +9 -2
- package/dist/server/express/index.js +1 -1
- package/dist/server/index.d.ts +268 -84
- package/dist/server/index.js +664 -418
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp/index.d.ts +89 -27
- package/dist/server/mcp/index.js +281 -62
- package/dist/server/mcp/index.js.map +1 -1
- package/dist/server/otel.d.ts +3 -3
- package/dist/{sharing-DVa8W-yR.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
- package/dist/testing/client.d.ts +14 -14
- package/dist/testing/client.js +19 -10
- package/dist/testing/client.js.map +1 -1
- package/dist/testing/index.d.ts +50 -13
- package/dist/testing/index.js +113 -21
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock.d.ts +5 -5
- package/dist/testing/mock.js +17 -9
- package/dist/tracked-BR5b2O-U.d.ts +43 -0
- package/dist/{types-Cu0vmx7c.d.ts → types-CLRCQGnO.d.ts} +4 -3
- package/dist/types-tMagHbjy.d.ts +151 -0
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +6 -3
- package/package.json +5 -1
- package/dist/chunk-2PWMUVC7.js.map +0 -1
- package/dist/chunk-4DIQHASK.js.map +0 -1
- package/dist/chunk-4YO5H5ON.js.map +0 -1
- package/dist/chunk-B2P7AZ25.js.map +0 -1
- package/dist/chunk-CDKG4TFA.js.map +0 -1
- package/dist/chunk-DD4SKCNO.js.map +0 -1
- package/dist/chunk-H23KEFBA.js.map +0 -1
- package/dist/chunk-OECZPRPW.js.map +0 -1
- package/dist/chunk-QEKVYG5F.js.map +0 -1
- package/dist/chunk-REX5YPHX.js.map +0 -1
- package/dist/chunk-RT6OILOI.js.map +0 -1
- package/dist/chunk-RZTP4IEW.js.map +0 -1
- package/dist/chunk-SHEGLZEP.js.map +0 -1
- package/dist/chunk-TBMKJ26R.js.map +0 -1
- package/dist/chunk-VSQBHPWH.js.map +0 -1
- package/dist/chunk-X5CWPX7H.js.map +0 -1
- package/dist/chunk-YSWH776Y.js +0 -13
- package/dist/chunk-YSWH776Y.js.map +0 -1
- package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
- package/dist/chunk-ZIVPHYRG.js.map +0 -1
- package/dist/logger-BY28acW-.d.ts +0 -16
- /package/dist/{rateLimit-ZMIZJUZF.js.map → client/core.js.map} +0 -0
package/dist/testing/mock.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as AccessLevel, ae as ContractMap, J as AnyContract, ap as MethodName, al as InputOf, ar as OutputOf, af as EntityOf, ac as CollectionName, aw as ScopeOf, an as ItemOf, az as StreamName, am as IsScopedStream, ay as StreamItemOf, aa as ChannelName, a9 as ChannelInputOf, ag as EventName, ah as EventPayloadOf } from '../infer-
|
|
1
|
+
import { A as AccessLevel, ae as ContractMap, J as AnyContract, ap as MethodName, al as InputOf, ar as OutputOf, af as EntityOf, ac as CollectionName, aw as ScopeOf, an as ItemOf, az as StreamName, am as IsScopedStream, ay as StreamItemOf, aa as ChannelName, a9 as ChannelInputOf, ag as EventName, ah as EventPayloadOf } from '../infer-Br62cnyW.js';
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { ReactNode, ReactElement } from 'react';
|
|
4
|
-
import { i as MethodMember, E as EntityMembers, C as CollectionMember, y as StreamMember, u as ChannelMember, v as EventMember, n as QuickdrawInvalidate } from '../clientTypes-
|
|
5
|
-
import { H as AdminMethodsOf } from '../admin-
|
|
4
|
+
import { i as MethodMember, E as EntityMembers, C as CollectionMember, y as StreamMember, u as ChannelMember, v as EventMember, n as QuickdrawInvalidate } from '../clientTypes-CUUNJwWs.js';
|
|
5
|
+
import { H as AdminMethodsOf } from '../admin-CS7JB_UH.js';
|
|
6
6
|
import { Q as QuickdrawError } from '../errors-S-bxEIBC.js';
|
|
7
7
|
import '../keys-CqKkljVN.js';
|
|
8
|
-
import '../adminSchemas-
|
|
9
|
-
import '../envelope-
|
|
8
|
+
import '../adminSchemas-29cGgrg5.js';
|
|
9
|
+
import '../envelope-BMBaxppV.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* How a mocked method answers. Until one of the `mock*` setters runs, every
|
package/dist/testing/mock.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMockClient
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-I3JCFS7H.js";
|
|
4
|
+
import "../chunk-64I6MYBC.js";
|
|
5
|
+
import "../chunk-XD7SRDUY.js";
|
|
6
|
+
import "../chunk-4D2DOGAW.js";
|
|
7
|
+
import "../chunk-AK23XSWD.js";
|
|
8
|
+
import "../chunk-DKE6QO26.js";
|
|
9
|
+
import "../chunk-STH5DLQP.js";
|
|
10
|
+
import "../chunk-IIQ3WMJK.js";
|
|
11
|
+
import "../chunk-2FDSKLBO.js";
|
|
12
|
+
import "../chunk-MPQAT55F.js";
|
|
13
|
+
import "../chunk-A2RBQD66.js";
|
|
14
|
+
import "../chunk-X4ZU4QH5.js";
|
|
15
|
+
import "../chunk-GYLWEJHW.js";
|
|
8
16
|
import "../chunk-47AEXVDM.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-SN3OZVEQ.js";
|
|
18
|
+
import "../chunk-7Y5ROPXL.js";
|
|
19
|
+
import "../chunk-Q4OGQM5I.js";
|
|
20
|
+
import "../chunk-QSU47XEX.js";
|
|
13
21
|
export {
|
|
14
22
|
createMockClient
|
|
15
23
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const TRACKED: unique symbol;
|
|
2
|
+
/** What marks a client as tracked: a type only, with no property at run time. */
|
|
3
|
+
interface TrackedMark {
|
|
4
|
+
readonly [TRACKED]: true;
|
|
5
|
+
}
|
|
6
|
+
/** The client an interactive `$transaction` of `C` passes its callback, or `C` itself when it has none. */
|
|
7
|
+
type TransactionClientOf<C> = C extends {
|
|
8
|
+
$transaction(fn: (tx: infer Tx) => unknown, options?: unknown): unknown;
|
|
9
|
+
} ? Tx : C;
|
|
10
|
+
/** The interactive `$transaction` of a tracked `C`: its callback gets the tracked transaction client. */
|
|
11
|
+
interface TrackedInteractiveTransaction<C, Options> {
|
|
12
|
+
$transaction<R>(fn: (tx: TrackedTransaction<C>) => Promise<R>, options?: Options): Promise<R>;
|
|
13
|
+
}
|
|
14
|
+
/** `$transaction` declared again, with Prisma's options, for a `C` that has an interactive one; nothing for one that has none. */
|
|
15
|
+
type TrackedTransactions<C> = C extends {
|
|
16
|
+
$transaction(fn: (tx: infer _Tx) => unknown, options?: infer Options): unknown;
|
|
17
|
+
} ? TrackedInteractiveTransaction<C, Options> : unknown;
|
|
18
|
+
/**
|
|
19
|
+
* A database client whose writes the framework sees: what `trackPrisma`
|
|
20
|
+
* returns. It is still a `C` everywhere a `C` is asked for, but a plain `C`
|
|
21
|
+
* is not a `Tracked<C>`, so a helper that writes takes `db: Tracked<Db>`
|
|
22
|
+
* and the untracked client passed to it is a type error. Its interactive
|
|
23
|
+
* `$transaction` passes a {@link TrackedTransaction}; the array form is
|
|
24
|
+
* Prisma's own.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* export const db = trackPrisma(new PrismaClient({ adapter })); // Tracked<PrismaClient>
|
|
28
|
+
* export async function archive(client: Tracked<PrismaClient>, id: string): Promise<void> {
|
|
29
|
+
* await client.project.update({ where: { id }, data: { archived: true } });
|
|
30
|
+
* }
|
|
31
|
+
* await qd.run(() => archive(db, projectId)); // archive(prisma, projectId) is a type error
|
|
32
|
+
*/
|
|
33
|
+
type Tracked<C> = TrackedMark & TrackedTransactions<C> & C;
|
|
34
|
+
/**
|
|
35
|
+
* The client an interactive `db.$transaction(async (tx) => ...)` of a
|
|
36
|
+
* tracked `db` passes as `tx`, tracked too: Prisma's transaction client of
|
|
37
|
+
* `C`. `C` is the client, tracked or not; a transaction client stays itself.
|
|
38
|
+
* A helper that writes inside or outside a transaction takes
|
|
39
|
+
* `TrackedTransaction<Db>`, which both `db` and `tx` are.
|
|
40
|
+
*/
|
|
41
|
+
type TrackedTransaction<C> = Tracked<TransactionClientOf<C>>;
|
|
42
|
+
|
|
43
|
+
export type { Tracked as T, TrackedTransaction as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AccessLevel, ae as ContractMap } from './infer-
|
|
1
|
+
import { A as AccessLevel, ae as ContractMap } from './infer-Br62cnyW.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Who is calling. A transport authenticates the connection or request and
|
|
@@ -28,7 +28,8 @@ interface Principal {
|
|
|
28
28
|
* - `context`: the fields `initQuickdraw({ context })` adds to every handler's `ctx`.
|
|
29
29
|
* - `contracts`: the app's contracts (`{ task, project }`), which type `qd.caller`.
|
|
30
30
|
* - `mcp`: the fields the MCP bridge's `context` option gives calls that
|
|
31
|
-
* arrive over MCP,
|
|
31
|
+
* arrive over MCP, and the calls they make through `ctx.services`, which
|
|
32
|
+
* handlers read as `ctx.mcp` (token scopes, for example).
|
|
32
33
|
*
|
|
33
34
|
* @example
|
|
34
35
|
* export const qd = initQuickdraw<{ db: AppPrisma; principal: AppPrincipal }>();
|
|
@@ -69,4 +70,4 @@ type Transport = "socket" | "http" | "mcp" | "internal" | "legacy";
|
|
|
69
70
|
/** A value, or a promise of it. */
|
|
70
71
|
type MaybePromise<T> = T | PromiseLike<T>;
|
|
71
72
|
|
|
72
|
-
export type { ContextExtensionOf as C, DbOf as D, MaybePromise as M, Principal as P, QuickdrawTypes as Q, Transport as T, McpContext as a,
|
|
73
|
+
export type { ContextExtensionOf as C, DbOf as D, MaybePromise as M, Principal as P, QuickdrawTypes as Q, Transport as T, McpContext as a, PrincipalOf as b, McpContextOf as c, PrincipalKindOf as d };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { ab as PeerLabel } from './envelope-BMBaxppV.js';
|
|
2
|
+
|
|
3
|
+
/** A peer's clock, as a link estimates it. */
|
|
4
|
+
interface PeerClock {
|
|
5
|
+
/** The peer's clock now, in milliseconds: this side's `performance.now()` plus `offset`. */
|
|
6
|
+
now(): number;
|
|
7
|
+
/** The peer's clock minus this side's, in milliseconds; 0 before the first pong. */
|
|
8
|
+
readonly offset: number;
|
|
9
|
+
/** The round trip, smoothed, in milliseconds; 0 before the first pong. */
|
|
10
|
+
readonly rtt: number;
|
|
11
|
+
/** How much round trips vary, smoothed, in milliseconds. */
|
|
12
|
+
readonly jitter: number;
|
|
13
|
+
/** True once enough pongs arrived for `offset` to hold: about half a second after the link opens. */
|
|
14
|
+
readonly synced: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Where a link is: `connecting` until a path carries it, `open` while one
|
|
19
|
+
* does (`path` says which), `closed` for good (`closeReason` says why).
|
|
20
|
+
*/
|
|
21
|
+
type PeerLinkState = "connecting" | "open" | "closed";
|
|
22
|
+
/** What carries an open link: WebRTC data channels between the two clients, or the server's relay. */
|
|
23
|
+
type PeerPath = "direct" | "relay";
|
|
24
|
+
/**
|
|
25
|
+
* Why a link closed:
|
|
26
|
+
*
|
|
27
|
+
* - `closed`: this side's `close()`;
|
|
28
|
+
* - `bye`: the peer closed it, left the room or disconnected (the server
|
|
29
|
+
* says so for a peer that left);
|
|
30
|
+
* - `left`: this socket left the link's room, or was taken out of it;
|
|
31
|
+
* - `disconnected`: this side's socket disconnected (a link lives as long
|
|
32
|
+
* as the socket it started on), or the connection was closed;
|
|
33
|
+
* - `timeout`: no path opened within 15 seconds;
|
|
34
|
+
* - `lost`: nothing was heard from the peer for 8 seconds, or the direct
|
|
35
|
+
* path of a link that may not use the relay (`relay: "never"`) dropped
|
|
36
|
+
* after it opened;
|
|
37
|
+
* - `failed`: the direct path failed and the link may not use the relay
|
|
38
|
+
* (`relay: "never"`);
|
|
39
|
+
* - `refused`: the server refused a signal (the peer is not in the room,
|
|
40
|
+
* this socket signals too many peers, ...);
|
|
41
|
+
* - `unsupported`: the server serves no peer links (its hello lists no
|
|
42
|
+
* `"peer"`), or the link may use neither WebRTC (absent here) nor the
|
|
43
|
+
* relay.
|
|
44
|
+
*/
|
|
45
|
+
type PeerCloseReason = "closed" | "bye" | "left" | "disconnected" | "timeout" | "lost" | "failed" | "refused" | "unsupported";
|
|
46
|
+
/** What a link counted. */
|
|
47
|
+
interface PeerLinkStats {
|
|
48
|
+
/** App messages a path took: under a lag (`setLag`), each as it goes. */
|
|
49
|
+
readonly sent: number;
|
|
50
|
+
/** App messages received. */
|
|
51
|
+
readonly received: number;
|
|
52
|
+
/**
|
|
53
|
+
* App messages `send` dropped: sent while the link was not open, a `fast`
|
|
54
|
+
* message while the data channel was backed up, or one over the relay's
|
|
55
|
+
* limits. Under a lag, also a held `fast` message its path refused as it
|
|
56
|
+
* came due, and a `rel` one sent while a held `rel` message waits for its
|
|
57
|
+
* path.
|
|
58
|
+
*/
|
|
59
|
+
readonly dropped: number;
|
|
60
|
+
/**
|
|
61
|
+
* App messages the lag lost (`setLag`'s `loss`), sent or received: `fast`
|
|
62
|
+
* ones alone, and never counted in `dropped`.
|
|
63
|
+
*/
|
|
64
|
+
readonly simulatedLoss: number;
|
|
65
|
+
}
|
|
66
|
+
/** A link's simulated network, as `setLag` set it. */
|
|
67
|
+
interface PeerLinkLag {
|
|
68
|
+
/** How long each message waits, each way, in milliseconds. */
|
|
69
|
+
readonly ms: number;
|
|
70
|
+
/** Up to this many milliseconds more, at random, per message. */
|
|
71
|
+
readonly jitter: number;
|
|
72
|
+
/** The share of `fast` messages lost, each way, from 0 to 1. */
|
|
73
|
+
readonly loss: number;
|
|
74
|
+
}
|
|
75
|
+
/** What `setLag` takes: each part defaults to 0. */
|
|
76
|
+
interface PeerLinkLagOptions {
|
|
77
|
+
/** How long each message waits, each way, in milliseconds. */
|
|
78
|
+
readonly ms?: number;
|
|
79
|
+
/** Up to this many milliseconds more, at random, per message. */
|
|
80
|
+
readonly jitter?: number;
|
|
81
|
+
/** The share of `fast` messages lost, each way, from 0 to 1. `rel` ones never are. */
|
|
82
|
+
readonly loss?: number;
|
|
83
|
+
/** Random numbers from 0 to 1, for jitter and loss. Default `Math.random`; pass a seeded one to repeat a run. */
|
|
84
|
+
readonly random?: () => number;
|
|
85
|
+
}
|
|
86
|
+
/** A link's events and their listeners' arguments. */
|
|
87
|
+
interface PeerLinkEvents {
|
|
88
|
+
/** An app message from the peer, on `label`. */
|
|
89
|
+
message: (data: unknown, label: PeerLabel) => void;
|
|
90
|
+
/** The link opened, on `path`: once. */
|
|
91
|
+
open: (path: PeerPath) => void;
|
|
92
|
+
/** The link's state or path changed. */
|
|
93
|
+
state: (state: PeerLinkState, path: PeerPath | undefined) => void;
|
|
94
|
+
/** The link closed, for good: once. */
|
|
95
|
+
close: (reason: PeerCloseReason) => void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A link to another socket of an app room: two channels, `rel` (ordered,
|
|
99
|
+
* reliable) and `fast` (unordered, never retransmitted), over WebRTC data
|
|
100
|
+
* channels or, when those cannot form, the server's relay, with the same
|
|
101
|
+
* behaviour either way. Messages are JSON values.
|
|
102
|
+
*/
|
|
103
|
+
interface PeerLink {
|
|
104
|
+
/** The app room the link belongs to. */
|
|
105
|
+
readonly room: string;
|
|
106
|
+
/** The peer's socket id. */
|
|
107
|
+
readonly peer: string;
|
|
108
|
+
/** The peer's user, as the server named it in the peer's first signal; `undefined` until then. */
|
|
109
|
+
readonly userId: string | undefined;
|
|
110
|
+
readonly state: PeerLinkState;
|
|
111
|
+
/** What carries the link while it is open. */
|
|
112
|
+
readonly path: PeerPath | undefined;
|
|
113
|
+
/** Why the link closed, once it has. */
|
|
114
|
+
readonly closeReason: PeerCloseReason | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Sends `data` (any JSON value) on `label`. Returns false when it was
|
|
117
|
+
* dropped: the link is not open, `fast` is backed up, or the relay's rate
|
|
118
|
+
* is spent (`stats.dropped` counts it). `rel` delivers in order while the
|
|
119
|
+
* path holds; a path change (the direct path failed, the relay took over)
|
|
120
|
+
* may lose `rel` messages in flight, and emits `state`. Under a lag
|
|
121
|
+
* (`setLag`) it returns true for a message it holds. Throws a
|
|
122
|
+
* `RangeError` for a message over `limits.peers.maxMessageBytes`.
|
|
123
|
+
*/
|
|
124
|
+
send(label: PeerLabel, data: unknown): boolean;
|
|
125
|
+
/** Calls `listener` on `event`; returns its removal. */
|
|
126
|
+
on<E extends keyof PeerLinkEvents>(event: E, listener: PeerLinkEvents[E]): () => void;
|
|
127
|
+
/** The peer's clock, read from pings the link sends on `fast`. */
|
|
128
|
+
readonly clock: PeerClock;
|
|
129
|
+
/** What the link counted. */
|
|
130
|
+
readonly stats: PeerLinkStats;
|
|
131
|
+
/**
|
|
132
|
+
* Simulates a bad network on this link, both ways and on either path, for
|
|
133
|
+
* a test, a bench or a host that gives itself its peers' lag: each
|
|
134
|
+
* message waits `ms` plus up to `jitter` milliseconds, and a `fast` one
|
|
135
|
+
* is lost with probability `loss` (`stats.simulatedLoss` counts the
|
|
136
|
+
* app's). `rel` messages are never lost and keep their order; one its
|
|
137
|
+
* path refuses as it comes due goes again a little later. The clock's
|
|
138
|
+
* pings wait too, so `clock.rtt` reads the lagged round trip. A new lag
|
|
139
|
+
* leaves what is held on its time; `null` (or all zeros) ends it, and
|
|
140
|
+
* what is held goes on the next task, in order. A link that closes drops
|
|
141
|
+
* what it holds. Throws a `TypeError` for a part out of range. Does
|
|
142
|
+
* nothing once the link is closed.
|
|
143
|
+
*/
|
|
144
|
+
setLag(lag: PeerLinkLagOptions | null): void;
|
|
145
|
+
/** The lag `setLag` set; `null` for none. */
|
|
146
|
+
readonly lag: PeerLinkLag | null;
|
|
147
|
+
/** Closes the link and tells the peer. Does nothing once it is closed. */
|
|
148
|
+
close(): void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type { PeerPath as P, PeerLink as a, PeerClock as b, PeerCloseReason as c, PeerLinkEvents as d, PeerLinkLag as e, PeerLinkLagOptions as f, PeerLinkState as g, PeerLinkStats as h };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { M as MethodQueryKey } from '../keys-CqKkljVN.js';
|
|
2
2
|
export { C as CollectionQueryKey, E as EntityQueryKey, K as KEY_ROOT, b as MethodKeyPrefix, S as ServiceKeyPrefix, c as collectionKey, e as entityKey, m as methodKey, a as methodKeyPrefix, s as serviceKeyPrefix } from '../keys-CqKkljVN.js';
|
|
3
|
-
import {
|
|
4
|
-
import { ae as ContractMap, ap as MethodName, J as AnyContract, ao as KindOf, al as InputOf, ar as OutputOf } from '../infer-Teo1xpsd.js';
|
|
3
|
+
import { ae as ContractMap, ap as MethodName, J as AnyContract, ao as KindOf, al as InputOf, ar as OutputOf } from '../infer-Br62cnyW.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Format a currency value for display.
|
|
@@ -91,6 +90,19 @@ interface ServerCallerOptions {
|
|
|
91
90
|
/** The `fetch` to call with. Default: the global one. */
|
|
92
91
|
readonly fetch?: typeof fetch;
|
|
93
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* The part of a TanStack `QueryClient` that `prefetch` calls, which any
|
|
95
|
+
* `QueryClient` is: `prefetchQuery` with the method's key and a function
|
|
96
|
+
* that calls it.
|
|
97
|
+
*/
|
|
98
|
+
interface QueryClientLike {
|
|
99
|
+
prefetchQuery(options: {
|
|
100
|
+
readonly queryKey: MethodQueryKey;
|
|
101
|
+
readonly queryFn: (context: {
|
|
102
|
+
readonly signal: AbortSignal;
|
|
103
|
+
}) => Promise<unknown>;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
}
|
|
94
106
|
/** Options of one HTTP call. */
|
|
95
107
|
interface ServerCallOptions {
|
|
96
108
|
/** Aborting it cancels the request; the call rejects with `CANCELLED`. */
|
|
@@ -104,7 +116,7 @@ interface ServerQuery<C extends AnyContract, M extends MethodName<C>> {
|
|
|
104
116
|
/** The key the query's result is cached under, the one the client's hooks read. */
|
|
105
117
|
key(...args: InputArgs<C, M, []>): MethodQueryKey<InputOf<C, M>>;
|
|
106
118
|
/** Calls the query into `queryClient`, as `queryClient.prefetchQuery` does: it never rejects. */
|
|
107
|
-
prefetch(queryClient:
|
|
119
|
+
prefetch(queryClient: QueryClientLike, ...args: InputArgs<C, M, []>): Promise<void>;
|
|
108
120
|
}
|
|
109
121
|
/** A mutation of the server caller. */
|
|
110
122
|
interface ServerMutation<C extends AnyContract, M extends MethodName<C>> {
|
|
@@ -137,4 +149,4 @@ type ServerCaller<Contracts extends ContractMap> = {
|
|
|
137
149
|
*/
|
|
138
150
|
declare function createServerCaller<const Contracts extends ContractMap>(contracts: Contracts, options: ServerCallerOptions): ServerCaller<Contracts>;
|
|
139
151
|
|
|
140
|
-
export { type BreadcrumbItem, type JWTPayload, MethodQueryKey, type NavItem, type ServerCallOptions, type ServerCaller, type ServerCallerHeaders, type ServerCallerOptions, type ServerMethod, type ServerMutation, type ServerQuery, buildBreadcrumbs, createServerCaller, findNavItemByHref, findParentNavItem, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, parseJWTPayload, routeRequiresAuth, truncate };
|
|
152
|
+
export { type BreadcrumbItem, type JWTPayload, MethodQueryKey, type NavItem, type QueryClientLike, type ServerCallOptions, type ServerCaller, type ServerCallerHeaders, type ServerCallerOptions, type ServerMethod, type ServerMutation, type ServerQuery, buildBreadcrumbs, createServerCaller, findNavItemByHref, findParentNavItem, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, parseJWTPayload, routeRequiresAuth, truncate };
|
package/dist/utils/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseJWTPayload,
|
|
12
12
|
routeRequiresAuth,
|
|
13
13
|
truncate
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-CYE4UBOB.js";
|
|
15
15
|
import {
|
|
16
16
|
KEY_ROOT,
|
|
17
17
|
collectionKey,
|
|
@@ -19,8 +19,11 @@ import {
|
|
|
19
19
|
methodKey,
|
|
20
20
|
methodKeyPrefix,
|
|
21
21
|
serviceKeyPrefix
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
} from "../chunk-IIQ3WMJK.js";
|
|
23
|
+
import "../chunk-MPQAT55F.js";
|
|
24
|
+
import "../chunk-47AEXVDM.js";
|
|
25
|
+
import "../chunk-Q4OGQM5I.js";
|
|
26
|
+
import "../chunk-QSU47XEX.js";
|
|
24
27
|
export {
|
|
25
28
|
KEY_ROOT,
|
|
26
29
|
buildBreadcrumbs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fitzzero/quickdraw-core",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3",
|
|
4
4
|
"description": "Fast fullstack patterns for real-time applications with Socket.io and TanStack Query",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fullstack",
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"types": "./dist/client/index.d.ts",
|
|
54
54
|
"import": "./dist/client/index.js"
|
|
55
55
|
},
|
|
56
|
+
"./client/core": {
|
|
57
|
+
"types": "./dist/client/core.d.ts",
|
|
58
|
+
"import": "./dist/client/core.js"
|
|
59
|
+
},
|
|
56
60
|
"./utils": {
|
|
57
61
|
"types": "./dist/utils/index.d.ts",
|
|
58
62
|
"import": "./dist/utils/index.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/caller.ts","../src/server/pipeline/errors.ts","../src/server/pipeline/schemaOutput.ts","../src/server/pipeline/validation.ts","../src/server/context.ts"],"sourcesContent":["// The in-process caller (RFC 0003 section 10): `caller.taskService.rename(input)`\n// runs the same pipeline as a socket call, with transport `\"internal\"`. Its\n// types come from the contracts: a method takes what a client would pass\n// (`InputOf`) and resolves with what a client would receive (`OutputOf`).\n// A failed call rejects with its `QuickdrawError`; an `INTERNAL` one keeps\n// the original error as `cause`.\n//\n// A caller through a server's dispatcher (`qd.caller`, `server.dispatcher.caller`)\n// gives a principal that carries no `serviceAccess` the grants the server's\n// `auth.loadServiceAccess` loads, as a socket's handshake and an HTTP call\n// do (finding F5.1 of the quickdraw-chat migration: an app's REST route ran\n// its in-process call with no grants at all): once per caller, at its first\n// call, and again after the server applied new grants to a user\n// (`access.refresh`, a written grant, another node's broadcast), as a\n// socket's are refreshed. A principal that carries grants, even `{}`, keeps\n// exactly those.\n\nimport type { AnyContract } from \"../contract/defineContract\";\nimport type { ContractMap, InputOf, MethodName, OutputOf } from \"../contract/infer\";\nimport { INTERNAL_MESSAGE, QuickdrawError } from \"../protocol/errors\";\nimport type { Dispatch } from \"./pipeline/pipeline\";\nimport type { DispatchRequest } from \"./pipeline/request\";\nimport type { ServerAuth } from \"./transports/auth\";\nimport type { Principal, QuickdrawTypes } from \"./types\";\n\n/** Options of one in-process call. */\nexport interface CallOptions {\n /** Cancels the call (queries only), like a client's `qd:cancel`. */\n readonly signal?: AbortSignal;\n}\n\n/** One method of the in-process caller. The input may be left out when the method accepts `undefined`. */\nexport type MethodCaller<C extends AnyContract, M extends MethodName<C>> = (\n ...args: undefined extends InputOf<C, M>\n ? [input?: InputOf<C, M>, options?: CallOptions]\n : [input: InputOf<C, M>, options?: CallOptions]\n) => Promise<OutputOf<C, M>>;\n\n/** The in-process caller of one service: one function per method. */\nexport type ServiceCaller<C extends AnyContract> = {\n readonly [M in MethodName<C>]: MethodCaller<C, M>;\n};\n\n/** The in-process caller of a set of contracts, by service name: `caller.taskService.rename(input)`. */\nexport type Caller<C extends AnyContract> = {\n readonly [Name in C[\"name\"]]: ServiceCaller<Extract<C, { readonly name: Name }>>;\n};\n\n/**\n * The type of `qd.caller(principal)`: typed from the app's `contracts` when\n * `QuickdrawTypes` declares them, and untyped (any service, method and\n * input) otherwise.\n */\nexport type CallerFor<T extends QuickdrawTypes> = T extends {\n readonly contracts: infer Contracts extends ContractMap;\n}\n ? Caller<Contracts[keyof Contracts]>\n : Caller<AnyContract>;\n\n/** Where the in-process callers of a server's dispatcher get the grants of a principal that carries none. */\nexport interface CallerGrants {\n /** The server's `auth.loadServiceAccess`. */\n readonly load: NonNullable<ServerAuth[\"loadServiceAccess\"]>;\n /**\n * Rises each time the server applies new grants to a user: a caller that\n * loaded its principal's grants before loads them again at its next call.\n */\n readonly version: () => number;\n}\n\nconst CALLER_GRANTS = new WeakMap<object, CallerGrants>();\n\n/**\n * Makes the in-process callers of `dispatcher` (its `caller`, and `qd.caller`\n * while it is the current one) load grants through `grants`: `createServer`\n * registers its `auth.loadServiceAccess`.\n */\nexport function setCallerGrants(dispatcher: object, grants: CallerGrants): void {\n CALLER_GRANTS.set(dispatcher, grants);\n}\n\n/** Where the callers of `dispatcher` load grants from, or `undefined` when they load none. */\nexport function callerGrantsOf(dispatcher: object | undefined): CallerGrants | undefined {\n return dispatcher === undefined ? undefined : CALLER_GRANTS.get(dispatcher);\n}\n\n/** How the calls of a {@link createCaller} run. */\nexport interface CallerSettings {\n /** Cancels every call too: `ctx.services` passes the calling method's `ctx.signal`. */\n readonly signal?: AbortSignal;\n /** Where to load a principal's grants from, asked at each call; `undefined` loads none. */\n readonly grants?: () => CallerGrants | undefined;\n}\n\ntype MethodFunction = (input?: unknown, options?: CallOptions) => Promise<unknown>;\n\nasync function invoke(resolve: () => Dispatch, request: DispatchRequest): Promise<unknown> {\n const result = await resolve()(request);\n if (!result.ok) {\n throw result.error;\n }\n return result.notModified === true ? undefined : result.data;\n}\n\n/**\n * A read-only object whose members are made on first access and kept. It is\n * never mistaken for a promise: `then` reads as `undefined`.\n */\nexport function lazyMembers<Member>(make: (name: string) => Member): object {\n const made = new Map<string, Member>();\n return new Proxy(Object.freeze({}), {\n get(_target, name) {\n if (typeof name !== \"string\" || name === \"then\") {\n return undefined;\n }\n let member = made.get(name);\n if (member === undefined) {\n member = make(name);\n made.set(name, member);\n }\n return member;\n },\n });\n}\n\n/** `signal`, and also `outer` when there is one: aborted when either is. */\nfunction bothSignals(outer: AbortSignal | undefined, signal: AbortSignal | undefined) {\n if (outer === undefined || signal === undefined) {\n return outer ?? signal;\n }\n return AbortSignal.any([outer, signal]);\n}\n\n/** True when `principal` carries grants of its own (`{}` included): they are kept as they are. */\nfunction carriesGrants(principal: Principal): boolean {\n return principal.serviceAccess !== undefined && principal.serviceAccess !== null;\n}\n\n/** `principal` with the grants `grants` loads (`{}` for none). A failed load is `INTERNAL`, keeping the error as `cause`. */\nasync function withLoadedGrants(principal: Principal, grants: CallerGrants): Promise<Principal> {\n let serviceAccess: Awaited<ReturnType<CallerGrants[\"load\"]>>;\n try {\n serviceAccess = await grants.load(principal.userId);\n } catch (error) {\n const failure = new QuickdrawError(\"INTERNAL\", INTERNAL_MESSAGE);\n failure.cause = error;\n throw failure;\n }\n return { ...principal, serviceAccess: serviceAccess ?? {} };\n}\n\n/** What each call of a caller runs as: the principal, or a promise of it while its grants load. */\ntype PrincipalOfCall = () => Principal | null | Promise<Principal>;\n\n/**\n * The principal each call of a caller runs as: `principal` itself when it is\n * `null`, carries grants, or `grants` gives no loader; else `principal` with\n * the grants loaded at the first call, kept until the server applied new\n * grants to a user (its version rose) or the loader changed. A load that\n * failed is not kept: the next call loads again.\n */\nfunction principalOfCalls(\n principal: Principal | null,\n grants: CallerSettings[\"grants\"],\n): PrincipalOfCall {\n if (principal === null || carriesGrants(principal) || grants === undefined) {\n return () => principal;\n }\n interface Held {\n readonly from: CallerGrants;\n readonly version: number;\n readonly loading: Promise<Principal>;\n loaded?: Principal;\n }\n let held: Held | undefined;\n return () => {\n const from = grants();\n if (from === undefined) {\n return principal;\n }\n const version = from.version();\n if (held?.from === from && held.version === version) {\n return held.loaded ?? held.loading;\n }\n const entry: Held = { from, version, loading: withLoadedGrants(principal, from) };\n held = entry;\n entry.loading.then(\n (loaded) => {\n entry.loaded = loaded;\n },\n () => {\n if (held === entry) {\n held = undefined;\n }\n },\n );\n return entry.loading;\n };\n}\n\n/**\n * Creates an in-process caller acting as `principal` (`null` for an\n * anonymous caller). `resolve` returns the dispatch function to call through;\n * it is asked on every call, so a caller made before its dispatcher exists\n * works once one does. Every call is also cancelled with `settings.signal`,\n * when given (`ctx.services` passes the calling method's `ctx.signal`). With\n * `settings.grants`, a principal that carries no grants calls with the ones\n * it loads (see the top of this file).\n */\nexport function createCaller(\n resolve: () => Dispatch,\n principal: Principal | null,\n settings: CallerSettings = {},\n): object {\n const principalOfCall = principalOfCalls(principal, settings.grants);\n return lazyMembers((service) =>\n lazyMembers<MethodFunction>((method) => async (input, options) => {\n const runAs = principalOfCall();\n return await invoke(resolve, {\n service,\n method,\n input,\n // Awaited only while grants load: a known principal is dispatched at once, as before.\n principal: runAs instanceof Promise ? await runAs : runAs,\n transport: \"internal\",\n signal: bothSignals(settings.signal, options?.signal),\n });\n }),\n );\n}\n","// How the pipeline turns whatever a stage or handler threw into the error the\n// caller receives (RFC 0003 section 3). A `QuickdrawError` with one of the\n// error codes passes through. Prisma's two known request errors that callers\n// can act on become `CONFLICT` and `NOT_FOUND`. Everything else becomes\n// `INTERNAL` with the generic message, keeping the original as `cause` for\n// the log and for in-process callers; `toWire` never sends it. That includes\n// a `QuickdrawError` whose code is not one of the error codes, which a cast or\n// a 4.x port (`new QuickdrawError(404, ...)`) can build: no transport has a\n// reply or an HTTP status for it.\n\nimport { INTERNAL_MESSAGE, isErrorCode, QuickdrawError } from \"../../protocol/errors\";\n\n/** The error a cancelled call settles with. */\nexport function cancelledError(): QuickdrawError {\n return new QuickdrawError(\"CANCELLED\", \"The call was cancelled\");\n}\n\n/** The error a call settles with when its handler runs past the time limit. */\nexport function timeoutError(timeoutMs: number): QuickdrawError {\n return new QuickdrawError(\"TIMEOUT\", `The call ran past its time limit of ${timeoutMs} ms`);\n}\n\n/** Throws `CANCELLED` when `signal` has aborted. */\nexport function throwIfCancelled(signal: AbortSignal | undefined): void {\n if (signal?.aborted === true) {\n throw cancelledError();\n }\n}\n\n/**\n * The error a call settles with once its signal aborted: the `TIMEOUT` error\n * its time limit aborted it with, or else `CANCELLED`.\n */\nexport function abortError(signal: AbortSignal): QuickdrawError {\n const reason: unknown = signal.reason;\n return reason instanceof QuickdrawError && reason.code === \"TIMEOUT\" ? reason : cancelledError();\n}\n\nfunction prismaError(error: unknown): QuickdrawError | undefined {\n if (!(error instanceof Error) || error.name !== \"PrismaClientKnownRequestError\") {\n return undefined;\n }\n const { code } = error as Error & { readonly code?: unknown };\n if (code === \"P2002\") {\n return new QuickdrawError(\"CONFLICT\", \"A unique constraint failed\");\n }\n if (code === \"P2025\") {\n return new QuickdrawError(\"NOT_FOUND\", \"Record not found\");\n }\n return undefined;\n}\n\n/**\n * The `QuickdrawError` a caller receives for `error`. Anything but a\n * `QuickdrawError` with a known code becomes another error that keeps the\n * original as `cause`, so it can be logged in full.\n */\nexport function toQuickdrawError(error: unknown): QuickdrawError {\n if (error instanceof QuickdrawError && isErrorCode(error.code)) {\n return error;\n }\n const mapped = prismaError(error) ?? new QuickdrawError(\"INTERNAL\", INTERNAL_MESSAGE);\n mapped.cause = error;\n return mapped;\n}\n","// Schema outputs (RFC 0003 section 9, step 8): a method whose output is a\n// schema of its own, not `\"entity\"` and not a projection, sends its result\n// reduced to what that schema's JSON Schema declares, on every transport and\n// whatever `outputValidation` is. A handler may return a whole row; only the\n// keys the schema declares leave the server. rc.5 and before sent what the\n// handler returned, so `{ id, name }` answered with `db.user.update(...)`\n// sent `email` too (the final review of the release candidates, item B).\n//\n// The reduction is compiled once per method, when its service is defined,\n// from the schema's Standard JSON Schema (draft-07, a value JSON Schema\n// cannot write read as any value): a call walks the compiled shapes and\n// never reads the schema. What a value keeps, by what the schema says there:\n//\n// | JSON Schema | A value there keeps |\n// |-------------------------------------------|------------------------------------------------------|\n// | an object with `properties` | the keys `properties` declares, each reduced by its |\n// | | own schema; another key only where |\n// | | `patternProperties` matches it or |\n// | | `additionalProperties` allows it (`true`, `{}`, or a |\n// | | schema that reduces its value) |\n// | an object declaring no key (a record, | every key, each value reduced by |\n// | `{ type: \"object\" }`) | `additionalProperties` when it is a schema |\n// | an array | its items, each reduced by `items` (a tuple's by |\n// | | position, the rest by `additionalItems`) |\n// | `anyOf`, `oneOf`, `allOf` | what any of its schemas keeps |\n// | `{}` (any value), `true`, a `$ref` it | everything, as it is |\n// | cannot follow | |\n// | a scalar (`string`, `const`, `enum`, ...) | a scalar as it is; a plain object there keeps no key |\n//\n// Only plain objects and arrays are reduced: a `Date`, a `Decimal` or a\n// class instance goes as it is. Nothing is copied unless a key or an item is\n// dropped, so a handler that returns exactly its schema's keys costs one\n// pass over them. An output without JSON Schema (a Zod 3 schema) cannot be\n// reduced and is sent as returned; in development its reply is checked for\n// keys the contract tiers instead (`emit/tieredOutputs.ts`).\n\nimport { hasJsonSchema, type StandardSchemaV1 } from \"../../contract/standardSchema\";\nimport type { SchemaOutput } from \"../service\";\n\ntype JsonNode = Readonly<Record<string, unknown>>;\n\n/** How the values at one place of an output are reduced. */\ninterface Shape {\n /** Any value: kept as it is. */\n readonly any: boolean;\n /** How a plain object there is reduced; without one, it keeps no key. */\n object: ObjectShape | undefined;\n /** How an array there is reduced; without one, each item is reduced by this shape. */\n array: ArrayShape | undefined;\n}\n\ninterface ObjectShape {\n /** The declared keys' shapes, in an object without a prototype: a lookup per key is a property read. */\n readonly properties: Readonly<Record<string, Shape | undefined>>;\n readonly patterns: readonly { readonly regex: RegExp; readonly shape: Shape }[];\n /** How the value of a key `properties` and `patterns` do not declare is reduced; `undefined` drops the key. */\n readonly additional: Shape | undefined;\n}\n\ninterface ArrayShape {\n readonly prefix: readonly Shape[];\n /** How the items past `prefix` are reduced; `undefined` drops them. */\n readonly rest: Shape | undefined;\n}\n\n/** Any value, kept as it is. */\nconst ANY: Shape = Object.freeze({ any: true, object: undefined, array: undefined });\n\n/** What one JSON Schema node declares on its own, before its `anyOf`, `oneOf`, `allOf` and `$ref`. */\ninterface Node {\n readonly id: number;\n any: boolean;\n object:\n | {\n properties: Map<string, Node>;\n patterns: { regex: RegExp; node: Node }[];\n additional: Node | undefined;\n }\n | undefined;\n array: { prefix: Node[]; rest: Node | undefined } | undefined;\n /** The schemas it is one of, or all of: its branches and the node its `$ref` names. */\n readonly members: Node[];\n}\n\nfunction isRecord(value: unknown): value is JsonNode {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** True for an object literal, or `Object.create(null)`, of any realm: what a reduction may copy. */\nfunction isPlainObject(value: object): value is Readonly<Record<string, unknown>> {\n const prototype = Object.getPrototypeOf(value) as object | null;\n return (\n prototype === Object.prototype ||\n prototype === null ||\n Object.getPrototypeOf(prototype) === null\n );\n}\n\n/** The node a `$ref` names in the document: `#`, or a JSON Pointer into it; `undefined` when it names none. */\nfunction follow(ref: string, root: JsonNode): unknown {\n if (ref === \"#\") {\n return root;\n }\n if (!ref.startsWith(\"#/\")) {\n return undefined;\n }\n let node: unknown = root;\n for (const raw of ref.slice(2).split(\"/\")) {\n let part: string;\n try {\n part = decodeURIComponent(raw).replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n } catch {\n return undefined;\n }\n node = isRecord(node) && Object.hasOwn(node, part) ? node[part] : undefined;\n }\n return node;\n}\n\nconst BRANCHES = [\"anyOf\", \"oneOf\", \"allOf\"] as const;\n\nfunction hasAny(node: JsonNode, keywords: readonly string[]): boolean {\n return keywords.some((keyword) => node[keyword] !== undefined);\n}\n\nfunction typesOf(node: JsonNode): readonly unknown[] | undefined {\n const { type } = node;\n if (typeof type === \"string\") {\n return [type];\n }\n return Array.isArray(type) ? type : undefined;\n}\n\nfunction patternOf(source: string): RegExp | undefined {\n try {\n return new RegExp(source, \"u\");\n } catch {\n try {\n return new RegExp(source);\n } catch {\n return undefined;\n }\n }\n}\n\n/** Every node `nodes` stand for: themselves and, through their members, the schemas they combine. */\nfunction expand(nodes: readonly Node[]): Node[] {\n const seen = new Set<Node>();\n const pending = [...nodes];\n for (let node = pending.pop(); node !== undefined; node = pending.pop()) {\n if (!seen.has(node)) {\n seen.add(node);\n pending.push(...node.members);\n }\n }\n return [...seen];\n}\n\n/**\n * Compiles one JSON Schema document: reads it into nodes (each JSON node\n * once, `$ref` cycles included), then builds the shapes calls walk, one per\n * set of nodes a value may meet, merged once.\n */\nclass Compiler {\n private next = 0;\n private readonly nodes = new Map<unknown, Node>();\n private readonly shapes = new Map<string, Shape>();\n\n constructor(private readonly root: JsonNode) {}\n\n private make(any: boolean): Node {\n this.next += 1;\n return { id: this.next, any, object: undefined, array: undefined, members: [] };\n }\n\n /** The node a JSON Schema value stands for. `true` and absent are any value. */\n read(value: unknown): Node {\n if (value === undefined || value === true) {\n return this.make(true);\n }\n if (!isRecord(value)) {\n // `false` (no value) and anything malformed: a scalar, which keeps no key of an object.\n return this.make(false);\n }\n const known = this.nodes.get(value);\n if (known !== undefined) {\n return known;\n }\n const node = this.make(false);\n this.nodes.set(value, node);\n this.readMembers(node, value);\n this.readParts(node, value);\n return node;\n }\n\n /** The node's `$ref` target and its `anyOf`, `oneOf` and `allOf` branches. */\n private readMembers(node: Node, json: JsonNode): void {\n const { $ref } = json;\n if (typeof $ref === \"string\") {\n const target = follow($ref, this.root);\n node.members.push(target === undefined ? this.make(true) : this.read(target));\n }\n for (const keyword of BRANCHES) {\n const members = json[keyword];\n if (!Array.isArray(members)) {\n continue;\n }\n for (const member of members) {\n const read = this.read(member);\n // A part of an `allOf` that allows any value adds nothing to the others.\n if (!(keyword === \"allOf\" && read.any && members.length > 1)) {\n node.members.push(read);\n }\n }\n }\n }\n\n /** What the node declares itself: an object, an array, a scalar, or any value. */\n private readParts(node: Node, json: JsonNode): void {\n const types = typesOf(json);\n const combined = node.members.length > 0;\n const objectKeywords = hasAny(json, [\n \"properties\",\n \"patternProperties\",\n \"additionalProperties\",\n ]);\n const arrayKeywords = hasAny(json, [\"items\", \"prefixItems\", \"additionalItems\"]);\n if (objectKeywords) {\n node.object = this.readObject(json);\n } else if (!combined && types?.includes(\"object\") === true) {\n // An object that declares no key, as a record does: every key.\n node.object = { properties: new Map(), patterns: [], additional: this.make(true) };\n }\n if (arrayKeywords) {\n node.array = this.readArray(json);\n } else if (!combined && types?.includes(\"array\") === true) {\n node.array = { prefix: [], rest: this.make(true) };\n }\n const scalar = types !== undefined || hasAny(json, [\"const\", \"enum\"]);\n node.any = !combined && !objectKeywords && !arrayKeywords && !scalar;\n }\n\n private readObject(json: JsonNode): NonNullable<Node[\"object\"]> {\n const properties = new Map<string, Node>();\n if (isRecord(json.properties)) {\n for (const [key, schema] of Object.entries(json.properties)) {\n properties.set(key, this.read(schema));\n }\n }\n const patterns: { regex: RegExp; node: Node }[] = [];\n let open = false;\n if (isRecord(json.patternProperties)) {\n for (const [source, schema] of Object.entries(json.patternProperties)) {\n const regex = patternOf(source);\n if (regex === undefined) {\n open = true;\n } else {\n patterns.push({ regex, node: this.read(schema) });\n }\n }\n }\n const { additionalProperties } = json;\n let additional: Node | undefined;\n if (open) {\n additional = this.make(true);\n } else if (additionalProperties === undefined) {\n // Properties declared and nothing said of the others: the declared keys only.\n additional =\n json.properties === undefined && json.patternProperties === undefined\n ? this.make(true)\n : undefined;\n } else {\n additional = additionalProperties === false ? undefined : this.read(additionalProperties);\n }\n return { properties, patterns, additional };\n }\n\n private readArray(json: JsonNode): NonNullable<Node[\"array\"]> {\n const { items, prefixItems, additionalItems } = json;\n if (Array.isArray(items)) {\n // draft-07's tuple: `items` by position, `additionalItems` past them.\n return {\n prefix: items.map((item: unknown) => this.read(item)),\n rest: additionalItems === false ? undefined : this.read(additionalItems),\n };\n }\n const prefix = Array.isArray(prefixItems)\n ? prefixItems.map((item: unknown) => this.read(item))\n : [];\n return { prefix, rest: items === false ? undefined : this.read(items) };\n }\n\n /** The shape of a value any of `nodes` describes. */\n shapeOf(nodes: readonly Node[]): Shape {\n const all = expand(nodes);\n if (all.some((node) => node.any)) {\n return ANY;\n }\n const key = all\n .map((node) => node.id)\n .sort((a, b) => a - b)\n .join(\",\");\n const known = this.shapes.get(key);\n if (known !== undefined) {\n return known;\n }\n // Registered before its parts are built, so a recursive schema meets itself.\n const shape: Shape = { any: false, object: undefined, array: undefined };\n this.shapes.set(key, shape);\n const objects = all.flatMap((node) => (node.object === undefined ? [] : [node.object]));\n const arrays = all.flatMap((node) => (node.array === undefined ? [] : [node.array]));\n shape.object = objects.length === 0 ? undefined : this.objectShapeOf(objects);\n shape.array = arrays.length === 0 ? undefined : this.arrayShapeOf(arrays);\n return shape;\n }\n\n private objectShapeOf(objects: readonly NonNullable<Node[\"object\"]>[]): ObjectShape {\n const keys = new Set(objects.flatMap((object) => [...object.properties.keys()]));\n const properties = Object.create(null) as Record<string, Shape>;\n for (const key of keys) {\n const nodes = objects.flatMap((object) => {\n const declared =\n object.properties.get(key) ??\n object.patterns.find(({ regex }) => regex.test(key))?.node ??\n object.additional;\n return declared === undefined ? [] : [declared];\n });\n properties[key] = this.shapeOf(nodes);\n }\n const patterns = objects.flatMap((object) =>\n object.patterns.map(({ regex, node }) => ({ regex, shape: this.shapeOf([node]) })),\n );\n const additional = objects.flatMap((object) =>\n object.additional === undefined ? [] : [object.additional],\n );\n return {\n properties,\n patterns,\n additional: additional.length === 0 ? undefined : this.shapeOf(additional),\n };\n }\n\n private arrayShapeOf(arrays: readonly NonNullable<Node[\"array\"]>[]): ArrayShape {\n const length = Math.max(...arrays.map((array) => array.prefix.length));\n const at = (index: number): Node[] =>\n arrays.flatMap((array) => {\n const node = index < array.prefix.length ? array.prefix[index] : array.rest;\n return node === undefined ? [] : [node];\n });\n const prefix = Array.from({ length }, (_, index) => this.shapeOf(at(index)));\n const rest = arrays.flatMap((array) => (array.rest === undefined ? [] : [array.rest]));\n return { prefix, rest: rest.length === 0 ? undefined : this.shapeOf(rest) };\n }\n}\n\n/** Marks a key or an item a reduction drops. */\nconst DROPPED: unique symbol = Symbol(\"dropped\");\n\n/** Sets `key` on a copy, `__proto__` too, as an own key. */\nfunction assign(copy: Record<string, unknown>, key: string, value: unknown): void {\n if (key === \"__proto__\") {\n Object.defineProperty(copy, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n } else {\n copy[key] = value;\n }\n}\n\nfunction shapeOfKey(object: ObjectShape, key: string): Shape | undefined {\n const declared = object.properties[key];\n if (declared !== undefined) {\n return declared;\n }\n for (const { regex, shape } of object.patterns) {\n if (regex.test(key)) {\n return shape;\n }\n }\n return object.additional;\n}\n\n/** `item` as `shape` keeps it, or `DROPPED`; a scalar is kept without a call. */\nfunction keep(shape: Shape | undefined, item: unknown): unknown {\n if (shape === undefined) {\n return DROPPED;\n }\n return shape.any || typeof item !== \"object\" || item === null ? item : reduce(shape, item);\n}\n\nfunction reduceObject(\n object: ObjectShape | undefined,\n value: Readonly<Record<string, unknown>>,\n): Readonly<Record<string, unknown>> {\n const keys = Object.keys(value);\n let copy: Record<string, unknown> | undefined;\n for (let index = 0; index < keys.length; index += 1) {\n const key = keys[index] as string;\n const item = value[key];\n const kept = keep(object === undefined ? undefined : shapeOfKey(object, key), item);\n if (copy === undefined) {\n if (kept === item) {\n continue;\n }\n copy = {};\n for (let earlier = 0; earlier < index; earlier += 1) {\n const name = keys[earlier] as string;\n assign(copy, name, value[name]);\n }\n }\n if (kept !== DROPPED) {\n assign(copy, key, kept);\n }\n }\n return copy ?? value;\n}\n\nfunction reduceArray(shape: Shape, value: readonly unknown[]): readonly unknown[] {\n const { array } = shape;\n let copy: unknown[] | undefined;\n for (let index = 0; index < value.length; index += 1) {\n const item: unknown = value[index];\n const kept = keep(\n array === undefined ? shape : index < array.prefix.length ? array.prefix[index] : array.rest,\n item,\n );\n if (copy === undefined) {\n if (kept === item) {\n continue;\n }\n copy = value.slice(0, index);\n }\n if (kept !== DROPPED) {\n copy.push(kept);\n }\n }\n return copy ?? value;\n}\n\n/** An object `value` as `shape` keeps it. */\nfunction reduce(shape: Shape, value: object): unknown {\n if (Array.isArray(value)) {\n return reduceArray(shape, value);\n }\n return isPlainObject(value) ? reduceObject(shape.object, value) : value;\n}\n\n/** Where a shape declares each key it names, at any depth: the shortest path found first. */\nfunction keyPaths(root: Shape): ReadonlyMap<string, string> {\n const paths = new Map<string, string>();\n const seen = new Set<Shape>();\n const queue: { readonly shape: Shape; readonly path: string }[] = [{ shape: root, path: \"\" }];\n for (let index = 0; index < queue.length; index += 1) {\n const { shape, path } = queue[index] as { readonly shape: Shape; readonly path: string };\n if (seen.has(shape)) {\n continue;\n }\n seen.add(shape);\n if (shape.object !== undefined) {\n for (const [key, child] of Object.entries(shape.object.properties)) {\n if (child === undefined) {\n continue;\n }\n const at = path === \"\" ? key : `${path}.${key}`;\n if (!paths.has(key)) {\n paths.set(key, at);\n }\n queue.push({ shape: child, path: at });\n }\n for (const { shape: child } of shape.object.patterns) {\n queue.push({ shape: child, path: `${path}{}` });\n }\n if (shape.object.additional !== undefined) {\n queue.push({ shape: shape.object.additional, path: `${path}{}` });\n }\n }\n if (shape.array !== undefined) {\n for (const child of shape.array.prefix) {\n queue.push({ shape: child, path: `${path}[]` });\n }\n if (shape.array.rest !== undefined) {\n queue.push({ shape: shape.array.rest, path: `${path}[]` });\n }\n }\n }\n return paths;\n}\n\n/** Writes values JSON Schema has no form for as `{}` (any value), keeping the keys beside them (Zod 4). */\nconst UNREPRESENTABLE_AS_ANY = Object.freeze({ unrepresentable: \"any\" });\n\n/**\n * Compiles a method's output schema (see the top of this file), or\n * `undefined` when it has no Standard JSON Schema or cannot write one: such\n * an output is sent as the handler returns it.\n */\nexport function compileSchemaOutput(schema: StandardSchemaV1): SchemaOutput | undefined {\n if (!hasJsonSchema(schema)) {\n return undefined;\n }\n let json: unknown;\n try {\n json = schema[\"~standard\"].jsonSchema.output({\n target: \"draft-07\",\n libraryOptions: UNREPRESENTABLE_AS_ANY,\n });\n } catch {\n return undefined;\n }\n if (!isRecord(json)) {\n return undefined;\n }\n const compiler = new Compiler(json);\n const root = compiler.shapeOf([compiler.read(json)]);\n let paths: ReadonlyMap<string, string> | undefined;\n return Object.freeze({\n pick: (value: unknown) => keep(root, value),\n keyPaths: () => (paths ??= keyPaths(root)),\n });\n}\n","// Input and output validation (RFC 0003 section 9, steps 3 and 8). Input\n// failures reach the caller as `VALIDATION` with `data.issues` in the wire\n// shape `{ path, message }[]`. 4.1 sent Zod's message as a code-400 string\n// (4.1 `src/server/ServiceRegistry.ts:296-305`), and only when the method\n// had a schema at all.\n\nimport type { AnyContract } from \"../../contract/defineContract\";\nimport type { MethodOutput } from \"../../contract/methods\";\nimport {\n isStandardSchema,\n validate,\n type StandardSchemaV1,\n type ValidationIssue,\n} from \"../../contract/standardSchema\";\nimport { QuickdrawError, type WireIssue } from \"../../protocol/errors\";\nimport type { SchemaOutput } from \"../service\";\nimport { compileSchemaOutput } from \"./schemaOutput\";\n\ntype PathSegment = NonNullable<ValidationIssue[\"path\"]>[number];\n\nfunction wireKey(key: PropertyKey): string | number {\n if (typeof key === \"symbol\") {\n return key.description ?? key.toString();\n }\n return key;\n}\n\nfunction wireSegment(segment: PathSegment): string | number {\n return typeof segment === \"object\" ? wireKey(segment.key) : wireKey(segment);\n}\n\n/**\n * Standard Schema issues in the wire shape of RFC 0003 section 3: each path\n * as object keys and array indexes (a `{ key }` segment becomes its key, a\n * symbol its description), and the message unchanged.\n */\nexport function toWireIssues(issues: readonly ValidationIssue[]): WireIssue[] {\n return issues.map((issue) => ({\n path: (issue.path ?? []).map(wireSegment),\n message: issue.message,\n }));\n}\n\n/** Validates a call's input. Resolves with the parsed input, or rejects with `VALIDATION`. */\nexport async function parseInput(\n schema: StandardSchemaV1,\n input: unknown,\n label: string,\n): Promise<unknown> {\n const result = await validate(schema, input);\n if (result.issues !== undefined) {\n throw new QuickdrawError(\"VALIDATION\", `Invalid input for ${label}`, {\n issues: toWireIssues(result.issues),\n });\n }\n return result.value;\n}\n\nfunction derivedSchema(validateValue: StandardSchemaV1.Props[\"validate\"]): StandardSchemaV1 {\n return Object.freeze({\n \"~standard\": Object.freeze({ version: 1, vendor: \"quickdraw\", validate: validateValue }),\n });\n}\n\nfunction nullableOf(inner: StandardSchemaV1): StandardSchemaV1 {\n return derivedSchema((value) =>\n value === null ? { value } : inner[\"~standard\"].validate(value),\n );\n}\n\nfunction listOfSchema(inner: StandardSchemaV1): StandardSchemaV1 {\n return derivedSchema(async (value) => {\n if (!Array.isArray(value)) {\n return { issues: [{ message: \"Expected an array\", path: [] }] };\n }\n const results = await Promise.all(value.map((item: unknown) => validate(inner, item)));\n const issues = results.flatMap((result, index) =>\n (result.issues ?? []).map((issue) => ({\n message: issue.message,\n path: [index, ...(issue.path ?? [])],\n })),\n );\n return issues.length > 0 ? { issues } : { value };\n });\n}\n\nfunction projectionSchema(contract: AnyContract, projection: string): StandardSchemaV1 {\n const found = projection === \"entity\" ? contract.entity : contract.projections[projection];\n if (found === undefined) {\n throw new TypeError(\n `defineService(\"${contract.name}\"): output names unknown projection \"${projection}\"`,\n );\n }\n return found;\n}\n\n/**\n * The schema a method's result is checked against: its `output` schema, or\n * the entity or projection schema it names, wrapped for `nullable(...)` and\n * `listOf(...)` (RFC 0003 section 17).\n */\nexport function outputSchemaOf(contract: AnyContract, output: MethodOutput): StandardSchemaV1 {\n if (isStandardSchema(output)) {\n return output;\n }\n if (typeof output === \"string\") {\n return projectionSchema(contract, output);\n }\n const row = projectionSchema(contract, output.projection);\n return output.kind === \"nullable\" ? nullableOf(row) : listOfSchema(row);\n}\n\n/**\n * A method output that is a schema of its own, compiled to reduce results to\n * what it declares (`schemaOutput.ts`); `undefined` for a projection output\n * or a schema without JSON Schema.\n */\nexport function schemaOutputOf(output: MethodOutput): SchemaOutput | undefined {\n return isStandardSchema(output) ? compileSchemaOutput(output) : undefined;\n}\n\n/** The problems with a handler's result, or `undefined` when it matches the method's output. */\nexport async function outputIssues(\n output: StandardSchemaV1,\n value: unknown,\n): Promise<WireIssue[] | undefined> {\n const result = await validate(output, value);\n return result.issues === undefined ? undefined : toWireIssues(result.issues);\n}\n","// The argument every handler receives, `{ input, ctx, db }` (RFC 0003\n// section 3). `ctx` replaces 4.1's `ServiceMethodContext` (`userId`,\n// `socketId`, `serviceAccess`; 4.1 `src/shared/types.ts:111-115`) and the\n// habit of overriding `defineMethod` to add fields: an app adds its own\n// fields once, through `initQuickdraw({ context })`.\n\nimport type { AnyContract } from \"../contract/defineContract\";\nimport type { Logger } from \"../contract/logger\";\nimport { QuickdrawError } from \"../protocol/errors\";\nimport type { DispatcherAccess, PolicyEngine } from \"./access/api\";\nimport { createCaller, type CallerFor } from \"./caller\";\nimport type { Dispatch } from \"./pipeline/pipeline\";\nimport type { ContextRooms, Presence } from \"./realtime/types\";\nimport type { AnyService } from \"./service\";\nimport type { StorageAdapter } from \"./storage\";\nimport type {\n ContextExtensionOf,\n DbOf,\n McpContext,\n McpContextOf,\n Principal,\n PrincipalOf,\n QuickdrawTypes,\n Transport,\n} from \"./types\";\n\n/** Options of `ctx.touch`. */\nexport interface TouchOptions {\n /** The rows were deleted rather than changed. */\n readonly removed?: boolean;\n}\n\n/**\n * `ctx.services`: in-process callers for the app's services (RFC 0003\n * sections 3 and 10), by service name: `ctx.services.projectService.get(input)`.\n * A call runs the whole pipeline (input check, access, handler, output\n * check) as the calling principal with transport `\"internal\"`, its writes\n * join the calling method's unit of work (one flush for both), and it is\n * cancelled with `ctx.signal`. Typed by the `contracts` of the app's types,\n * like `qd.caller`; untyped without them.\n */\nexport type ContextServices<T extends QuickdrawTypes = QuickdrawTypes> = CallerFor<T>;\n\nexport type { ContextRooms, Presence };\n\n/**\n * The fields of `ctx` the framework provides, whatever the app adds. `M` is\n * the type of `ctx.mcp`.\n */\nexport interface BaseContext<P = Principal, M = McpContext> {\n /**\n * Who is calling. `null` only in a `\"public\"` method called without\n * credentials; every other access form guarantees a principal.\n */\n readonly principal: P;\n /**\n * Aborts when the call is cancelled (a query whose callers all cancelled)\n * or runs past its time limit. Pass it to anything that can stop early.\n */\n readonly signal: AbortSignal;\n /** A logger bound to this call's service, method and request id. */\n readonly log: Logger;\n /** Identifies this call in logs and in its completion record. */\n readonly requestId: string;\n /** How the call arrived. */\n readonly transport: Transport;\n /**\n * The socket the call arrived on: its id, as the client socket's `id`,\n * `onRoomLeave`'s `socketId` and a channel handler's `ctx.socketId` name\n * it (a game keys a player's input by it). A call through the 4.x legacy\n * shim has it too: it arrived on a socket. `undefined` for a call that\n * did not arrive over a socket: HTTP, MCP, in process, `ctx.services`. In\n * a method that shares its runs (`share`), the first caller's.\n */\n readonly socketId?: string;\n /**\n * The fields the MCP bridge's `context` option produced for this call, such\n * as the scopes of the agent's token; typed by `QuickdrawTypes[\"mcp\"]`.\n * `undefined` unless the call arrived over MCP.\n */\n readonly mcp?: M;\n /**\n * Records writes the tracked database client cannot see, raw SQL and\n * database cascades (RFC 0003 section 5.2), as if the client had made\n * them here: inside an open `db.$transaction` they join it and are dropped\n * on rollback. `target` is the model name (`\"task\"`); `removed` marks the\n * rows deleted. Does nothing when the dispatcher's `db` is not tracked.\n */\n touch(\n target: string | AnyContract,\n ids: string | readonly string[],\n options?: TouchOptions,\n ): void;\n /**\n * In-process callers for the app's services, as this call's principal:\n * `await ctx.services.projectService.get({ id })`. See {@link ContextServices}.\n */\n readonly services: ContextServices;\n /**\n * App-defined rooms the calling socket joins and leaves (`join` answers\n * `false` for a call without a socket), and typed room events: `emit` and\n * `emitToUser` (RFC 0003 section 12.5).\n */\n readonly rooms: ContextRooms;\n /** Who is online, when they were last seen, and who is in a room (RFC 0003 section 12.5). */\n readonly presence: Presence;\n}\n\n/**\n * A handler's `ctx`: the framework's fields plus the app's own from\n * `initQuickdraw({ context })`. An app field cannot replace a framework field.\n */\nexport type HandlerContext<T extends QuickdrawTypes, P = PrincipalOf<T>> = Omit<\n ContextExtensionOf<T>,\n keyof BaseContext\n> &\n Omit<BaseContext<P, McpContextOf<T>>, \"services\"> & {\n /** In-process callers for the app's services, typed by its `contracts`. */\n readonly services: ContextServices<T>;\n };\n\n/** What a handler receives: the parsed input, the call's context and the app's database client. */\nexport interface HandlerArgs<T extends QuickdrawTypes, Input, P = PrincipalOf<T>> {\n /** The input after its schema ran: defaults applied, transforms done. */\n readonly input: Input;\n readonly ctx: HandlerContext<T, P>;\n /** The database client given to the dispatcher, passed through unchanged. */\n readonly db: DbOf<T>;\n}\n\n/** Any handler's `ctx`, as the pipeline handles it. */\nexport type AnyContext = BaseContext<Principal | null>;\n\n/**\n * What `qd.run(fn)` and `dispatcher.run(fn)` give `fn`: the part of a\n * handler's `ctx` that means something outside a method call. A job has no\n * caller, so `principal` is `null`. A `fn` that takes no parameter still\n * works.\n *\n * @example\n * await qd.run(async (ctx) => {\n * const ids = await renumberWithSql(projectId);\n * ctx.touch(\"task\", ids);\n * });\n */\nexport interface RunContext {\n /** `ctx.touch`: records rows the tracked client cannot see (raw SQL, cascades) in this run's unit of work. */\n readonly touch: BaseContext[\"touch\"];\n /** The dispatcher's logger, bound to this run's request id. */\n readonly log: Logger;\n readonly principal: null;\n}\n\n/** Options of `qd.run(fn, options)` and `dispatcher.run(fn, options)`. */\nexport interface RunOptions {\n /**\n * Run `fn` in a unit of work of its own even inside a method call or a\n * transaction: for background work a handler starts and does not await\n * (a push sent after the reply, pruning what it reports dead). Its writes\n * flush once `fn` settles, on their own, instead of joining the handler's\n * unit, which may have flushed long before (they would then flush as\n * ambient writes, with a development warning). A failed flush is logged.\n * Default `false`: inside an open unit of work or transaction, `fn` joins\n * it.\n *\n * @example\n * // in a handler, not awaited: the reply does not wait for the push\n * void qd.run(() => sendPushes(db, message), { detached: true }).catch((error) => {\n * ctx.log.error(\"Pushing the message failed\", { error: String(error) });\n * });\n */\n readonly detached?: boolean;\n}\n\n/** Builds the app's fields of `ctx` from the framework's: the `context` option of `initQuickdraw`. */\nexport type ContextExtender = (base: AnyContext) => object;\n\n/**\n * What the framework's kits (RFC 0003 section 12) know about the call a\n * `ctx` belongs to: the service whose method runs, and the dispatcher's\n * access policies and storage adapter. A kit's handlers are made before any\n * dispatcher exists, so they find these through `kitRuntimeOf(ctx)`. It is\n * never a member of `ctx`.\n */\nexport interface KitRuntime {\n readonly service: AnyService;\n /** `dispatcher.access`, and `resolve` for levels without service grants (a collection scope's). */\n readonly access: DispatcherAccess & Pick<PolicyEngine, \"resolve\">;\n readonly storage: StorageAdapter | undefined;\n /** How many sockets sit in a room, for the admin kit's subscriber counts. */\n readonly occupancy?: RoomOccupancy;\n /**\n * The revision a read made from now on is no older than (the search\n * kit's pages): the process's last one, or behind a cluster's counter the\n * counter's.\n */\n readonly claimRevision?: () => number | Promise<number>;\n /**\n * Runs `fn` in a detached unit of work of the dispatcher, as\n * `qd.run(fn, { detached: true })` does: a kit's work after its call (the\n * admin kit's `onCommitted`), whose writes flush on their own.\n */\n readonly runDetached?: (fn: () => unknown) => Promise<unknown>;\n}\n\n/** The sockets in a room (RFC 0003 section 6), as this process sees its rooms. */\nexport interface RoomOccupancy {\n /** This process's sockets in `room`: none without a server. */\n sockets(room: string): number;\n /**\n * `true` when this process sees every socket: its server has no cluster\n * adapter (Redis), or there is no server.\n */\n complete(): boolean;\n}\n\n/**\n * The per-call fields the dispatcher fills in. `touch` is the dispatcher's\n * (its tracked writes), `rooms` and `presence` its live data's, `dispatch`\n * its own dispatch function, which `ctx.services` calls through; a context\n * built without them gets a `touch` that does nothing, `rooms` that join\n * nothing and send nothing, a `presence` that sees nobody, and `services`\n * that throw `INTERNAL`. `kit` is kept beside the context, never on it.\n */\nexport type ContextFields = Pick<\n AnyContext,\n \"principal\" | \"signal\" | \"log\" | \"requestId\" | \"transport\" | \"socketId\" | \"mcp\"\n> &\n Partial<Pick<AnyContext, \"touch\" | \"rooms\" | \"presence\">> & {\n readonly kit?: KitRuntime;\n readonly dispatch?: Dispatch;\n };\n\nconst KIT_RUNTIMES = new WeakMap<object, KitRuntime>();\nconst SERVICE_CALLERS = new WeakMap<object, (signal: AbortSignal) => ContextServices>();\n\n/**\n * The kit runtime of the call `ctx` belongs to, or `undefined` for a\n * context no dispatcher built.\n */\nexport function kitRuntimeOf(ctx: object): KitRuntime | undefined {\n return KIT_RUNTIMES.get(ctx);\n}\n\nfunction withRuntime<Ctx extends object>(\n ctx: Ctx,\n runtime: KitRuntime | undefined,\n services: ((signal: AbortSignal) => ContextServices) | undefined,\n): Ctx {\n if (runtime !== undefined) {\n KIT_RUNTIMES.set(ctx, runtime);\n }\n if (services !== undefined) {\n SERVICE_CALLERS.set(ctx, services);\n }\n return ctx;\n}\n\n/** A signal that never aborts, for calls that cannot be cancelled. */\nexport const NEVER_ABORTED: AbortSignal = new AbortController().signal;\n\nfunction notAvailable(member: string): QuickdrawError {\n return new QuickdrawError(\n \"INTERNAL\",\n `${member} needs a dispatcher: it calls through the dispatcher that runs the method`,\n );\n}\n\nfunction untracked(): void {\n // Without tracked writes there is nothing to record.\n}\n\n// Names that inspection, serialization and test matchers read from any\n// object. They answer `undefined` so logging a `ctx` never throws.\nconst INSPECTED = new Set([\n \"then\",\n \"toJSON\",\n \"constructor\",\n \"toString\",\n \"valueOf\",\n \"asymmetricMatch\",\n \"$$typeof\",\n \"nodeType\",\n]);\n\nfunction unavailable(member: string): ContextServices {\n return new Proxy(Object.freeze({}), {\n get(_target, key) {\n if (typeof key === \"symbol\" || INSPECTED.has(key)) {\n return undefined;\n }\n throw notAvailable(`${member}.${key}`);\n },\n });\n}\n\nconst SERVICES: ContextServices = unavailable(\"ctx.services\");\n\n/** The `ctx.rooms` of a context no dispatcher built: no socket to join with, no server to send through. */\nconst NO_ROOMS: ContextRooms = Object.freeze({\n join: () => false,\n leave: ((_room: string, target?: unknown) =>\n target === undefined ? false : Promise.resolve()) as ContextRooms[\"leave\"],\n emit: untracked,\n emitToUser: untracked,\n size: () => 0,\n});\n\n/** The `ctx.presence` of a context no dispatcher built: no server, so nobody is online. */\nconst NO_PRESENCE: Presence = Object.freeze({\n isOnline: () => Promise.resolve(false),\n lastSeen: () => Promise.resolve(null),\n count: () => Promise.resolve(0),\n users: () => Promise.resolve([]),\n});\n\n/**\n * `ctx.services` for a signal: callers acting as `principal` through\n * `dispatch`, every call cancelled with the signal.\n */\nfunction servicesOf(\n dispatch: Dispatch | undefined,\n principal: Principal | null,\n): ((signal: AbortSignal) => ContextServices) | undefined {\n if (dispatch === undefined) {\n return undefined;\n }\n return (signal) => createCaller(() => dispatch, principal, { signal }) as ContextServices;\n}\n\n/**\n * Builds a call's `ctx`: the framework's fields, then the app's fields from\n * `extend`. The framework's fields win when the names collide.\n */\nexport function createContext(fields: ContextFields, extend?: ContextExtender): AnyContext {\n const { kit, dispatch, ...own } = fields;\n const services = servicesOf(dispatch, own.principal);\n const base: AnyContext = Object.freeze({\n ...own,\n touch: own.touch ?? untracked,\n services: services?.(own.signal) ?? SERVICES,\n rooms: own.rooms ?? NO_ROOMS,\n presence: own.presence ?? NO_PRESENCE,\n });\n if (extend === undefined) {\n return withRuntime(base, kit, services);\n }\n return withRuntime(Object.freeze({ ...extend(base), ...base }), kit, services);\n}\n\n/**\n * The same `ctx` with another signal: the one a handler run aborts. Its\n * `ctx.services` calls are cancelled with that signal.\n */\nexport function withSignal(ctx: AnyContext, signal: AbortSignal): AnyContext {\n const services = SERVICE_CALLERS.get(ctx);\n const next =\n services === undefined ? { ...ctx, signal } : { ...ctx, signal, services: services(signal) };\n return withRuntime(Object.freeze(next), KIT_RUNTIMES.get(ctx), services);\n}\n"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,g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