feat!: retirer readUnion de la surface publiee, et lire un document par requete ancree
readUnion etait N requetes ancrees plus une politique de lot : une lecture qui echoue avalee en reponse vide, un document dont on ne detient pas la cle ecarte au lieu d'etre refuse, un regroupement en sacs de proprietes, et le filtrage du prefixe reserve. Rien en amont ne repond a cette composition, et son annotation citait sparql_query -- une citation exacte attachee a une affirmation fausse. Une composition ne s'aligne pas sur une fonction. Ce qui reste est ce qu'il y avait dessous : docs.sparqlQuery ancre sur un document, qui va deja chercher la cle servie par le magasin public -- donc une reference nue suffit toujours pour lire un document public, sans rien changer a useShapeQuery. Lire plusieurs documents, c'est cet appel une fois par document, et la tolerance a une lecture qui echoue revient a l'appelant, la ou l'amont la laisse : une requete ancree sur un depot que le verifier ne detient pas rejette. Cote src, l'unique lecture interne restante devient read-document.ts : un document, une requete ancree, precedee de l'ouverture du depot -- barriere que index-deposit consulte pour distinguer une absence d'un depot non synchronise. Le harnais e2e et l'exemple composent la leur, avec leur catch visible au point d'appel. Version majeure : 1.0.0-dev.8.
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
import { test, expect, describe, mock, afterAll, beforeEach } from "bun:test";
|
||||
import { configure, docs, storeRegistry, readUnion } from "../src/index";
|
||||
import { configure, docs, storeRegistry } from "../src/index";
|
||||
import {
|
||||
configureStoreRegistry,
|
||||
setCurrentUser,
|
||||
@@ -56,6 +56,25 @@ const RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
||||
/** The application's own predicate — the note's title, in the document it created. */
|
||||
const TITLE = "urn:test:title";
|
||||
|
||||
/**
|
||||
* The titles `doc` carries, read the way an APPLICATION reads one document since
|
||||
* `1.0.0-dev.8`: the published anchored `docs.sparqlQuery`, naming the document. It
|
||||
* replaces `readUnion([doc])`, which was the same anchored query with a batch around it.
|
||||
*/
|
||||
async function titlesIn(doc: Nuri): Promise<string[]> {
|
||||
const res = await docs.sparqlQuery(
|
||||
SESSION.sessionId,
|
||||
"SELECT ?s ?p ?o WHERE { ?s ?p ?o }",
|
||||
undefined,
|
||||
doc,
|
||||
"readDoc",
|
||||
);
|
||||
const rows = (res as { results?: { bindings?: Array<Record<string, { value: string }>> } })
|
||||
.results?.bindings ?? [];
|
||||
return rows.filter((r) => r["p"]?.value === TITLE).map((r) => r["o"]!.value);
|
||||
}
|
||||
|
||||
|
||||
const ALL_SCOPES: StoreType[] = ["public", "protected", "private"];
|
||||
|
||||
// --- the fake broker -------------------------------------------------------
|
||||
@@ -354,9 +373,11 @@ describe("after a reload, the creator comes back to its own document", () => {
|
||||
});
|
||||
}
|
||||
|
||||
// Shape 2 — listed, but does reading it answer? `readUnion` is the library's own
|
||||
// listing read, and it DROPS a document whose cap the reader does not hold: a failure
|
||||
// that arrives as an absence, which is the family this project has been bitten by.
|
||||
// Shape 2 — listed, but does reading it answer? The anchored `docs.sparqlQuery` is what
|
||||
// an application reads one document with, and it REFUSES a document whose cap the reader
|
||||
// does not hold. It did not always: until `1.0.0-dev.8` the published read for this was
|
||||
// `readUnion`, which DROPPED such a document — a failure arriving as an absence, which
|
||||
// is the family this project has been bitten by, and half the reason that call went.
|
||||
for (const scope of ALL_SCOPES) {
|
||||
test(`[${scope}] reading it by reference answers its content`, async () => {
|
||||
const quads: Quad[] = [];
|
||||
@@ -367,8 +388,7 @@ describe("after a reload, the creator comes back to its own document", () => {
|
||||
|
||||
// The application kept the reference (a route, a deep link) and reads it directly,
|
||||
// without listing its store first.
|
||||
const subjects = await readUnion([note]);
|
||||
expect(subjects.map((s) => s.props[TITLE]?.[0])).toEqual(["the note"]);
|
||||
expect(await titlesIn(note)).toEqual(["the note"]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user