@relate/contrib-web 0.0.0-stage → 0.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/LICENSE +201 -0
- package/README.md +242 -2
- package/conformance/example-site/blank.html +2 -0
- package/conformance/example-site/broken.html +35 -0
- package/conformance/example-site/index.html +35 -0
- package/conformance/example-site/notes.html +35 -0
- package/conformance/example-site/page-1.html +35 -0
- package/conformance/example-site/page-2.html +35 -0
- package/conformance/example-site/public/descriptor-b.json +16 -0
- package/conformance/example-site/public/descriptor-broken.json +16 -0
- package/conformance/example-site/public/descriptor-mismatch.json +16 -0
- package/conformance/example-site/public/descriptor.json +16 -0
- package/conformance/example-site/public/graph-b.json +14408 -0
- package/conformance/example-site/public/graph.json +10808 -0
- package/conformance/example-site/rel-page.ts +147 -0
- package/conformance/example-site/vite.config.ts +23 -0
- package/conformance/make-example.ts +22 -0
- package/conformance/run.ts +152 -0
- package/conformance/scenarios.ts +285 -0
- package/dist/application/options.d.ts +9 -0
- package/dist/application/options.js +64 -0
- package/dist/application/options.js.map +1 -0
- package/dist/application/ranges.d.ts +7 -0
- package/dist/application/ranges.js +14 -0
- package/dist/application/ranges.js.map +1 -0
- package/dist/application/storage.d.ts +34 -0
- package/dist/application/storage.js +60 -0
- package/dist/application/storage.js.map +1 -0
- package/dist/application/types.d.ts +49 -0
- package/dist/application/types.js +2 -0
- package/dist/application/types.js.map +1 -0
- package/dist/build/canonical.d.ts +5 -0
- package/dist/build/canonical.js +26 -0
- package/dist/build/canonical.js.map +1 -0
- package/dist/build/descriptor.d.ts +16 -0
- package/dist/build/descriptor.js +13 -0
- package/dist/build/descriptor.js.map +1 -0
- package/dist/build/index.d.ts +6 -0
- package/dist/build/index.js +6 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/inline.d.ts +16 -0
- package/dist/build/inline.js +44 -0
- package/dist/build/inline.js.map +1 -0
- package/dist/build/prepare.d.ts +11 -0
- package/dist/build/prepare.js +25 -0
- package/dist/build/prepare.js.map +1 -0
- package/dist/catalog/api.d.ts +30 -0
- package/dist/catalog/api.js +56 -0
- package/dist/catalog/api.js.map +1 -0
- package/dist/catalog/catalog.d.ts +51 -0
- package/dist/catalog/catalog.js +104 -0
- package/dist/catalog/catalog.js.map +1 -0
- package/dist/catalog/directory.d.ts +30 -0
- package/dist/catalog/directory.js +116 -0
- package/dist/catalog/directory.js.map +1 -0
- package/dist/catalog/file.d.ts +12 -0
- package/dist/catalog/file.js +84 -0
- package/dist/catalog/file.js.map +1 -0
- package/dist/catalog/index.d.ts +10 -0
- package/dist/catalog/index.js +12 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog/memory-storage.d.ts +16 -0
- package/dist/catalog/memory-storage.js +56 -0
- package/dist/catalog/memory-storage.js.map +1 -0
- package/dist/catalog/opfs-storage.d.ts +10 -0
- package/dist/catalog/opfs-storage.js +71 -0
- package/dist/catalog/opfs-storage.js.map +1 -0
- package/dist/catalog/remove.d.ts +21 -0
- package/dist/catalog/remove.js +85 -0
- package/dist/catalog/remove.js.map +1 -0
- package/dist/catalog/storage.d.ts +11 -0
- package/dist/catalog/storage.js +4 -0
- package/dist/catalog/storage.js.map +1 -0
- package/dist/catalog/types.d.ts +68 -0
- package/dist/catalog/types.js +4 -0
- package/dist/catalog/types.js.map +1 -0
- package/dist/client/application.d.ts +32 -0
- package/dist/client/application.js +99 -0
- package/dist/client/application.js.map +1 -0
- package/dist/client/client.d.ts +2 -0
- package/dist/client/client.js +445 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/diagnostic.d.ts +6 -0
- package/dist/client/diagnostic.js +35 -0
- package/dist/client/diagnostic.js.map +1 -0
- package/dist/client/events.d.ts +27 -0
- package/dist/client/events.js +31 -0
- package/dist/client/events.js.map +1 -0
- package/dist/client/failure.d.ts +13 -0
- package/dist/client/failure.js +40 -0
- package/dist/client/failure.js.map +1 -0
- package/dist/client/scope.d.ts +15 -0
- package/dist/client/scope.js +39 -0
- package/dist/client/scope.js.map +1 -0
- package/dist/client/status.d.ts +14 -0
- package/dist/client/status.js +34 -0
- package/dist/client/status.js.map +1 -0
- package/dist/client/subscriptions.d.ts +31 -0
- package/dist/client/subscriptions.js +64 -0
- package/dist/client/subscriptions.js.map +1 -0
- package/dist/client/types.d.ts +82 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/conformance/run.d.ts +61 -0
- package/dist/conformance/run.js +121 -0
- package/dist/conformance/run.js.map +1 -0
- package/dist/conformance/scenarios.d.ts +25 -0
- package/dist/conformance/scenarios.js +257 -0
- package/dist/conformance/scenarios.js.map +1 -0
- package/dist/data/descriptor.d.ts +20 -0
- package/dist/data/descriptor.js +75 -0
- package/dist/data/descriptor.js.map +1 -0
- package/dist/data/types.d.ts +41 -0
- package/dist/data/types.js +3 -0
- package/dist/data/types.js.map +1 -0
- package/dist/data/validate.d.ts +22 -0
- package/dist/data/validate.js +118 -0
- package/dist/data/validate.js.map +1 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles/index.d.ts +5 -0
- package/dist/profiles/index.js +9 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/per-page.d.ts +2 -0
- package/dist/profiles/per-page.js +11 -0
- package/dist/profiles/per-page.js.map +1 -0
- package/dist/profiles/persistent.d.ts +5 -0
- package/dist/profiles/persistent.js +14 -0
- package/dist/profiles/persistent.js.map +1 -0
- package/dist/validate.d.ts +5 -0
- package/dist/validate.js +4 -0
- package/dist/validate.js.map +1 -0
- package/dist/worker/application/classify.d.ts +30 -0
- package/dist/worker/application/classify.js +57 -0
- package/dist/worker/application/classify.js.map +1 -0
- package/dist/worker/application/init.d.ts +12 -0
- package/dist/worker/application/init.js +64 -0
- package/dist/worker/application/init.js.map +1 -0
- package/dist/worker/application/lifecycle.d.ts +29 -0
- package/dist/worker/application/lifecycle.js +86 -0
- package/dist/worker/application/lifecycle.js.map +1 -0
- package/dist/worker/application/losses.d.ts +11 -0
- package/dist/worker/application/losses.js +61 -0
- package/dist/worker/application/losses.js.map +1 -0
- package/dist/worker/application/migrate.d.ts +16 -0
- package/dist/worker/application/migrate.js +54 -0
- package/dist/worker/application/migrate.js.map +1 -0
- package/dist/worker/application/open-store.d.ts +31 -0
- package/dist/worker/application/open-store.js +60 -0
- package/dist/worker/application/open-store.js.map +1 -0
- package/dist/worker/application/seed.d.ts +14 -0
- package/dist/worker/application/seed.js +50 -0
- package/dist/worker/application/seed.js.map +1 -0
- package/dist/worker/application/transfer.d.ts +31 -0
- package/dist/worker/application/transfer.js +134 -0
- package/dist/worker/application/transfer.js.map +1 -0
- package/dist/worker/cache.d.ts +15 -0
- package/dist/worker/cache.js +45 -0
- package/dist/worker/cache.js.map +1 -0
- package/dist/worker/encode.d.ts +1 -0
- package/dist/worker/encode.js +43 -0
- package/dist/worker/encode.js.map +1 -0
- package/dist/worker/engine.d.ts +35 -0
- package/dist/worker/engine.js +99 -0
- package/dist/worker/engine.js.map +1 -0
- package/dist/worker/legacy-copy.d.ts +2 -0
- package/dist/worker/legacy-copy.js +19 -0
- package/dist/worker/legacy-copy.js.map +1 -0
- package/dist/worker/loader.d.ts +40 -0
- package/dist/worker/loader.js +96 -0
- package/dist/worker/loader.js.map +1 -0
- package/dist/worker/protocol.d.ts +121 -0
- package/dist/worker/protocol.js +2 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/store.d.ts +12 -0
- package/dist/worker/store.js +39 -0
- package/dist/worker/store.js.map +1 -0
- package/dist/worker/sweep.d.ts +8 -0
- package/dist/worker/sweep.js +21 -0
- package/dist/worker/sweep.js.map +1 -0
- package/dist/worker/worker.d.ts +1 -0
- package/dist/worker/worker.js +198 -0
- package/dist/worker/worker.js.map +1 -0
- package/package.json +81 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Descriptor, GraphDocument, IndexSpec } from "../data/types.js";
|
|
2
|
+
import type { Engine } from "./engine.js";
|
|
3
|
+
/** The document was rejected before any statement ran. */
|
|
4
|
+
export declare class LoadError extends Error {
|
|
5
|
+
readonly reason: "invalid-document" | "mismatch";
|
|
6
|
+
readonly path: string;
|
|
7
|
+
constructor(reason: "invalid-document" | "mismatch", path: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** The engine reported an error in a result envelope. */
|
|
10
|
+
export declare class EngineError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare const NODE_STATEMENT = "UNWIND $rows AS row CREATE (n:$(row.labels)) SET n = row.props RETURN row.k AS k, elementId(n) AS e";
|
|
14
|
+
export declare const LINK_STATEMENT: string;
|
|
15
|
+
export interface LoadOptions {
|
|
16
|
+
/** When present, the data must agree with it and its indexes are the ones created. */
|
|
17
|
+
descriptor?: Descriptor | null;
|
|
18
|
+
/** The indexes to create when there is no descriptor. */
|
|
19
|
+
indexes?: IndexSpec[];
|
|
20
|
+
/** Added as a `scope` property to every node the load creates. */
|
|
21
|
+
scope?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface LoadResult {
|
|
24
|
+
nodes: number;
|
|
25
|
+
links: number;
|
|
26
|
+
}
|
|
27
|
+
/** Run one statement and return the parsed envelope; an error in the envelope throws. */
|
|
28
|
+
export declare function run(engine: Engine, statement: string, params?: unknown): {
|
|
29
|
+
rows: Array<Record<string, unknown>>;
|
|
30
|
+
};
|
|
31
|
+
/** Create exactly these indexes (an index that already exists is left alone). */
|
|
32
|
+
export declare function createIndexes(engine: Engine, specs: IndexSpec[]): void;
|
|
33
|
+
/** Validate a document and, when there is a descriptor, check that the two agree. Throws LoadError. */
|
|
34
|
+
export declare function prepare(input: unknown, opts?: LoadOptions): GraphDocument;
|
|
35
|
+
/** Load a document that has already been through `prepare`. Indexes are created before the nodes. */
|
|
36
|
+
export declare function loadGraph(engine: Engine, document: GraphDocument, opts?: LoadOptions): LoadResult;
|
|
37
|
+
/** Validate, check agreement, create the indexes and load. Nothing runs if the document is rejected. */
|
|
38
|
+
export declare function loadDocument(engine: Engine, input: unknown, opts?: LoadOptions): LoadResult;
|
|
39
|
+
/** Remove the nodes of one scope (and their relationships). */
|
|
40
|
+
export declare function dropScope(engine: Engine, scope: string): void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Loads a validated graph data document into an engine through two fixed statements (specs research R2).
|
|
2
|
+
// Link endpoints are resolved through the element ids the engine returns for the nodes, so no label or index
|
|
3
|
+
// takes part, and the statements do not depend on which labels or types a document uses.
|
|
4
|
+
import { BATCH_SIZE } from "../config.js";
|
|
5
|
+
import { checkAgreement } from "../data/descriptor.js";
|
|
6
|
+
import { validate } from "../data/validate.js";
|
|
7
|
+
import { encodeParams } from "./encode.js";
|
|
8
|
+
/** The document was rejected before any statement ran. */
|
|
9
|
+
export class LoadError extends Error {
|
|
10
|
+
reason;
|
|
11
|
+
path;
|
|
12
|
+
constructor(reason, path, message) {
|
|
13
|
+
super(path === "" ? message : `${path}: ${message}`);
|
|
14
|
+
this.name = "LoadError";
|
|
15
|
+
this.reason = reason;
|
|
16
|
+
this.path = path;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** The engine reported an error in a result envelope. */
|
|
20
|
+
export class EngineError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "EngineError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const NODE_STATEMENT = "UNWIND $rows AS row CREATE (n:$(row.labels)) SET n = row.props RETURN row.k AS k, elementId(n) AS e";
|
|
27
|
+
export const LINK_STATEMENT = "UNWIND $rows AS row MATCH (a) WHERE elementId(a) = row.s MATCH (b) WHERE elementId(b) = row.t " +
|
|
28
|
+
"CREATE (a)-[r:$(row.type)]->(b) SET r = row.props";
|
|
29
|
+
/** Run one statement and return the parsed envelope; an error in the envelope throws. */
|
|
30
|
+
export function run(engine, statement, params = null) {
|
|
31
|
+
const envelope = JSON.parse(engine.execute(statement, params === null ? null : encodeParams(params)));
|
|
32
|
+
if (envelope.error)
|
|
33
|
+
throw new EngineError(envelope.error);
|
|
34
|
+
return envelope;
|
|
35
|
+
}
|
|
36
|
+
const quote = (name) => `\`${name.replace(/`/g, "``")}\``;
|
|
37
|
+
/** Create exactly these indexes (an index that already exists is left alone). */
|
|
38
|
+
export function createIndexes(engine, specs) {
|
|
39
|
+
for (const { label, property } of specs) {
|
|
40
|
+
run(engine, `CREATE INDEX IF NOT EXISTS FOR (n:${quote(label)}) ON (n.${quote(property)})`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Validate a document and, when there is a descriptor, check that the two agree. Throws LoadError. */
|
|
44
|
+
export function prepare(input, opts = {}) {
|
|
45
|
+
const checked = validate(input, { scoped: Boolean(opts.scope) });
|
|
46
|
+
if (!checked.ok)
|
|
47
|
+
throw new LoadError("invalid-document", checked.path, checked.message);
|
|
48
|
+
if (opts.descriptor) {
|
|
49
|
+
const agreement = checkAgreement(opts.descriptor, checked.document);
|
|
50
|
+
if (!agreement.ok)
|
|
51
|
+
throw new LoadError("mismatch", agreement.path, agreement.message);
|
|
52
|
+
}
|
|
53
|
+
return checked.document;
|
|
54
|
+
}
|
|
55
|
+
/** Load a document that has already been through `prepare`. Indexes are created before the nodes. */
|
|
56
|
+
export function loadGraph(engine, document, opts = {}) {
|
|
57
|
+
createIndexes(engine, opts.descriptor?.indexes ?? opts.indexes ?? []);
|
|
58
|
+
const elementIds = new Map();
|
|
59
|
+
for (let i = 0; i < document.nodes.length; i += BATCH_SIZE) {
|
|
60
|
+
const batch = document.nodes.slice(i, i + BATCH_SIZE);
|
|
61
|
+
const rows = batch.map((node, j) => ({
|
|
62
|
+
k: j,
|
|
63
|
+
labels: node.labels ?? [],
|
|
64
|
+
props: { id: node.id, ...node.properties, ...(opts.scope ? { scope: opts.scope } : {}) },
|
|
65
|
+
}));
|
|
66
|
+
const result = run(engine, NODE_STATEMENT, { rows }).rows;
|
|
67
|
+
if (result.length !== batch.length)
|
|
68
|
+
throw new EngineError(`a node batch created ${result.length} of ${batch.length} nodes`);
|
|
69
|
+
for (const row of result) {
|
|
70
|
+
const node = batch[row.k];
|
|
71
|
+
if (!node)
|
|
72
|
+
throw new EngineError("the engine returned a row for an unknown node");
|
|
73
|
+
elementIds.set(node.id, row.e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (let i = 0; i < document.links.length; i += BATCH_SIZE) {
|
|
77
|
+
const batch = document.links.slice(i, i + BATCH_SIZE);
|
|
78
|
+
const rows = batch.map((link) => ({
|
|
79
|
+
s: elementIds.get(link.source),
|
|
80
|
+
t: elementIds.get(link.target),
|
|
81
|
+
type: link.type,
|
|
82
|
+
props: link.properties ?? {},
|
|
83
|
+
}));
|
|
84
|
+
run(engine, LINK_STATEMENT, { rows });
|
|
85
|
+
}
|
|
86
|
+
return { nodes: document.nodes.length, links: document.links.length };
|
|
87
|
+
}
|
|
88
|
+
/** Validate, check agreement, create the indexes and load. Nothing runs if the document is rejected. */
|
|
89
|
+
export function loadDocument(engine, input, opts = {}) {
|
|
90
|
+
return loadGraph(engine, prepare(input, opts), opts);
|
|
91
|
+
}
|
|
92
|
+
/** Remove the nodes of one scope (and their relationships). */
|
|
93
|
+
export function dropScope(engine, scope) {
|
|
94
|
+
run(engine, "MATCH (n) WHERE n.scope = $scope DETACH DELETE n", { scope });
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/worker/loader.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,6GAA6G;AAC7G,yFAAyF;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uB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pec } from "../data/types.js";
|
|
3
|
+
/** The application half of an init message (ADR-009); everything in it is plain data. */
|
|
4
|
+
export interface ApplicationInit {
|
|
5
|
+
name: string;
|
|
6
|
+
version: number;
|
|
7
|
+
/** `reset` is `resetApplication()`: open the store, reset it and seed it. */
|
|
8
|
+
intent: "open" | "reset";
|
|
9
|
+
/**
|
|
10
|
+
* The seed. `document`: inline data. `descriptor` with `dataUrl`: an inline descriptor whose data the worker fetches when
|
|
11
|
+
* needed. `url`: an absolute URL of a document or a descriptor, fetched by the worker only when the store needs a seed.
|
|
12
|
+
*/
|
|
13
|
+
seed: {
|
|
14
|
+
document: GraphDocument | null;
|
|
15
|
+
dataUrl: string | null;
|
|
16
|
+
descriptor: Descriptor | null;
|
|
17
|
+
url: string | null;
|
|
18
|
+
};
|
|
19
|
+
indexes: IndexSpec[];
|
|
20
|
+
migrations: Record<string, MigrationStep[]>;
|
|
21
|
+
onUnavailable: "memory" | "fail";
|
|
22
|
+
onError: "fail" | "memory";
|
|
23
|
+
whenLocked: "wait" | "memory";
|
|
24
|
+
}
|
|
25
|
+
export interface InitMessage {
|
|
26
|
+
type: "init";
|
|
27
|
+
engineUrl: string;
|
|
28
|
+
descriptor: Descriptor | null;
|
|
29
|
+
/** Absolute URL of the data document when the graph has a descriptor or was given as a URL. */
|
|
30
|
+
dataUrl: string | null;
|
|
31
|
+
/** An inline data document, when the graph was given as data. */
|
|
32
|
+
document: GraphDocument | null;
|
|
33
|
+
/** Used only when there is no descriptor. */
|
|
34
|
+
indexes: IndexSpec[];
|
|
35
|
+
useStore: boolean;
|
|
36
|
+
/** Present in application mode, where the descriptor, dataUrl, document and useStore fields are unused. */
|
|
37
|
+
application?: ApplicationInit;
|
|
38
|
+
attempt: number;
|
|
39
|
+
}
|
|
40
|
+
export interface QueryMessage {
|
|
41
|
+
type: "query";
|
|
42
|
+
id: number;
|
|
43
|
+
statement: string;
|
|
44
|
+
paramsJson: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface ScopedAddMessage {
|
|
47
|
+
type: "scoped-add";
|
|
48
|
+
id: number;
|
|
49
|
+
scope: string;
|
|
50
|
+
document: GraphDocument;
|
|
51
|
+
}
|
|
52
|
+
export interface ScopedDropMessage {
|
|
53
|
+
type: "scoped-drop";
|
|
54
|
+
id: number;
|
|
55
|
+
scope: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ExportApplicationMessage {
|
|
58
|
+
type: "export-application";
|
|
59
|
+
id: number;
|
|
60
|
+
allowLoss: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ImportApplicationMessage {
|
|
63
|
+
type: "import-application";
|
|
64
|
+
id: number;
|
|
65
|
+
envelope: ExportEnvelope;
|
|
66
|
+
}
|
|
67
|
+
export type ClientMessage = InitMessage | QueryMessage | ScopedAddMessage | ScopedDropMessage | ExportApplicationMessage | ImportApplicationMessage;
|
|
68
|
+
export interface Timings {
|
|
69
|
+
init?: number;
|
|
70
|
+
open?: number;
|
|
71
|
+
load?: number;
|
|
72
|
+
restore?: number;
|
|
73
|
+
total: number;
|
|
74
|
+
}
|
|
75
|
+
export interface ReadyMessage {
|
|
76
|
+
type: "ready";
|
|
77
|
+
restored: boolean;
|
|
78
|
+
timings: Timings;
|
|
79
|
+
}
|
|
80
|
+
export type InitFailReason = "trap" | "unsupported" | "worker-error" | "invalid-document" | "invalid-descriptor" | "mismatch" | "store" | "store-unmarked" | "store-newer" | "import-interrupted" | "store-lost" | "store-unreadable" | "unavailable" | "migration-failed";
|
|
81
|
+
export interface InitFailedMessage {
|
|
82
|
+
type: "init-failed";
|
|
83
|
+
reason: InitFailReason;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
export interface StoreRetryMessage {
|
|
87
|
+
type: "store-retry";
|
|
88
|
+
attempt: number;
|
|
89
|
+
waitMs: number;
|
|
90
|
+
}
|
|
91
|
+
/** The worker's storage state changed (application mode). `persisted` is added by the page. */
|
|
92
|
+
export interface StorageMessage {
|
|
93
|
+
type: "storage";
|
|
94
|
+
kind: "durable" | "memory" | "waiting";
|
|
95
|
+
reason?: "unavailable" | "locked" | "error";
|
|
96
|
+
}
|
|
97
|
+
/** Answers an export-application: the envelope is null when losses exist and they were not allowed. */
|
|
98
|
+
export interface ApplicationExportedMessage {
|
|
99
|
+
type: "application-exported";
|
|
100
|
+
id: number;
|
|
101
|
+
envelope: ExportEnvelope | null;
|
|
102
|
+
losses: LossReport;
|
|
103
|
+
}
|
|
104
|
+
export interface ResultMessage {
|
|
105
|
+
type: "result";
|
|
106
|
+
id: number;
|
|
107
|
+
/** The engine's envelope as text; the client parses it and changes nothing. */
|
|
108
|
+
envelopeText: string;
|
|
109
|
+
}
|
|
110
|
+
/** Acknowledges a scoped-add or scoped-drop. */
|
|
111
|
+
export interface DoneMessage {
|
|
112
|
+
type: "done";
|
|
113
|
+
id: number;
|
|
114
|
+
}
|
|
115
|
+
export interface ErrorMessage {
|
|
116
|
+
type: "error";
|
|
117
|
+
id: number;
|
|
118
|
+
reason: "trap" | "invalid-document" | "rejected" | "migration-failed";
|
|
119
|
+
message: string;
|
|
120
|
+
}
|
|
121
|
+
export type WorkerMessage = ReadyMessage | InitFailedMessage | StoreRetryMessage | StorageMessage | ApplicationExportedMessage | ResultMessage | DoneMessage | ErrorMessage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/worker/protocol.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Engine } from "./engine.js";
|
|
2
|
+
/** Waits between attempts: from the first wait, doubling up to the longest, until the budget is spent. */
|
|
3
|
+
export declare function retryWaits(config?: {
|
|
4
|
+
initialMs: number;
|
|
5
|
+
maxMs: number;
|
|
6
|
+
totalMs: number;
|
|
7
|
+
}): Generator<number>;
|
|
8
|
+
/**
|
|
9
|
+
* Open the store `rel-<id>`. A locked store is retried on the schedule above; `onRetry` hears each wait. Returns
|
|
10
|
+
* null when the store stays locked or cannot be opened at all, and the caller continues in memory.
|
|
11
|
+
*/
|
|
12
|
+
export declare function openStore(id: string, onRetry: (attempt: number, waitMs: number) => void, sleep?: (ms: number) => Promise<void>): Promise<Engine | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Opening the durable store with a bounded retry when another holder has it locked (ADR-001 2.2).
|
|
2
|
+
import { STORE_RETRY } from "../config.js";
|
|
3
|
+
import { Engine, StorageLockedError } from "./engine.js";
|
|
4
|
+
/** Waits between attempts: from the first wait, doubling up to the longest, until the budget is spent. */
|
|
5
|
+
export function* retryWaits(config = STORE_RETRY) {
|
|
6
|
+
let wait = config.initialMs;
|
|
7
|
+
let remaining = config.totalMs;
|
|
8
|
+
while (remaining > 0) {
|
|
9
|
+
const next = Math.min(wait, remaining);
|
|
10
|
+
yield next;
|
|
11
|
+
remaining -= next;
|
|
12
|
+
wait = Math.min(wait * 2, config.maxMs);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
|
+
/**
|
|
17
|
+
* Open the store `rel-<id>`. A locked store is retried on the schedule above; `onRetry` hears each wait. Returns
|
|
18
|
+
* null when the store stays locked or cannot be opened at all, and the caller continues in memory.
|
|
19
|
+
*/
|
|
20
|
+
export async function openStore(id, onRetry, sleep = defaultSleep) {
|
|
21
|
+
const waits = retryWaits();
|
|
22
|
+
let attempt = 0;
|
|
23
|
+
for (;;) {
|
|
24
|
+
try {
|
|
25
|
+
return await Engine.store(id);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
if (!(e instanceof StorageLockedError))
|
|
29
|
+
return null;
|
|
30
|
+
const next = waits.next();
|
|
31
|
+
if (next.done)
|
|
32
|
+
return null;
|
|
33
|
+
attempt++;
|
|
34
|
+
onRetry(attempt, next.value);
|
|
35
|
+
await sleep(next.value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=store.js.map
|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AC;YACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YAC3B,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC7B,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Engine } from "./engine.js";
|
|
2
|
+
/** Remove every node that carries a `scope` property: page data a departed page did not get to drop (FR-027). */
|
|
3
|
+
export declare function sweepScoped(engine: Engine): void;
|
|
4
|
+
export declare function nodeCount(engine: Engine): number;
|
|
5
|
+
/** The indexes someone created: the engine's built-in token lookup indexes (type LOOKUP, present in every store since 1.2) are not counted. */
|
|
6
|
+
export declare function userIndexCount(engine: Engine): number;
|
|
7
|
+
/** A store holding no node and no index (a new store, or one just reset). */
|
|
8
|
+
export declare function isEmpty(engine: Engine): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Start-up checks on an opened store.
|
|
2
|
+
import { run } from "./loader.js";
|
|
3
|
+
/** Remove every node that carries a `scope` property: page data a departed page did not get to drop (FR-027). */
|
|
4
|
+
export function sweepScoped(engine) {
|
|
5
|
+
const found = run(engine, "MATCH (n) WHERE n.scope IS NOT NULL RETURN count(n) AS c").rows[0]?.c;
|
|
6
|
+
if (typeof found === "number" && found > 0)
|
|
7
|
+
run(engine, "MATCH (n) WHERE n.scope IS NOT NULL DETACH DELETE n");
|
|
8
|
+
}
|
|
9
|
+
export function nodeCount(engine) {
|
|
10
|
+
const c = run(engine, "MATCH (n) RETURN count(n) AS c").rows[0]?.c;
|
|
11
|
+
return typeof c === "number" ? c : 0;
|
|
12
|
+
}
|
|
13
|
+
/** The indexes someone created: the engine's built-in token lookup indexes (type LOOKUP, present in every store since 1.2) are not counted. */
|
|
14
|
+
export function userIndexCount(engine) {
|
|
15
|
+
return run(engine, "SHOW INDEXES").rows.filter((r) => r.type !== "LOOKUP").length;
|
|
16
|
+
}
|
|
17
|
+
/** A store holding no node and no index (a new store, or one just reset). */
|
|
18
|
+
export function isEmpty(engine) {
|
|
19
|
+
return nodeCount(engine) === 0 && userIndexCount(engine) === 0;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sweep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep.js","sourceRoot":"","sources":["../../src/worker/sweep.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,iHAAiH;AACjH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,0DAA0D,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjG,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC;QAAE,GAAG,CAAC,MAAM,EAAE,qDAAqD,CAAC,CAAC;AACjH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACnE,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,+IAA+I;AAC/I,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;AACpF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// The worker entry: owns one engine instance and answers the client's messages (contracts/worker-protocol.md).
|
|
2
|
+
import { validateDescriptor } from "../data/descriptor.js";
|
|
3
|
+
import { Engine, TrapError } from "./engine.js";
|
|
4
|
+
import { dropScope, EngineError, LoadError, loadDocument, loadGraph, prepare } from "./loader.js";
|
|
5
|
+
import { openStore } from "./store.js";
|
|
6
|
+
import { beginRebuild, canRestore, finishRebuild } from "./cache.js";
|
|
7
|
+
import { removeLegacyCopy } from "./legacy-copy.js";
|
|
8
|
+
import { openCatalog } from "../catalog/index.js";
|
|
9
|
+
import { initApplication } from "./application/init.js";
|
|
10
|
+
import { MigrationError } from "./application/migrate.js";
|
|
11
|
+
import { SeedError, seedDescriptor } from "./application/seed.js";
|
|
12
|
+
import { ImportRejected, exportApplication, importApplication } from "./application/transfer.js";
|
|
13
|
+
const scope = self;
|
|
14
|
+
let engine = null;
|
|
15
|
+
/** The application this worker serves, when it was started in application mode. */
|
|
16
|
+
let application = undefined;
|
|
17
|
+
let session = null;
|
|
18
|
+
const send = (message) => scope.postMessage(message);
|
|
19
|
+
const since = (t0) => Math.round((performance.now() - t0) * 10) / 10;
|
|
20
|
+
const messageOf = (e) => (e instanceof Error ? e.message : String(e));
|
|
21
|
+
function failure(e) {
|
|
22
|
+
if (e instanceof LoadError)
|
|
23
|
+
return { type: "init-failed", reason: e.reason, message: e.message };
|
|
24
|
+
if (e instanceof TrapError)
|
|
25
|
+
return { type: "init-failed", reason: "trap", message: e.message };
|
|
26
|
+
if (typeof WebAssembly === "undefined")
|
|
27
|
+
return { type: "init-failed", reason: "unsupported", message: "WebAssembly is not available" };
|
|
28
|
+
if (e instanceof EngineError)
|
|
29
|
+
return { type: "init-failed", reason: "worker-error", message: e.message };
|
|
30
|
+
return { type: "init-failed", reason: "worker-error", message: messageOf(e) };
|
|
31
|
+
}
|
|
32
|
+
/** The start-up of contracts/worker-protocol.md: restore from a store when its catalog entry matches, else load. */
|
|
33
|
+
async function init(msg) {
|
|
34
|
+
if (msg.application) {
|
|
35
|
+
application = msg.application;
|
|
36
|
+
try {
|
|
37
|
+
session = await initApplication(msg, send);
|
|
38
|
+
engine = session?.engine ?? null;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
send(failure(e));
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const t0 = performance.now();
|
|
46
|
+
const timings = { total: 0 };
|
|
47
|
+
try {
|
|
48
|
+
const descriptor = msg.descriptor;
|
|
49
|
+
if (descriptor) {
|
|
50
|
+
const checked = validateDescriptor(descriptor);
|
|
51
|
+
if (!checked.ok) {
|
|
52
|
+
send({ type: "init-failed", reason: "invalid-descriptor", message: `${checked.path}: ${checked.message}` });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let t = performance.now();
|
|
57
|
+
await Engine.load(msg.engineUrl);
|
|
58
|
+
timings.init = since(t);
|
|
59
|
+
// With a store: open it (retrying a locked one), and restore if its catalog entry has this revision.
|
|
60
|
+
let rebuild = null;
|
|
61
|
+
if (msg.useStore && descriptor) {
|
|
62
|
+
t = performance.now();
|
|
63
|
+
const opened = await openStore(descriptor.id, (attempt, waitMs) => send({ type: "store-retry", attempt, waitMs }));
|
|
64
|
+
timings.open = since(t);
|
|
65
|
+
if (opened) {
|
|
66
|
+
engine = opened;
|
|
67
|
+
const catalog = openCatalog(true);
|
|
68
|
+
await removeLegacyCopy(descriptor.id);
|
|
69
|
+
t = performance.now();
|
|
70
|
+
if (await canRestore(opened, catalog, descriptor)) {
|
|
71
|
+
timings.restore = since(t);
|
|
72
|
+
timings.total = since(t0);
|
|
73
|
+
send({ type: "ready", restored: true, timings });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (await beginRebuild(opened, catalog, descriptor)) {
|
|
77
|
+
rebuild = { catalog };
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// The catalog cannot record the rebuild, so the durable store is not touched: load in memory instead.
|
|
81
|
+
opened.release();
|
|
82
|
+
engine = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
engine ??= Engine.memory();
|
|
87
|
+
t = performance.now();
|
|
88
|
+
let input = msg.document;
|
|
89
|
+
if (input === null) {
|
|
90
|
+
if (!msg.dataUrl)
|
|
91
|
+
throw new Error("no data location was given");
|
|
92
|
+
const response = await fetch(msg.dataUrl);
|
|
93
|
+
if (!response.ok)
|
|
94
|
+
throw new Error(`the data could not be fetched: ${response.status} ${response.statusText}`);
|
|
95
|
+
input = await response.json();
|
|
96
|
+
}
|
|
97
|
+
loadDocument(engine, input, { descriptor, indexes: msg.indexes });
|
|
98
|
+
if (rebuild && descriptor)
|
|
99
|
+
await finishRebuild(rebuild.catalog, descriptor);
|
|
100
|
+
timings.load = since(t);
|
|
101
|
+
timings.total = since(t0);
|
|
102
|
+
send({ type: "ready", restored: false, timings });
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
send(failure(e));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function query(msg) {
|
|
109
|
+
try {
|
|
110
|
+
if (!engine)
|
|
111
|
+
throw new TrapError("no instance");
|
|
112
|
+
send({ type: "result", id: msg.id, envelopeText: engine.execute(msg.statement, msg.paramsJson) });
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
send({ type: "error", id: msg.id, reason: "trap", message: messageOf(e) });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function scopedAdd(msg) {
|
|
119
|
+
try {
|
|
120
|
+
if (!engine)
|
|
121
|
+
throw new TrapError("no instance");
|
|
122
|
+
loadGraph(engine, prepare(msg.document, { scope: msg.scope }), { scope: msg.scope });
|
|
123
|
+
send({ type: "done", id: msg.id });
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
if (e instanceof LoadError)
|
|
127
|
+
send({ type: "error", id: msg.id, reason: "invalid-document", message: e.message });
|
|
128
|
+
else
|
|
129
|
+
send({ type: "error", id: msg.id, reason: "trap", message: messageOf(e) });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function scopedDrop(msg) {
|
|
133
|
+
try {
|
|
134
|
+
if (!engine)
|
|
135
|
+
throw new TrapError("no instance");
|
|
136
|
+
dropScope(engine, msg.scope);
|
|
137
|
+
send({ type: "done", id: msg.id });
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
send({ type: "error", id: msg.id, reason: "trap", message: messageOf(e) });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function transferError(id, e) {
|
|
144
|
+
if (e instanceof MigrationError)
|
|
145
|
+
send({ type: "error", id, reason: "migration-failed", message: e.message });
|
|
146
|
+
else if (e instanceof ImportRejected || e instanceof LoadError || e instanceof SeedError)
|
|
147
|
+
send({ type: "error", id, reason: "rejected", message: e.message });
|
|
148
|
+
else
|
|
149
|
+
send({ type: "error", id, reason: "trap", message: messageOf(e) });
|
|
150
|
+
}
|
|
151
|
+
function exportApp(msg) {
|
|
152
|
+
try {
|
|
153
|
+
if (!engine || !application)
|
|
154
|
+
throw new TrapError("no application instance");
|
|
155
|
+
const { envelope, losses } = exportApplication(engine, application, msg.allowLoss);
|
|
156
|
+
send({ type: "application-exported", id: msg.id, envelope, losses });
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
transferError(msg.id, e);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function importApp(msg) {
|
|
163
|
+
try {
|
|
164
|
+
if (!engine || !application)
|
|
165
|
+
throw new TrapError("no application instance");
|
|
166
|
+
// the indexes of a seed given as a URL are in its descriptor, which a restored store never fetched
|
|
167
|
+
const indexes = (await seedDescriptor(application.seed))?.indexes ?? application.indexes;
|
|
168
|
+
if (!session)
|
|
169
|
+
throw new TrapError("no application session");
|
|
170
|
+
await importApplication(engine, { catalog: session.catalog, store: session.store, name: application.name, version: application.version, indexes, migrations: application.migrations }, msg.envelope);
|
|
171
|
+
send({ type: "done", id: msg.id });
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
transferError(msg.id, e);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Messages that use the store run one at a time, in arrival order. An import awaits the catalog between engine steps, and
|
|
178
|
+
// without this a query, an export or another import could run inside it and see (or change) a half-imported store.
|
|
179
|
+
let chain = Promise.resolve();
|
|
180
|
+
const serially = (job) => {
|
|
181
|
+
chain = chain.then(job).catch(() => undefined);
|
|
182
|
+
};
|
|
183
|
+
scope.onmessage = (e) => {
|
|
184
|
+
const msg = e.data;
|
|
185
|
+
if (msg.type === "init")
|
|
186
|
+
void init(msg);
|
|
187
|
+
else if (msg.type === "query")
|
|
188
|
+
serially(() => query(msg));
|
|
189
|
+
else if (msg.type === "scoped-add")
|
|
190
|
+
serially(() => scopedAdd(msg));
|
|
191
|
+
else if (msg.type === "scoped-drop")
|
|
192
|
+
serially(() => scopedDrop(msg));
|
|
193
|
+
else if (msg.type === "export-application")
|
|
194
|
+
serially(() => exportApp(msg));
|
|
195
|
+
else if (msg.type === "import-application")
|
|
196
|
+
serially(() => importApp(msg));
|
|
197
|
+
};
|
|
198
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/worker/worker.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EA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