nowity 1.0.0 → 1.1.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 +23 -5
- package/dist/client/confirmed-store.d.ts.map +1 -1
- package/dist/client/confirmed-store.js +4 -1
- package/dist/client/connection.d.ts.map +1 -1
- package/dist/client/connection.js +1 -2
- package/dist/client/nowity-client.d.ts +16 -3
- package/dist/client/nowity-client.d.ts.map +1 -1
- package/dist/client/nowity-client.js +54 -28
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +5 -4
- package/dist/core/normalize.d.ts.map +1 -1
- package/dist/core/normalize.js +6 -0
- package/dist/core/protocol.d.ts +10 -0
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/server/api/bridge.js +11 -3
- package/dist/server/api/collector.js +2 -3
- package/dist/server/api/configure.d.ts +0 -5
- package/dist/server/api/configure.d.ts.map +1 -1
- package/dist/server/api/configure.js +0 -1
- package/dist/server/api/prerender.js +1 -2
- package/dist/server/api/runtime.d.ts +8 -0
- package/dist/server/api/runtime.d.ts.map +1 -1
- package/dist/server/api/runtime.js +2 -0
- package/dist/server/change-source/outbox-change-source.js +5 -5
- package/dist/server/change-source/wal-change-source.js +1 -1
- package/dist/server/evaluate.d.ts +11 -1
- package/dist/server/evaluate.d.ts.map +1 -1
- package/dist/server/evaluate.js +15 -4
- package/dist/server/mutator.d.ts +2 -1
- package/dist/server/mutator.d.ts.map +1 -1
- package/dist/server/query.d.ts +7 -0
- package/dist/server/query.d.ts.map +1 -1
- package/dist/server/setup-sql.d.ts +10 -0
- package/dist/server/setup-sql.d.ts.map +1 -0
- package/dist/server/{sql/setup.sql → setup-sql.js} +82 -36
- package/dist/server/setup.d.ts +1 -2
- package/dist/server/setup.d.ts.map +1 -1
- package/dist/server/setup.js +5 -53
- package/dist/server/ssr.js +1 -1
- package/dist/server/sync-engine.d.ts +2 -0
- package/dist/server/sync-engine.d.ts.map +1 -1
- package/dist/server/sync-engine.js +12 -12
- package/dist/server/ws-server.d.ts.map +1 -1
- package/dist/server/ws-server.js +25 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npm run db:push # push the demo Prisma schema
|
|
|
27
27
|
npm run prisma:generate # both delegate to example-next, where the schema lives
|
|
28
28
|
npm run example # end-to-end demo, prints what a UI observer sees
|
|
29
29
|
npx ts-node -P tsconfig.test.json example/contract-demo.ts # the class-based API
|
|
30
|
-
npm test #
|
|
30
|
+
npm test # 143 tests, including all 11 acceptance scenarios
|
|
31
31
|
npm run perf # fan-out cost against a real database, before and after
|
|
32
32
|
|
|
33
33
|
cd example-next && npm run dev # http://localhost:3000/projects/demo?user=u-alice
|
|
@@ -184,6 +184,13 @@ the session cookie the pages already use.
|
|
|
184
184
|
The schema is read from the Prisma client, which already carries it, and the
|
|
185
185
|
change source defaults to the outbox on `DATABASE_URL`.
|
|
186
186
|
|
|
187
|
+
Nowity's own tables — the outbox, the epochs, the mutation bookkeeping — live in
|
|
188
|
+
a schema of their own, `nowity`, so `prisma db push` never sees them and never
|
|
189
|
+
offers to drop them. `setupNowity(pool, tables)` creates them and is idempotent,
|
|
190
|
+
so it can run at boot; to manage the schema through migrations instead, put
|
|
191
|
+
`NOWITY_SETUP_SQL` in one. An install from 1.0, which kept them in `public`, is
|
|
192
|
+
moved over by the same call, triggers and data included.
|
|
193
|
+
|
|
187
194
|
`services` does nothing a decorator has not already done — a class registers
|
|
188
195
|
itself the moment its module is evaluated. What the list buys is that the import
|
|
189
196
|
is a real one, visible in the file rather than a side effect, and checked: a
|
|
@@ -200,7 +207,8 @@ The same line the server runs, resolving to a proxy instead of an
|
|
|
200
207
|
implementation, and the same signature: `byProject` returns `Promise<Document[]>`
|
|
201
208
|
on both sides. What differs is that the objects in the array are live — the array
|
|
202
209
|
gains and loses rows, MobX tracks the fields, and `documents.rename(id, title)`
|
|
203
|
-
is an ordinary call
|
|
210
|
+
is an ordinary call: it resolves with whatever the method returned, and rejects
|
|
211
|
+
if the server refuses it.
|
|
204
212
|
|
|
205
213
|
Acquisition is asynchronous, so the two things a `status` field would carry are
|
|
206
214
|
not in the result at all: "not there yet" is a pending promise, "not allowed" is
|
|
@@ -448,6 +456,10 @@ it:
|
|
|
448
456
|
export const nowity = createNextNowity(nowityConfig);
|
|
449
457
|
```
|
|
450
458
|
|
|
459
|
+
The config is the one the sync server takes, `auth` included, so a page asks
|
|
460
|
+
the same `Authenticator` the socket does and cannot disagree with it about who
|
|
461
|
+
is looking.
|
|
462
|
+
|
|
451
463
|
A page says where its live queries are read, and nothing more:
|
|
452
464
|
|
|
453
465
|
```tsx
|
|
@@ -543,7 +555,7 @@ Three things follow from it being the database that coordinates:
|
|
|
543
555
|
rather than replaying history, and its clients are still correct because a
|
|
544
556
|
subscription's first answer is a snapshot of the database, not a replay of the
|
|
545
557
|
stream.
|
|
546
|
-
- **Retention waits for the slowest live reader.** `nowity_prune_outbox` deletes
|
|
558
|
+
- **Retention waits for the slowest live reader.** `nowity.nowity_prune_outbox` deletes
|
|
547
559
|
only what every consumer seen recently has passed. A consumer silent longer
|
|
548
560
|
than the staleness window is treated as gone, so set it well above any pause a
|
|
549
561
|
healthy process can take.
|
|
@@ -553,8 +565,14 @@ Scenario 22 runs two instances against one database and checks each of these.
|
|
|
553
565
|
### Escape hatches
|
|
554
566
|
|
|
555
567
|
`@query({ tables: [...] })` for a query that reads through something the tracker
|
|
556
|
-
cannot see, and `@query({
|
|
557
|
-
|
|
568
|
+
cannot see, and `@query({ idField })` when the rows are the endpoint's own shape
|
|
569
|
+
rather than a model's — a view assembled from several tables, say. The rows are
|
|
570
|
+
keyed by that field on both sides and stored under an entity of their own, named
|
|
571
|
+
after the endpoint; `@query({ entity })` names it yourself, when two endpoints
|
|
572
|
+
return the same thing.
|
|
573
|
+
|
|
574
|
+
A field the method leaves `undefined` is absent in the browser too — not
|
|
575
|
+
`null` — and one that disappears between two results is removed there. A query whose read set comes out empty is revalidated on every
|
|
558
576
|
transaction rather than quietly stopping — not knowing what a query reads may
|
|
559
577
|
never mean not recomputing it.
|
|
560
578
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmed-store.d.ts","sourceRoot":"","sources":["../../src/client/confirmed-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiD;IACtE,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiD;IAEvE,QAAQ,IAAI,MAAM,EAAE;IAIpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;IAI1C,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,GAAG,GAAG,SAAS;IAIlD,qDAAqD;IACrD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAgB9E,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"confirmed-store.d.ts","sourceRoot":"","sources":["../../src/client/confirmed-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiD;IACtE,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiD;IAEvE,QAAQ,IAAI,MAAM,EAAE;IAIpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;IAI1C,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,GAAG,GAAG,SAAS;IAIlD,qDAAqD;IACrD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAgB9E,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI;IAWrE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI;IAIjE,qDAAqD;IACrD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS/B,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,MAAM;IAed,OAAO,CAAC,OAAO;CAUlB"}
|
|
@@ -49,7 +49,10 @@ class ConfirmedStore {
|
|
|
49
49
|
for (const patch of patches) {
|
|
50
50
|
const map = this.rowMap(entity);
|
|
51
51
|
const existing = map.get(patch.id);
|
|
52
|
-
|
|
52
|
+
const row = existing ? { ...existing, ...patch.fields } : { ...patch.fields };
|
|
53
|
+
for (const key of patch.unset ?? [])
|
|
54
|
+
delete row[key];
|
|
55
|
+
map.set(patch.id, row);
|
|
53
56
|
this.retain(subId, entity, patch.id);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -1 +1 @@
|
|
|
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CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;IAIvE;;;;;;;OAOG;IACH,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAuB3C,OAAO,CAAC,IAAI;IAON,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;YA0B7C,MAAM;IAepB;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS;IAehD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAK9B,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAK/B,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,UAAU;CAMrB"}
|
|
@@ -200,8 +200,7 @@ class NowityConnection {
|
|
|
200
200
|
async call(name, args) {
|
|
201
201
|
const kind = await this.kindOf(name);
|
|
202
202
|
if (kind === "mutation") {
|
|
203
|
-
|
|
204
|
-
return undefined;
|
|
203
|
+
return this.client.mutate(name, args);
|
|
205
204
|
}
|
|
206
205
|
if (kind === "list") {
|
|
207
206
|
throw new Error(`"${name}" is a @list endpoint, so it has no single result to hand ` +
|
|
@@ -87,8 +87,20 @@ export declare class NowityClient {
|
|
|
87
87
|
* is a default, not an override.
|
|
88
88
|
*/
|
|
89
89
|
private serverEntities;
|
|
90
|
+
/**
|
|
91
|
+
* Id fields as the server keyed the rows it sent, per entity. The server
|
|
92
|
+
* diffs by them, so the store has to key by them too — a guess here files
|
|
93
|
+
* a row under "undefined" and turns its first patch into a fragment.
|
|
94
|
+
*/
|
|
95
|
+
private readonly sentIdFields;
|
|
90
96
|
private readonly onError;
|
|
91
97
|
private pending;
|
|
98
|
+
/**
|
|
99
|
+
* Who is waiting for each mutation's answer. Separate from {@link pending}:
|
|
100
|
+
* that queue is about data and empties when data arrives, this is about the
|
|
101
|
+
* returned value, which only the mutation's own result carries.
|
|
102
|
+
*/
|
|
103
|
+
private readonly callers;
|
|
92
104
|
/**
|
|
93
105
|
* Whether anything written here is still unconfirmed, as an observable.
|
|
94
106
|
*
|
|
@@ -134,10 +146,11 @@ export declare class NowityClient {
|
|
|
134
146
|
/**
|
|
135
147
|
* Run a named mutator: optimistically now, authoritatively on the server.
|
|
136
148
|
*
|
|
137
|
-
* The returned promise settles when the server has decided
|
|
138
|
-
* mutation was refused — by then the
|
|
149
|
+
* The returned promise settles when the server has decided, with whatever the
|
|
150
|
+
* endpoint returned. It rejects if the mutation was refused — by then the
|
|
151
|
+
* optimistic effect is already undone.
|
|
139
152
|
*/
|
|
140
|
-
mutate<A>(name: string, args: A): Promise<
|
|
153
|
+
mutate<A, R = unknown>(name: string, args: A): Promise<R>;
|
|
141
154
|
private handleMessage;
|
|
142
155
|
private handleWelcome;
|
|
143
156
|
private handleSnapshotMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nowity-client.d.ts","sourceRoot":"","sources":["../../src/client/nowity-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAqD,MAAM,MAAM,CAAC;AAC7F,OAAO,KAAK,EAER,gBAAgB,EAGhB,aAAa,EAEb,aAAa,EAGhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAO,MAAM,eAAe,CAAC;AAEnD,OAAO,EACH,SAAS,EAET,KAAK,eAAe,EAEvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IAC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AA+E;IAC/E,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,eAAe;IAiBvB,wFAAwF;IACxF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI5C,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,YAAY;IAMpB,8EAA8E;IAC9E,IAAI,oBAAoB,IAAI,MAAM,CAEjC;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,0EAA0E;IAC1E,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;CAG9C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAEpE"}
|
|
@@ -40,7 +40,19 @@ class NowityClient {
|
|
|
40
40
|
* is a default, not an override.
|
|
41
41
|
*/
|
|
42
42
|
this.serverEntities = {};
|
|
43
|
+
/**
|
|
44
|
+
* Id fields as the server keyed the rows it sent, per entity. The server
|
|
45
|
+
* diffs by them, so the store has to key by them too — a guess here files
|
|
46
|
+
* a row under "undefined" and turns its first patch into a fragment.
|
|
47
|
+
*/
|
|
48
|
+
this.sentIdFields = new Map();
|
|
43
49
|
this.pending = [];
|
|
50
|
+
/**
|
|
51
|
+
* Who is waiting for each mutation's answer. Separate from {@link pending}:
|
|
52
|
+
* that queue is about data and empties when data arrives, this is about the
|
|
53
|
+
* returned value, which only the mutation's own result carries.
|
|
54
|
+
*/
|
|
55
|
+
this.callers = new Map();
|
|
44
56
|
/**
|
|
45
57
|
* Whether anything written here is still unconfirmed, as an observable.
|
|
46
58
|
*
|
|
@@ -228,8 +240,9 @@ class NowityClient {
|
|
|
228
240
|
/**
|
|
229
241
|
* Run a named mutator: optimistically now, authoritatively on the server.
|
|
230
242
|
*
|
|
231
|
-
* The returned promise settles when the server has decided
|
|
232
|
-
* mutation was refused — by then the
|
|
243
|
+
* The returned promise settles when the server has decided, with whatever the
|
|
244
|
+
* endpoint returned. It rejects if the mutation was refused — by then the
|
|
245
|
+
* optimistic effect is already undone.
|
|
233
246
|
*/
|
|
234
247
|
mutate(name, args) {
|
|
235
248
|
// A mutation with no local counterpart is legal: it simply has no
|
|
@@ -237,7 +250,8 @@ class NowityClient {
|
|
|
237
250
|
// here would make every write opt into optimism, which is backwards.
|
|
238
251
|
const mutationId = ++this.lastMutationId;
|
|
239
252
|
return new Promise((resolve, reject) => {
|
|
240
|
-
this.
|
|
253
|
+
this.callers.set(mutationId, { resolve: resolve, reject });
|
|
254
|
+
this.pending.push({ mutationId, name, args });
|
|
241
255
|
(0, mobx_1.runInAction)(() => this.rebase());
|
|
242
256
|
this.send({ t: "mutate", mutationId, name, args });
|
|
243
257
|
});
|
|
@@ -269,7 +283,7 @@ class NowityClient {
|
|
|
269
283
|
});
|
|
270
284
|
break;
|
|
271
285
|
case "mutation-result":
|
|
272
|
-
this.handleMutationResult(message.mutationId, message.ok, message.error);
|
|
286
|
+
this.handleMutationResult(message.mutationId, message.ok, message.error, message.value);
|
|
273
287
|
break;
|
|
274
288
|
case "error":
|
|
275
289
|
this.handleServerError(message.subId, message.message);
|
|
@@ -297,6 +311,16 @@ class NowityClient {
|
|
|
297
311
|
this.ackThrough(serverLastMutationId);
|
|
298
312
|
this.rebase();
|
|
299
313
|
});
|
|
314
|
+
// A mutation already out of the queue is not re-sent, so its result —
|
|
315
|
+
// lost with the old socket — will never come. It did succeed: the data
|
|
316
|
+
// said so. Its value is what is lost, not its outcome.
|
|
317
|
+
const queued = new Set(this.pending.map((m) => m.mutationId));
|
|
318
|
+
for (const [mutationId, caller] of this.callers) {
|
|
319
|
+
if (queued.has(mutationId))
|
|
320
|
+
continue;
|
|
321
|
+
this.callers.delete(mutationId);
|
|
322
|
+
caller.resolve(undefined);
|
|
323
|
+
}
|
|
300
324
|
// Re-send everything the server has not seen, then re-establish the
|
|
301
325
|
// subscriptions. Snapshots recomputed afterwards may or may not already
|
|
302
326
|
// contain these mutations; whichever way, the reported lastMutationId says
|
|
@@ -333,6 +357,11 @@ class NowityClient {
|
|
|
333
357
|
sub.entity.set(snapshot.entity);
|
|
334
358
|
sub.epoch = snapshot.epoch;
|
|
335
359
|
sub.scope = snapshot.scope;
|
|
360
|
+
if (snapshot.idField)
|
|
361
|
+
this.sentIdFields.set(snapshot.entity, snapshot.idField);
|
|
362
|
+
for (const [entity, field] of Object.entries(snapshot.extraIdFields ?? {})) {
|
|
363
|
+
this.sentIdFields.set(entity, field);
|
|
364
|
+
}
|
|
336
365
|
this.confirmed.setSnapshot(snapshot.subId, snapshot.entity, snapshot.rows, this.idFieldOf(snapshot.entity));
|
|
337
366
|
for (const [entity, rows] of Object.entries(snapshot.extra ?? {})) {
|
|
338
367
|
this.confirmed.setSnapshot(snapshot.subId, entity, rows, this.idFieldOf(entity));
|
|
@@ -383,24 +412,25 @@ class NowityClient {
|
|
|
383
412
|
sub.error.set(reason);
|
|
384
413
|
this.resolveResync(subId);
|
|
385
414
|
}
|
|
386
|
-
handleMutationResult(mutationId, ok, error) {
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
return;
|
|
390
|
-
const mutation = this.pending[index];
|
|
415
|
+
handleMutationResult(mutationId, ok, error, value) {
|
|
416
|
+
const caller = this.callers.get(mutationId);
|
|
417
|
+
this.callers.delete(mutationId);
|
|
391
418
|
if (ok) {
|
|
392
|
-
//
|
|
393
|
-
// flight, and dropping now would make the UI flicker back to
|
|
394
|
-
// value.
|
|
395
|
-
//
|
|
396
|
-
|
|
419
|
+
// Stays in the pending queue: the data carrying its effect may still
|
|
420
|
+
// be in flight, and dropping now would make the UI flicker back to
|
|
421
|
+
// the old value. `ackThrough` empties the queue when data arrives
|
|
422
|
+
// that already includes this mutation.
|
|
423
|
+
caller?.resolve(value);
|
|
397
424
|
return;
|
|
398
425
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
426
|
+
const index = this.pending.findIndex((m) => m.mutationId === mutationId);
|
|
427
|
+
if (index !== -1) {
|
|
428
|
+
(0, mobx_1.runInAction)(() => {
|
|
429
|
+
this.pending.splice(index, 1);
|
|
430
|
+
this.rebase();
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
caller?.reject(new Error(error ?? "Mutation rejected"));
|
|
404
434
|
}
|
|
405
435
|
handleServerError(subId, messageText) {
|
|
406
436
|
if (subId) {
|
|
@@ -441,14 +471,7 @@ class NowityClient {
|
|
|
441
471
|
}
|
|
442
472
|
if (this.pending.length === 0)
|
|
443
473
|
return;
|
|
444
|
-
|
|
445
|
-
for (const mutation of this.pending) {
|
|
446
|
-
if (mutation.mutationId <= lastMutationId)
|
|
447
|
-
mutation.resolve();
|
|
448
|
-
else
|
|
449
|
-
kept.push(mutation);
|
|
450
|
-
}
|
|
451
|
-
this.pending = kept;
|
|
474
|
+
this.pending = this.pending.filter((mutation) => mutation.mutationId > lastMutationId);
|
|
452
475
|
}
|
|
453
476
|
// --------------------------------------------------------------- MobX identity
|
|
454
477
|
/** Observable identity map of an entity: id → live object. */
|
|
@@ -540,7 +563,10 @@ class NowityClient {
|
|
|
540
563
|
return this.subs.get(subId)?.single.get();
|
|
541
564
|
}
|
|
542
565
|
idFieldOf(entity) {
|
|
543
|
-
return this.
|
|
566
|
+
return (this.sentIdFields.get(entity) ??
|
|
567
|
+
this.opts.entities?.[entity]?.idField ??
|
|
568
|
+
this.serverEntities[entity]?.idField ??
|
|
569
|
+
"id");
|
|
544
570
|
}
|
|
545
571
|
descriptorOf(entity) {
|
|
546
572
|
return this.opts.entities?.[entity] ?? this.serverEntities[entity] ?? {};
|
package/dist/core/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/core/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/core/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,OAAO,CAoCvF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAM1E"}
|
package/dist/core/diff.js
CHANGED
|
@@ -23,6 +23,7 @@ function diffRowSets(prev, next) {
|
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
25
|
const fields = {};
|
|
26
|
+
const unset = [];
|
|
26
27
|
let changed = false;
|
|
27
28
|
for (const key of Object.keys(nextRow)) {
|
|
28
29
|
if (!(0, normalize_1.valuesEqual)(prevRow[key], nextRow[key])) {
|
|
@@ -30,16 +31,16 @@ function diffRowSets(prev, next) {
|
|
|
30
31
|
changed = true;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
// A field that disappeared
|
|
34
|
-
//
|
|
34
|
+
// A field that disappeared is removed on the client, not set to null —
|
|
35
|
+
// `null` is a value the endpoint may return, absence is another.
|
|
35
36
|
for (const key of Object.keys(prevRow)) {
|
|
36
37
|
if (!(key in nextRow)) {
|
|
37
|
-
|
|
38
|
+
unset.push(key);
|
|
38
39
|
changed = true;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
if (changed)
|
|
42
|
-
upsert.push({ id, fields });
|
|
43
|
+
upsert.push(unset.length ? { id, fields, unset } : { id, fields });
|
|
43
44
|
}
|
|
44
45
|
for (const id of prev.keys()) {
|
|
45
46
|
if (!next.has(id))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/core/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/core/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA0BtD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAO1C;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAM3D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAMxD"}
|
package/dist/core/normalize.js
CHANGED
|
@@ -33,6 +33,10 @@ function normalizeValue(value) {
|
|
|
33
33
|
return normalizeValue(asAny.toJSON());
|
|
34
34
|
const out = {};
|
|
35
35
|
for (const key of Object.keys(value).sort()) {
|
|
36
|
+
// Dropped like JSON drops it: an absent field and an `undefined` one
|
|
37
|
+
// are the same thing, and neither is `null`.
|
|
38
|
+
if (value[key] === undefined)
|
|
39
|
+
continue;
|
|
36
40
|
out[key] = normalizeValue(value[key]);
|
|
37
41
|
}
|
|
38
42
|
return out;
|
|
@@ -42,6 +46,8 @@ function normalizeValue(value) {
|
|
|
42
46
|
function normalizeRow(row) {
|
|
43
47
|
const out = {};
|
|
44
48
|
for (const key of Object.keys(row)) {
|
|
49
|
+
if (row[key] === undefined)
|
|
50
|
+
continue;
|
|
45
51
|
out[key] = normalizeValue(row[key]);
|
|
46
52
|
}
|
|
47
53
|
return out;
|
package/dist/core/protocol.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface HydrationPayload {
|
|
|
47
47
|
ids: EntityId[];
|
|
48
48
|
rows: Row[];
|
|
49
49
|
extra?: Record<string, Row[]>;
|
|
50
|
+
/** Field the rows are keyed by, when it is not `id`. */
|
|
51
|
+
idField?: string;
|
|
52
|
+
/** The same for the `extra` entity sets. */
|
|
53
|
+
extraIdFields?: Record<string, string>;
|
|
50
54
|
/** How the collection is ordered, when the endpoint's own query says so. */
|
|
51
55
|
order?: OrderKey[];
|
|
52
56
|
/** Which rows belong here, when the browser can decide that itself. */
|
|
@@ -143,6 +147,10 @@ export interface SubSnapshot {
|
|
|
143
147
|
rows: Row[];
|
|
144
148
|
/** Side entities (relation targets) keyed by entity name. */
|
|
145
149
|
extra?: Record<string, Row[]>;
|
|
150
|
+
/** Field the rows are keyed by, when it is not `id`. */
|
|
151
|
+
idField?: string;
|
|
152
|
+
/** The same for the `extra` entity sets. */
|
|
153
|
+
extraIdFields?: Record<string, string>;
|
|
146
154
|
/**
|
|
147
155
|
* How this result is ordered, when the endpoint's query declared it.
|
|
148
156
|
*
|
|
@@ -203,6 +211,8 @@ export interface ServerMutationResult {
|
|
|
203
211
|
mutationId: number;
|
|
204
212
|
ok: boolean;
|
|
205
213
|
error?: string;
|
|
214
|
+
/** What the endpoint returned, when it returned something. */
|
|
215
|
+
value?: unknown;
|
|
206
216
|
lastMutationId: number;
|
|
207
217
|
}
|
|
208
218
|
export interface ServerError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/core/protocol.ts"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CAC1B;AAED,MAAM,WAAW,WAAW;IACxB,CAAC,EAAE,OAAO,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GACnB,aAAa,GACb,cAAc,GACd,QAAQ,GACR,oBAAoB,GACpB,WAAW,CAAC"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -85,6 +85,8 @@ export interface RowPatch {
|
|
|
85
85
|
id: EntityId;
|
|
86
86
|
/** Only the fields that actually changed (on insert: all of them). */
|
|
87
87
|
fields: Row;
|
|
88
|
+
/** Fields the row no longer has. */
|
|
89
|
+
unset?: string[];
|
|
88
90
|
}
|
|
89
91
|
/** Difference between two consecutive results of the same live query. */
|
|
90
92
|
export interface SetDiff {
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,4EAA4E;AAC5E,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEtD,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;CACnB;AAED,kDAAkD;AAClD,eAAO,MAAM,QAAQ,EAAG,KAAc,CAAC;AAEvC,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,OAAO,EAAE,GAAG,OAAO,QAAQ,CAAC;AAEpD;;;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OAAO,CAElD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { WalChangeSource, type WalChangeSourceOptions, } from "./server/change-s
|
|
|
34
34
|
export type { ChangeSource } from "./server/change-source/change-source";
|
|
35
35
|
/** Schema setup: the outbox triggers every tracked table needs. */
|
|
36
36
|
export { setupNowity, trackTable, untrackTable, setReplicaIdentityFull, type TrackedTables, } from "./server/setup";
|
|
37
|
+
export { NOWITY_SETUP_SQL } from "./server/setup-sql";
|
|
37
38
|
export { createNextNowity, currentNextNowity, type NextNowity, type ReadAs, type ReadOptions, } from "./next/server";
|
|
38
39
|
export { Live, type LiveProps } from "./next/live";
|
|
39
40
|
export { serveNext, type ServeNextOptions, type ServedNext } from "./next/serve";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACH,GAAG,EACH,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,YAAY,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG5E,OAAO,EACH,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAA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AC7B,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAG3F,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
35
35
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.WebSocketTransport = exports.currentConnection = exports.activeConnection = exports.NowityConnection = exports.configureNowityServer = exports.withNowity = exports.serveNext = exports.Live = exports.currentNextNowity = exports.createNextNowity = exports.setReplicaIdentityFull = exports.untrackTable = exports.trackTable = exports.setupNowity = exports.WalChangeSource = exports.OutboxChangeSource = exports.prerender = exports.AnonymousAuthenticator = exports.Authenticator = exports.Session = exports.createNowityRuntime = exports.createNowityServer = exports.isRejected = exports.isForbidden = exports.Rejected = exports.Forbidden = exports.countQuery = exports.pageQuery = exports.endpointName = exports.contractOf = exports.mutation = exports.list = exports.query = exports.contract = exports.api = void 0;
|
|
38
|
+
exports.WebSocketTransport = exports.currentConnection = exports.activeConnection = exports.NowityConnection = exports.configureNowityServer = exports.withNowity = exports.serveNext = exports.Live = exports.currentNextNowity = exports.createNextNowity = exports.NOWITY_SETUP_SQL = exports.setReplicaIdentityFull = exports.untrackTable = exports.trackTable = exports.setupNowity = exports.WalChangeSource = exports.OutboxChangeSource = exports.prerender = exports.AnonymousAuthenticator = exports.Authenticator = exports.Session = exports.createNowityRuntime = exports.createNowityServer = exports.isRejected = exports.isForbidden = exports.Rejected = exports.Forbidden = exports.countQuery = exports.pageQuery = exports.endpointName = exports.contractOf = exports.mutation = exports.list = exports.query = exports.contract = exports.api = void 0;
|
|
39
39
|
// ------------------------------------------------------------------- contracts
|
|
40
40
|
var contract_1 = require("./api/contract");
|
|
41
41
|
Object.defineProperty(exports, "api", { enumerable: true, get: function () { return contract_1.api; } });
|
|
@@ -75,6 +75,8 @@ Object.defineProperty(exports, "setupNowity", { enumerable: true, get: function
|
|
|
75
75
|
Object.defineProperty(exports, "trackTable", { enumerable: true, get: function () { return setup_1.trackTable; } });
|
|
76
76
|
Object.defineProperty(exports, "untrackTable", { enumerable: true, get: function () { return setup_1.untrackTable; } });
|
|
77
77
|
Object.defineProperty(exports, "setReplicaIdentityFull", { enumerable: true, get: function () { return setup_1.setReplicaIdentityFull; } });
|
|
78
|
+
var setup_sql_1 = require("./server/setup-sql");
|
|
79
|
+
Object.defineProperty(exports, "NOWITY_SETUP_SQL", { enumerable: true, get: function () { return setup_sql_1.NOWITY_SETUP_SQL; } });
|
|
78
80
|
// ------------------------------------------------------------------------ next
|
|
79
81
|
var server_1 = require("./next/server");
|
|
80
82
|
Object.defineProperty(exports, "createNextNowity", { enumerable: true, get: function () { return server_1.createNextNowity; } });
|
|
@@ -92,7 +92,7 @@ function buildApi(options) {
|
|
|
92
92
|
mutationId: ctx.mutationId,
|
|
93
93
|
};
|
|
94
94
|
try {
|
|
95
|
-
await call(execution, args);
|
|
95
|
+
return await call(execution, args);
|
|
96
96
|
}
|
|
97
97
|
catch (err) {
|
|
98
98
|
// The engine already knows how to treat a refused write;
|
|
@@ -264,8 +264,12 @@ function queryExecution(ctx, tracker, list) {
|
|
|
264
264
|
* then observe one author object, and renaming them updates both.
|
|
265
265
|
*/
|
|
266
266
|
function shape(returned, execution, options, tracker, name) {
|
|
267
|
-
const entity = options.entity ?? execution.lastModel;
|
|
268
267
|
const model = execution.lastModel;
|
|
268
|
+
// An `idField` of its own means the rows are the endpoint's own shape, not
|
|
269
|
+
// the last model it happened to read — so they get an entity of their own
|
|
270
|
+
// too, rather than being filed among that model's rows under the wrong id.
|
|
271
|
+
const entity = options.entity ?? (options.idField ? name : model);
|
|
272
|
+
const idField = options.idField ?? (model ? tracker.idField(model) : undefined);
|
|
269
273
|
const tables = readSetOf(execution, options);
|
|
270
274
|
const keys = tables ? keySetOf(execution, options) : undefined;
|
|
271
275
|
const single = !Array.isArray(returned);
|
|
@@ -274,9 +278,13 @@ function shape(returned, execution, options, tracker, name) {
|
|
|
274
278
|
const flattened = model
|
|
275
279
|
? rows.map((row) => lift(model, row, tracker, extra))
|
|
276
280
|
: rows;
|
|
281
|
+
const extraIdFields = {};
|
|
282
|
+
for (const target of Object.keys(extra))
|
|
283
|
+
extraIdFields[target] = tracker.idField(target);
|
|
277
284
|
return {
|
|
278
285
|
rows: flattened,
|
|
279
|
-
...(Object.keys(extra).length ? { extra } : {}),
|
|
286
|
+
...(Object.keys(extra).length ? { extra, extraIdFields } : {}),
|
|
287
|
+
...(idField ? { idField } : {}),
|
|
280
288
|
...(tables ? { tables } : {}),
|
|
281
289
|
...(keys ? { keys } : {}),
|
|
282
290
|
...(entity ? { entity } : {}),
|
|
@@ -163,8 +163,7 @@ async function readOne(snap, deps, session, query, args) {
|
|
|
163
163
|
...(output.order ? { order: output.order } : {}),
|
|
164
164
|
...(output.filter ? { filter: output.filter } : {}),
|
|
165
165
|
ids: output.ids,
|
|
166
|
-
rows
|
|
167
|
-
...(rows.extra ? { extra: rows.extra } : {}),
|
|
166
|
+
...rows,
|
|
168
167
|
};
|
|
169
168
|
}
|
|
170
169
|
catch (err) {
|
|
@@ -179,6 +178,6 @@ async function readOne(snap, deps, session, query, args) {
|
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
async function readEpoch(snap, scope) {
|
|
182
|
-
const { rows } = await snap.query(`SELECT version::text AS version FROM nowity_scope_epoch WHERE scope = $1`, [scope]);
|
|
181
|
+
const { rows } = await snap.query(`SELECT version::text AS version FROM nowity.nowity_scope_epoch WHERE scope = $1`, [scope]);
|
|
183
182
|
return rows.length ? Number(rows[0].version) : 0;
|
|
184
183
|
}
|
|
@@ -10,11 +10,6 @@ export interface NowityServerConfig extends NowityRuntimeConfig {
|
|
|
10
10
|
changeSource?: ChangeSource | (() => ChangeSource);
|
|
11
11
|
/** Used for the default change source. Defaults to `DATABASE_URL`. */
|
|
12
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
13
|
syncServer?: Omit<NowitySyncServerOptions, "engine">;
|
|
19
14
|
/** See {@link SyncEngineOptions.narrowInvalidation}. On unless set. */
|
|
20
15
|
narrowInvalidation?: boolean;
|
|
@@ -1 +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
|
|
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,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,CAoC3E"}
|
|
@@ -33,7 +33,6 @@ function resolveChangeSource(config) {
|
|
|
33
33
|
}
|
|
34
34
|
function createNowityServer(config) {
|
|
35
35
|
const runtime = (0, runtime_1.createNowityRuntime)(config);
|
|
36
|
-
(0, ironbean_1.take)(auth_1.Authenticator).bindTo((config.auth ?? auth_1.AnonymousAuthenticator));
|
|
37
36
|
const authenticator = (0, ironbean_1.getBaseApplicationContext)().getBean(auth_1.Authenticator);
|
|
38
37
|
const engine = new sync_engine_1.SyncEngine({
|
|
39
38
|
snapshots: runtime.snapshots,
|
|
@@ -41,8 +41,7 @@ async function runOne(deps, snap, session, contract, method, args, hydration) {
|
|
|
41
41
|
entity: output.entity ?? def.entity,
|
|
42
42
|
...(output.single ? { single: true } : {}),
|
|
43
43
|
ids: output.ids,
|
|
44
|
-
rows
|
|
45
|
-
...(rows.extra ? { extra: rows.extra } : {}),
|
|
44
|
+
...rows,
|
|
46
45
|
scope: null,
|
|
47
46
|
epoch: 0,
|
|
48
47
|
});
|
|
@@ -23,6 +23,14 @@ export interface NowityRuntimeConfig {
|
|
|
23
23
|
* listed without `@api` fails at startup rather than at the first call.
|
|
24
24
|
*/
|
|
25
25
|
services?: Function[];
|
|
26
|
+
/**
|
|
27
|
+
* The {@link Authenticator} implementation. Without one every connection is
|
|
28
|
+
* anonymous, which is right for a prototype and wrong for anything else.
|
|
29
|
+
*
|
|
30
|
+
* Bound here rather than by the sync server, because a page rendered by
|
|
31
|
+
* Next asks the same question the socket does and has to get the same answer.
|
|
32
|
+
*/
|
|
33
|
+
auth?: Function;
|
|
26
34
|
onWarning?: (message: string) => void;
|
|
27
35
|
}
|
|
28
36
|
export interface NowityRuntime {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/server/api/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/server/api/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAe,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGzE,MAAM,WAAW,mBAAmB;IAChC,uCAAuC;IACvC,MAAM,EAAE,GAAG,CAAC;IACZ,gDAAgD;IAChD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,QAAQ,CAAC;IACd,SAAS,EAAE,oBAAoB,CAAC;IAChC,2EAA2E;IAC3E,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,cAAc,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAgC9E"}
|