wiki-graph-sdk 0.8.3 → 0.8.4
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 +5 -0
- package/dist/archives.cjs +364 -6
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +4 -216
- package/dist/archives.js +366 -6
- package/dist/archives.js.map +1 -1
- package/dist/index-DQzLAnjf.d.ts +346 -0
- package/dist/index.cjs +574 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.js +565 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/archives.d.ts
CHANGED
|
@@ -1,219 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
export { h as WikiGraphArchiveChapterInspection, i as WikiGraphArchiveCover, j as WikiGraphArchiveCreateOptions, k as WikiGraphArchiveCreateResult, l as WikiGraphArchiveEvidenceOptions, m as WikiGraphArchiveExistsError, n as WikiGraphArchiveHandle, o as WikiGraphArchiveIndexArtifactInspection, p as WikiGraphArchiveIndexStatus, q as WikiGraphArchiveIndexSyncOptions, r as WikiGraphArchiveInspection, s as WikiGraphArchiveListOptions, W as WikiGraphArchiveManager, t as WikiGraphArchivePageOptions, u as WikiGraphArchiveRelatedOptions, v as WikiGraphArchiveScope, w as WikiGraphArchiveScopeOptions, x as WikiGraphArchiveSearchOptions, y as WikiGraphArchiveWriteOptions, z as WikiGraphChapterArtifactStatus, B as WikiGraphChapterMoveOptions, D as WikiGraphChapterResetStage, E as WikiGraphChapterSourceOptions, F as WikiGraphChapterTreeInput, G as WikiGraphOperationOptions, S as inspectWikiGraphArchive } from './index-DQzLAnjf.js';
|
|
2
|
+
export { a as WikiGraphArchiveOwnershipError, W as WikiGraphArchiveTarget } from './target-CZ7elwmj.js';
|
|
3
|
+
import 'wiki-graph-core';
|
|
4
|
+
import './jobs-CRK-DZ40.js';
|
|
5
5
|
import './default-worker.js';
|
|
6
6
|
import './runtime-config.js';
|
|
7
7
|
import 'zod';
|
|
8
|
-
|
|
9
|
-
interface WikiGraphArchiveIndexArtifactInspection {
|
|
10
|
-
readonly current: boolean;
|
|
11
|
-
readonly exists: boolean;
|
|
12
|
-
readonly kind: IndexArtifactKind;
|
|
13
|
-
readonly sourceRevision?: number;
|
|
14
|
-
}
|
|
15
|
-
interface WikiGraphArchiveChapterInspection {
|
|
16
|
-
readonly capabilities: {
|
|
17
|
-
readonly knowledgeGraph: {
|
|
18
|
-
readonly completed: boolean;
|
|
19
|
-
};
|
|
20
|
-
readonly readingGraph: {
|
|
21
|
-
readonly completed: boolean;
|
|
22
|
-
};
|
|
23
|
-
readonly readingSummary: {
|
|
24
|
-
readonly completed: boolean;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
readonly chapter: ChapterEntry;
|
|
28
|
-
readonly indexes: {
|
|
29
|
-
readonly fts: WikiGraphArchiveIndexArtifactInspection;
|
|
30
|
-
readonly sourceEmbedding: WikiGraphArchiveIndexArtifactInspection;
|
|
31
|
-
readonly summaryEmbedding: WikiGraphArchiveIndexArtifactInspection;
|
|
32
|
-
};
|
|
33
|
-
readonly revision: number;
|
|
34
|
-
readonly summaryWords: number;
|
|
35
|
-
}
|
|
36
|
-
interface WikiGraphArchiveInspection {
|
|
37
|
-
readonly archiveUri: string;
|
|
38
|
-
readonly chapters: readonly WikiGraphArchiveChapterInspection[];
|
|
39
|
-
readonly localIndexCache: {
|
|
40
|
-
readonly current: boolean;
|
|
41
|
-
};
|
|
42
|
-
readonly scope: {
|
|
43
|
-
readonly chapterId?: number;
|
|
44
|
-
readonly type: "archive" | "chapter";
|
|
45
|
-
};
|
|
46
|
-
readonly uri: string;
|
|
47
|
-
}
|
|
48
|
-
declare function inspectWikiGraphArchive(document: ReadonlyDocument, options: {
|
|
49
|
-
readonly archiveUri: string;
|
|
50
|
-
readonly chapterId?: number;
|
|
51
|
-
}): Promise<WikiGraphArchiveInspection>;
|
|
52
|
-
|
|
53
|
-
interface WikiGraphOperationOptions {
|
|
54
|
-
readonly signal?: AbortSignal;
|
|
55
|
-
}
|
|
56
|
-
type SearchIndexCapabilityStatus = Awaited<ReturnType<typeof readSearchIndexCapabilityStatus>>;
|
|
57
|
-
type SearchIndexProgressEvent = Parameters<NonNullable<Parameters<typeof rebuildArchiveSearchIndex>[1]>>[0];
|
|
58
|
-
type WikiGraphChapterResetStage = Exclude<ChapterStage, "summarized">;
|
|
59
|
-
type WikiGraphChapterSourceOptions = NonNullable<Parameters<typeof setChapterSource>[3]>;
|
|
60
|
-
type WikiGraphChapterTreeInput = Parameters<typeof applyChapterTree>[1];
|
|
61
|
-
interface WikiGraphArchiveCreateOptions extends WikiGraphOperationOptions {
|
|
62
|
-
readonly importPath?: string;
|
|
63
|
-
readonly onProgress?: WikiGraphProgressCallback;
|
|
64
|
-
readonly path: string;
|
|
65
|
-
readonly replace?: boolean;
|
|
66
|
-
}
|
|
67
|
-
interface WikiGraphArchiveCreateResult {
|
|
68
|
-
readonly locatedUri: string;
|
|
69
|
-
readonly path: string;
|
|
70
|
-
}
|
|
71
|
-
declare class WikiGraphArchiveExistsError extends Error {
|
|
72
|
-
readonly code = "WIKI_GRAPH_ARCHIVE_EXISTS";
|
|
73
|
-
readonly path: string;
|
|
74
|
-
constructor(path: string);
|
|
75
|
-
}
|
|
76
|
-
interface WikiGraphArchiveWriteOptions extends WikiGraphOperationOptions {
|
|
77
|
-
readonly onIndexSyncError?: (error: unknown) => void;
|
|
78
|
-
readonly refreshLibraryIndex?: boolean;
|
|
79
|
-
readonly searchIndexWritebackPolicy?: "archive" | "cache";
|
|
80
|
-
}
|
|
81
|
-
interface WikiGraphArchiveIndexStatus {
|
|
82
|
-
readonly capabilities: SearchIndexCapabilityStatus;
|
|
83
|
-
readonly current: boolean;
|
|
84
|
-
}
|
|
85
|
-
interface WikiGraphArchiveCover {
|
|
86
|
-
readonly data: Uint8Array;
|
|
87
|
-
readonly mediaType: string;
|
|
88
|
-
readonly path: string;
|
|
89
|
-
}
|
|
90
|
-
interface WikiGraphArchiveIndexSyncOptions extends WikiGraphOperationOptions {
|
|
91
|
-
readonly onProgress?: (event: SearchIndexProgressEvent) => void | Promise<void>;
|
|
92
|
-
readonly skipUnindexed?: boolean;
|
|
93
|
-
}
|
|
94
|
-
interface WikiGraphChapterArtifactStatus {
|
|
95
|
-
readonly artifact?: {
|
|
96
|
-
readonly createdAt: string;
|
|
97
|
-
readonly metadata: Readonly<Record<string, unknown>>;
|
|
98
|
-
readonly sourceRevision: number;
|
|
99
|
-
};
|
|
100
|
-
readonly chapterId: number;
|
|
101
|
-
readonly current: boolean;
|
|
102
|
-
readonly kind: IndexArtifactKind;
|
|
103
|
-
readonly missing: boolean;
|
|
104
|
-
readonly revision: number;
|
|
105
|
-
}
|
|
106
|
-
interface WikiGraphChapterMoveOptions {
|
|
107
|
-
readonly afterPath?: string;
|
|
108
|
-
readonly beforePath?: string;
|
|
109
|
-
readonly first?: boolean;
|
|
110
|
-
readonly last?: boolean;
|
|
111
|
-
readonly parentPath?: string;
|
|
112
|
-
readonly root?: boolean;
|
|
113
|
-
}
|
|
114
|
-
interface WikiGraphArchiveScopeOptions {
|
|
115
|
-
readonly chapters?: readonly number[];
|
|
116
|
-
readonly depth?: number;
|
|
117
|
-
}
|
|
118
|
-
interface WikiGraphArchiveSearchOptions extends Omit<ArchiveFindOptions, "archiveKey" | "chapters">, WikiGraphArchiveScopeOptions, WikiGraphOperationOptions {
|
|
119
|
-
}
|
|
120
|
-
interface WikiGraphArchiveListOptions extends Omit<ArchiveCollectionOptions, "chapters">, WikiGraphArchiveScopeOptions, WikiGraphOperationOptions {
|
|
121
|
-
}
|
|
122
|
-
interface WikiGraphArchivePageOptions extends WikiGraphOperationOptions {
|
|
123
|
-
readonly backlinks?: boolean;
|
|
124
|
-
readonly evidenceLimit?: number;
|
|
125
|
-
readonly order?: "doc-asc" | "doc-desc";
|
|
126
|
-
readonly sourceContext?: number;
|
|
127
|
-
}
|
|
128
|
-
interface WikiGraphArchiveRelatedOptions extends WikiGraphOperationOptions {
|
|
129
|
-
readonly cursor?: string;
|
|
130
|
-
readonly evidenceLimit?: number;
|
|
131
|
-
readonly limit?: number;
|
|
132
|
-
readonly order?: "doc-asc" | "doc-desc";
|
|
133
|
-
readonly query?: string;
|
|
134
|
-
readonly queryMode?: SearchIndexQueryMode;
|
|
135
|
-
readonly role?: "any" | "object" | "self" | "subject";
|
|
136
|
-
readonly skipUnindexed?: boolean;
|
|
137
|
-
readonly sourceContext?: number;
|
|
138
|
-
}
|
|
139
|
-
interface WikiGraphArchiveEvidenceOptions extends WikiGraphOperationOptions {
|
|
140
|
-
readonly cursor?: string;
|
|
141
|
-
readonly limit?: number;
|
|
142
|
-
readonly order?: "doc-asc" | "doc-desc";
|
|
143
|
-
readonly query?: string;
|
|
144
|
-
readonly queryMode?: SearchIndexQueryMode;
|
|
145
|
-
readonly skipUnindexed?: boolean;
|
|
146
|
-
readonly sourceContext?: number;
|
|
147
|
-
}
|
|
148
|
-
interface WikiGraphArchiveScope {
|
|
149
|
-
readonly chapterIds: readonly number[];
|
|
150
|
-
readonly entries: readonly ChapterEntry[];
|
|
151
|
-
}
|
|
152
|
-
declare class WikiGraphArchiveManager {
|
|
153
|
-
#private;
|
|
154
|
-
constructor(runtime: WikiGraphJobRuntime);
|
|
155
|
-
create(options: WikiGraphArchiveCreateOptions): Promise<WikiGraphArchiveCreateResult>;
|
|
156
|
-
open(target: WikiGraphArchiveTarget, options?: WikiGraphOperationOptions): Promise<WikiGraphArchiveHandle>;
|
|
157
|
-
}
|
|
158
|
-
declare class WikiGraphArchiveHandle {
|
|
159
|
-
#private;
|
|
160
|
-
constructor(runtime: WikiGraphJobRuntime, location: unknown);
|
|
161
|
-
get archiveKey(): string;
|
|
162
|
-
get indexScope(): QueryIndexScope;
|
|
163
|
-
get locatedUri(): string;
|
|
164
|
-
get objectUri(): string;
|
|
165
|
-
get path(): string;
|
|
166
|
-
get target(): WikiGraphArchiveTarget;
|
|
167
|
-
inspect(options?: WikiGraphOperationOptions & {
|
|
168
|
-
readonly chapterId?: number;
|
|
169
|
-
}): Promise<WikiGraphArchiveInspection>;
|
|
170
|
-
search(query: string, options?: WikiGraphArchiveSearchOptions): Promise<ArchiveFindResult>;
|
|
171
|
-
list(options?: WikiGraphArchiveListOptions): Promise<ArchiveCollectionResult | ArchiveSourceLocatorResult>;
|
|
172
|
-
ensureSearchIndex(options?: WikiGraphArchiveScopeOptions & WikiGraphOperationOptions): Promise<void>;
|
|
173
|
-
getSearchIndexStatus(options?: WikiGraphOperationOptions): Promise<WikiGraphArchiveIndexStatus>;
|
|
174
|
-
syncSearchIndex(options?: WikiGraphArchiveIndexSyncOptions): Promise<{
|
|
175
|
-
readonly rebuilt: boolean;
|
|
176
|
-
}>;
|
|
177
|
-
cleanSearchIndex(options?: WikiGraphOperationOptions): Promise<WikiGraphArchiveIndexStatus>;
|
|
178
|
-
/** Clear cached search sessions without changing the archive index. */
|
|
179
|
-
clearSearchSessions(options?: WikiGraphOperationOptions): Promise<void>;
|
|
180
|
-
listChapters(options?: WikiGraphOperationOptions): Promise<readonly ChapterEntry[]>;
|
|
181
|
-
getChapter(path: string, options?: WikiGraphOperationOptions): Promise<ChapterEntry>;
|
|
182
|
-
addChapter(options: {
|
|
183
|
-
readonly parentPath?: string;
|
|
184
|
-
readonly source?: string;
|
|
185
|
-
readonly title?: string;
|
|
186
|
-
}): Promise<ChapterDetails>;
|
|
187
|
-
getChapterArtifact(path: string, kind: IndexArtifactKind): Promise<WikiGraphChapterArtifactStatus>;
|
|
188
|
-
deleteChapterArtifact(path: string, kind: IndexArtifactKind): Promise<{
|
|
189
|
-
readonly chapterId: number;
|
|
190
|
-
readonly deleted: true;
|
|
191
|
-
readonly kind: IndexArtifactKind;
|
|
192
|
-
}>;
|
|
193
|
-
moveChapter(path: string, options: WikiGraphChapterMoveOptions): Promise<ChapterDetails>;
|
|
194
|
-
removeChapter(path: string, recursive?: boolean): Promise<void>;
|
|
195
|
-
resetChapter(path: string, stage: WikiGraphChapterResetStage): Promise<ChapterDetails>;
|
|
196
|
-
setChapterSource(path: string, source: string, options?: WikiGraphChapterSourceOptions): Promise<ChapterDetails>;
|
|
197
|
-
setChapterSummary(path: string, summary: string): Promise<ChapterDetails>;
|
|
198
|
-
setChapterTitle(path: string, title: Parameters<typeof setChapterTitle>[2]): Promise<ChapterDetails>;
|
|
199
|
-
getChapterTree(): Promise<ChapterTree>;
|
|
200
|
-
applyChapterTree(tree: WikiGraphChapterTreeInput, options?: {
|
|
201
|
-
readonly dryRun?: boolean;
|
|
202
|
-
}): Promise<ChapterTreeApplyResult>;
|
|
203
|
-
page(objectUri?: string, options?: WikiGraphArchivePageOptions): Promise<ArchivePage>;
|
|
204
|
-
related(objectUri?: string, options?: WikiGraphArchiveRelatedOptions): Promise<ArchiveRelatedResult>;
|
|
205
|
-
evidence(objectUri?: string, options?: WikiGraphArchiveEvidenceOptions): Promise<ArchiveEvidence>;
|
|
206
|
-
pack(objectUri?: string, budget?: number, options?: WikiGraphOperationOptions): Promise<ArchivePack>;
|
|
207
|
-
getMetadata(objectPath: string, options?: WikiGraphOperationOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
208
|
-
readBookMeta(options?: WikiGraphOperationOptions): Promise<BookMeta | undefined>;
|
|
209
|
-
replaceBookMeta(meta: BookMeta, options?: WikiGraphArchiveWriteOptions): Promise<BookMeta>;
|
|
210
|
-
setArchiveTitle(title: string | null, options?: WikiGraphArchiveWriteOptions): Promise<string | null>;
|
|
211
|
-
readCover(options?: WikiGraphOperationOptions): Promise<WikiGraphArchiveCover | undefined>;
|
|
212
|
-
replaceMetadata(objectPath: string, value: Readonly<Record<string, unknown>>, options?: WikiGraphArchiveWriteOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
213
|
-
putMetadata(objectPath: string, key: string, value: unknown, options?: WikiGraphArchiveWriteOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
214
|
-
deleteMetadata(objectPath: string, key: string, options?: WikiGraphArchiveWriteOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
215
|
-
clearMetadata(objectPath: string, options?: WikiGraphArchiveWriteOptions): Promise<Readonly<Record<string, unknown>>>;
|
|
216
|
-
resolveScope(options?: WikiGraphArchiveScopeOptions & WikiGraphOperationOptions): Promise<WikiGraphArchiveScope | undefined>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export { type WikiGraphArchiveChapterInspection, type WikiGraphArchiveCover, type WikiGraphArchiveCreateOptions, type WikiGraphArchiveCreateResult, type WikiGraphArchiveEvidenceOptions, WikiGraphArchiveExistsError, WikiGraphArchiveHandle, type WikiGraphArchiveIndexArtifactInspection, type WikiGraphArchiveIndexStatus, type WikiGraphArchiveIndexSyncOptions, type WikiGraphArchiveInspection, type WikiGraphArchiveListOptions, WikiGraphArchiveManager, type WikiGraphArchivePageOptions, type WikiGraphArchiveRelatedOptions, type WikiGraphArchiveScope, type WikiGraphArchiveScopeOptions, type WikiGraphArchiveSearchOptions, WikiGraphArchiveTarget, type WikiGraphArchiveWriteOptions, type WikiGraphChapterArtifactStatus, type WikiGraphChapterMoveOptions, type WikiGraphChapterResetStage, type WikiGraphChapterSourceOptions, type WikiGraphChapterTreeInput, type WikiGraphOperationOptions, inspectWikiGraphArchive };
|
package/dist/archives.js
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
assertNoActiveBuildJobConflicts,
|
|
16
16
|
assertNoActiveBuildJobs,
|
|
17
17
|
deleteArchiveSearchSessions,
|
|
18
|
+
createContinuationCursor,
|
|
19
|
+
deleteContinuationCursor,
|
|
18
20
|
DirectoryDocument,
|
|
19
21
|
findArchiveObjects,
|
|
20
22
|
formatLocatedWikiGraphUri as formatLocatedWikiGraphUri2,
|
|
@@ -1925,6 +1927,236 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
|
|
|
1925
1927
|
});
|
|
1926
1928
|
}
|
|
1927
1929
|
|
|
1930
|
+
// src/pages.ts
|
|
1931
|
+
function createCursor(implementation) {
|
|
1932
|
+
let released = false;
|
|
1933
|
+
const assertLive = () => {
|
|
1934
|
+
if (released) throw new Error("Cursor has been released.");
|
|
1935
|
+
};
|
|
1936
|
+
return {
|
|
1937
|
+
pageClass: implementation.pageClass,
|
|
1938
|
+
async next(options = {}) {
|
|
1939
|
+
assertLive();
|
|
1940
|
+
return await implementation.next(options);
|
|
1941
|
+
},
|
|
1942
|
+
async token() {
|
|
1943
|
+
assertLive();
|
|
1944
|
+
return await implementation.token();
|
|
1945
|
+
},
|
|
1946
|
+
async release() {
|
|
1947
|
+
if (released) return;
|
|
1948
|
+
released = true;
|
|
1949
|
+
await implementation.release?.();
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
function createPageCursor(implementation) {
|
|
1954
|
+
let token;
|
|
1955
|
+
return createCursor({
|
|
1956
|
+
pageClass: implementation.pageClass,
|
|
1957
|
+
next: async (options) => await implementation.next(implementation.rawCursor, options),
|
|
1958
|
+
token: async () => {
|
|
1959
|
+
token ??= await implementation.createToken(implementation.rawCursor);
|
|
1960
|
+
return token;
|
|
1961
|
+
},
|
|
1962
|
+
release: async () => {
|
|
1963
|
+
if (token !== void 0) await implementation.releaseToken?.(token);
|
|
1964
|
+
token = void 0;
|
|
1965
|
+
}
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
// src/result-pages.ts
|
|
1970
|
+
var ArchiveFindPage = class _ArchiveFindPage {
|
|
1971
|
+
result;
|
|
1972
|
+
chapters;
|
|
1973
|
+
items;
|
|
1974
|
+
lens;
|
|
1975
|
+
lensHint;
|
|
1976
|
+
limit;
|
|
1977
|
+
match;
|
|
1978
|
+
rawNextCursor;
|
|
1979
|
+
order;
|
|
1980
|
+
query;
|
|
1981
|
+
terms;
|
|
1982
|
+
types;
|
|
1983
|
+
#cursor;
|
|
1984
|
+
constructor(result, cursor = null) {
|
|
1985
|
+
this.result = result;
|
|
1986
|
+
this.chapters = result.chapters;
|
|
1987
|
+
this.items = result.items;
|
|
1988
|
+
this.lens = result.lens;
|
|
1989
|
+
this.lensHint = result.lensHint;
|
|
1990
|
+
this.limit = result.limit;
|
|
1991
|
+
this.match = result.match;
|
|
1992
|
+
this.rawNextCursor = result.nextCursor;
|
|
1993
|
+
this.order = result.order;
|
|
1994
|
+
this.query = result.query;
|
|
1995
|
+
this.terms = result.terms;
|
|
1996
|
+
this.types = result.types;
|
|
1997
|
+
this.#cursor = cursor;
|
|
1998
|
+
}
|
|
1999
|
+
static pageClass = _ArchiveFindPage;
|
|
2000
|
+
[Symbol.iterator]() {
|
|
2001
|
+
return this.items[Symbol.iterator]();
|
|
2002
|
+
}
|
|
2003
|
+
nextCursor() {
|
|
2004
|
+
return this.#cursor;
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
var ArchiveCollectionPage = class _ArchiveCollectionPage {
|
|
2008
|
+
result;
|
|
2009
|
+
chapters;
|
|
2010
|
+
ids;
|
|
2011
|
+
items;
|
|
2012
|
+
limit;
|
|
2013
|
+
rawNextCursor;
|
|
2014
|
+
order;
|
|
2015
|
+
types;
|
|
2016
|
+
#cursor;
|
|
2017
|
+
constructor(result, cursor = null) {
|
|
2018
|
+
this.result = result;
|
|
2019
|
+
this.chapters = result.chapters;
|
|
2020
|
+
this.ids = result.ids;
|
|
2021
|
+
this.items = result.items;
|
|
2022
|
+
this.limit = result.limit;
|
|
2023
|
+
this.rawNextCursor = result.nextCursor;
|
|
2024
|
+
this.order = result.order;
|
|
2025
|
+
this.types = result.types;
|
|
2026
|
+
this.#cursor = cursor;
|
|
2027
|
+
}
|
|
2028
|
+
static pageClass = _ArchiveCollectionPage;
|
|
2029
|
+
[Symbol.iterator]() {
|
|
2030
|
+
return this.items[Symbol.iterator]();
|
|
2031
|
+
}
|
|
2032
|
+
nextCursor() {
|
|
2033
|
+
return this.#cursor;
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
var ArchiveEvidencePage = class _ArchiveEvidencePage {
|
|
2037
|
+
result;
|
|
2038
|
+
items;
|
|
2039
|
+
limit;
|
|
2040
|
+
rawNextCursor;
|
|
2041
|
+
#cursor;
|
|
2042
|
+
constructor(result, cursor = null) {
|
|
2043
|
+
this.result = result;
|
|
2044
|
+
this.items = result.items;
|
|
2045
|
+
this.limit = result.limit;
|
|
2046
|
+
this.rawNextCursor = result.nextCursor;
|
|
2047
|
+
this.#cursor = cursor;
|
|
2048
|
+
}
|
|
2049
|
+
static pageClass = _ArchiveEvidencePage;
|
|
2050
|
+
[Symbol.iterator]() {
|
|
2051
|
+
return this.items[Symbol.iterator]();
|
|
2052
|
+
}
|
|
2053
|
+
nextCursor() {
|
|
2054
|
+
return this.#cursor;
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
var ArchiveRelatedPage = class _ArchiveRelatedPage {
|
|
2058
|
+
result;
|
|
2059
|
+
items;
|
|
2060
|
+
limit;
|
|
2061
|
+
rawNextCursor;
|
|
2062
|
+
#cursor;
|
|
2063
|
+
constructor(result, cursor = null) {
|
|
2064
|
+
this.result = result;
|
|
2065
|
+
this.items = result.items;
|
|
2066
|
+
this.limit = result.limit;
|
|
2067
|
+
this.rawNextCursor = result.nextCursor;
|
|
2068
|
+
this.#cursor = cursor;
|
|
2069
|
+
}
|
|
2070
|
+
static pageClass = _ArchiveRelatedPage;
|
|
2071
|
+
[Symbol.iterator]() {
|
|
2072
|
+
return this.items[Symbol.iterator]();
|
|
2073
|
+
}
|
|
2074
|
+
nextCursor() {
|
|
2075
|
+
return this.#cursor;
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
|
|
2079
|
+
result;
|
|
2080
|
+
items;
|
|
2081
|
+
limit;
|
|
2082
|
+
rawNextCursor;
|
|
2083
|
+
#cursor;
|
|
2084
|
+
constructor(result, cursor = null) {
|
|
2085
|
+
this.result = result;
|
|
2086
|
+
this.items = result.items;
|
|
2087
|
+
this.limit = result.limit;
|
|
2088
|
+
this.rawNextCursor = result.nextCursor;
|
|
2089
|
+
this.#cursor = cursor;
|
|
2090
|
+
}
|
|
2091
|
+
static pageClass = _ArchiveSourceLocatorPage;
|
|
2092
|
+
[Symbol.iterator]() {
|
|
2093
|
+
return this.items[Symbol.iterator]();
|
|
2094
|
+
}
|
|
2095
|
+
nextCursor() {
|
|
2096
|
+
return this.#cursor;
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
function createArchiveFindPage(result, next, createToken, releaseToken) {
|
|
2100
|
+
return new ArchiveFindPage(
|
|
2101
|
+
result,
|
|
2102
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2103
|
+
pageClass: ArchiveFindPage,
|
|
2104
|
+
rawCursor: result.nextCursor,
|
|
2105
|
+
next,
|
|
2106
|
+
createToken,
|
|
2107
|
+
releaseToken
|
|
2108
|
+
})
|
|
2109
|
+
);
|
|
2110
|
+
}
|
|
2111
|
+
function createArchiveCollectionPage(result, next, createToken, releaseToken) {
|
|
2112
|
+
return new ArchiveCollectionPage(
|
|
2113
|
+
result,
|
|
2114
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2115
|
+
pageClass: ArchiveCollectionPage,
|
|
2116
|
+
rawCursor: result.nextCursor,
|
|
2117
|
+
next,
|
|
2118
|
+
createToken,
|
|
2119
|
+
releaseToken
|
|
2120
|
+
})
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
function createArchiveEvidencePage(result, next, createToken, releaseToken) {
|
|
2124
|
+
return new ArchiveEvidencePage(
|
|
2125
|
+
result,
|
|
2126
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2127
|
+
pageClass: ArchiveEvidencePage,
|
|
2128
|
+
rawCursor: result.nextCursor,
|
|
2129
|
+
next,
|
|
2130
|
+
createToken,
|
|
2131
|
+
releaseToken
|
|
2132
|
+
})
|
|
2133
|
+
);
|
|
2134
|
+
}
|
|
2135
|
+
function createArchiveRelatedPage(result, next, createToken, releaseToken) {
|
|
2136
|
+
return new ArchiveRelatedPage(
|
|
2137
|
+
result,
|
|
2138
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2139
|
+
pageClass: ArchiveRelatedPage,
|
|
2140
|
+
rawCursor: result.nextCursor,
|
|
2141
|
+
next,
|
|
2142
|
+
createToken,
|
|
2143
|
+
releaseToken
|
|
2144
|
+
})
|
|
2145
|
+
);
|
|
2146
|
+
}
|
|
2147
|
+
function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
|
|
2148
|
+
return new ArchiveSourceLocatorPage(
|
|
2149
|
+
result,
|
|
2150
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2151
|
+
pageClass: ArchiveSourceLocatorPage,
|
|
2152
|
+
rawCursor: result.nextCursor,
|
|
2153
|
+
next,
|
|
2154
|
+
createToken,
|
|
2155
|
+
releaseToken
|
|
2156
|
+
})
|
|
2157
|
+
);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
1928
2160
|
// src/archive/archive.ts
|
|
1929
2161
|
var WikiGraphArchiveExistsError = class extends Error {
|
|
1930
2162
|
code = "WIKI_GRAPH_ARCHIVE_EXISTS";
|
|
@@ -2012,6 +2244,14 @@ var WikiGraphArchiveHandle = class {
|
|
|
2012
2244
|
get target() {
|
|
2013
2245
|
return this.#location.target;
|
|
2014
2246
|
}
|
|
2247
|
+
async #persistCursor(cursor) {
|
|
2248
|
+
return await this.#runtime.run(
|
|
2249
|
+
async () => await createContinuationCursor(cursor)
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
async #releaseCursor(cursor) {
|
|
2253
|
+
await this.#runtime.run(async () => await deleteContinuationCursor(cursor));
|
|
2254
|
+
}
|
|
2015
2255
|
async inspect(options = {}) {
|
|
2016
2256
|
return await this.#readDocument(
|
|
2017
2257
|
async (document) => await inspectWikiGraphArchive(document, {
|
|
@@ -2026,7 +2266,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2026
2266
|
options.queryMode,
|
|
2027
2267
|
options.signal
|
|
2028
2268
|
);
|
|
2029
|
-
|
|
2269
|
+
const result = await this.#writeDocument(
|
|
2030
2270
|
async (document) => {
|
|
2031
2271
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2032
2272
|
embeddingProvider
|
|
@@ -2047,9 +2287,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
2047
2287
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2048
2288
|
}
|
|
2049
2289
|
);
|
|
2290
|
+
return createArchiveFindPage(
|
|
2291
|
+
result,
|
|
2292
|
+
async (cursor, nextOptions) => await this.search(query, {
|
|
2293
|
+
...options,
|
|
2294
|
+
cursor,
|
|
2295
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2296
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2297
|
+
}),
|
|
2298
|
+
(cursor) => this.#persistCursor({
|
|
2299
|
+
archiveKey: this.archiveKey,
|
|
2300
|
+
archivePath: this.path,
|
|
2301
|
+
chapters: options.chapters ?? null,
|
|
2302
|
+
cursor,
|
|
2303
|
+
format: "json",
|
|
2304
|
+
indexScope: this.indexScope,
|
|
2305
|
+
kind: "search",
|
|
2306
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2307
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2308
|
+
...options.match === void 0 ? {} : { match: options.match },
|
|
2309
|
+
...options.order === void 0 ? {} : { order: options.order },
|
|
2310
|
+
query,
|
|
2311
|
+
...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
|
|
2312
|
+
...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
|
|
2313
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2314
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2315
|
+
types: options.types ?? null
|
|
2316
|
+
}),
|
|
2317
|
+
(token) => this.#releaseCursor(token)
|
|
2318
|
+
);
|
|
2050
2319
|
}
|
|
2051
2320
|
async list(options = {}) {
|
|
2052
|
-
|
|
2321
|
+
const result = await this.#readDocument(async (document) => {
|
|
2053
2322
|
if (isSourceLocatorScopeUri(this.objectUri)) {
|
|
2054
2323
|
return await listArchiveSourceLocators(document, this.objectUri, {
|
|
2055
2324
|
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
@@ -2062,6 +2331,53 @@ var WikiGraphArchiveHandle = class {
|
|
|
2062
2331
|
...chapters === void 0 ? {} : { chapters }
|
|
2063
2332
|
});
|
|
2064
2333
|
}, options);
|
|
2334
|
+
if (isSourceLocatorScopeUri(this.objectUri)) {
|
|
2335
|
+
return createArchiveSourceLocatorPage(
|
|
2336
|
+
result,
|
|
2337
|
+
async (cursor, nextOptions) => await this.list({
|
|
2338
|
+
...options,
|
|
2339
|
+
cursor,
|
|
2340
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2341
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2342
|
+
}),
|
|
2343
|
+
(cursor) => this.#persistCursor({
|
|
2344
|
+
archiveKey: this.archiveKey,
|
|
2345
|
+
archivePath: this.path,
|
|
2346
|
+
cursor,
|
|
2347
|
+
format: "json",
|
|
2348
|
+
indexScope: this.indexScope,
|
|
2349
|
+
kind: "source-locators",
|
|
2350
|
+
targetUri: this.objectUri
|
|
2351
|
+
}),
|
|
2352
|
+
(token) => this.#releaseCursor(token)
|
|
2353
|
+
);
|
|
2354
|
+
}
|
|
2355
|
+
return createArchiveCollectionPage(
|
|
2356
|
+
result,
|
|
2357
|
+
async (cursor, nextOptions) => await this.list({
|
|
2358
|
+
...options,
|
|
2359
|
+
cursor,
|
|
2360
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2361
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2362
|
+
}),
|
|
2363
|
+
(cursor) => this.#persistCursor({
|
|
2364
|
+
archiveKey: this.archiveKey,
|
|
2365
|
+
archivePath: this.path,
|
|
2366
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2367
|
+
chapters: options.chapters ?? null,
|
|
2368
|
+
cursor,
|
|
2369
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2370
|
+
format: "json",
|
|
2371
|
+
ids: options.ids ?? null,
|
|
2372
|
+
indexScope: this.indexScope,
|
|
2373
|
+
kind: "collection",
|
|
2374
|
+
order: options.order ?? "doc-asc",
|
|
2375
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2376
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2377
|
+
types: options.types ?? null
|
|
2378
|
+
}),
|
|
2379
|
+
(token) => this.#releaseCursor(token)
|
|
2380
|
+
);
|
|
2065
2381
|
}
|
|
2066
2382
|
async ensureSearchIndex(options = {}) {
|
|
2067
2383
|
const embeddingProvider = await this.#runtime.run(
|
|
@@ -2338,19 +2654,30 @@ var WikiGraphArchiveHandle = class {
|
|
|
2338
2654
|
if (options.queryMode !== void 0) {
|
|
2339
2655
|
throw new Error("`queryMode` requires `query`.");
|
|
2340
2656
|
}
|
|
2341
|
-
|
|
2657
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2342
2658
|
const chapters = await this.#resolveScope(document, {});
|
|
2343
2659
|
return await listRelatedArchiveObjects(document, objectUri, {
|
|
2344
2660
|
...withoutOperation(options),
|
|
2345
2661
|
...chapters === void 0 ? {} : { chapters }
|
|
2346
2662
|
});
|
|
2347
2663
|
}, options);
|
|
2664
|
+
return createArchiveRelatedPage(
|
|
2665
|
+
result2,
|
|
2666
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
2667
|
+
...options,
|
|
2668
|
+
cursor,
|
|
2669
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2670
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2671
|
+
}),
|
|
2672
|
+
(cursor) => Promise.resolve(cursor),
|
|
2673
|
+
() => Promise.resolve()
|
|
2674
|
+
);
|
|
2348
2675
|
}
|
|
2349
2676
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2350
2677
|
options.queryMode,
|
|
2351
2678
|
options.signal
|
|
2352
2679
|
);
|
|
2353
|
-
|
|
2680
|
+
const result = await this.#writeDocument(
|
|
2354
2681
|
async (document) => {
|
|
2355
2682
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2356
2683
|
embeddingProvider
|
|
@@ -2370,25 +2697,47 @@ var WikiGraphArchiveHandle = class {
|
|
|
2370
2697
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2371
2698
|
}
|
|
2372
2699
|
);
|
|
2700
|
+
return createArchiveRelatedPage(
|
|
2701
|
+
result,
|
|
2702
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
2703
|
+
...options,
|
|
2704
|
+
cursor,
|
|
2705
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2706
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2707
|
+
}),
|
|
2708
|
+
(cursor) => Promise.resolve(cursor),
|
|
2709
|
+
() => Promise.resolve()
|
|
2710
|
+
);
|
|
2373
2711
|
}
|
|
2374
2712
|
async evidence(objectUri = this.objectUri, options = {}) {
|
|
2375
2713
|
if (options.query === void 0) {
|
|
2376
2714
|
if (options.queryMode !== void 0) {
|
|
2377
2715
|
throw new Error("`queryMode` requires `query`.");
|
|
2378
2716
|
}
|
|
2379
|
-
|
|
2717
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2380
2718
|
const chapters = await this.#resolveScope(document, {});
|
|
2381
2719
|
return await listArchiveEvidence(document, objectUri, {
|
|
2382
2720
|
...withoutOperation(options),
|
|
2383
2721
|
...chapters === void 0 ? {} : { chapters }
|
|
2384
2722
|
});
|
|
2385
2723
|
}, options);
|
|
2724
|
+
return createArchiveEvidencePage(
|
|
2725
|
+
result2,
|
|
2726
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
2727
|
+
...options,
|
|
2728
|
+
cursor,
|
|
2729
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2730
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2731
|
+
}),
|
|
2732
|
+
(cursor) => Promise.resolve(cursor),
|
|
2733
|
+
() => Promise.resolve()
|
|
2734
|
+
);
|
|
2386
2735
|
}
|
|
2387
2736
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2388
2737
|
options.queryMode,
|
|
2389
2738
|
options.signal
|
|
2390
2739
|
);
|
|
2391
|
-
|
|
2740
|
+
const result = await this.#writeDocument(
|
|
2392
2741
|
async (document) => {
|
|
2393
2742
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2394
2743
|
embeddingProvider
|
|
@@ -2408,6 +2757,17 @@ var WikiGraphArchiveHandle = class {
|
|
|
2408
2757
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2409
2758
|
}
|
|
2410
2759
|
);
|
|
2760
|
+
return createArchiveEvidencePage(
|
|
2761
|
+
result,
|
|
2762
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
2763
|
+
...options,
|
|
2764
|
+
cursor,
|
|
2765
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2766
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2767
|
+
}),
|
|
2768
|
+
(cursor) => Promise.resolve(cursor),
|
|
2769
|
+
() => Promise.resolve()
|
|
2770
|
+
);
|
|
2411
2771
|
}
|
|
2412
2772
|
async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
|
|
2413
2773
|
return await this.#readDocument(
|