nowity 1.0.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 +751 -0
- package/dist/api/contract.d.ts +186 -0
- package/dist/api/contract.d.ts.map +1 -0
- package/dist/api/contract.js +251 -0
- package/dist/api/errors.d.ts +50 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +50 -0
- package/dist/api/index.d.ts +13 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +32 -0
- package/dist/client/confirmed-store.d.ts +33 -0
- package/dist/client/confirmed-store.d.ts.map +1 -0
- package/dist/client/confirmed-store.js +123 -0
- package/dist/client/connection.d.ts +102 -0
- package/dist/client/connection.d.ts.map +1 -0
- package/dist/client/connection.js +285 -0
- package/dist/client/list.d.ts +102 -0
- package/dist/client/list.d.ts.map +1 -0
- package/dist/client/list.js +257 -0
- package/dist/client/live-query.d.ts +153 -0
- package/dist/client/live-query.d.ts.map +1 -0
- package/dist/client/live-query.js +244 -0
- package/dist/client/nowity-client.d.ts +188 -0
- package/dist/client/nowity-client.d.ts.map +1 -0
- package/dist/client/nowity-client.js +580 -0
- package/dist/client/null-transport.d.ts +16 -0
- package/dist/client/null-transport.d.ts.map +1 -0
- package/dist/client/null-transport.js +17 -0
- package/dist/client/overlay.d.ts +44 -0
- package/dist/client/overlay.d.ts.map +1 -0
- package/dist/client/overlay.js +90 -0
- package/dist/client/query-source.d.ts +78 -0
- package/dist/client/query-source.d.ts.map +1 -0
- package/dist/client/query-source.js +57 -0
- package/dist/client/ssr-source.d.ts +70 -0
- package/dist/client/ssr-source.d.ts.map +1 -0
- package/dist/client/ssr-source.js +134 -0
- package/dist/client/transport.d.ts +19 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/transport.js +2 -0
- package/dist/client/ws-transport.d.ts +30 -0
- package/dist/client/ws-transport.d.ts.map +1 -0
- package/dist/client/ws-transport.js +89 -0
- package/dist/client.d.ts +47 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +80 -0
- package/dist/core/diff.d.ts +14 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +56 -0
- package/dist/core/normalize.d.ts +16 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/normalize.js +67 -0
- package/dist/core/protocol.d.ts +215 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +14 -0
- package/dist/core/ssr-bridge.d.ts +69 -0
- package/dist/core/ssr-bridge.d.ts.map +1 -0
- package/dist/core/ssr-bridge.js +40 -0
- package/dist/core/types.d.ts +96 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +17 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/ironbean/client.d.ts +7 -0
- package/dist/ironbean/client.d.ts.map +1 -0
- package/dist/ironbean/client.js +38 -0
- package/dist/ironbean/server.d.ts +42 -0
- package/dist/ironbean/server.d.ts.map +1 -0
- package/dist/ironbean/server.js +62 -0
- package/dist/ironbean/tokens.d.ts +26 -0
- package/dist/ironbean/tokens.d.ts.map +1 -0
- package/dist/ironbean/tokens.js +23 -0
- package/dist/next/config.d.ts +7 -0
- package/dist/next/config.d.ts.map +1 -0
- package/dist/next/config.js +77 -0
- package/dist/next/live.d.ts +69 -0
- package/dist/next/live.d.ts.map +1 -0
- package/dist/next/live.js +70 -0
- package/dist/next/serve.d.ts +44 -0
- package/dist/next/serve.d.ts.map +1 -0
- package/dist/next/serve.js +107 -0
- package/dist/next/server.d.ts +62 -0
- package/dist/next/server.d.ts.map +1 -0
- package/dist/next/server.js +127 -0
- package/dist/react/connection-context.d.ts +4 -0
- package/dist/react/connection-context.d.ts.map +1 -0
- package/dist/react/connection-context.js +28 -0
- package/dist/react/grid-list.d.ts +34 -0
- package/dist/react/grid-list.d.ts.map +1 -0
- package/dist/react/grid-list.js +62 -0
- package/dist/react/hydrate.d.ts +22 -0
- package/dist/react/hydrate.d.ts.map +1 -0
- package/dist/react/hydrate.js +18 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +51 -0
- package/dist/react/list.d.ts +31 -0
- package/dist/react/list.d.ts.map +1 -0
- package/dist/react/list.js +35 -0
- package/dist/react/prerendered.d.ts +33 -0
- package/dist/react/prerendered.d.ts.map +1 -0
- package/dist/react/prerendered.js +165 -0
- package/dist/react/provider.d.ts +64 -0
- package/dist/react/provider.d.ts.map +1 -0
- package/dist/react/provider.js +130 -0
- package/dist/react/refusals.d.ts +31 -0
- package/dist/react/refusals.d.ts.map +1 -0
- package/dist/react/refusals.js +51 -0
- package/dist/react/restricted.d.ts +76 -0
- package/dist/react/restricted.d.ts.map +1 -0
- package/dist/react/restricted.js +126 -0
- package/dist/react/use-list.d.ts +42 -0
- package/dist/react/use-list.d.ts.map +1 -0
- package/dist/react/use-list.js +56 -0
- package/dist/react/use-query.d.ts +66 -0
- package/dist/react/use-query.d.ts.map +1 -0
- package/dist/react/use-query.js +126 -0
- package/dist/react/virtual.d.ts +60 -0
- package/dist/react/virtual.d.ts.map +1 -0
- package/dist/react/virtual.js +131 -0
- package/dist/server/api/auth.d.ts +37 -0
- package/dist/server/api/auth.d.ts.map +1 -0
- package/dist/server/api/auth.js +54 -0
- package/dist/server/api/bridge.d.ts +28 -0
- package/dist/server/api/bridge.d.ts.map +1 -0
- package/dist/server/api/bridge.js +330 -0
- package/dist/server/api/collector.d.ts +25 -0
- package/dist/server/api/collector.d.ts.map +1 -0
- package/dist/server/api/collector.js +184 -0
- package/dist/server/api/configure.d.ts +31 -0
- package/dist/server/api/configure.d.ts.map +1 -0
- package/dist/server/api/configure.js +67 -0
- package/dist/server/api/execution.d.ts +77 -0
- package/dist/server/api/execution.d.ts.map +1 -0
- package/dist/server/api/execution.js +97 -0
- package/dist/server/api/list.d.ts +141 -0
- package/dist/server/api/list.d.ts.map +1 -0
- package/dist/server/api/list.js +281 -0
- package/dist/server/api/prerender.d.ts +32 -0
- package/dist/server/api/prerender.d.ts.map +1 -0
- package/dist/server/api/prerender.js +69 -0
- package/dist/server/api/read-keys.d.ts +128 -0
- package/dist/server/api/read-keys.d.ts.map +1 -0
- package/dist/server/api/read-keys.js +464 -0
- package/dist/server/api/read-set.d.ts +103 -0
- package/dist/server/api/read-set.d.ts.map +1 -0
- package/dist/server/api/read-set.js +210 -0
- package/dist/server/api/runtime.d.ts +36 -0
- package/dist/server/api/runtime.d.ts.map +1 -0
- package/dist/server/api/runtime.js +49 -0
- package/dist/server/api/tracked-client.d.ts +6 -0
- package/dist/server/api/tracked-client.d.ts.map +1 -0
- package/dist/server/api/tracked-client.js +56 -0
- package/dist/server/change-source/change-source.d.ts +41 -0
- package/dist/server/change-source/change-source.d.ts.map +1 -0
- package/dist/server/change-source/change-source.js +2 -0
- package/dist/server/change-source/outbox-change-source.d.ts +106 -0
- package/dist/server/change-source/outbox-change-source.d.ts.map +1 -0
- package/dist/server/change-source/outbox-change-source.js +237 -0
- package/dist/server/change-source/wal-change-source.d.ts +85 -0
- package/dist/server/change-source/wal-change-source.d.ts.map +1 -0
- package/dist/server/change-source/wal-change-source.js +193 -0
- package/dist/server/db.d.ts +51 -0
- package/dist/server/db.d.ts.map +1 -0
- package/dist/server/db.js +53 -0
- package/dist/server/evaluate.d.ts +39 -0
- package/dist/server/evaluate.d.ts.map +1 -0
- package/dist/server/evaluate.js +61 -0
- package/dist/server/invalidation-index.d.ts +64 -0
- package/dist/server/invalidation-index.d.ts.map +1 -0
- package/dist/server/invalidation-index.js +0 -0
- package/dist/server/mutator.d.ts +59 -0
- package/dist/server/mutator.d.ts.map +1 -0
- package/dist/server/mutator.js +77 -0
- package/dist/server/query.d.ts +113 -0
- package/dist/server/query.d.ts.map +1 -0
- package/dist/server/query.js +35 -0
- package/dist/server/setup.d.ts +30 -0
- package/dist/server/setup.d.ts.map +1 -0
- package/dist/server/setup.js +107 -0
- package/dist/server/sql/setup.sql +215 -0
- package/dist/server/ssr.d.ts +29 -0
- package/dist/server/ssr.d.ts.map +1 -0
- package/dist/server/ssr.js +43 -0
- package/dist/server/sync-engine.d.ts +256 -0
- package/dist/server/sync-engine.d.ts.map +1 -0
- package/dist/server/sync-engine.js +805 -0
- package/dist/server/ws-server.d.ts +56 -0
- package/dist/server/ws-server.d.ts.map +1 -0
- package/dist/server/ws-server.js +241 -0
- package/package.json +81 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openSsrCollector = openSsrCollector;
|
|
4
|
+
/**
|
|
5
|
+
* Reading a page's queries because it asked for them, not because it listed them.
|
|
6
|
+
*
|
|
7
|
+
* {@link prerender} needs the page to name every endpoint its components are
|
|
8
|
+
* about to call. Nothing checks that list against what they actually call, and
|
|
9
|
+
* the way it goes wrong is the worst kind: a component gains a query, nobody
|
|
10
|
+
* updates the page, and the only symptom is that one panel waits for the socket.
|
|
11
|
+
* It never fails, it just quietly stops being prerendered.
|
|
12
|
+
*
|
|
13
|
+
* A collector inverts that. It holds one snapshot open for the whole render and
|
|
14
|
+
* answers the queries the components ask for, as they ask for them, recording
|
|
15
|
+
* each answer on the way past. The list is the render's own behaviour, so it
|
|
16
|
+
* cannot drift from it.
|
|
17
|
+
*
|
|
18
|
+
* The snapshot is the same one-point-in-time guarantee `prerender` gives: a page
|
|
19
|
+
* whose components read four endpoints still cannot show them from four
|
|
20
|
+
* different moments.
|
|
21
|
+
*/
|
|
22
|
+
const node_crypto_1 = require("node:crypto");
|
|
23
|
+
const errors_1 = require("../../api/errors");
|
|
24
|
+
const ssr_bridge_1 = require("../../core/ssr-bridge");
|
|
25
|
+
const evaluate_1 = require("../evaluate");
|
|
26
|
+
function openSsrCollector(deps, session) {
|
|
27
|
+
const id = (0, node_crypto_1.randomUUID)();
|
|
28
|
+
const payloads = [];
|
|
29
|
+
let pending = 0;
|
|
30
|
+
let closed = false;
|
|
31
|
+
let releaseSnapshot;
|
|
32
|
+
let snapshotReady;
|
|
33
|
+
let snapshotFailed;
|
|
34
|
+
const ready = new Promise((resolve, reject) => {
|
|
35
|
+
snapshotReady = resolve;
|
|
36
|
+
snapshotFailed = reject;
|
|
37
|
+
});
|
|
38
|
+
const releasable = new Promise((resolve) => {
|
|
39
|
+
releaseSnapshot = resolve;
|
|
40
|
+
});
|
|
41
|
+
let running = null;
|
|
42
|
+
/**
|
|
43
|
+
* Open the snapshot, on the first read and not before.
|
|
44
|
+
*
|
|
45
|
+
* A render that never reads must not cost a transaction, and there is one on
|
|
46
|
+
* every client-side navigation: the App Router asks the server for the new
|
|
47
|
+
* route's payload, that render produces the boundary and its ticket, and the
|
|
48
|
+
* components under it are then rendered by the *browser*, which reads through
|
|
49
|
+
* the socket it already has. Nothing ever looks this collector up. Opening
|
|
50
|
+
* eagerly held a pooled connection for each of those until the guard below
|
|
51
|
+
* fired — ten seconds of `idle in transaction` per navigation, for a
|
|
52
|
+
* snapshot nobody was ever going to read.
|
|
53
|
+
*/
|
|
54
|
+
function open() {
|
|
55
|
+
if (!running) {
|
|
56
|
+
// The snapshot outlives the call that opened it: `withSnapshot` is
|
|
57
|
+
// callback-scoped, so the callback simply parks until the render is
|
|
58
|
+
// done with it. Whatever the runner does at the end — COMMIT, or
|
|
59
|
+
// closing a Prisma transaction — happens when `close()` lets the
|
|
60
|
+
// callback return.
|
|
61
|
+
running = deps.snapshots
|
|
62
|
+
.withSnapshot(async (snap) => {
|
|
63
|
+
snapshotReady(snap);
|
|
64
|
+
await releasable;
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
snapshotFailed(err);
|
|
68
|
+
throw err;
|
|
69
|
+
});
|
|
70
|
+
// Nobody may be awaiting it yet, and a snapshot that fails to open
|
|
71
|
+
// would otherwise be reported as an unhandled rejection before the
|
|
72
|
+
// first read.
|
|
73
|
+
running.catch(() => undefined);
|
|
74
|
+
}
|
|
75
|
+
return ready;
|
|
76
|
+
}
|
|
77
|
+
// Still armed from the start, and deliberately: an unread collector has to
|
|
78
|
+
// leave the registry too, and nothing but a clock knows when a render that
|
|
79
|
+
// asked for nothing is over.
|
|
80
|
+
const guard = setTimeout(() => void close(), deps.timeoutMs ?? 10000);
|
|
81
|
+
guard.unref?.();
|
|
82
|
+
async function close() {
|
|
83
|
+
if (closed)
|
|
84
|
+
return;
|
|
85
|
+
closed = true;
|
|
86
|
+
clearTimeout(guard);
|
|
87
|
+
(0, ssr_bridge_1.forgetSsrReader)(id);
|
|
88
|
+
releaseSnapshot();
|
|
89
|
+
await running?.catch(() => undefined);
|
|
90
|
+
}
|
|
91
|
+
async function read(query, args) {
|
|
92
|
+
if (closed)
|
|
93
|
+
throw Object.assign(new Error("SSR collector closed"), { code: ssr_bridge_1.SSR_CLOSED });
|
|
94
|
+
// Counted before the first await, so a render that has just asked for a
|
|
95
|
+
// query is never mistaken for one that has gone quiet.
|
|
96
|
+
pending += 1;
|
|
97
|
+
try {
|
|
98
|
+
const payload = await readOne(await open(), deps, session, query, args);
|
|
99
|
+
payloads.push(payload);
|
|
100
|
+
return payload;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
pending -= 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Wait for the render to stop asking.
|
|
108
|
+
*
|
|
109
|
+
* There is no signal for "React has finished this boundary", so quiet stands
|
|
110
|
+
* in for it: nothing in flight, and nothing new started across a turn of the
|
|
111
|
+
* event loop. A component that resolves one query and then asks for a second
|
|
112
|
+
* keeps the count above zero long enough to be seen, because the read is
|
|
113
|
+
* registered synchronously when it starts.
|
|
114
|
+
*/
|
|
115
|
+
async function collected() {
|
|
116
|
+
for (let settled = 0; settled < 20 && !closed;) {
|
|
117
|
+
const before = payloads.length;
|
|
118
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
119
|
+
settled = pending === 0 && payloads.length === before ? settled + 1 : 0;
|
|
120
|
+
if (settled >= 2)
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
const result = payloads.slice();
|
|
124
|
+
// The snapshot has done its job. Holding a database transaction open for
|
|
125
|
+
// the rest of the response would cost a pooled connection per request,
|
|
126
|
+
// and the render has stopped reading.
|
|
127
|
+
void close();
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
const collector = {
|
|
131
|
+
id,
|
|
132
|
+
close,
|
|
133
|
+
read,
|
|
134
|
+
collected,
|
|
135
|
+
manifest: () => deps.manifest,
|
|
136
|
+
};
|
|
137
|
+
(0, ssr_bridge_1.registerSsrReader)(id, collector);
|
|
138
|
+
return collector;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* One query, answered exactly as the sync engine would answer it.
|
|
142
|
+
*
|
|
143
|
+
* Same authorization check, same scope epoch — so a payload the browser adopts
|
|
144
|
+
* cannot carry rows the socket would then take away, and a patch computed before
|
|
145
|
+
* a permission change can still be dropped against the epoch that came with it.
|
|
146
|
+
*/
|
|
147
|
+
async function readOne(snap, deps, session, query, args) {
|
|
148
|
+
const def = deps.queries.get(query);
|
|
149
|
+
const ctx = { db: snap, session };
|
|
150
|
+
const scope = def.scope ? def.scope(args, ctx) : null;
|
|
151
|
+
const epoch = scope ? await readEpoch(snap, scope) : 0;
|
|
152
|
+
const base = { query, args, entity: def.entity, scope, epoch };
|
|
153
|
+
if (def.authorize && !(await def.authorize(args, ctx))) {
|
|
154
|
+
return { ...base, ids: [], rows: [], denied: true };
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const output = await (0, evaluate_1.evaluateQuery)(def, args, session, snap);
|
|
158
|
+
const rows = (0, evaluate_1.outputRows)(output);
|
|
159
|
+
return {
|
|
160
|
+
...base,
|
|
161
|
+
entity: output.entity ?? def.entity,
|
|
162
|
+
...(output.single ? { single: true } : {}),
|
|
163
|
+
...(output.order ? { order: output.order } : {}),
|
|
164
|
+
...(output.filter ? { filter: output.filter } : {}),
|
|
165
|
+
ids: output.ids,
|
|
166
|
+
rows: rows.rows,
|
|
167
|
+
...(rows.extra ? { extra: rows.extra } : {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
// An endpoint that refuses by throwing is refusing, not failing. It is
|
|
172
|
+
// the ordinary way to say no — the read that got there is what the
|
|
173
|
+
// subscription then watches, so access granted later wakes it — and a
|
|
174
|
+
// page renders "no access" for that panel rather than losing the render
|
|
175
|
+
// to an error boundary.
|
|
176
|
+
if (!(0, errors_1.isForbidden)(err))
|
|
177
|
+
throw err;
|
|
178
|
+
return { ...base, ids: [], rows: [], denied: true };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function readEpoch(snap, scope) {
|
|
182
|
+
const { rows } = await snap.query(`SELECT version::text AS version FROM nowity_scope_epoch WHERE scope = $1`, [scope]);
|
|
183
|
+
return rows.length ? Number(rows[0].version) : 0;
|
|
184
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ChangeSource } from "../change-source/change-source";
|
|
2
|
+
import { SyncEngine } from "../sync-engine";
|
|
3
|
+
import { NowitySyncServer, type NowitySyncServerOptions } from "../ws-server";
|
|
4
|
+
import { type NowityRuntime, type NowityRuntimeConfig } from "./runtime";
|
|
5
|
+
export interface NowityServerConfig extends NowityRuntimeConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Where changes come from. Defaults to the outbox on {@link databaseUrl},
|
|
8
|
+
* which is what §5.1 of the design doc settles on anyway.
|
|
9
|
+
*/
|
|
10
|
+
changeSource?: ChangeSource | (() => ChangeSource);
|
|
11
|
+
/** Used for the default change source. Defaults to `DATABASE_URL`. */
|
|
12
|
+
databaseUrl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The {@link Authenticator} implementation. Without one every connection is
|
|
15
|
+
* anonymous, which is right for a prototype and wrong for anything else.
|
|
16
|
+
*/
|
|
17
|
+
auth?: Function;
|
|
18
|
+
syncServer?: Omit<NowitySyncServerOptions, "engine">;
|
|
19
|
+
/** See {@link SyncEngineOptions.narrowInvalidation}. On unless set. */
|
|
20
|
+
narrowInvalidation?: boolean;
|
|
21
|
+
onError?: (err: Error) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface NowityServer extends NowityRuntime {
|
|
24
|
+
engine: SyncEngine;
|
|
25
|
+
server: NowitySyncServer;
|
|
26
|
+
/** Start the change stream and the socket; resolves with the port. */
|
|
27
|
+
start(): Promise<number>;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createNowityServer(config: NowityServerConfig): NowityServer;
|
|
31
|
+
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../src/server/api/configure.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,UAAU,EAA0B,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE9F,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC3D;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,CAAC;IACnD,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,UAAU,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;IACrD,uEAAuE;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IAC/C,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,sEAAsE;IACtE,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAgBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAqC3E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNowityServer = createNowityServer;
|
|
4
|
+
/**
|
|
5
|
+
* The sync process: the read runtime plus the change stream and the socket.
|
|
6
|
+
*
|
|
7
|
+
* Everything that is not derivable is listed here and nowhere else — the
|
|
8
|
+
* database, the change source, how a connection authenticates. Contracts
|
|
9
|
+
* register themselves by being imported, implementations find their contract by
|
|
10
|
+
* extending it, invalidation dependencies come from what queries read, and
|
|
11
|
+
* entity shapes come from the Prisma schema.
|
|
12
|
+
*/
|
|
13
|
+
const ironbean_1 = require("ironbean");
|
|
14
|
+
const outbox_change_source_1 = require("../change-source/outbox-change-source");
|
|
15
|
+
const mutator_1 = require("../mutator");
|
|
16
|
+
const sync_engine_1 = require("../sync-engine");
|
|
17
|
+
const ws_server_1 = require("../ws-server");
|
|
18
|
+
const auth_1 = require("./auth");
|
|
19
|
+
const runtime_1 = require("./runtime");
|
|
20
|
+
function resolveChangeSource(config) {
|
|
21
|
+
if (typeof config.changeSource === "function")
|
|
22
|
+
return config.changeSource();
|
|
23
|
+
if (config.changeSource)
|
|
24
|
+
return config.changeSource;
|
|
25
|
+
const connectionString = config.databaseUrl ?? process.env.DATABASE_URL;
|
|
26
|
+
if (!connectionString) {
|
|
27
|
+
throw new Error("No changeSource and no DATABASE_URL to build the default one from.");
|
|
28
|
+
}
|
|
29
|
+
// Required lazily: an application that brings its own change source should
|
|
30
|
+
// not be made to depend on `pg` for one it never uses.
|
|
31
|
+
const { Pool } = require("pg");
|
|
32
|
+
return new outbox_change_source_1.OutboxChangeSource({ pool: new Pool({ connectionString }) });
|
|
33
|
+
}
|
|
34
|
+
function createNowityServer(config) {
|
|
35
|
+
const runtime = (0, runtime_1.createNowityRuntime)(config);
|
|
36
|
+
(0, ironbean_1.take)(auth_1.Authenticator).bindTo((config.auth ?? auth_1.AnonymousAuthenticator));
|
|
37
|
+
const authenticator = (0, ironbean_1.getBaseApplicationContext)().getBean(auth_1.Authenticator);
|
|
38
|
+
const engine = new sync_engine_1.SyncEngine({
|
|
39
|
+
snapshots: runtime.snapshots,
|
|
40
|
+
writes: new mutator_1.PrismaWriteRunner(runtime.prisma),
|
|
41
|
+
source: resolveChangeSource(config),
|
|
42
|
+
queries: runtime.api.queries,
|
|
43
|
+
mutators: runtime.api.mutators,
|
|
44
|
+
api: { contracts: runtime.api.manifest.contracts, entities: runtime.api.entities },
|
|
45
|
+
narrowInvalidation: config.narrowInvalidation,
|
|
46
|
+
onError: config.onError,
|
|
47
|
+
});
|
|
48
|
+
const server = new ws_server_1.NowitySyncServer({
|
|
49
|
+
...config.syncServer,
|
|
50
|
+
engine,
|
|
51
|
+
authenticate: (request) => authenticator.authenticate(request),
|
|
52
|
+
onError: config.onError,
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
...runtime,
|
|
56
|
+
engine,
|
|
57
|
+
server,
|
|
58
|
+
async start() {
|
|
59
|
+
await engine.start();
|
|
60
|
+
return server.listen();
|
|
61
|
+
},
|
|
62
|
+
async stop() {
|
|
63
|
+
await server.close();
|
|
64
|
+
await engine.stop();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { SessionInfo } from "../query";
|
|
2
|
+
import type { ListExecution } from "./list";
|
|
3
|
+
import type { KeyCollector } from "./read-keys";
|
|
4
|
+
export interface Execution {
|
|
5
|
+
kind: "query" | "mutation";
|
|
6
|
+
session: SessionInfo;
|
|
7
|
+
/** Prisma client bound to this execution's snapshot or write transaction. */
|
|
8
|
+
prisma: any;
|
|
9
|
+
/** Tables read so far, as recorded by the tracking extension. */
|
|
10
|
+
reads: Set<string>;
|
|
11
|
+
/**
|
|
12
|
+
* The same reads, narrowed to rows wherever the query's own `where` said
|
|
13
|
+
* which ones.
|
|
14
|
+
*
|
|
15
|
+
* Absent for mutations, which are never invalidated. Present but empty is a
|
|
16
|
+
* meaningful state: it says the execution read nothing at all.
|
|
17
|
+
*/
|
|
18
|
+
keys?: KeyCollector;
|
|
19
|
+
/**
|
|
20
|
+
* Set when the execution asked which connection it is running for.
|
|
21
|
+
*
|
|
22
|
+
* Two subscriptions of two clients to the same query with the same arguments
|
|
23
|
+
* have the same answer — unless the endpoint looked at `clientId`, which is
|
|
24
|
+
* the one part of the session that differs between two tabs of one user.
|
|
25
|
+
* Recording that it was read is what makes it safe to compute such a query
|
|
26
|
+
* once per change instead of once per client.
|
|
27
|
+
*/
|
|
28
|
+
usedClientId?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Set when something was read in a way the tracker cannot see (raw SQL).
|
|
31
|
+
* Such a query is revalidated on every transaction rather than guessed at.
|
|
32
|
+
*/
|
|
33
|
+
untracked: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Model of the most recent model-level operation.
|
|
36
|
+
*
|
|
37
|
+
* The rows an endpoint returns are almost always the result of its last
|
|
38
|
+
* query, so this is what names the entity in the client's identity map.
|
|
39
|
+
* `@query({ entity })` overrides it for the methods where it is not.
|
|
40
|
+
*/
|
|
41
|
+
lastModel?: string;
|
|
42
|
+
/** Present for mutations only. */
|
|
43
|
+
mutationId?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Present while a `@list` endpoint runs for one window.
|
|
46
|
+
*
|
|
47
|
+
* It is what lets a method that takes no paging arguments be paged anyway:
|
|
48
|
+
* the tracking client reads the window off it and pushes `LIMIT`/`OFFSET`
|
|
49
|
+
* into the collection's own query.
|
|
50
|
+
*/
|
|
51
|
+
list?: ListExecution;
|
|
52
|
+
}
|
|
53
|
+
export declare function runInExecution<T>(execution: Execution, fn: () => Promise<T>): Promise<T>;
|
|
54
|
+
export declare function currentExecution(): Execution;
|
|
55
|
+
export declare function peekExecution(): Execution | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The caller's identity, injectable into any API implementation.
|
|
58
|
+
*
|
|
59
|
+
* Every read goes through the ambient execution, so one singleton instance is
|
|
60
|
+
* correct for every connection at once.
|
|
61
|
+
*/
|
|
62
|
+
export declare class Session {
|
|
63
|
+
get clientId(): string;
|
|
64
|
+
get userId(): string | null;
|
|
65
|
+
/** Whatever `authenticate` put on the connection. */
|
|
66
|
+
get meta(): Record<string, unknown>;
|
|
67
|
+
/** Identity or bust — for endpoints that make no sense anonymously. */
|
|
68
|
+
requireUserId(): string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A stable proxy that forwards every access to the current execution's client.
|
|
72
|
+
*
|
|
73
|
+
* The container binds this once as the app's `Db`; each property read resolves
|
|
74
|
+
* against whichever transaction the caller is currently inside.
|
|
75
|
+
*/
|
|
76
|
+
export declare function ambientPrisma<T extends object>(): T;
|
|
77
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/server/api/execution.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,6EAA6E;IAC7E,MAAM,EAAE,GAAG,CAAC;IACZ,iEAAiE;IACjE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;CACxB;AAID,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxF;AAED,wBAAgB,gBAAgB,IAAI,SAAS,CAS5C;AAED,wBAAgB,aAAa,IAAI,SAAS,GAAG,SAAS,CAErD;AAED;;;;;GAKG;AACH,qBACa,OAAO;IAChB,IAAI,QAAQ,IAAI,MAAM,CAIrB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,IAAI,CAE1B;IAED,qDAAqD;IACrD,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElC;IAED,uEAAuE;IACvE,aAAa,IAAI,MAAM;CAK1B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,KAAK,CAAC,CAcnD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Session = void 0;
|
|
10
|
+
exports.runInExecution = runInExecution;
|
|
11
|
+
exports.currentExecution = currentExecution;
|
|
12
|
+
exports.peekExecution = peekExecution;
|
|
13
|
+
exports.ambientPrisma = ambientPrisma;
|
|
14
|
+
/**
|
|
15
|
+
* What an endpoint method runs inside.
|
|
16
|
+
*
|
|
17
|
+
* A `@query` or `@mutation` method takes only its own arguments — no context
|
|
18
|
+
* parameter, no session parameter. Everything ambient it needs (the database
|
|
19
|
+
* bound to the engine's read snapshot, the caller's identity, the read-set
|
|
20
|
+
* recorder) lives in an `AsyncLocalStorage` frame set up around the call, and is
|
|
21
|
+
* handed to the method through dependency injection.
|
|
22
|
+
*
|
|
23
|
+
* That is what lets `Db` and `Session` be ordinary singletons in the container
|
|
24
|
+
* while still meaning something different for every single execution: they are
|
|
25
|
+
* thin ambient views, not captured values.
|
|
26
|
+
*/
|
|
27
|
+
const async_hooks_1 = require("async_hooks");
|
|
28
|
+
const ironbean_1 = require("ironbean");
|
|
29
|
+
const storage = new async_hooks_1.AsyncLocalStorage();
|
|
30
|
+
function runInExecution(execution, fn) {
|
|
31
|
+
// The `await` has to happen *inside* the frame, not outside it. A Prisma call
|
|
32
|
+
// is lazy — the query runs when its promise is awaited — so a method that
|
|
33
|
+
// returns `this.db.project.findMany(...)` without awaiting would execute
|
|
34
|
+
// after the frame had already been left, and the read-set tracker would see
|
|
35
|
+
// nothing at all.
|
|
36
|
+
return storage.run(execution, async () => await fn());
|
|
37
|
+
}
|
|
38
|
+
function currentExecution() {
|
|
39
|
+
const execution = storage.getStore();
|
|
40
|
+
if (!execution) {
|
|
41
|
+
throw new Error("No Nowity execution in progress. `Db` and `Session` are only available " +
|
|
42
|
+
"inside a @query or @mutation method (or inside `prerender`).");
|
|
43
|
+
}
|
|
44
|
+
return execution;
|
|
45
|
+
}
|
|
46
|
+
function peekExecution() {
|
|
47
|
+
return storage.getStore();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The caller's identity, injectable into any API implementation.
|
|
51
|
+
*
|
|
52
|
+
* Every read goes through the ambient execution, so one singleton instance is
|
|
53
|
+
* correct for every connection at once.
|
|
54
|
+
*/
|
|
55
|
+
let Session = class Session {
|
|
56
|
+
get clientId() {
|
|
57
|
+
const execution = currentExecution();
|
|
58
|
+
execution.usedClientId = true;
|
|
59
|
+
return execution.session.clientId;
|
|
60
|
+
}
|
|
61
|
+
get userId() {
|
|
62
|
+
return currentExecution().session.userId;
|
|
63
|
+
}
|
|
64
|
+
/** Whatever `authenticate` put on the connection. */
|
|
65
|
+
get meta() {
|
|
66
|
+
return currentExecution().session.meta;
|
|
67
|
+
}
|
|
68
|
+
/** Identity or bust — for endpoints that make no sense anonymously. */
|
|
69
|
+
requireUserId() {
|
|
70
|
+
const userId = this.userId;
|
|
71
|
+
if (userId === null)
|
|
72
|
+
throw new Error("Not signed in");
|
|
73
|
+
return userId;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.Session = Session;
|
|
77
|
+
exports.Session = Session = __decorate([
|
|
78
|
+
ironbean_1.component
|
|
79
|
+
], Session);
|
|
80
|
+
/**
|
|
81
|
+
* A stable proxy that forwards every access to the current execution's client.
|
|
82
|
+
*
|
|
83
|
+
* The container binds this once as the app's `Db`; each property read resolves
|
|
84
|
+
* against whichever transaction the caller is currently inside.
|
|
85
|
+
*/
|
|
86
|
+
function ambientPrisma() {
|
|
87
|
+
return new Proxy({}, {
|
|
88
|
+
get(_target, property) {
|
|
89
|
+
const client = currentExecution().prisma;
|
|
90
|
+
const value = client[property];
|
|
91
|
+
return typeof value === "function" ? value.bind(client) : value;
|
|
92
|
+
},
|
|
93
|
+
has(_target, property) {
|
|
94
|
+
return property in currentExecution().prisma;
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paging an endpoint that has no paging.
|
|
3
|
+
*
|
|
4
|
+
* A `@list` method states what the collection is — `findMany` with a `where` and
|
|
5
|
+
* an `orderBy`, and a permission check on the way there — and says nothing about
|
|
6
|
+
* offsets, because it cannot know any: which forty rows matter is a fact about a
|
|
7
|
+
* scrollbar in a browser, and it changes several times a second.
|
|
8
|
+
*
|
|
9
|
+
* So the window is pushed in from outside. The method runs exactly as written,
|
|
10
|
+
* and the tracking client puts `LIMIT` and `OFFSET` into the one call that
|
|
11
|
+
* produces the collection — the last `findMany`, which is the same rule the
|
|
12
|
+
* framework already uses to name the entity. Everything before it, the
|
|
13
|
+
* membership lookup that decides whether the caller may look at all, runs
|
|
14
|
+
* untouched and lands in the read set as usual. A window is therefore a live
|
|
15
|
+
* query like any other: it re-runs when a table it read changes, and the browser
|
|
16
|
+
* gets a patch for the rows it is actually showing.
|
|
17
|
+
*
|
|
18
|
+
* Which call is the last one is only knowable after the method has finished, and
|
|
19
|
+
* by then it has already run — which would mean reading the whole collection
|
|
20
|
+
* once to find out how not to read it. So the first execution of an endpoint is
|
|
21
|
+
* a *probe*: the method runs with every query it makes capped to a single row,
|
|
22
|
+
* purely to see where its calls fall. The answer is thrown away; what is kept is
|
|
23
|
+
* where the collection was, and every execution after it pushes the window
|
|
24
|
+
* straight in.
|
|
25
|
+
*
|
|
26
|
+
* When the guess turns out wrong — a method that branches, so the window landed
|
|
27
|
+
* in some other query — the rows are thrown away and the method is run whole
|
|
28
|
+
* instead. Not being able to page may never mean answering with the wrong rows;
|
|
29
|
+
* it may only mean answering the slow way.
|
|
30
|
+
*/
|
|
31
|
+
import type { OrderKey, RowFilter } from "../../core/protocol";
|
|
32
|
+
import type { Row } from "../../core/types";
|
|
33
|
+
import type { Execution } from "./execution";
|
|
34
|
+
/** What one run of a list endpoint is being asked for. */
|
|
35
|
+
export type ListWant = {
|
|
36
|
+
kind: "page";
|
|
37
|
+
offset: number;
|
|
38
|
+
limit: number;
|
|
39
|
+
}
|
|
40
|
+
/** Only how many rows there are — the scrollbar's question. */
|
|
41
|
+
| {
|
|
42
|
+
kind: "count";
|
|
43
|
+
};
|
|
44
|
+
/** Entity the count rows are stored under. Not a table, and cannot collide with one. */
|
|
45
|
+
export declare const LIST_COUNT_ENTITY = "nowity:list";
|
|
46
|
+
/** One `findMany` of a list execution, in the order it ran. */
|
|
47
|
+
export interface ListCall {
|
|
48
|
+
model: string;
|
|
49
|
+
/** Position among this execution's `findMany` calls, counting from one. */
|
|
50
|
+
ordinal: number;
|
|
51
|
+
/** The arguments as the method wrote them, before any window was pushed in. */
|
|
52
|
+
args: any;
|
|
53
|
+
windowed: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** The mutable state of one list execution, read and written by the tracking client. */
|
|
56
|
+
export interface ListExecution {
|
|
57
|
+
want: ListWant;
|
|
58
|
+
/** Where an earlier run found the collection, or null when nothing is known. */
|
|
59
|
+
plan: ListPlan | null;
|
|
60
|
+
/**
|
|
61
|
+
* A run whose answer nobody wants.
|
|
62
|
+
*
|
|
63
|
+
* Every query it makes is capped to one row: it is looking for the shape of
|
|
64
|
+
* the method, not for its result, and one row is enough to keep a guard on
|
|
65
|
+
* `rows.length` answering what it would have answered.
|
|
66
|
+
*/
|
|
67
|
+
probe: boolean;
|
|
68
|
+
calls: ListCall[];
|
|
69
|
+
/** The call the window was actually pushed into. */
|
|
70
|
+
windowed: ListCall | null;
|
|
71
|
+
}
|
|
72
|
+
export interface ListPlan {
|
|
73
|
+
ordinal: number;
|
|
74
|
+
model: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Where each endpoint's collection was last found.
|
|
78
|
+
*
|
|
79
|
+
* Keyed by endpoint rather than by arguments: it is a fact about the code, not
|
|
80
|
+
* about the call. A method that reaches its collection by different routes for
|
|
81
|
+
* different arguments simply gets its plan re-learned, which costs one extra
|
|
82
|
+
* execution and is still correct.
|
|
83
|
+
*
|
|
84
|
+
* "Probed and there was nothing to push into" is an answer too, and a different
|
|
85
|
+
* one from "not probed yet" — otherwise an endpoint that cannot be paged would
|
|
86
|
+
* be probed again before every window it ever serves.
|
|
87
|
+
*/
|
|
88
|
+
export declare class ListPlans {
|
|
89
|
+
private readonly plans;
|
|
90
|
+
known(endpoint: string): boolean;
|
|
91
|
+
get(endpoint: string): ListPlan | null;
|
|
92
|
+
learn(endpoint: string, plan: ListPlan | null): void;
|
|
93
|
+
forget(endpoint: string): void;
|
|
94
|
+
}
|
|
95
|
+
export declare function beginList(want: ListWant, plan: ListPlan | null): ListExecution;
|
|
96
|
+
/**
|
|
97
|
+
* A `findMany` about to run inside a list execution.
|
|
98
|
+
*
|
|
99
|
+
* Returns the arguments it should run with — the method's own, plus the window
|
|
100
|
+
* when this is the call the plan points at. A collection that already limits
|
|
101
|
+
* itself is left alone: composing someone else's `take` with ours would answer
|
|
102
|
+
* with rows neither of us asked for.
|
|
103
|
+
*/
|
|
104
|
+
export declare function interceptFindMany(list: ListExecution, model: string, args: any): {
|
|
105
|
+
args: any;
|
|
106
|
+
call: ListCall;
|
|
107
|
+
};
|
|
108
|
+
export interface ListAttempt {
|
|
109
|
+
execution: Execution;
|
|
110
|
+
returned: unknown;
|
|
111
|
+
}
|
|
112
|
+
export interface ListOutcome {
|
|
113
|
+
/** The execution that produced the answer — its read set is the subscription's. */
|
|
114
|
+
execution: Execution;
|
|
115
|
+
/** The rows of the window that was asked for. */
|
|
116
|
+
rows: Row[];
|
|
117
|
+
/** How many rows the whole collection has. Only a count run works this out. */
|
|
118
|
+
total: number;
|
|
119
|
+
/** The collection's ordering, when it is one the browser can evaluate. */
|
|
120
|
+
order?: OrderKey[];
|
|
121
|
+
/** The collection's membership, when it is one the browser can evaluate. */
|
|
122
|
+
filter?: RowFilter;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Run a list endpoint for one window, pushing the window in where it can.
|
|
126
|
+
*
|
|
127
|
+
* `run` starts the method inside a fresh execution; it may be called twice, and
|
|
128
|
+
* the second run is the honest one — whole method, no window, sliced in memory.
|
|
129
|
+
*/
|
|
130
|
+
export declare function evaluateList(plans: ListPlans, endpoint: string, want: ListWant, run: (list: ListExecution) => Promise<ListAttempt>,
|
|
131
|
+
/** How a field may be compared in a browser, from the schema. */
|
|
132
|
+
kindOf?: (model: string, field: string) => OrderKey["type"] | undefined): Promise<ListOutcome>;
|
|
133
|
+
/**
|
|
134
|
+
* Identity of a collection's count row.
|
|
135
|
+
*
|
|
136
|
+
* It has to be stable across recomputations — the client's identity map is what
|
|
137
|
+
* makes a changing total a field update rather than a row being replaced — and
|
|
138
|
+
* distinct per collection, which the endpoint and its arguments already are.
|
|
139
|
+
*/
|
|
140
|
+
export declare function countRowId(endpoint: string, args: unknown): string;
|
|
141
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/server/api/list.ts"],"names":[],"mappings":"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"}
|