wiki-graph-sdk 0.8.3 → 0.9.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/README.md +5 -0
- package/dist/archives.cjs +405 -25
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +4 -216
- package/dist/archives.js +409 -25
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +3 -2
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +3 -2
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +22 -9
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +23 -9
- package/dist/default-worker.js.map +1 -1
- package/dist/index-DQzLAnjf.d.ts +346 -0
- package/dist/index.cjs +690 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.js +686 -94
- package/dist/index.js.map +1 -1
- package/dist/maintenance.cjs +3 -2
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +3 -2
- package/dist/maintenance.js.map +1 -1
- package/dist/worker.cjs +22 -9
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +23 -9
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
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,
|
|
@@ -41,6 +43,7 @@ import {
|
|
|
41
43
|
getChapterTree,
|
|
42
44
|
WikiGraph as WikiGraph2,
|
|
43
45
|
WikiGraphArchiveFile as WikiGraphArchiveFile2,
|
|
46
|
+
WikiGraphDirectoryFile as WikiGraphDirectoryFile2,
|
|
44
47
|
TOC_FILE_VERSION,
|
|
45
48
|
writeWikgArchive,
|
|
46
49
|
ObjectMetadataKind
|
|
@@ -1290,6 +1293,9 @@ import {
|
|
|
1290
1293
|
resolveWikiGraphLibrary,
|
|
1291
1294
|
resolveWikiGraphLibraryArchiveFile
|
|
1292
1295
|
} from "wiki-graph-core";
|
|
1296
|
+
function requireWikiGraphArchiveFile(location) {
|
|
1297
|
+
return location.archiveFile;
|
|
1298
|
+
}
|
|
1293
1299
|
var WikiGraphArchiveOwnershipError = class extends Error {
|
|
1294
1300
|
code = "WIKI_GRAPH_ARCHIVE_OWNERSHIP_MISMATCH";
|
|
1295
1301
|
constructor(message) {
|
|
@@ -1406,11 +1412,12 @@ async function findMatchingMembers(libraries, candidate, candidateIdentity) {
|
|
|
1406
1412
|
...library.isDefault ? {} : { publicId: library.publicId }
|
|
1407
1413
|
});
|
|
1408
1414
|
for (const archive of archives) {
|
|
1409
|
-
|
|
1415
|
+
const physical = archive.file ?? archive.directory;
|
|
1416
|
+
if (physical === void 0) continue;
|
|
1410
1417
|
members.push({
|
|
1411
1418
|
archive,
|
|
1412
1419
|
library,
|
|
1413
|
-
memberPath: getNodeResourcePath(
|
|
1420
|
+
memberPath: getNodeResourcePath(physical)
|
|
1414
1421
|
});
|
|
1415
1422
|
}
|
|
1416
1423
|
}
|
|
@@ -1900,17 +1907,30 @@ function formatLocatedChapterUri(archiveUri, chapter) {
|
|
|
1900
1907
|
// src/archive/write.ts
|
|
1901
1908
|
import {
|
|
1902
1909
|
WikiGraphArchiveFile,
|
|
1910
|
+
WikiGraphDirectoryFile,
|
|
1903
1911
|
writeWikiGraphLibraryArchive
|
|
1904
1912
|
} from "wiki-graph-core";
|
|
1905
1913
|
async function writeWikiGraphArchiveLocation(location, operation, options = {}) {
|
|
1906
1914
|
const cacheOnly = options.searchIndexWritebackPolicy === "cache";
|
|
1907
|
-
const write = async (archiveFile = location.archiveFile) =>
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
invalidateContinuationCursors:
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1915
|
+
const write = async (archiveFile = location.archiveFile) => {
|
|
1916
|
+
const writeOptions = {
|
|
1917
|
+
...cacheOnly ? {} : { derivedStateKeys: [location.archiveKey, location.archivePath] },
|
|
1918
|
+
...options.invalidateContinuationCursors === void 0 ? {} : {
|
|
1919
|
+
invalidateContinuationCursors: options.invalidateContinuationCursors
|
|
1920
|
+
},
|
|
1921
|
+
...options.searchIndexWritebackPolicy === void 0 ? {} : { searchIndexWritebackPolicy: options.searchIndexWritebackPolicy }
|
|
1922
|
+
};
|
|
1923
|
+
if (archiveFile.kind === "directory") {
|
|
1924
|
+
return await new WikiGraphDirectoryFile(archiveFile).write(
|
|
1925
|
+
operation,
|
|
1926
|
+
writeOptions
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
return await new WikiGraphArchiveFile(archiveFile).write(
|
|
1930
|
+
operation,
|
|
1931
|
+
writeOptions
|
|
1932
|
+
);
|
|
1933
|
+
};
|
|
1914
1934
|
if (location.libraryArchiveTarget === void 0 || cacheOnly || options.refreshLibraryIndex === false) {
|
|
1915
1935
|
return await write();
|
|
1916
1936
|
}
|
|
@@ -1925,6 +1945,236 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
|
|
|
1925
1945
|
});
|
|
1926
1946
|
}
|
|
1927
1947
|
|
|
1948
|
+
// src/pages.ts
|
|
1949
|
+
function createCursor(implementation) {
|
|
1950
|
+
let released = false;
|
|
1951
|
+
const assertLive = () => {
|
|
1952
|
+
if (released) throw new Error("Cursor has been released.");
|
|
1953
|
+
};
|
|
1954
|
+
return {
|
|
1955
|
+
pageClass: implementation.pageClass,
|
|
1956
|
+
async next(options = {}) {
|
|
1957
|
+
assertLive();
|
|
1958
|
+
return await implementation.next(options);
|
|
1959
|
+
},
|
|
1960
|
+
async token() {
|
|
1961
|
+
assertLive();
|
|
1962
|
+
return await implementation.token();
|
|
1963
|
+
},
|
|
1964
|
+
async release() {
|
|
1965
|
+
if (released) return;
|
|
1966
|
+
released = true;
|
|
1967
|
+
await implementation.release?.();
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
function createPageCursor(implementation) {
|
|
1972
|
+
let token;
|
|
1973
|
+
return createCursor({
|
|
1974
|
+
pageClass: implementation.pageClass,
|
|
1975
|
+
next: async (options) => await implementation.next(implementation.rawCursor, options),
|
|
1976
|
+
token: async () => {
|
|
1977
|
+
token ??= await implementation.createToken(implementation.rawCursor);
|
|
1978
|
+
return token;
|
|
1979
|
+
},
|
|
1980
|
+
release: async () => {
|
|
1981
|
+
if (token !== void 0) await implementation.releaseToken?.(token);
|
|
1982
|
+
token = void 0;
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
// src/result-pages.ts
|
|
1988
|
+
var ArchiveFindPage = class _ArchiveFindPage {
|
|
1989
|
+
result;
|
|
1990
|
+
chapters;
|
|
1991
|
+
items;
|
|
1992
|
+
lens;
|
|
1993
|
+
lensHint;
|
|
1994
|
+
limit;
|
|
1995
|
+
match;
|
|
1996
|
+
rawNextCursor;
|
|
1997
|
+
order;
|
|
1998
|
+
query;
|
|
1999
|
+
terms;
|
|
2000
|
+
types;
|
|
2001
|
+
#cursor;
|
|
2002
|
+
constructor(result, cursor = null) {
|
|
2003
|
+
this.result = result;
|
|
2004
|
+
this.chapters = result.chapters;
|
|
2005
|
+
this.items = result.items;
|
|
2006
|
+
this.lens = result.lens;
|
|
2007
|
+
this.lensHint = result.lensHint;
|
|
2008
|
+
this.limit = result.limit;
|
|
2009
|
+
this.match = result.match;
|
|
2010
|
+
this.rawNextCursor = result.nextCursor;
|
|
2011
|
+
this.order = result.order;
|
|
2012
|
+
this.query = result.query;
|
|
2013
|
+
this.terms = result.terms;
|
|
2014
|
+
this.types = result.types;
|
|
2015
|
+
this.#cursor = cursor;
|
|
2016
|
+
}
|
|
2017
|
+
static pageClass = _ArchiveFindPage;
|
|
2018
|
+
[Symbol.iterator]() {
|
|
2019
|
+
return this.items[Symbol.iterator]();
|
|
2020
|
+
}
|
|
2021
|
+
nextCursor() {
|
|
2022
|
+
return this.#cursor;
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
var ArchiveCollectionPage = class _ArchiveCollectionPage {
|
|
2026
|
+
result;
|
|
2027
|
+
chapters;
|
|
2028
|
+
ids;
|
|
2029
|
+
items;
|
|
2030
|
+
limit;
|
|
2031
|
+
rawNextCursor;
|
|
2032
|
+
order;
|
|
2033
|
+
types;
|
|
2034
|
+
#cursor;
|
|
2035
|
+
constructor(result, cursor = null) {
|
|
2036
|
+
this.result = result;
|
|
2037
|
+
this.chapters = result.chapters;
|
|
2038
|
+
this.ids = result.ids;
|
|
2039
|
+
this.items = result.items;
|
|
2040
|
+
this.limit = result.limit;
|
|
2041
|
+
this.rawNextCursor = result.nextCursor;
|
|
2042
|
+
this.order = result.order;
|
|
2043
|
+
this.types = result.types;
|
|
2044
|
+
this.#cursor = cursor;
|
|
2045
|
+
}
|
|
2046
|
+
static pageClass = _ArchiveCollectionPage;
|
|
2047
|
+
[Symbol.iterator]() {
|
|
2048
|
+
return this.items[Symbol.iterator]();
|
|
2049
|
+
}
|
|
2050
|
+
nextCursor() {
|
|
2051
|
+
return this.#cursor;
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
var ArchiveEvidencePage = class _ArchiveEvidencePage {
|
|
2055
|
+
result;
|
|
2056
|
+
items;
|
|
2057
|
+
limit;
|
|
2058
|
+
rawNextCursor;
|
|
2059
|
+
#cursor;
|
|
2060
|
+
constructor(result, cursor = null) {
|
|
2061
|
+
this.result = result;
|
|
2062
|
+
this.items = result.items;
|
|
2063
|
+
this.limit = result.limit;
|
|
2064
|
+
this.rawNextCursor = result.nextCursor;
|
|
2065
|
+
this.#cursor = cursor;
|
|
2066
|
+
}
|
|
2067
|
+
static pageClass = _ArchiveEvidencePage;
|
|
2068
|
+
[Symbol.iterator]() {
|
|
2069
|
+
return this.items[Symbol.iterator]();
|
|
2070
|
+
}
|
|
2071
|
+
nextCursor() {
|
|
2072
|
+
return this.#cursor;
|
|
2073
|
+
}
|
|
2074
|
+
};
|
|
2075
|
+
var ArchiveRelatedPage = class _ArchiveRelatedPage {
|
|
2076
|
+
result;
|
|
2077
|
+
items;
|
|
2078
|
+
limit;
|
|
2079
|
+
rawNextCursor;
|
|
2080
|
+
#cursor;
|
|
2081
|
+
constructor(result, cursor = null) {
|
|
2082
|
+
this.result = result;
|
|
2083
|
+
this.items = result.items;
|
|
2084
|
+
this.limit = result.limit;
|
|
2085
|
+
this.rawNextCursor = result.nextCursor;
|
|
2086
|
+
this.#cursor = cursor;
|
|
2087
|
+
}
|
|
2088
|
+
static pageClass = _ArchiveRelatedPage;
|
|
2089
|
+
[Symbol.iterator]() {
|
|
2090
|
+
return this.items[Symbol.iterator]();
|
|
2091
|
+
}
|
|
2092
|
+
nextCursor() {
|
|
2093
|
+
return this.#cursor;
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
|
|
2097
|
+
result;
|
|
2098
|
+
items;
|
|
2099
|
+
limit;
|
|
2100
|
+
rawNextCursor;
|
|
2101
|
+
#cursor;
|
|
2102
|
+
constructor(result, cursor = null) {
|
|
2103
|
+
this.result = result;
|
|
2104
|
+
this.items = result.items;
|
|
2105
|
+
this.limit = result.limit;
|
|
2106
|
+
this.rawNextCursor = result.nextCursor;
|
|
2107
|
+
this.#cursor = cursor;
|
|
2108
|
+
}
|
|
2109
|
+
static pageClass = _ArchiveSourceLocatorPage;
|
|
2110
|
+
[Symbol.iterator]() {
|
|
2111
|
+
return this.items[Symbol.iterator]();
|
|
2112
|
+
}
|
|
2113
|
+
nextCursor() {
|
|
2114
|
+
return this.#cursor;
|
|
2115
|
+
}
|
|
2116
|
+
};
|
|
2117
|
+
function createArchiveFindPage(result, next, createToken, releaseToken) {
|
|
2118
|
+
return new ArchiveFindPage(
|
|
2119
|
+
result,
|
|
2120
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2121
|
+
pageClass: ArchiveFindPage,
|
|
2122
|
+
rawCursor: result.nextCursor,
|
|
2123
|
+
next,
|
|
2124
|
+
createToken,
|
|
2125
|
+
releaseToken
|
|
2126
|
+
})
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
function createArchiveCollectionPage(result, next, createToken, releaseToken) {
|
|
2130
|
+
return new ArchiveCollectionPage(
|
|
2131
|
+
result,
|
|
2132
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2133
|
+
pageClass: ArchiveCollectionPage,
|
|
2134
|
+
rawCursor: result.nextCursor,
|
|
2135
|
+
next,
|
|
2136
|
+
createToken,
|
|
2137
|
+
releaseToken
|
|
2138
|
+
})
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
function createArchiveEvidencePage(result, next, createToken, releaseToken) {
|
|
2142
|
+
return new ArchiveEvidencePage(
|
|
2143
|
+
result,
|
|
2144
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2145
|
+
pageClass: ArchiveEvidencePage,
|
|
2146
|
+
rawCursor: result.nextCursor,
|
|
2147
|
+
next,
|
|
2148
|
+
createToken,
|
|
2149
|
+
releaseToken
|
|
2150
|
+
})
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
function createArchiveRelatedPage(result, next, createToken, releaseToken) {
|
|
2154
|
+
return new ArchiveRelatedPage(
|
|
2155
|
+
result,
|
|
2156
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2157
|
+
pageClass: ArchiveRelatedPage,
|
|
2158
|
+
rawCursor: result.nextCursor,
|
|
2159
|
+
next,
|
|
2160
|
+
createToken,
|
|
2161
|
+
releaseToken
|
|
2162
|
+
})
|
|
2163
|
+
);
|
|
2164
|
+
}
|
|
2165
|
+
function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
|
|
2166
|
+
return new ArchiveSourceLocatorPage(
|
|
2167
|
+
result,
|
|
2168
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2169
|
+
pageClass: ArchiveSourceLocatorPage,
|
|
2170
|
+
rawCursor: result.nextCursor,
|
|
2171
|
+
next,
|
|
2172
|
+
createToken,
|
|
2173
|
+
releaseToken
|
|
2174
|
+
})
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
1928
2178
|
// src/archive/archive.ts
|
|
1929
2179
|
var WikiGraphArchiveExistsError = class extends Error {
|
|
1930
2180
|
code = "WIKI_GRAPH_ARCHIVE_EXISTS";
|
|
@@ -2012,6 +2262,14 @@ var WikiGraphArchiveHandle = class {
|
|
|
2012
2262
|
get target() {
|
|
2013
2263
|
return this.#location.target;
|
|
2014
2264
|
}
|
|
2265
|
+
async #persistCursor(cursor) {
|
|
2266
|
+
return await this.#runtime.run(
|
|
2267
|
+
async () => await createContinuationCursor(cursor)
|
|
2268
|
+
);
|
|
2269
|
+
}
|
|
2270
|
+
async #releaseCursor(cursor) {
|
|
2271
|
+
await this.#runtime.run(async () => await deleteContinuationCursor(cursor));
|
|
2272
|
+
}
|
|
2015
2273
|
async inspect(options = {}) {
|
|
2016
2274
|
return await this.#readDocument(
|
|
2017
2275
|
async (document) => await inspectWikiGraphArchive(document, {
|
|
@@ -2026,7 +2284,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2026
2284
|
options.queryMode,
|
|
2027
2285
|
options.signal
|
|
2028
2286
|
);
|
|
2029
|
-
|
|
2287
|
+
const result = await this.#writeDocument(
|
|
2030
2288
|
async (document) => {
|
|
2031
2289
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2032
2290
|
embeddingProvider
|
|
@@ -2047,9 +2305,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
2047
2305
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2048
2306
|
}
|
|
2049
2307
|
);
|
|
2308
|
+
return createArchiveFindPage(
|
|
2309
|
+
result,
|
|
2310
|
+
async (cursor, nextOptions) => await this.search(query, {
|
|
2311
|
+
...options,
|
|
2312
|
+
cursor,
|
|
2313
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2314
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2315
|
+
}),
|
|
2316
|
+
(cursor) => this.#persistCursor({
|
|
2317
|
+
archiveKey: this.archiveKey,
|
|
2318
|
+
archivePath: this.path,
|
|
2319
|
+
chapters: options.chapters ?? null,
|
|
2320
|
+
cursor,
|
|
2321
|
+
format: "json",
|
|
2322
|
+
indexScope: this.indexScope,
|
|
2323
|
+
kind: "search",
|
|
2324
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2325
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2326
|
+
...options.match === void 0 ? {} : { match: options.match },
|
|
2327
|
+
...options.order === void 0 ? {} : { order: options.order },
|
|
2328
|
+
query,
|
|
2329
|
+
...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
|
|
2330
|
+
...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
|
|
2331
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2332
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2333
|
+
types: options.types ?? null
|
|
2334
|
+
}),
|
|
2335
|
+
(token) => this.#releaseCursor(token)
|
|
2336
|
+
);
|
|
2050
2337
|
}
|
|
2051
2338
|
async list(options = {}) {
|
|
2052
|
-
|
|
2339
|
+
const result = await this.#readDocument(async (document) => {
|
|
2053
2340
|
if (isSourceLocatorScopeUri(this.objectUri)) {
|
|
2054
2341
|
return await listArchiveSourceLocators(document, this.objectUri, {
|
|
2055
2342
|
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
@@ -2062,6 +2349,53 @@ var WikiGraphArchiveHandle = class {
|
|
|
2062
2349
|
...chapters === void 0 ? {} : { chapters }
|
|
2063
2350
|
});
|
|
2064
2351
|
}, options);
|
|
2352
|
+
if (isSourceLocatorScopeUri(this.objectUri)) {
|
|
2353
|
+
return createArchiveSourceLocatorPage(
|
|
2354
|
+
result,
|
|
2355
|
+
async (cursor, nextOptions) => await this.list({
|
|
2356
|
+
...options,
|
|
2357
|
+
cursor,
|
|
2358
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2359
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2360
|
+
}),
|
|
2361
|
+
(cursor) => this.#persistCursor({
|
|
2362
|
+
archiveKey: this.archiveKey,
|
|
2363
|
+
archivePath: this.path,
|
|
2364
|
+
cursor,
|
|
2365
|
+
format: "json",
|
|
2366
|
+
indexScope: this.indexScope,
|
|
2367
|
+
kind: "source-locators",
|
|
2368
|
+
targetUri: this.objectUri
|
|
2369
|
+
}),
|
|
2370
|
+
(token) => this.#releaseCursor(token)
|
|
2371
|
+
);
|
|
2372
|
+
}
|
|
2373
|
+
return createArchiveCollectionPage(
|
|
2374
|
+
result,
|
|
2375
|
+
async (cursor, nextOptions) => await this.list({
|
|
2376
|
+
...options,
|
|
2377
|
+
cursor,
|
|
2378
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2379
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2380
|
+
}),
|
|
2381
|
+
(cursor) => this.#persistCursor({
|
|
2382
|
+
archiveKey: this.archiveKey,
|
|
2383
|
+
archivePath: this.path,
|
|
2384
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2385
|
+
chapters: options.chapters ?? null,
|
|
2386
|
+
cursor,
|
|
2387
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2388
|
+
format: "json",
|
|
2389
|
+
ids: options.ids ?? null,
|
|
2390
|
+
indexScope: this.indexScope,
|
|
2391
|
+
kind: "collection",
|
|
2392
|
+
order: options.order ?? "doc-asc",
|
|
2393
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2394
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2395
|
+
types: options.types ?? null
|
|
2396
|
+
}),
|
|
2397
|
+
(token) => this.#releaseCursor(token)
|
|
2398
|
+
);
|
|
2065
2399
|
}
|
|
2066
2400
|
async ensureSearchIndex(options = {}) {
|
|
2067
2401
|
const embeddingProvider = await this.#runtime.run(
|
|
@@ -2250,7 +2584,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2250
2584
|
return await this.#writeDocument(async (document) => {
|
|
2251
2585
|
const chapterId = await resolveChapterPathReadonly(document, path);
|
|
2252
2586
|
await assertChapterResetAllowed(
|
|
2253
|
-
this.#location
|
|
2587
|
+
requireWikiGraphArchiveFile(this.#location),
|
|
2254
2588
|
chapterId,
|
|
2255
2589
|
stage
|
|
2256
2590
|
);
|
|
@@ -2338,19 +2672,30 @@ var WikiGraphArchiveHandle = class {
|
|
|
2338
2672
|
if (options.queryMode !== void 0) {
|
|
2339
2673
|
throw new Error("`queryMode` requires `query`.");
|
|
2340
2674
|
}
|
|
2341
|
-
|
|
2675
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2342
2676
|
const chapters = await this.#resolveScope(document, {});
|
|
2343
2677
|
return await listRelatedArchiveObjects(document, objectUri, {
|
|
2344
2678
|
...withoutOperation(options),
|
|
2345
2679
|
...chapters === void 0 ? {} : { chapters }
|
|
2346
2680
|
});
|
|
2347
2681
|
}, options);
|
|
2682
|
+
return createArchiveRelatedPage(
|
|
2683
|
+
result2,
|
|
2684
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
2685
|
+
...options,
|
|
2686
|
+
cursor,
|
|
2687
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2688
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2689
|
+
}),
|
|
2690
|
+
(cursor) => Promise.resolve(cursor),
|
|
2691
|
+
() => Promise.resolve()
|
|
2692
|
+
);
|
|
2348
2693
|
}
|
|
2349
2694
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2350
2695
|
options.queryMode,
|
|
2351
2696
|
options.signal
|
|
2352
2697
|
);
|
|
2353
|
-
|
|
2698
|
+
const result = await this.#writeDocument(
|
|
2354
2699
|
async (document) => {
|
|
2355
2700
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2356
2701
|
embeddingProvider
|
|
@@ -2370,25 +2715,47 @@ var WikiGraphArchiveHandle = class {
|
|
|
2370
2715
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2371
2716
|
}
|
|
2372
2717
|
);
|
|
2718
|
+
return createArchiveRelatedPage(
|
|
2719
|
+
result,
|
|
2720
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
2721
|
+
...options,
|
|
2722
|
+
cursor,
|
|
2723
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2724
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2725
|
+
}),
|
|
2726
|
+
(cursor) => Promise.resolve(cursor),
|
|
2727
|
+
() => Promise.resolve()
|
|
2728
|
+
);
|
|
2373
2729
|
}
|
|
2374
2730
|
async evidence(objectUri = this.objectUri, options = {}) {
|
|
2375
2731
|
if (options.query === void 0) {
|
|
2376
2732
|
if (options.queryMode !== void 0) {
|
|
2377
2733
|
throw new Error("`queryMode` requires `query`.");
|
|
2378
2734
|
}
|
|
2379
|
-
|
|
2735
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2380
2736
|
const chapters = await this.#resolveScope(document, {});
|
|
2381
2737
|
return await listArchiveEvidence(document, objectUri, {
|
|
2382
2738
|
...withoutOperation(options),
|
|
2383
2739
|
...chapters === void 0 ? {} : { chapters }
|
|
2384
2740
|
});
|
|
2385
2741
|
}, options);
|
|
2742
|
+
return createArchiveEvidencePage(
|
|
2743
|
+
result2,
|
|
2744
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
2745
|
+
...options,
|
|
2746
|
+
cursor,
|
|
2747
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2748
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2749
|
+
}),
|
|
2750
|
+
(cursor) => Promise.resolve(cursor),
|
|
2751
|
+
() => Promise.resolve()
|
|
2752
|
+
);
|
|
2386
2753
|
}
|
|
2387
2754
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2388
2755
|
options.queryMode,
|
|
2389
2756
|
options.signal
|
|
2390
2757
|
);
|
|
2391
|
-
|
|
2758
|
+
const result = await this.#writeDocument(
|
|
2392
2759
|
async (document) => {
|
|
2393
2760
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2394
2761
|
embeddingProvider
|
|
@@ -2408,6 +2775,17 @@ var WikiGraphArchiveHandle = class {
|
|
|
2408
2775
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2409
2776
|
}
|
|
2410
2777
|
);
|
|
2778
|
+
return createArchiveEvidencePage(
|
|
2779
|
+
result,
|
|
2780
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
2781
|
+
...options,
|
|
2782
|
+
cursor,
|
|
2783
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2784
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2785
|
+
}),
|
|
2786
|
+
(cursor) => Promise.resolve(cursor),
|
|
2787
|
+
() => Promise.resolve()
|
|
2788
|
+
);
|
|
2411
2789
|
}
|
|
2412
2790
|
async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
|
|
2413
2791
|
return await this.#readDocument(
|
|
@@ -2452,14 +2830,18 @@ var WikiGraphArchiveHandle = class {
|
|
|
2452
2830
|
}, options);
|
|
2453
2831
|
}
|
|
2454
2832
|
async readCover(options = {}) {
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2833
|
+
return await this.#runtime.run(async () => {
|
|
2834
|
+
if (this.#location.archiveFile.kind === "directory") {
|
|
2835
|
+
return await this.#readDocument(
|
|
2836
|
+
async (document) => await document.readCover()
|
|
2837
|
+
);
|
|
2838
|
+
}
|
|
2839
|
+
const app = new WikiGraph2({});
|
|
2840
|
+
return await app.openSession(
|
|
2458
2841
|
this.#location.archiveFile,
|
|
2459
2842
|
async (archive) => await archive.readCover()
|
|
2460
|
-
)
|
|
2461
|
-
|
|
2462
|
-
);
|
|
2843
|
+
);
|
|
2844
|
+
}, options.signal);
|
|
2463
2845
|
}
|
|
2464
2846
|
async replaceMetadata(objectPath, value, options = {}) {
|
|
2465
2847
|
return await this.#writeDocument(async (document) => {
|
|
@@ -2500,9 +2882,11 @@ var WikiGraphArchiveHandle = class {
|
|
|
2500
2882
|
}
|
|
2501
2883
|
async #readDocument(operation, options = {}) {
|
|
2502
2884
|
return await this.#runtime.run(
|
|
2503
|
-
async () =>
|
|
2504
|
-
|
|
2505
|
-
)
|
|
2885
|
+
async () => this.#location.archiveFile.kind === "directory" ? await new WikiGraphDirectoryFile2(
|
|
2886
|
+
this.#location.archiveFile
|
|
2887
|
+
).readDocument(operation) : await new WikiGraphArchiveFile2(
|
|
2888
|
+
this.#location.archiveFile
|
|
2889
|
+
).readDocument(operation),
|
|
2506
2890
|
options.signal
|
|
2507
2891
|
);
|
|
2508
2892
|
}
|