@synnaxlabs/client 0.57.1 → 0.57.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-DDACDVZ-.js → client-BsVW3qAW.js} +3812 -3763
- package/dist/client-BsVW3qAW.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/src/label/store.d.ts +1 -1
- package/dist/src/label/store.d.ts.map +1 -1
- package/dist/src/ontology/client.d.ts.map +1 -1
- package/dist/src/ontology/store.d.ts +16 -1
- package/dist/src/ontology/store.d.ts.map +1 -1
- package/dist/src/query/external.d.ts +1 -0
- package/dist/src/query/external.d.ts.map +1 -1
- package/dist/src/query/indexes.d.ts +32 -0
- package/dist/src/query/indexes.d.ts.map +1 -0
- package/dist/src/query/table.d.ts +10 -1
- package/dist/src/query/table.d.ts.map +1 -1
- package/dist/src/ranger/client.d.ts +2 -0
- package/dist/src/ranger/client.d.ts.map +1 -1
- package/dist/src/status/client.d.ts.map +1 -1
- package/dist/testutil.js +1 -1
- package/package.json +5 -5
- package/src/label/store.ts +7 -2
- package/src/ontology/client.ts +15 -8
- package/src/ontology/store.ts +27 -5
- package/src/query/external.ts +1 -0
- package/src/query/indexes.ts +81 -0
- package/src/query/table.ts +25 -5
- package/src/ranger/client.ts +26 -16
- package/src/status/client.ts +14 -8
- package/dist/client-DDACDVZ-.js.map +0 -1
package/src/ranger/client.ts
CHANGED
|
@@ -340,16 +340,13 @@ const watchRelationships = <Q extends query.Params>(
|
|
|
340
340
|
affectedRangeKeys(relOfEvent(event)),
|
|
341
341
|
);
|
|
342
342
|
|
|
343
|
-
const rangesWithLabel = (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const keys = relationships
|
|
348
|
-
.get(
|
|
343
|
+
const rangesWithLabel = (cache: ontology.Cache, key: label.Key): Key[] | null => {
|
|
344
|
+
const keys = cache
|
|
345
|
+
.relationshipsTo(label.ontologyID(key))
|
|
346
|
+
.filter(
|
|
349
347
|
(r) =>
|
|
350
348
|
r.type === label.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE &&
|
|
351
|
-
r.from.type === "range"
|
|
352
|
-
r.to.key === key,
|
|
349
|
+
r.from.type === "range",
|
|
353
350
|
)
|
|
354
351
|
.map((r) => r.from.key);
|
|
355
352
|
return keys.length === 0 ? null : keys;
|
|
@@ -358,10 +355,10 @@ const rangesWithLabel = (
|
|
|
358
355
|
/** Projects label content changes onto the ranges they label. */
|
|
359
356
|
const watchLabels = <Q extends query.Params>(
|
|
360
357
|
labels: query.Table<label.Key, label.Label>,
|
|
361
|
-
|
|
358
|
+
cache: ontology.Cache,
|
|
362
359
|
): query.Watch<Q, Key> =>
|
|
363
360
|
query.watch<Q, Key, label.Key, label.Label>(labels, (event) =>
|
|
364
|
-
rangesWithLabel(
|
|
361
|
+
rangesWithLabel(cache, event.key),
|
|
365
362
|
);
|
|
366
363
|
|
|
367
364
|
/** Config for {@link Client}. */
|
|
@@ -422,7 +419,9 @@ export class Client extends query.Retriever<
|
|
|
422
419
|
query.deriveWatch(relationships, (event) =>
|
|
423
420
|
affectedRangeKeys(relOfEvent(event)),
|
|
424
421
|
),
|
|
425
|
-
query.deriveWatch(labels, (event) =>
|
|
422
|
+
query.deriveWatch(labels, (event) =>
|
|
423
|
+
rangesWithLabel(ontologyClient.cache, event.key),
|
|
424
|
+
),
|
|
426
425
|
],
|
|
427
426
|
});
|
|
428
427
|
const single = cache.queries<Key | Name, Range, Key, Range>({
|
|
@@ -443,7 +442,7 @@ export class Client extends query.Retriever<
|
|
|
443
442
|
matches: (r, query) => this.requestMatches(r, query),
|
|
444
443
|
watch: [
|
|
445
444
|
watchRelationships<RetrieveRequest>(relationships),
|
|
446
|
-
watchLabels<RetrieveRequest>(labels,
|
|
445
|
+
watchLabels<RetrieveRequest>(labels, ontologyClient.cache),
|
|
447
446
|
],
|
|
448
447
|
},
|
|
449
448
|
compose: (r) => this.composeOne(r),
|
|
@@ -597,7 +596,7 @@ export class Client extends query.Retriever<
|
|
|
597
596
|
private composeOne(cached: Range): Range {
|
|
598
597
|
const id = ontologyID(cached.key);
|
|
599
598
|
const labels = label.cachedLabelsOf(
|
|
600
|
-
this.cfg.ontology.cache
|
|
599
|
+
this.cfg.ontology.cache,
|
|
601
600
|
this.cfg.labels.store,
|
|
602
601
|
id,
|
|
603
602
|
);
|
|
@@ -642,6 +641,17 @@ export class Client extends query.Retriever<
|
|
|
642
641
|
}
|
|
643
642
|
}
|
|
644
643
|
|
|
644
|
+
/** Writes a fetch response as one batch per table, so each table flushes once. */
|
|
645
|
+
private writeThroughMany(ranges: Range[]): void {
|
|
646
|
+
this.store.batch(() =>
|
|
647
|
+
this.cfg.labels.store.batch(() =>
|
|
648
|
+
this.cfg.ontology.cache.relationships.batch(() =>
|
|
649
|
+
ranges.forEach((r) => this.writeThrough(r)),
|
|
650
|
+
),
|
|
651
|
+
),
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
|
|
645
655
|
/**
|
|
646
656
|
* Fetches the given keys with labels and parents included, writing them and
|
|
647
657
|
* their relationships through. Powers the table's fetch primitive.
|
|
@@ -652,7 +662,7 @@ export class Client extends query.Retriever<
|
|
|
652
662
|
keys,
|
|
653
663
|
ignoreNotFoundError: true,
|
|
654
664
|
});
|
|
655
|
-
|
|
665
|
+
this.writeThroughMany(ranges);
|
|
656
666
|
return ranges;
|
|
657
667
|
}
|
|
658
668
|
|
|
@@ -686,7 +696,7 @@ export class Client extends query.Retriever<
|
|
|
686
696
|
private async fetchRequest(query: RetrieveRequest): Promise<Range[]> {
|
|
687
697
|
if (isKeysOnly(query)) return await this.store.retrieve(query.keys);
|
|
688
698
|
const ranges = await this.execRetrieve({ ...BASE_REQUEST, ...query });
|
|
689
|
-
|
|
699
|
+
this.writeThroughMany(ranges);
|
|
690
700
|
return ranges;
|
|
691
701
|
}
|
|
692
702
|
|
|
@@ -701,7 +711,7 @@ export class Client extends query.Retriever<
|
|
|
701
711
|
return false;
|
|
702
712
|
if (primitive.isNonZero(req.hasLabels)) {
|
|
703
713
|
const labels = label.cachedLabelsOf(
|
|
704
|
-
this.cfg.ontology.cache
|
|
714
|
+
this.cfg.ontology.cache,
|
|
705
715
|
this.cfg.labels.store,
|
|
706
716
|
ontologyID(r.key),
|
|
707
717
|
);
|
package/src/status/client.ts
CHANGED
|
@@ -99,7 +99,7 @@ export class Client extends query.Retriever<
|
|
|
99
99
|
value: (changed, prev) => {
|
|
100
100
|
const next = { ...prev, ...changed };
|
|
101
101
|
const id = ontologyID(changed.key);
|
|
102
|
-
next.labels = label.cachedLabelsOf(
|
|
102
|
+
next.labels = label.cachedLabelsOf(ontologyClient.cache, labels.store, id);
|
|
103
103
|
return next;
|
|
104
104
|
},
|
|
105
105
|
}),
|
|
@@ -278,7 +278,7 @@ export class Client extends query.Retriever<
|
|
|
278
278
|
/** Rebuilds a cached status with its cached labels attached. */
|
|
279
279
|
private compose(cached: Status): Status {
|
|
280
280
|
const labels = label.cachedLabelsOf(
|
|
281
|
-
this.cfg.ontology.cache
|
|
281
|
+
this.cfg.ontology.cache,
|
|
282
282
|
this.cfg.labels.store,
|
|
283
283
|
ontologyID(cached.key),
|
|
284
284
|
);
|
|
@@ -307,7 +307,14 @@ export class Client extends query.Retriever<
|
|
|
307
307
|
/** Fetches statuses and writes their included labels through the caches. */
|
|
308
308
|
private async fetchThrough(req: RetrieveRequest): Promise<Status[]> {
|
|
309
309
|
const statuses = await this.execRetrieve({ ...BASE_REQUEST, ...req });
|
|
310
|
-
|
|
310
|
+
// One batch per table, so each table flushes once for the whole response.
|
|
311
|
+
this.store.batch(() =>
|
|
312
|
+
this.cfg.labels.store.batch(() =>
|
|
313
|
+
this.cfg.ontology.cache.relationships.batch(() =>
|
|
314
|
+
statuses.forEach((s) => this.writeThrough(s)),
|
|
315
|
+
),
|
|
316
|
+
),
|
|
317
|
+
);
|
|
311
318
|
return statuses;
|
|
312
319
|
}
|
|
313
320
|
|
|
@@ -362,13 +369,12 @@ export class Client extends query.Retriever<
|
|
|
362
369
|
|
|
363
370
|
/** Returns the keys of cached statuses labeled by the given label. */
|
|
364
371
|
private statusesLabeledBy(labelKey: label.Key): Key[] {
|
|
365
|
-
return this.cfg.ontology.cache
|
|
366
|
-
.
|
|
372
|
+
return this.cfg.ontology.cache
|
|
373
|
+
.relationshipsTo(label.ontologyID(labelKey))
|
|
374
|
+
.filter(
|
|
367
375
|
(r) =>
|
|
368
376
|
r.type === label.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE &&
|
|
369
|
-
r.from.type === "status"
|
|
370
|
-
r.to.type === "label" &&
|
|
371
|
-
r.to.key === labelKey,
|
|
377
|
+
r.from.type === "status",
|
|
372
378
|
)
|
|
373
379
|
.map((r) => r.from.key);
|
|
374
380
|
}
|