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 CHANGED
@@ -78,6 +78,11 @@ Job event subscriptions observe durable work without coupling observation to
78
78
  cancellation. Call `job.cancel()` explicitly to cancel a job; unsubscribing
79
79
  only stops the current listener.
80
80
 
81
+ `libraries.searchBuckets()` projects one shared search session into typed,
82
+ independently paginated buckets. Continue one bucket with
83
+ `libraries.continueSearchBucket()`; sibling cursors remain unchanged. The
84
+ existing `libraries.search()` API keeps its sequential single-cursor result.
85
+
81
86
  Services that receive chapter job artifacts as files can apply an ordered,
82
87
  lazy sequence through the Node delivery boundary without importing Core:
83
88
 
package/dist/archives.cjs CHANGED
@@ -1273,6 +1273,9 @@ function resolveWikiGraphRuntimePath(path) {
1273
1273
  var import_promises3 = require("fs/promises");
1274
1274
  var import_path3 = require("path");
1275
1275
  var import_wiki_graph_core2 = require("wiki-graph-core");
1276
+ function requireWikiGraphArchiveFile(location) {
1277
+ return location.archiveFile;
1278
+ }
1276
1279
  var WikiGraphArchiveOwnershipError = class extends Error {
1277
1280
  code = "WIKI_GRAPH_ARCHIVE_OWNERSHIP_MISMATCH";
1278
1281
  constructor(message) {
@@ -1389,11 +1392,12 @@ async function findMatchingMembers(libraries, candidate, candidateIdentity) {
1389
1392
  ...library.isDefault ? {} : { publicId: library.publicId }
1390
1393
  });
1391
1394
  for (const archive of archives) {
1392
- if (archive.file === void 0) continue;
1395
+ const physical = archive.file ?? archive.directory;
1396
+ if (physical === void 0) continue;
1393
1397
  members.push({
1394
1398
  archive,
1395
1399
  library,
1396
- memberPath: getNodeResourcePath(archive.file)
1400
+ memberPath: getNodeResourcePath(physical)
1397
1401
  });
1398
1402
  }
1399
1403
  }
@@ -1879,13 +1883,25 @@ function formatLocatedChapterUri(archiveUri, chapter) {
1879
1883
  var import_wiki_graph_core6 = require("wiki-graph-core");
1880
1884
  async function writeWikiGraphArchiveLocation(location, operation, options = {}) {
1881
1885
  const cacheOnly = options.searchIndexWritebackPolicy === "cache";
1882
- const write = async (archiveFile = location.archiveFile) => await new import_wiki_graph_core6.WikiGraphArchiveFile(archiveFile).write(operation, {
1883
- ...cacheOnly ? {} : { derivedStateKeys: [location.archiveKey, location.archivePath] },
1884
- ...options.invalidateContinuationCursors === void 0 ? {} : {
1885
- invalidateContinuationCursors: options.invalidateContinuationCursors
1886
- },
1887
- ...options.searchIndexWritebackPolicy === void 0 ? {} : { searchIndexWritebackPolicy: options.searchIndexWritebackPolicy }
1888
- });
1886
+ const write = async (archiveFile = location.archiveFile) => {
1887
+ const writeOptions = {
1888
+ ...cacheOnly ? {} : { derivedStateKeys: [location.archiveKey, location.archivePath] },
1889
+ ...options.invalidateContinuationCursors === void 0 ? {} : {
1890
+ invalidateContinuationCursors: options.invalidateContinuationCursors
1891
+ },
1892
+ ...options.searchIndexWritebackPolicy === void 0 ? {} : { searchIndexWritebackPolicy: options.searchIndexWritebackPolicy }
1893
+ };
1894
+ if (archiveFile.kind === "directory") {
1895
+ return await new import_wiki_graph_core6.WikiGraphDirectoryFile(archiveFile).write(
1896
+ operation,
1897
+ writeOptions
1898
+ );
1899
+ }
1900
+ return await new import_wiki_graph_core6.WikiGraphArchiveFile(archiveFile).write(
1901
+ operation,
1902
+ writeOptions
1903
+ );
1904
+ };
1889
1905
  if (location.libraryArchiveTarget === void 0 || cacheOnly || options.refreshLibraryIndex === false) {
1890
1906
  return await write();
1891
1907
  }
@@ -1900,6 +1916,236 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
1900
1916
  });
1901
1917
  }
1902
1918
 
1919
+ // src/pages.ts
1920
+ function createCursor(implementation) {
1921
+ let released = false;
1922
+ const assertLive = () => {
1923
+ if (released) throw new Error("Cursor has been released.");
1924
+ };
1925
+ return {
1926
+ pageClass: implementation.pageClass,
1927
+ async next(options = {}) {
1928
+ assertLive();
1929
+ return await implementation.next(options);
1930
+ },
1931
+ async token() {
1932
+ assertLive();
1933
+ return await implementation.token();
1934
+ },
1935
+ async release() {
1936
+ if (released) return;
1937
+ released = true;
1938
+ await implementation.release?.();
1939
+ }
1940
+ };
1941
+ }
1942
+ function createPageCursor(implementation) {
1943
+ let token;
1944
+ return createCursor({
1945
+ pageClass: implementation.pageClass,
1946
+ next: async (options) => await implementation.next(implementation.rawCursor, options),
1947
+ token: async () => {
1948
+ token ??= await implementation.createToken(implementation.rawCursor);
1949
+ return token;
1950
+ },
1951
+ release: async () => {
1952
+ if (token !== void 0) await implementation.releaseToken?.(token);
1953
+ token = void 0;
1954
+ }
1955
+ });
1956
+ }
1957
+
1958
+ // src/result-pages.ts
1959
+ var ArchiveFindPage = class _ArchiveFindPage {
1960
+ result;
1961
+ chapters;
1962
+ items;
1963
+ lens;
1964
+ lensHint;
1965
+ limit;
1966
+ match;
1967
+ rawNextCursor;
1968
+ order;
1969
+ query;
1970
+ terms;
1971
+ types;
1972
+ #cursor;
1973
+ constructor(result, cursor = null) {
1974
+ this.result = result;
1975
+ this.chapters = result.chapters;
1976
+ this.items = result.items;
1977
+ this.lens = result.lens;
1978
+ this.lensHint = result.lensHint;
1979
+ this.limit = result.limit;
1980
+ this.match = result.match;
1981
+ this.rawNextCursor = result.nextCursor;
1982
+ this.order = result.order;
1983
+ this.query = result.query;
1984
+ this.terms = result.terms;
1985
+ this.types = result.types;
1986
+ this.#cursor = cursor;
1987
+ }
1988
+ static pageClass = _ArchiveFindPage;
1989
+ [Symbol.iterator]() {
1990
+ return this.items[Symbol.iterator]();
1991
+ }
1992
+ nextCursor() {
1993
+ return this.#cursor;
1994
+ }
1995
+ };
1996
+ var ArchiveCollectionPage = class _ArchiveCollectionPage {
1997
+ result;
1998
+ chapters;
1999
+ ids;
2000
+ items;
2001
+ limit;
2002
+ rawNextCursor;
2003
+ order;
2004
+ types;
2005
+ #cursor;
2006
+ constructor(result, cursor = null) {
2007
+ this.result = result;
2008
+ this.chapters = result.chapters;
2009
+ this.ids = result.ids;
2010
+ this.items = result.items;
2011
+ this.limit = result.limit;
2012
+ this.rawNextCursor = result.nextCursor;
2013
+ this.order = result.order;
2014
+ this.types = result.types;
2015
+ this.#cursor = cursor;
2016
+ }
2017
+ static pageClass = _ArchiveCollectionPage;
2018
+ [Symbol.iterator]() {
2019
+ return this.items[Symbol.iterator]();
2020
+ }
2021
+ nextCursor() {
2022
+ return this.#cursor;
2023
+ }
2024
+ };
2025
+ var ArchiveEvidencePage = class _ArchiveEvidencePage {
2026
+ result;
2027
+ items;
2028
+ limit;
2029
+ rawNextCursor;
2030
+ #cursor;
2031
+ constructor(result, cursor = null) {
2032
+ this.result = result;
2033
+ this.items = result.items;
2034
+ this.limit = result.limit;
2035
+ this.rawNextCursor = result.nextCursor;
2036
+ this.#cursor = cursor;
2037
+ }
2038
+ static pageClass = _ArchiveEvidencePage;
2039
+ [Symbol.iterator]() {
2040
+ return this.items[Symbol.iterator]();
2041
+ }
2042
+ nextCursor() {
2043
+ return this.#cursor;
2044
+ }
2045
+ };
2046
+ var ArchiveRelatedPage = class _ArchiveRelatedPage {
2047
+ result;
2048
+ items;
2049
+ limit;
2050
+ rawNextCursor;
2051
+ #cursor;
2052
+ constructor(result, cursor = null) {
2053
+ this.result = result;
2054
+ this.items = result.items;
2055
+ this.limit = result.limit;
2056
+ this.rawNextCursor = result.nextCursor;
2057
+ this.#cursor = cursor;
2058
+ }
2059
+ static pageClass = _ArchiveRelatedPage;
2060
+ [Symbol.iterator]() {
2061
+ return this.items[Symbol.iterator]();
2062
+ }
2063
+ nextCursor() {
2064
+ return this.#cursor;
2065
+ }
2066
+ };
2067
+ var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
2068
+ result;
2069
+ items;
2070
+ limit;
2071
+ rawNextCursor;
2072
+ #cursor;
2073
+ constructor(result, cursor = null) {
2074
+ this.result = result;
2075
+ this.items = result.items;
2076
+ this.limit = result.limit;
2077
+ this.rawNextCursor = result.nextCursor;
2078
+ this.#cursor = cursor;
2079
+ }
2080
+ static pageClass = _ArchiveSourceLocatorPage;
2081
+ [Symbol.iterator]() {
2082
+ return this.items[Symbol.iterator]();
2083
+ }
2084
+ nextCursor() {
2085
+ return this.#cursor;
2086
+ }
2087
+ };
2088
+ function createArchiveFindPage(result, next, createToken, releaseToken) {
2089
+ return new ArchiveFindPage(
2090
+ result,
2091
+ result.nextCursor === null ? null : createPageCursor({
2092
+ pageClass: ArchiveFindPage,
2093
+ rawCursor: result.nextCursor,
2094
+ next,
2095
+ createToken,
2096
+ releaseToken
2097
+ })
2098
+ );
2099
+ }
2100
+ function createArchiveCollectionPage(result, next, createToken, releaseToken) {
2101
+ return new ArchiveCollectionPage(
2102
+ result,
2103
+ result.nextCursor === null ? null : createPageCursor({
2104
+ pageClass: ArchiveCollectionPage,
2105
+ rawCursor: result.nextCursor,
2106
+ next,
2107
+ createToken,
2108
+ releaseToken
2109
+ })
2110
+ );
2111
+ }
2112
+ function createArchiveEvidencePage(result, next, createToken, releaseToken) {
2113
+ return new ArchiveEvidencePage(
2114
+ result,
2115
+ result.nextCursor === null ? null : createPageCursor({
2116
+ pageClass: ArchiveEvidencePage,
2117
+ rawCursor: result.nextCursor,
2118
+ next,
2119
+ createToken,
2120
+ releaseToken
2121
+ })
2122
+ );
2123
+ }
2124
+ function createArchiveRelatedPage(result, next, createToken, releaseToken) {
2125
+ return new ArchiveRelatedPage(
2126
+ result,
2127
+ result.nextCursor === null ? null : createPageCursor({
2128
+ pageClass: ArchiveRelatedPage,
2129
+ rawCursor: result.nextCursor,
2130
+ next,
2131
+ createToken,
2132
+ releaseToken
2133
+ })
2134
+ );
2135
+ }
2136
+ function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
2137
+ return new ArchiveSourceLocatorPage(
2138
+ result,
2139
+ result.nextCursor === null ? null : createPageCursor({
2140
+ pageClass: ArchiveSourceLocatorPage,
2141
+ rawCursor: result.nextCursor,
2142
+ next,
2143
+ createToken,
2144
+ releaseToken
2145
+ })
2146
+ );
2147
+ }
2148
+
1903
2149
  // src/archive/archive.ts
1904
2150
  var WikiGraphArchiveExistsError = class extends Error {
1905
2151
  code = "WIKI_GRAPH_ARCHIVE_EXISTS";
@@ -1987,6 +2233,14 @@ var WikiGraphArchiveHandle = class {
1987
2233
  get target() {
1988
2234
  return this.#location.target;
1989
2235
  }
2236
+ async #persistCursor(cursor) {
2237
+ return await this.#runtime.run(
2238
+ async () => await (0, import_wiki_graph_core7.createContinuationCursor)(cursor)
2239
+ );
2240
+ }
2241
+ async #releaseCursor(cursor) {
2242
+ await this.#runtime.run(async () => await (0, import_wiki_graph_core7.deleteContinuationCursor)(cursor));
2243
+ }
1990
2244
  async inspect(options = {}) {
1991
2245
  return await this.#readDocument(
1992
2246
  async (document) => await inspectWikiGraphArchive(document, {
@@ -2001,7 +2255,7 @@ var WikiGraphArchiveHandle = class {
2001
2255
  options.queryMode,
2002
2256
  options.signal
2003
2257
  );
2004
- return await this.#writeDocument(
2258
+ const result = await this.#writeDocument(
2005
2259
  async (document) => {
2006
2260
  const chapters = await this.#resolveQueryChapters(document, options, {
2007
2261
  embeddingProvider
@@ -2022,9 +2276,38 @@ var WikiGraphArchiveHandle = class {
2022
2276
  ...options.signal === void 0 ? {} : { signal: options.signal }
2023
2277
  }
2024
2278
  );
2279
+ return createArchiveFindPage(
2280
+ result,
2281
+ async (cursor, nextOptions) => await this.search(query, {
2282
+ ...options,
2283
+ cursor,
2284
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2285
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2286
+ }),
2287
+ (cursor) => this.#persistCursor({
2288
+ archiveKey: this.archiveKey,
2289
+ archivePath: this.path,
2290
+ chapters: options.chapters ?? null,
2291
+ cursor,
2292
+ format: "json",
2293
+ indexScope: this.indexScope,
2294
+ kind: "search",
2295
+ ...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
2296
+ ...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
2297
+ ...options.match === void 0 ? {} : { match: options.match },
2298
+ ...options.order === void 0 ? {} : { order: options.order },
2299
+ query,
2300
+ ...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
2301
+ ...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
2302
+ ...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
2303
+ ...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
2304
+ types: options.types ?? null
2305
+ }),
2306
+ (token) => this.#releaseCursor(token)
2307
+ );
2025
2308
  }
2026
2309
  async list(options = {}) {
2027
- return await this.#readDocument(async (document) => {
2310
+ const result = await this.#readDocument(async (document) => {
2028
2311
  if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
2029
2312
  return await (0, import_wiki_graph_core7.listArchiveSourceLocators)(document, this.objectUri, {
2030
2313
  ...options.cursor === void 0 ? {} : { cursor: options.cursor },
@@ -2037,6 +2320,53 @@ var WikiGraphArchiveHandle = class {
2037
2320
  ...chapters === void 0 ? {} : { chapters }
2038
2321
  });
2039
2322
  }, options);
2323
+ if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
2324
+ return createArchiveSourceLocatorPage(
2325
+ result,
2326
+ async (cursor, nextOptions) => await this.list({
2327
+ ...options,
2328
+ cursor,
2329
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2330
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2331
+ }),
2332
+ (cursor) => this.#persistCursor({
2333
+ archiveKey: this.archiveKey,
2334
+ archivePath: this.path,
2335
+ cursor,
2336
+ format: "json",
2337
+ indexScope: this.indexScope,
2338
+ kind: "source-locators",
2339
+ targetUri: this.objectUri
2340
+ }),
2341
+ (token) => this.#releaseCursor(token)
2342
+ );
2343
+ }
2344
+ return createArchiveCollectionPage(
2345
+ result,
2346
+ async (cursor, nextOptions) => await this.list({
2347
+ ...options,
2348
+ cursor,
2349
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2350
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2351
+ }),
2352
+ (cursor) => this.#persistCursor({
2353
+ archiveKey: this.archiveKey,
2354
+ archivePath: this.path,
2355
+ ...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
2356
+ chapters: options.chapters ?? null,
2357
+ cursor,
2358
+ ...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
2359
+ format: "json",
2360
+ ids: options.ids ?? null,
2361
+ indexScope: this.indexScope,
2362
+ kind: "collection",
2363
+ order: options.order ?? "doc-asc",
2364
+ ...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
2365
+ ...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
2366
+ types: options.types ?? null
2367
+ }),
2368
+ (token) => this.#releaseCursor(token)
2369
+ );
2040
2370
  }
2041
2371
  async ensureSearchIndex(options = {}) {
2042
2372
  const embeddingProvider = await this.#runtime.run(
@@ -2225,7 +2555,7 @@ var WikiGraphArchiveHandle = class {
2225
2555
  return await this.#writeDocument(async (document) => {
2226
2556
  const chapterId = await (0, import_wiki_graph_core7.resolveChapterPathReadonly)(document, path);
2227
2557
  await assertChapterResetAllowed(
2228
- this.#location.archiveFile,
2558
+ requireWikiGraphArchiveFile(this.#location),
2229
2559
  chapterId,
2230
2560
  stage
2231
2561
  );
@@ -2313,19 +2643,30 @@ var WikiGraphArchiveHandle = class {
2313
2643
  if (options.queryMode !== void 0) {
2314
2644
  throw new Error("`queryMode` requires `query`.");
2315
2645
  }
2316
- return await this.#readDocument(async (document) => {
2646
+ const result2 = await this.#readDocument(async (document) => {
2317
2647
  const chapters = await this.#resolveScope(document, {});
2318
2648
  return await (0, import_wiki_graph_core7.listRelatedArchiveObjects)(document, objectUri, {
2319
2649
  ...withoutOperation(options),
2320
2650
  ...chapters === void 0 ? {} : { chapters }
2321
2651
  });
2322
2652
  }, options);
2653
+ return createArchiveRelatedPage(
2654
+ result2,
2655
+ async (cursor, nextOptions) => await this.related(objectUri, {
2656
+ ...options,
2657
+ cursor,
2658
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2659
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2660
+ }),
2661
+ (cursor) => Promise.resolve(cursor),
2662
+ () => Promise.resolve()
2663
+ );
2323
2664
  }
2324
2665
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2325
2666
  options.queryMode,
2326
2667
  options.signal
2327
2668
  );
2328
- return await this.#writeDocument(
2669
+ const result = await this.#writeDocument(
2329
2670
  async (document) => {
2330
2671
  const chapters = await this.#resolveQueryChapters(document, options, {
2331
2672
  embeddingProvider
@@ -2345,25 +2686,47 @@ var WikiGraphArchiveHandle = class {
2345
2686
  ...options.signal === void 0 ? {} : { signal: options.signal }
2346
2687
  }
2347
2688
  );
2689
+ return createArchiveRelatedPage(
2690
+ result,
2691
+ async (cursor, nextOptions) => await this.related(objectUri, {
2692
+ ...options,
2693
+ cursor,
2694
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2695
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2696
+ }),
2697
+ (cursor) => Promise.resolve(cursor),
2698
+ () => Promise.resolve()
2699
+ );
2348
2700
  }
2349
2701
  async evidence(objectUri = this.objectUri, options = {}) {
2350
2702
  if (options.query === void 0) {
2351
2703
  if (options.queryMode !== void 0) {
2352
2704
  throw new Error("`queryMode` requires `query`.");
2353
2705
  }
2354
- return await this.#readDocument(async (document) => {
2706
+ const result2 = await this.#readDocument(async (document) => {
2355
2707
  const chapters = await this.#resolveScope(document, {});
2356
2708
  return await (0, import_wiki_graph_core7.listArchiveEvidence)(document, objectUri, {
2357
2709
  ...withoutOperation(options),
2358
2710
  ...chapters === void 0 ? {} : { chapters }
2359
2711
  });
2360
2712
  }, options);
2713
+ return createArchiveEvidencePage(
2714
+ result2,
2715
+ async (cursor, nextOptions) => await this.evidence(objectUri, {
2716
+ ...options,
2717
+ cursor,
2718
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2719
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2720
+ }),
2721
+ (cursor) => Promise.resolve(cursor),
2722
+ () => Promise.resolve()
2723
+ );
2361
2724
  }
2362
2725
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2363
2726
  options.queryMode,
2364
2727
  options.signal
2365
2728
  );
2366
- return await this.#writeDocument(
2729
+ const result = await this.#writeDocument(
2367
2730
  async (document) => {
2368
2731
  const chapters = await this.#resolveQueryChapters(document, options, {
2369
2732
  embeddingProvider
@@ -2383,6 +2746,17 @@ var WikiGraphArchiveHandle = class {
2383
2746
  ...options.signal === void 0 ? {} : { signal: options.signal }
2384
2747
  }
2385
2748
  );
2749
+ return createArchiveEvidencePage(
2750
+ result,
2751
+ async (cursor, nextOptions) => await this.evidence(objectUri, {
2752
+ ...options,
2753
+ cursor,
2754
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2755
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2756
+ }),
2757
+ (cursor) => Promise.resolve(cursor),
2758
+ () => Promise.resolve()
2759
+ );
2386
2760
  }
2387
2761
  async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
2388
2762
  return await this.#readDocument(
@@ -2427,14 +2801,18 @@ var WikiGraphArchiveHandle = class {
2427
2801
  }, options);
2428
2802
  }
2429
2803
  async readCover(options = {}) {
2430
- const app = new import_wiki_graph_core7.WikiGraph({});
2431
- return await this.#runtime.run(
2432
- async () => await app.openSession(
2804
+ return await this.#runtime.run(async () => {
2805
+ if (this.#location.archiveFile.kind === "directory") {
2806
+ return await this.#readDocument(
2807
+ async (document) => await document.readCover()
2808
+ );
2809
+ }
2810
+ const app = new import_wiki_graph_core7.WikiGraph({});
2811
+ return await app.openSession(
2433
2812
  this.#location.archiveFile,
2434
2813
  async (archive) => await archive.readCover()
2435
- ),
2436
- options.signal
2437
- );
2814
+ );
2815
+ }, options.signal);
2438
2816
  }
2439
2817
  async replaceMetadata(objectPath, value, options = {}) {
2440
2818
  return await this.#writeDocument(async (document) => {
@@ -2475,9 +2853,11 @@ var WikiGraphArchiveHandle = class {
2475
2853
  }
2476
2854
  async #readDocument(operation, options = {}) {
2477
2855
  return await this.#runtime.run(
2478
- async () => await new import_wiki_graph_core7.WikiGraphArchiveFile(this.#location.archiveFile).readDocument(
2479
- operation
2480
- ),
2856
+ async () => this.#location.archiveFile.kind === "directory" ? await new import_wiki_graph_core7.WikiGraphDirectoryFile(
2857
+ this.#location.archiveFile
2858
+ ).readDocument(operation) : await new import_wiki_graph_core7.WikiGraphArchiveFile(
2859
+ this.#location.archiveFile
2860
+ ).readDocument(operation),
2481
2861
  options.signal
2482
2862
  );
2483
2863
  }