@powerhousedao/reactor 5.0.1-staging.1 → 5.0.1-staging.10
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/src/cache/kysely-write-cache.d.ts +4 -3
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
- package/dist/src/cache/kysely-write-cache.js +12 -12
- package/dist/src/cache/kysely-write-cache.js.map +1 -1
- package/dist/src/client/reactor-client.d.ts +2 -2
- package/dist/src/client/reactor-client.d.ts.map +1 -1
- package/dist/src/client/reactor-client.js +8 -8
- package/dist/src/client/reactor-client.js.map +1 -1
- package/dist/src/client/types.d.ts +4 -4
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.d.ts +32 -0
- package/dist/src/core/reactor-builder.d.ts.map +1 -0
- package/dist/src/core/reactor-builder.js +120 -0
- package/dist/src/core/reactor-builder.js.map +1 -0
- package/dist/src/core/reactor.d.ts +25 -10
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/reactor.js +627 -284
- package/dist/src/core/reactor.js.map +1 -1
- package/dist/src/core/types.d.ts +64 -7
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils.d.ts +46 -2
- package/dist/src/core/utils.d.ts.map +1 -1
- package/dist/src/core/utils.js +119 -0
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +1 -0
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.js +41 -17
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -1
- package/dist/src/executor/simple-job-executor.d.ts +14 -2
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.js +383 -249
- package/dist/src/executor/simple-job-executor.js.map +1 -1
- package/dist/src/executor/types.d.ts +2 -0
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/executor/util.d.ts +18 -0
- package/dist/src/executor/util.d.ts.map +1 -1
- package/dist/src/executor/util.js +42 -1
- package/dist/src/executor/util.js.map +1 -1
- package/dist/src/index.d.ts +9 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts +3 -2
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +1 -1
- package/dist/src/job-tracker/in-memory-job-tracker.js +7 -1
- package/dist/src/job-tracker/in-memory-job-tracker.js.map +1 -1
- package/dist/src/job-tracker/interfaces.d.ts +5 -4
- package/dist/src/job-tracker/interfaces.d.ts.map +1 -1
- package/dist/src/queue/interfaces.d.ts +5 -4
- package/dist/src/queue/interfaces.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.d.ts +3 -2
- package/dist/src/queue/job-execution-handle.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.js +2 -2
- package/dist/src/queue/job-execution-handle.js.map +1 -1
- package/dist/src/queue/queue.d.ts +4 -2
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/queue.js +16 -4
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/queue/types.d.ts +12 -6
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts +10 -6
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/document-view.js +116 -113
- package/dist/src/read-models/document-view.js.map +1 -1
- package/dist/src/read-models/types.d.ts +3 -3
- package/dist/src/read-models/types.d.ts.map +1 -1
- package/dist/src/shared/consistency-tracker.d.ts +48 -0
- package/dist/src/shared/consistency-tracker.d.ts.map +1 -0
- package/dist/src/shared/consistency-tracker.js +123 -0
- package/dist/src/shared/consistency-tracker.js.map +1 -0
- package/dist/src/shared/types.d.ts +35 -1
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/storage/interfaces.d.ts +148 -2
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/interfaces.js.map +1 -1
- package/dist/src/storage/kysely/document-indexer.d.ts +28 -0
- package/dist/src/storage/kysely/document-indexer.d.ts.map +1 -0
- package/dist/src/storage/kysely/document-indexer.js +350 -0
- package/dist/src/storage/kysely/document-indexer.js.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts.map +1 -1
- package/dist/src/storage/kysely/keyframe-store.js +6 -13
- package/dist/src/storage/kysely/keyframe-store.js.map +1 -1
- package/dist/src/storage/kysely/store.js +1 -1
- package/dist/src/storage/kysely/store.js.map +1 -1
- package/dist/src/storage/kysely/types.d.ts +35 -2
- package/dist/src/storage/kysely/types.d.ts.map +1 -1
- package/dist/src/storage/migrations/001_create_operation_table.d.ts +3 -0
- package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/001_create_operation_table.js +40 -0
- package/dist/src/storage/migrations/001_create_operation_table.js.map +1 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.d.ts +3 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.js +27 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.js.map +1 -0
- package/dist/src/storage/migrations/003_create_document_table.d.ts +3 -0
- package/dist/src/storage/migrations/003_create_document_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/003_create_document_table.js +10 -0
- package/dist/src/storage/migrations/003_create_document_table.js.map +1 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts +3 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.js +35 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.js.map +1 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts +3 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.js +10 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.js.map +1 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts +3 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js +49 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js.map +1 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts +3 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js +24 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js.map +1 -0
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts +3 -0
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/008_create_view_state_table.js +9 -0
- package/dist/src/storage/migrations/008_create_view_state_table.js.map +1 -0
- package/dist/src/storage/migrations/index.d.ts +3 -0
- package/dist/src/storage/migrations/index.d.ts.map +1 -0
- package/dist/src/storage/migrations/index.js +3 -0
- package/dist/src/storage/migrations/index.js.map +1 -0
- package/dist/src/storage/migrations/migrator.d.ts +5 -0
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -0
- package/dist/src/storage/migrations/migrator.js +51 -0
- package/dist/src/storage/migrations/migrator.js.map +1 -0
- package/dist/src/storage/migrations/run-migrations.d.ts +2 -0
- package/dist/src/storage/migrations/run-migrations.d.ts.map +1 -0
- package/dist/src/storage/migrations/run-migrations.js +58 -0
- package/dist/src/storage/migrations/run-migrations.js.map +1 -0
- package/dist/src/storage/migrations/types.d.ts +9 -0
- package/dist/src/storage/migrations/types.d.ts.map +1 -0
- package/dist/src/storage/migrations/types.js +2 -0
- package/dist/src/storage/migrations/types.js.map +1 -0
- package/dist/src/storage/txn.d.ts.map +1 -1
- package/dist/src/storage/txn.js +2 -0
- package/dist/src/storage/txn.js.map +1 -1
- package/package.json +8 -5
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a consistency key from documentId, scope, and branch.
|
|
3
|
+
*/
|
|
4
|
+
export function makeConsistencyKey(documentId, scope, branch) {
|
|
5
|
+
return `${documentId}:${scope}:${branch}`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tracks operation indexes for documents and provides read-after-write consistency guarantees.
|
|
9
|
+
* Maintains an in-memory map of the latest operation index for each (documentId, scope, branch) tuple.
|
|
10
|
+
*/
|
|
11
|
+
export class ConsistencyTracker {
|
|
12
|
+
state = new Map();
|
|
13
|
+
waiters = [];
|
|
14
|
+
update(coordinates) {
|
|
15
|
+
const deduplicated = this.deduplicateCoordinates(coordinates);
|
|
16
|
+
for (let i = 0; i < deduplicated.length; i++) {
|
|
17
|
+
const coord = deduplicated[i];
|
|
18
|
+
const key = makeConsistencyKey(coord.documentId, coord.scope, coord.branch);
|
|
19
|
+
const current = this.state.get(key);
|
|
20
|
+
if (current === undefined || coord.operationIndex > current) {
|
|
21
|
+
this.state.set(key, coord.operationIndex);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
this.checkWaiters();
|
|
25
|
+
}
|
|
26
|
+
getLatest(key) {
|
|
27
|
+
return this.state.get(key);
|
|
28
|
+
}
|
|
29
|
+
waitFor(coordinates, timeoutMs, signal) {
|
|
30
|
+
if (signal?.aborted) {
|
|
31
|
+
return Promise.reject(new Error("Operation aborted"));
|
|
32
|
+
}
|
|
33
|
+
if (this.areCoordinatesSatisfied(coordinates)) {
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
}
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const waiter = {
|
|
38
|
+
coordinates,
|
|
39
|
+
resolve,
|
|
40
|
+
reject,
|
|
41
|
+
signal,
|
|
42
|
+
};
|
|
43
|
+
if (timeoutMs !== undefined) {
|
|
44
|
+
waiter.timeoutId = setTimeout(() => {
|
|
45
|
+
this.removeWaiter(waiter);
|
|
46
|
+
reject(new Error(`Consistency wait timed out after ${timeoutMs}ms`));
|
|
47
|
+
}, timeoutMs);
|
|
48
|
+
}
|
|
49
|
+
if (signal) {
|
|
50
|
+
const abortHandler = () => {
|
|
51
|
+
this.removeWaiter(waiter);
|
|
52
|
+
reject(new Error("Operation aborted"));
|
|
53
|
+
};
|
|
54
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
55
|
+
}
|
|
56
|
+
this.waiters.push(waiter);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
serialize() {
|
|
60
|
+
return Array.from(this.state.entries());
|
|
61
|
+
}
|
|
62
|
+
hydrate(entries) {
|
|
63
|
+
this.state.clear();
|
|
64
|
+
for (const [key, index] of entries) {
|
|
65
|
+
this.state.set(key, index);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
deduplicateCoordinates(coordinates) {
|
|
69
|
+
const map = new Map();
|
|
70
|
+
for (let i = 0; i < coordinates.length; i++) {
|
|
71
|
+
const coord = coordinates[i];
|
|
72
|
+
const key = makeConsistencyKey(coord.documentId, coord.scope, coord.branch);
|
|
73
|
+
const existing = map.get(key);
|
|
74
|
+
if (!existing || coord.operationIndex > existing.operationIndex) {
|
|
75
|
+
map.set(key, coord);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return Array.from(map.values());
|
|
79
|
+
}
|
|
80
|
+
areCoordinatesSatisfied(coordinates) {
|
|
81
|
+
for (let i = 0; i < coordinates.length; i++) {
|
|
82
|
+
const coord = coordinates[i];
|
|
83
|
+
const key = makeConsistencyKey(coord.documentId, coord.scope, coord.branch);
|
|
84
|
+
const latest = this.state.get(key);
|
|
85
|
+
if (latest === undefined || latest < coord.operationIndex) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
checkWaiters() {
|
|
92
|
+
const satisfiedWaiters = [];
|
|
93
|
+
const unsatisfiedWaiters = [];
|
|
94
|
+
for (const waiter of this.waiters) {
|
|
95
|
+
if (waiter.signal?.aborted) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (this.areCoordinatesSatisfied(waiter.coordinates)) {
|
|
99
|
+
satisfiedWaiters.push(waiter);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
unsatisfiedWaiters.push(waiter);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
this.waiters = unsatisfiedWaiters;
|
|
106
|
+
for (const waiter of satisfiedWaiters) {
|
|
107
|
+
if (waiter.timeoutId !== undefined) {
|
|
108
|
+
clearTimeout(waiter.timeoutId);
|
|
109
|
+
}
|
|
110
|
+
waiter.resolve();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
removeWaiter(waiter) {
|
|
114
|
+
const index = this.waiters.indexOf(waiter);
|
|
115
|
+
if (index !== -1) {
|
|
116
|
+
this.waiters.splice(index, 1);
|
|
117
|
+
}
|
|
118
|
+
if (waiter.timeoutId !== undefined) {
|
|
119
|
+
clearTimeout(waiter.timeoutId);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=consistency-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistency-tracker.js","sourceRoot":"","sources":["../../../src/shared/consistency-tracker.ts"],"names":[],"mappings":"AA4CA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAkB,EAClB,KAAa,EACb,MAAc;IAEd,OAAO,GAAG,UAAU,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC1C,OAAO,GAAa,EAAE,CAAC;IAE/B,MAAM,CAAC,WAAoC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,C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E,CAAC;gBACrD,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC;QAElC,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACjC,CAAC;YACD,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAAc;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACnC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
* System operations use this special ID along with the "system" scope.
|
|
4
4
|
*/
|
|
5
5
|
export declare const SYSTEM_DOCUMENT_ID = "00000000-0000-0000-0000-000000000000";
|
|
6
|
+
/**
|
|
7
|
+
* Information about an error including message and stack trace.
|
|
8
|
+
*/
|
|
9
|
+
export type ErrorInfo = {
|
|
10
|
+
message: string;
|
|
11
|
+
stack: string;
|
|
12
|
+
};
|
|
6
13
|
/**
|
|
7
14
|
* Describes the status of a shutdown operation.
|
|
8
15
|
*/
|
|
@@ -40,8 +47,13 @@ export type JobInfo = {
|
|
|
40
47
|
status: JobStatus;
|
|
41
48
|
createdAtUtcIso: string;
|
|
42
49
|
completedAtUtcIso?: string;
|
|
43
|
-
error?:
|
|
50
|
+
error?: ErrorInfo;
|
|
51
|
+
errorHistory?: ErrorInfo[];
|
|
44
52
|
result?: any;
|
|
53
|
+
/**
|
|
54
|
+
* A token for coordinating reads, only valid once a job reaches COMPLETED.
|
|
55
|
+
*/
|
|
56
|
+
consistencyToken: ConsistencyToken;
|
|
45
57
|
};
|
|
46
58
|
/**
|
|
47
59
|
* Job execution statuses
|
|
@@ -92,4 +104,26 @@ export type PagedResults<T> = {
|
|
|
92
104
|
next?: () => Promise<PagedResults<T>>;
|
|
93
105
|
nextCursor?: string;
|
|
94
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* A string key in the format `documentId:scope:branch` used to identify a consistency checkpoint.
|
|
109
|
+
*/
|
|
110
|
+
export type ConsistencyKey = `${string}:${string}:${string}`;
|
|
111
|
+
/**
|
|
112
|
+
* Describes a specific point in a document's operation history.
|
|
113
|
+
*/
|
|
114
|
+
export type ConsistencyCoordinate = {
|
|
115
|
+
documentId: string;
|
|
116
|
+
scope: string;
|
|
117
|
+
branch: string;
|
|
118
|
+
operationIndex: number;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* A token that captures the state of write operations at a point in time.
|
|
122
|
+
* Can be used to ensure read-after-write consistency.
|
|
123
|
+
*/
|
|
124
|
+
export type ConsistencyToken = {
|
|
125
|
+
version: 1;
|
|
126
|
+
createdAtUtcIso: string;
|
|
127
|
+
coordinates: ConsistencyCoordinate[];
|
|
128
|
+
};
|
|
95
129
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;OAQG;IACH,IAAI,UAAU,IAAI,OAAO,CAAC;CAC3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E,MAAM,CAAC;IACxB,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AA0BzE;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,6CAAmB,CAAA;AACrB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAoBD;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,wCAAwC;IACxC,gCAAmB,CAAA;IACnB,sCAAsC;IACtC,gCAAmB,CAAA;IACnB,iCAAiC;IACjC,oCAAuB,CAAA;IACvB,kCAAkC;IAClC,8BAAiB,CAAA;AACnB,CAAC,EATW,SAAS,KAAT,SAAS,QASpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Operation, PHDocument } from "document-model";
|
|
2
|
+
import type { ConsistencyToken } from "../shared/types.js";
|
|
2
3
|
export type OperationContext = {
|
|
3
4
|
documentId: string;
|
|
4
5
|
documentType: string;
|
|
@@ -102,20 +103,165 @@ export interface IDocumentView {
|
|
|
102
103
|
* documents from operations - it always requires resultingState.
|
|
103
104
|
*/
|
|
104
105
|
indexOperations(items: OperationWithContext[]): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Blocks until the view has processed the coordinates referenced by the
|
|
108
|
+
* provided consistency token.
|
|
109
|
+
*
|
|
110
|
+
* @param token - Consistency token derived from the originating job
|
|
111
|
+
* @param timeoutMs - Optional timeout window in milliseconds
|
|
112
|
+
* @param signal - Optional abort signal to cancel the wait
|
|
113
|
+
*/
|
|
114
|
+
waitForConsistency(token: ConsistencyToken, timeoutMs?: number, signal?: AbortSignal): Promise<void>;
|
|
105
115
|
/**
|
|
106
116
|
* Returns true if and only if the documents exist.
|
|
107
117
|
*
|
|
108
118
|
* @param documentIds - The list of document ids to check.
|
|
119
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
109
120
|
* @param signal - Optional abort signal to cancel the request
|
|
110
121
|
*/
|
|
111
|
-
exists(documentIds: string[], signal?: AbortSignal): Promise<boolean[]>;
|
|
122
|
+
exists(documentIds: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<boolean[]>;
|
|
112
123
|
/**
|
|
113
124
|
* Returns the document with the given id.
|
|
114
125
|
*
|
|
115
126
|
* @param documentId - The id of the document to get.
|
|
116
127
|
* @param view - Optional filter containing branch and scopes information
|
|
128
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
129
|
+
* @param signal - Optional abort signal to cancel the request
|
|
130
|
+
*/
|
|
131
|
+
get<TDocument extends PHDocument>(documentId: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
|
|
132
|
+
/**
|
|
133
|
+
* Finds documents by their document type.
|
|
134
|
+
*
|
|
135
|
+
* @param type - The document type to search for
|
|
136
|
+
* @param view - Optional filter containing branch and scopes information
|
|
137
|
+
* @param paging - Optional paging options for cursor-based pagination
|
|
138
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
139
|
+
* @param signal - Optional abort signal to cancel the request
|
|
140
|
+
*/
|
|
141
|
+
findByType(type: string, view?: ViewFilter, paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<PHDocument>>;
|
|
142
|
+
/**
|
|
143
|
+
* Resolves a slug to a document ID.
|
|
144
|
+
*
|
|
145
|
+
* @param slug - The slug to resolve
|
|
146
|
+
* @param view - Optional filter containing branch and scopes information
|
|
147
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
148
|
+
* @param signal - Optional abort signal to cancel the request
|
|
149
|
+
* @returns The document ID or undefined if the slug doesn't exist
|
|
150
|
+
*/
|
|
151
|
+
resolveSlug(slug: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string | undefined>;
|
|
152
|
+
}
|
|
153
|
+
export type DocumentRelationship = {
|
|
154
|
+
sourceId: string;
|
|
155
|
+
targetId: string;
|
|
156
|
+
relationshipType: string;
|
|
157
|
+
metadata?: Record<string, unknown>;
|
|
158
|
+
createdAt: Date;
|
|
159
|
+
updatedAt: Date;
|
|
160
|
+
};
|
|
161
|
+
export type DocumentGraphEdge = {
|
|
162
|
+
from: string;
|
|
163
|
+
to: string;
|
|
164
|
+
type: string;
|
|
165
|
+
};
|
|
166
|
+
export interface IDocumentGraph {
|
|
167
|
+
nodes: string[];
|
|
168
|
+
edges: DocumentGraphEdge[];
|
|
169
|
+
}
|
|
170
|
+
export interface IDocumentIndexer {
|
|
171
|
+
/**
|
|
172
|
+
* Initializes the indexer and catches up on any missed operations.
|
|
173
|
+
*/
|
|
174
|
+
init(): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Indexes a list of operations to update the relationship graph.
|
|
177
|
+
*
|
|
178
|
+
* @param operations - Operations to index. Will process ADD_RELATIONSHIP and
|
|
179
|
+
* REMOVE_RELATIONSHIP operations.
|
|
180
|
+
*/
|
|
181
|
+
indexOperations(operations: OperationWithContext[]): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Blocks until the indexer has processed the coordinates referenced by the
|
|
184
|
+
* provided consistency token.
|
|
185
|
+
*
|
|
186
|
+
* @param token - Consistency token derived from the originating job
|
|
187
|
+
* @param timeoutMs - Optional timeout window in milliseconds
|
|
188
|
+
* @param signal - Optional abort signal to cancel the wait
|
|
189
|
+
*/
|
|
190
|
+
waitForConsistency(token: ConsistencyToken, timeoutMs?: number, signal?: AbortSignal): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Returns outgoing relationships from a document.
|
|
193
|
+
*
|
|
194
|
+
* @param documentId - The source document id
|
|
195
|
+
* @param types - Optional filter by relationship types
|
|
196
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
197
|
+
* @param signal - Optional abort signal to cancel the request
|
|
198
|
+
*/
|
|
199
|
+
getOutgoing(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Returns incoming relationships to a document.
|
|
202
|
+
*
|
|
203
|
+
* @param documentId - The target document id
|
|
204
|
+
* @param types - Optional filter by relationship types
|
|
205
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
206
|
+
* @param signal - Optional abort signal to cancel the request
|
|
207
|
+
*/
|
|
208
|
+
getIncoming(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Checks if a relationship exists between two documents.
|
|
211
|
+
*
|
|
212
|
+
* @param sourceId - The source document id
|
|
213
|
+
* @param targetId - The target document id
|
|
214
|
+
* @param types - Optional filter by relationship types
|
|
215
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
216
|
+
* @param signal - Optional abort signal to cancel the request
|
|
217
|
+
*/
|
|
218
|
+
hasRelationship(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<boolean>;
|
|
219
|
+
/**
|
|
220
|
+
* Returns all undirected relationships between two documents.
|
|
221
|
+
*
|
|
222
|
+
* @param a - The ID of the first document
|
|
223
|
+
* @param b - The ID of the second document
|
|
224
|
+
* @param types - Optional filter by relationship types
|
|
225
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
226
|
+
* @param signal - Optional abort signal to cancel the request
|
|
227
|
+
*/
|
|
228
|
+
getUndirectedRelationships(a: string, b: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Returns all directed relationships between two documents.
|
|
231
|
+
*
|
|
232
|
+
* @param sourceId - The source document id
|
|
233
|
+
* @param targetId - The target document id
|
|
234
|
+
* @param types - Optional filter by relationship types
|
|
235
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
236
|
+
* @param signal - Optional abort signal to cancel the request
|
|
237
|
+
*/
|
|
238
|
+
getDirectedRelationships(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
239
|
+
/**
|
|
240
|
+
* Finds a path from source to target following directed edges.
|
|
241
|
+
*
|
|
242
|
+
* @param sourceId - The source document id
|
|
243
|
+
* @param targetId - The target document id
|
|
244
|
+
* @param types - Optional filter by relationship types
|
|
245
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
246
|
+
* @param signal - Optional abort signal to cancel the request
|
|
247
|
+
* @returns Array of document ids representing the path, or null if no path exists
|
|
248
|
+
*/
|
|
249
|
+
findPath(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[] | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Returns all ancestors of a document in the relationship graph.
|
|
252
|
+
*
|
|
253
|
+
* @param documentId - The document id
|
|
254
|
+
* @param types - Optional filter by relationship types
|
|
255
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
256
|
+
* @param signal - Optional abort signal to cancel the request
|
|
257
|
+
*/
|
|
258
|
+
findAncestors(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<IDocumentGraph>;
|
|
259
|
+
/**
|
|
260
|
+
* Returns all relationship types currently in the system.
|
|
261
|
+
*
|
|
262
|
+
* @param consistencyToken - Optional token for read-after-write consistency
|
|
117
263
|
* @param signal - Optional abort signal to cancel the request
|
|
118
264
|
*/
|
|
119
|
-
|
|
265
|
+
getRelationshipTypes(consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
120
266
|
}
|
|
121
267
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/storage/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/storage/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,IAAI,EAAE,MAAM;CAIzB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI7C;AAED,MAAM,WAAW,SAAS;IACxB,aAAa,CAAC,GAAG,UAAU,EAAE,SA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ACX,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;OAKG;IACH,oBAAoB,CAClB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/storage/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/storage/interfaces.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,IAAY;QACtB,KAAK,CAAC,uBAAuB,IAAI,iBAAiB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,QAAgB,EAAE,MAAc;QAC1C,KAAK,CAAC,+BAA+B,QAAQ,SAAS,MAAM,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { IConsistencyTracker } from "../../shared/consistency-tracker.js";
|
|
3
|
+
import type { ConsistencyToken } from "../../shared/types.js";
|
|
4
|
+
import type { DocumentRelationship, IDocumentGraph, IDocumentIndexer, IOperationStore, OperationWithContext } from "../interfaces.js";
|
|
5
|
+
import type { Database as StorageDatabase, DocumentIndexerDatabase } from "./types.js";
|
|
6
|
+
type Database = StorageDatabase & DocumentIndexerDatabase;
|
|
7
|
+
export declare class KyselyDocumentIndexer implements IDocumentIndexer {
|
|
8
|
+
private db;
|
|
9
|
+
private operationStore;
|
|
10
|
+
private consistencyTracker;
|
|
11
|
+
private lastOperationId;
|
|
12
|
+
constructor(db: Kysely<Database>, operationStore: IOperationStore, consistencyTracker: IConsistencyTracker);
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
indexOperations(items: OperationWithContext[]): Promise<void>;
|
|
15
|
+
waitForConsistency(token: ConsistencyToken, timeoutMs?: number, signal?: AbortSignal): Promise<void>;
|
|
16
|
+
getOutgoing(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
17
|
+
getIncoming(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
18
|
+
hasRelationship(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<boolean>;
|
|
19
|
+
getUndirectedRelationships(a: string, b: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
20
|
+
getDirectedRelationships(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
|
|
21
|
+
findPath(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[] | null>;
|
|
22
|
+
findAncestors(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<IDocumentGraph>;
|
|
23
|
+
getRelationshipTypes(consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
|
|
24
|
+
private handleAddRelationship;
|
|
25
|
+
private handleRemoveRelationship;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=document-indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-indexer.d.ts","sourceRoot":"","sources":["../../../../src/storage/kysely/document-indexer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,QAAQ,IAAI,eAAe,EAC3B,uBAAuB,EAExB,MAAM,YAAY,CAAC;AAEpB,KAAK,QAAQ,GAAG,eAAe,GAAG,uBAAuB,CAAC;AAE1D,qBAAa,qBAAsB,YAAW,gBAAgB;IAI1D,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,kBAAkB;IAL5B,OAAO,CAAC,eAAe,CAAa;gBAG1B,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,EACpB,cAAc,EAAE,eAAe,EAC/B,kBAAkB,EAAE,mBAAmB;IAG3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+BrB,eAAe,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC7D,kBAAkB,CACtB,KAAK,EAAE,gBAAgB,EACvB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAOV,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,C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