wiki-graph-sdk 0.9.0 → 0.9.2
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/archives.cjs +316 -142
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.js +326 -148
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +268 -99
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +274 -103
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +258 -101
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +264 -105
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs +214 -54
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +214 -54
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +214 -54
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.js +214 -54
- package/dist/gc.js.map +1 -1
- package/dist/index.cjs +354 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +369 -184
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs +214 -54
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +214 -54
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs +264 -97
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +270 -101
- package/dist/maintenance.js.map +1 -1
- package/dist/node-platform.cjs +214 -54
- package/dist/node-platform.cjs.map +1 -1
- package/dist/node-platform.d.ts +2 -0
- package/dist/node-platform.js +214 -54
- package/dist/node-platform.js.map +1 -1
- package/dist/runtime-config.cjs +214 -54
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +214 -54
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs +214 -54
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +214 -54
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +257 -96
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +263 -100
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11,7 +11,9 @@ import { Readable as Readable2 } from "stream";
|
|
|
11
11
|
import {
|
|
12
12
|
addChapter,
|
|
13
13
|
applyChapterTree,
|
|
14
|
-
|
|
14
|
+
assertArchiveQueryReady,
|
|
15
|
+
resolveIndexedArchiveChapterScope,
|
|
16
|
+
ensureWikiGraphArchiveSchemaCurrent,
|
|
15
17
|
assertNoActiveBuildJobConflicts,
|
|
16
18
|
assertNoActiveBuildJobs,
|
|
17
19
|
deleteArchiveSearchSessions,
|
|
@@ -31,7 +33,7 @@ import {
|
|
|
31
33
|
moveChapter,
|
|
32
34
|
packArchiveContext,
|
|
33
35
|
parseLocatedWikiGraphUri as parseLocatedWikiGraphUri2,
|
|
34
|
-
|
|
36
|
+
prepareArchivePage,
|
|
35
37
|
readSearchIndexCapabilityStatus,
|
|
36
38
|
rebuildArchiveSearchIndex,
|
|
37
39
|
removeChapter,
|
|
@@ -162,6 +164,15 @@ var NodeFile = class {
|
|
|
162
164
|
this.name = name;
|
|
163
165
|
}
|
|
164
166
|
path;
|
|
167
|
+
async getPhysicalIdentity() {
|
|
168
|
+
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
169
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
170
|
+
return void 0;
|
|
171
|
+
throw error;
|
|
172
|
+
});
|
|
173
|
+
if (value === void 0) return void 0;
|
|
174
|
+
return `${value.dev}:${value.ino}`;
|
|
175
|
+
}
|
|
165
176
|
kind = "file";
|
|
166
177
|
[NODE_RESOURCE_KIND] = "file";
|
|
167
178
|
identity;
|
|
@@ -286,6 +297,15 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
286
297
|
this.name = pathModule.basename(path);
|
|
287
298
|
}
|
|
288
299
|
path;
|
|
300
|
+
async getPhysicalIdentity() {
|
|
301
|
+
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
302
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
303
|
+
return void 0;
|
|
304
|
+
throw error;
|
|
305
|
+
});
|
|
306
|
+
if (value === void 0) return void 0;
|
|
307
|
+
return `${value.dev}:${value.ino}`;
|
|
308
|
+
}
|
|
289
309
|
kind = "directory";
|
|
290
310
|
[NODE_RESOURCE_KIND] = "directory";
|
|
291
311
|
identity;
|
|
@@ -295,8 +315,10 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
295
315
|
const file = new NodeFile(pathModule.join(this.path, name));
|
|
296
316
|
try {
|
|
297
317
|
return (await fsPromises.stat(file.path)).isFile() ? file : void 0;
|
|
298
|
-
} catch {
|
|
299
|
-
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
320
|
+
return void 0;
|
|
321
|
+
throw error;
|
|
300
322
|
}
|
|
301
323
|
}
|
|
302
324
|
async getLastModified() {
|
|
@@ -314,8 +336,10 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
314
336
|
const directory = new _NodeDirectory(pathModule.join(this.path, name));
|
|
315
337
|
try {
|
|
316
338
|
return (await fsPromises.stat(directory.path)).isDirectory() ? directory : void 0;
|
|
317
|
-
} catch {
|
|
318
|
-
|
|
339
|
+
} catch (error) {
|
|
340
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
341
|
+
return void 0;
|
|
342
|
+
throw error;
|
|
319
343
|
}
|
|
320
344
|
}
|
|
321
345
|
async list() {
|
|
@@ -439,14 +463,23 @@ async function openNativeNodeDatabase(file, flags) {
|
|
|
439
463
|
});
|
|
440
464
|
});
|
|
441
465
|
}
|
|
442
|
-
async function openNodeZip(file) {
|
|
466
|
+
async function openNodeZip(file, options = {}) {
|
|
443
467
|
const path = getBrandedNodeResourcePath(file, "file");
|
|
444
468
|
if (path === void 0) {
|
|
445
469
|
throw new TypeError("The Node ZIP adapter requires a NodeFile");
|
|
446
470
|
}
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
471
|
+
const handle = await fsPromises.open(path, "r");
|
|
472
|
+
let size;
|
|
473
|
+
try {
|
|
474
|
+
size = (await handle.stat()).size;
|
|
475
|
+
} catch (error) {
|
|
476
|
+
await handle.close();
|
|
477
|
+
throw error;
|
|
478
|
+
}
|
|
479
|
+
const open2 = () => new Promise((resolve4, reject) => {
|
|
480
|
+
yauzl.fromRandomAccessReader(
|
|
481
|
+
new NodeZipSource(handle),
|
|
482
|
+
size,
|
|
450
483
|
{ autoClose: false, lazyEntries: true },
|
|
451
484
|
(error, opened) => {
|
|
452
485
|
if (error || opened === void 0)
|
|
@@ -455,63 +488,192 @@ async function openNodeZip(file) {
|
|
|
455
488
|
}
|
|
456
489
|
);
|
|
457
490
|
});
|
|
458
|
-
|
|
459
|
-
(
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
error instanceof Error ? error : new Error("Cannot scan ZIP central directory")
|
|
465
|
-
);
|
|
466
|
-
};
|
|
467
|
-
const resolveEntries = () => {
|
|
468
|
-
zipFile.off("error", rejectAndClose);
|
|
469
|
-
resolve4(discovered);
|
|
470
|
-
};
|
|
471
|
-
zipFile.on("entry", (entry) => {
|
|
472
|
-
if (!entry.fileName.endsWith("/")) {
|
|
473
|
-
discovered.set(entry.fileName, entry);
|
|
474
|
-
}
|
|
475
|
-
zipFile.readEntry();
|
|
476
|
-
});
|
|
477
|
-
zipFile.once("error", rejectAndClose);
|
|
478
|
-
zipFile.once("end", resolveEntries);
|
|
479
|
-
zipFile.readEntry();
|
|
480
|
-
}
|
|
481
|
-
);
|
|
491
|
+
try {
|
|
492
|
+
(await open2()).close();
|
|
493
|
+
} catch (error) {
|
|
494
|
+
await handle.close();
|
|
495
|
+
throw error;
|
|
496
|
+
}
|
|
482
497
|
let closed = false;
|
|
498
|
+
let pending = Promise.resolve();
|
|
499
|
+
let closing;
|
|
500
|
+
const run = (operation) => {
|
|
501
|
+
if (closed)
|
|
502
|
+
return Promise.reject(new Error("Cannot read a closed ZIP archive"));
|
|
503
|
+
const result = pending.then(async () => {
|
|
504
|
+
const zip = await open2();
|
|
505
|
+
try {
|
|
506
|
+
return await operation(zip);
|
|
507
|
+
} finally {
|
|
508
|
+
zip.close();
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
pending = result.then(
|
|
512
|
+
() => void 0,
|
|
513
|
+
() => void 0
|
|
514
|
+
);
|
|
515
|
+
return result;
|
|
516
|
+
};
|
|
517
|
+
const withEntry = (name, operation) => run(async (zip) => {
|
|
518
|
+
let exact;
|
|
519
|
+
let alias;
|
|
520
|
+
let aliasCollision = false;
|
|
521
|
+
await scanNodeZip(zip, (entry) => {
|
|
522
|
+
if (entry.fileName === name) exact = entry;
|
|
523
|
+
if (normalizeNodeZipName(entry.fileName) === name) {
|
|
524
|
+
if (alias !== void 0 && alias.fileName !== entry.fileName)
|
|
525
|
+
aliasCollision = true;
|
|
526
|
+
alias = entry;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
if ((exact === void 0 || options.entryNameMode === "normalized") && aliasCollision) {
|
|
530
|
+
let bestPosition = -1;
|
|
531
|
+
const candidates = await open2();
|
|
532
|
+
try {
|
|
533
|
+
await scanNodeZip(candidates, async (entry) => {
|
|
534
|
+
if (normalizeNodeZipName(entry.fileName) !== name) return;
|
|
535
|
+
const probe = await open2();
|
|
536
|
+
let position = 0;
|
|
537
|
+
try {
|
|
538
|
+
await scanNodeZip(probe, (candidate) => {
|
|
539
|
+
if (candidate.fileName === entry.fileName) return false;
|
|
540
|
+
position++;
|
|
541
|
+
});
|
|
542
|
+
} finally {
|
|
543
|
+
probe.close();
|
|
544
|
+
}
|
|
545
|
+
if (position >= bestPosition) {
|
|
546
|
+
bestPosition = position;
|
|
547
|
+
alias = entry;
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
return await operation(candidates, alias);
|
|
551
|
+
} finally {
|
|
552
|
+
candidates.close();
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return await operation(
|
|
556
|
+
zip,
|
|
557
|
+
options.entryNameMode === "normalized" ? alias : exact ?? alias
|
|
558
|
+
);
|
|
559
|
+
});
|
|
483
560
|
return {
|
|
484
561
|
close: () => {
|
|
485
|
-
if (!closed) zipFile.close();
|
|
486
562
|
closed = true;
|
|
487
|
-
|
|
563
|
+
closing ??= pending.then(() => handle.close());
|
|
564
|
+
return closing;
|
|
488
565
|
},
|
|
489
|
-
copyEntry:
|
|
490
|
-
if (closed) throw new Error("Cannot read a closed ZIP archive");
|
|
491
|
-
const entry = entries.get(name);
|
|
566
|
+
copyEntry: (name, target) => withEntry(name, async (zip, entry) => {
|
|
492
567
|
if (entry === void 0) return false;
|
|
493
|
-
await copyNodeZipEntry(
|
|
568
|
+
await copyNodeZipEntry(zip, entry, target);
|
|
494
569
|
return true;
|
|
495
|
-
},
|
|
496
|
-
getEntrySize: (name) =>
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
listEntries: () =>
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
570
|
+
}),
|
|
571
|
+
getEntrySize: (name) => withEntry(
|
|
572
|
+
name,
|
|
573
|
+
(_zip, entry) => Promise.resolve(entry?.uncompressedSize)
|
|
574
|
+
),
|
|
575
|
+
listEntries: () => run(async (zip) => {
|
|
576
|
+
const names = /* @__PURE__ */ new Set();
|
|
577
|
+
await scanNodeZip(zip, (entry) => {
|
|
578
|
+
names.add(entry.fileName);
|
|
579
|
+
});
|
|
580
|
+
return [...names];
|
|
581
|
+
}),
|
|
582
|
+
readEntryRange: (name, offset, length) => withEntry(name, async (zip, entry) => {
|
|
504
583
|
if (entry === void 0) return void 0;
|
|
505
|
-
return await readNodeZipEntryRange(
|
|
506
|
-
},
|
|
507
|
-
readEntry: async (
|
|
508
|
-
if (closed) throw new Error("Cannot read a closed ZIP archive");
|
|
509
|
-
const entry = entries.get(name);
|
|
584
|
+
return await readNodeZipEntryRange(zip, entry, offset, length);
|
|
585
|
+
}),
|
|
586
|
+
readEntry: (name) => withEntry(name, async (zip, entry) => {
|
|
510
587
|
if (entry === void 0) return void 0;
|
|
511
|
-
return await readNodeZipEntry(
|
|
512
|
-
}
|
|
588
|
+
return await readNodeZipEntry(zip, entry);
|
|
589
|
+
})
|
|
513
590
|
};
|
|
514
591
|
}
|
|
592
|
+
var NodeZipSource = class extends yauzl.RandomAccessReader {
|
|
593
|
+
constructor(handle) {
|
|
594
|
+
super();
|
|
595
|
+
this.handle = handle;
|
|
596
|
+
}
|
|
597
|
+
handle;
|
|
598
|
+
read(buffer, offset, length, position, callback) {
|
|
599
|
+
const read2 = (written) => {
|
|
600
|
+
if (written === length) {
|
|
601
|
+
callback(null);
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
fs.read(
|
|
605
|
+
this.handle.fd,
|
|
606
|
+
buffer,
|
|
607
|
+
offset + written,
|
|
608
|
+
length - written,
|
|
609
|
+
position + written,
|
|
610
|
+
(error, bytesRead) => {
|
|
611
|
+
if (error) callback(error);
|
|
612
|
+
else if (bytesRead === 0)
|
|
613
|
+
callback(new Error("Unexpected end of ZIP file"));
|
|
614
|
+
else read2(written + bytesRead);
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
};
|
|
618
|
+
read2(0);
|
|
619
|
+
}
|
|
620
|
+
_readStreamForRange(start, end) {
|
|
621
|
+
const handle = this.handle;
|
|
622
|
+
return Readable.from(
|
|
623
|
+
(async function* () {
|
|
624
|
+
for (let position = start; position < end; ) {
|
|
625
|
+
const buffer = Buffer.allocUnsafe(
|
|
626
|
+
Math.min(64 * 1024, end - position)
|
|
627
|
+
);
|
|
628
|
+
const { bytesRead } = await handle.read(
|
|
629
|
+
buffer,
|
|
630
|
+
0,
|
|
631
|
+
buffer.length,
|
|
632
|
+
position
|
|
633
|
+
);
|
|
634
|
+
if (bytesRead === 0) return;
|
|
635
|
+
position += bytesRead;
|
|
636
|
+
yield buffer.subarray(0, bytesRead);
|
|
637
|
+
}
|
|
638
|
+
})()
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
function normalizeNodeZipName(name) {
|
|
643
|
+
const normalized = name.replaceAll("\\", "/").trim().split("/").filter((part) => part !== "" && part !== ".").join("/");
|
|
644
|
+
return normalized.split("/").includes("..") ? void 0 : normalized;
|
|
645
|
+
}
|
|
646
|
+
async function scanNodeZip(zip, visit) {
|
|
647
|
+
await new Promise((resolve4, reject) => {
|
|
648
|
+
const cleanup = () => {
|
|
649
|
+
zip.off("entry", onEntry);
|
|
650
|
+
zip.off("end", onEnd);
|
|
651
|
+
zip.off("error", onError);
|
|
652
|
+
};
|
|
653
|
+
const onError = (error) => {
|
|
654
|
+
cleanup();
|
|
655
|
+
reject(error);
|
|
656
|
+
};
|
|
657
|
+
const onEnd = () => {
|
|
658
|
+
cleanup();
|
|
659
|
+
resolve4();
|
|
660
|
+
};
|
|
661
|
+
const onEntry = (entry) => {
|
|
662
|
+
void Promise.resolve().then(() => entry.fileName.endsWith("/") ? void 0 : visit(entry)).then((keepReading) => {
|
|
663
|
+
if (keepReading === false) onEnd();
|
|
664
|
+
else zip.readEntry();
|
|
665
|
+
}).catch(
|
|
666
|
+
(error) => onError(
|
|
667
|
+
error instanceof Error ? error : new Error("Cannot scan ZIP", { cause: error })
|
|
668
|
+
)
|
|
669
|
+
);
|
|
670
|
+
};
|
|
671
|
+
zip.on("entry", onEntry);
|
|
672
|
+
zip.once("end", onEnd);
|
|
673
|
+
zip.once("error", onError);
|
|
674
|
+
zip.readEntry();
|
|
675
|
+
});
|
|
676
|
+
}
|
|
515
677
|
async function copyNodeZipEntry(zipFile, entry, target) {
|
|
516
678
|
const writer = await target.openWriter();
|
|
517
679
|
try {
|
|
@@ -1410,17 +1572,29 @@ function resolveWikiGraphRuntimePath(path) {
|
|
|
1410
1572
|
|
|
1411
1573
|
// src/archive/target.ts
|
|
1412
1574
|
import { realpath, stat as stat2 } from "fs/promises";
|
|
1413
|
-
import { basename as basename2, dirname as dirname2,
|
|
1575
|
+
import { basename as basename2, dirname as dirname2, join as join3, resolve as resolve3 } from "path";
|
|
1414
1576
|
import {
|
|
1415
1577
|
formatLocatedWikiGraphUri,
|
|
1416
1578
|
formatWikiGraphLibraryUri,
|
|
1417
|
-
|
|
1418
|
-
|
|
1579
|
+
findWikiGraphLibraryByPhysicalIdentity,
|
|
1580
|
+
findWikiGraphLibraryArchivePhysicalAliases,
|
|
1419
1581
|
parseLocatedWikiGraphUri,
|
|
1420
1582
|
parseWikiGraphLibraryUri,
|
|
1421
1583
|
resolveWikiGraphLibrary,
|
|
1422
|
-
resolveWikiGraphLibraryArchiveFile
|
|
1584
|
+
resolveWikiGraphLibraryArchiveFile,
|
|
1585
|
+
isWikiGraphSchemaVersionError,
|
|
1586
|
+
WikiGraphSchemaVersionError
|
|
1423
1587
|
} from "wiki-graph-core";
|
|
1588
|
+
function rethrowArchiveSchemaError(error, target) {
|
|
1589
|
+
if (isWikiGraphSchemaVersionError(error) && error.target.kind === "archive") {
|
|
1590
|
+
throw new WikiGraphSchemaVersionError(
|
|
1591
|
+
target.kind === "standalone" ? { kind: "archive", path: resolveWikiGraphRuntimePath(target.path) } : { kind: "library", uri: target.uri.split("/arc/")[0] },
|
|
1592
|
+
error.actualVersion,
|
|
1593
|
+
error.supportedVersion
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
throw error;
|
|
1597
|
+
}
|
|
1424
1598
|
function requireWikiGraphArchiveFile(location) {
|
|
1425
1599
|
return location.archiveFile;
|
|
1426
1600
|
}
|
|
@@ -1441,12 +1615,7 @@ async function assertStandaloneWikiGraphArchivePath(inputPath) {
|
|
|
1441
1615
|
const path = resolveWikiGraphRuntimePath(inputPath);
|
|
1442
1616
|
const candidate = await canonicalPath(path);
|
|
1443
1617
|
const candidateIdentity = await readFileIdentity(path);
|
|
1444
|
-
const
|
|
1445
|
-
const matches = await findMatchingMembers(
|
|
1446
|
-
libraries,
|
|
1447
|
-
candidate,
|
|
1448
|
-
candidateIdentity
|
|
1449
|
-
);
|
|
1618
|
+
const matches = await findMatchingMembers(candidate, candidateIdentity);
|
|
1450
1619
|
if (matches.length > 0) {
|
|
1451
1620
|
const match = requireUnambiguousManagedMatch(path, matches);
|
|
1452
1621
|
throw new WikiGraphArchiveOwnershipError(
|
|
@@ -1455,15 +1624,26 @@ async function assertStandaloneWikiGraphArchivePath(inputPath) {
|
|
|
1455
1624
|
)}: ${path}. Use the library UUID URI ${match.archive.uri} instead.`
|
|
1456
1625
|
);
|
|
1457
1626
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1627
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
1628
|
+
for (const start of [candidate, resolve3(path)]) {
|
|
1629
|
+
for (let parent = dirname2(start); ; parent = dirname2(parent)) {
|
|
1630
|
+
ancestors.add(parent);
|
|
1631
|
+
if (dirname2(parent) === parent) break;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
for (const parent of ancestors) {
|
|
1635
|
+
const identity = await readFileIdentity(parent);
|
|
1636
|
+
const library = await findWikiGraphLibraryByPhysicalIdentity(
|
|
1637
|
+
identity,
|
|
1638
|
+
new NodeDirectory(parent).identity
|
|
1466
1639
|
);
|
|
1640
|
+
if (library !== void 0) {
|
|
1641
|
+
throw new WikiGraphArchiveOwnershipError(
|
|
1642
|
+
`Standalone archive path belongs to registered library ${formatWikiGraphLibraryUri(
|
|
1643
|
+
library.isDefault ? void 0 : library.publicId
|
|
1644
|
+
)}: ${path}. Scan the library, then address the archive by its library UUID URI.`
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1467
1647
|
}
|
|
1468
1648
|
return path;
|
|
1469
1649
|
}
|
|
@@ -1481,11 +1661,7 @@ async function resolveWikiGraphArchiveTarget(file) {
|
|
|
1481
1661
|
const path = getNodeResourcePath(file);
|
|
1482
1662
|
const candidate = await canonicalPath(path);
|
|
1483
1663
|
const candidateIdentity = await readFileIdentity(path);
|
|
1484
|
-
const matches = await findMatchingMembers(
|
|
1485
|
-
await listWikiGraphLibraries(),
|
|
1486
|
-
candidate,
|
|
1487
|
-
candidateIdentity
|
|
1488
|
-
);
|
|
1664
|
+
const matches = await findMatchingMembers(candidate, candidateIdentity);
|
|
1489
1665
|
if (matches.length > 0) {
|
|
1490
1666
|
const match = requireUnambiguousManagedMatch(path, matches);
|
|
1491
1667
|
return { kind: "library", uri: match.archive.uri };
|
|
@@ -1551,48 +1727,35 @@ function withObjectUri(archiveLocator, objectUri) {
|
|
|
1551
1727
|
async function canonicalPath(path) {
|
|
1552
1728
|
try {
|
|
1553
1729
|
return await realpath(path);
|
|
1554
|
-
} catch {
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
if (!(typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")))
|
|
1732
|
+
throw error;
|
|
1555
1733
|
const absolute = resolve3(path);
|
|
1556
1734
|
const parent = dirname2(absolute);
|
|
1557
1735
|
return parent === absolute ? absolute : join3(await canonicalPath(parent), basename2(absolute));
|
|
1558
1736
|
}
|
|
1559
1737
|
}
|
|
1560
|
-
function
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}
|
|
1564
|
-
async function findMatchingMembers(libraries, candidate, candidateIdentity) {
|
|
1738
|
+
async function findMatchingMembers(candidate, candidateIdentity) {
|
|
1739
|
+
if (candidateIdentity === void 0) return [];
|
|
1740
|
+
const archives = await findWikiGraphLibraryArchivePhysicalAliases(candidateIdentity);
|
|
1565
1741
|
const members = [];
|
|
1566
|
-
for (const
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
});
|
|
1572
|
-
for (const archive of archives) {
|
|
1573
|
-
const physical = archive.file ?? archive.directory;
|
|
1574
|
-
if (physical === void 0) continue;
|
|
1742
|
+
for (const archive of archives) {
|
|
1743
|
+
const parsed = parseWikiGraphLibraryUri(archive.libraryUri);
|
|
1744
|
+
const library = await resolveWikiGraphLibrary(parsed);
|
|
1745
|
+
const physical = archive.file ?? archive.directory;
|
|
1746
|
+
if (library !== void 0 && physical !== void 0)
|
|
1575
1747
|
members.push({
|
|
1576
1748
|
archive,
|
|
1577
1749
|
library,
|
|
1578
1750
|
memberPath: getNodeResourcePath(physical)
|
|
1579
1751
|
});
|
|
1580
|
-
}
|
|
1581
1752
|
}
|
|
1582
1753
|
const exact = [];
|
|
1583
1754
|
for (const member of members) {
|
|
1584
|
-
if (await canonicalPath(member.memberPath) === candidate)
|
|
1755
|
+
if (await canonicalPath(member.memberPath) === candidate)
|
|
1585
1756
|
exact.push(member);
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
if (exact.length > 0 || candidateIdentity === void 0) return exact;
|
|
1589
|
-
const identityMatches = [];
|
|
1590
|
-
for (const member of members) {
|
|
1591
|
-
if (await readFileIdentity(member.memberPath) === candidateIdentity) {
|
|
1592
|
-
identityMatches.push(member);
|
|
1593
|
-
}
|
|
1594
1757
|
}
|
|
1595
|
-
return
|
|
1758
|
+
return exact.length > 0 ? exact : members;
|
|
1596
1759
|
}
|
|
1597
1760
|
function requireUnambiguousManagedMatch(path, matches) {
|
|
1598
1761
|
if (matches.length === 1) return matches[0];
|
|
@@ -1604,8 +1767,10 @@ async function readFileIdentity(path) {
|
|
|
1604
1767
|
try {
|
|
1605
1768
|
const value = await stat2(path);
|
|
1606
1769
|
return `${value.dev}:${value.ino}`;
|
|
1607
|
-
} catch {
|
|
1608
|
-
|
|
1770
|
+
} catch (error) {
|
|
1771
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
1772
|
+
return void 0;
|
|
1773
|
+
throw error;
|
|
1609
1774
|
}
|
|
1610
1775
|
}
|
|
1611
1776
|
|
|
@@ -1667,11 +1832,15 @@ var WikiGraphConversionManager = class {
|
|
|
1667
1832
|
if (!("path" in options.input)) {
|
|
1668
1833
|
throw new Error("wikg input requires a file path.");
|
|
1669
1834
|
}
|
|
1835
|
+
const inputPath = options.input.path;
|
|
1670
1836
|
await app.openSession(
|
|
1671
|
-
new NodeFile(
|
|
1672
|
-
await assertStandaloneWikiGraphArchivePath(options.input.path)
|
|
1673
|
-
),
|
|
1837
|
+
new NodeFile(await assertStandaloneWikiGraphArchivePath(inputPath)),
|
|
1674
1838
|
write
|
|
1839
|
+
).catch(
|
|
1840
|
+
(error) => rethrowArchiveSchemaError(error, {
|
|
1841
|
+
kind: "standalone",
|
|
1842
|
+
path: inputPath
|
|
1843
|
+
})
|
|
1675
1844
|
);
|
|
1676
1845
|
} else if ("stream" in options.input) {
|
|
1677
1846
|
await app.digestTextStreamSession(
|
|
@@ -2096,6 +2265,12 @@ import {
|
|
|
2096
2265
|
async function writeWikiGraphArchiveLocation(location, operation, options = {}) {
|
|
2097
2266
|
const cacheOnly = options.searchIndexWritebackPolicy === "cache";
|
|
2098
2267
|
const write = async (archiveFile = location.archiveFile) => {
|
|
2268
|
+
if (cacheOnly) {
|
|
2269
|
+
return await new WikiGraphArchiveFile(archiveFile).readDocument(
|
|
2270
|
+
operation,
|
|
2271
|
+
{ searchIndexWritebackPolicy: "cache" }
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2099
2274
|
const writeOptions = {
|
|
2100
2275
|
...cacheOnly ? {} : { derivedStateKeys: [location.archiveKey, location.archivePath] },
|
|
2101
2276
|
...options.invalidateContinuationCursors === void 0 ? {} : {
|
|
@@ -2471,10 +2646,15 @@ var WikiGraphArchiveManager = class {
|
|
|
2471
2646
|
}, options.signal);
|
|
2472
2647
|
}
|
|
2473
2648
|
async open(target, options = {}) {
|
|
2474
|
-
const location = await this.#runtime.run(
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2649
|
+
const location = await this.#runtime.run(async () => {
|
|
2650
|
+
const location2 = await resolveWikiGraphArchiveLocation(target);
|
|
2651
|
+
try {
|
|
2652
|
+
await ensureWikiGraphArchiveSchemaCurrent(location2.archiveFile);
|
|
2653
|
+
} catch (error) {
|
|
2654
|
+
rethrowArchiveSchemaError(error, target);
|
|
2655
|
+
}
|
|
2656
|
+
return location2;
|
|
2657
|
+
}, options.signal);
|
|
2478
2658
|
return new WikiGraphArchiveHandle(this.#runtime, location);
|
|
2479
2659
|
}
|
|
2480
2660
|
};
|
|
@@ -2525,15 +2705,11 @@ var WikiGraphArchiveHandle = class {
|
|
|
2525
2705
|
options.queryMode,
|
|
2526
2706
|
options.signal
|
|
2527
2707
|
);
|
|
2528
|
-
const result = await this.#
|
|
2708
|
+
const result = await this.#readDocument(
|
|
2529
2709
|
async (document) => {
|
|
2530
2710
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2531
2711
|
embeddingProvider
|
|
2532
2712
|
});
|
|
2533
|
-
await ensureArchiveSearchIndex(document, {
|
|
2534
|
-
...chapters === void 0 ? {} : { chapters },
|
|
2535
|
-
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
2536
|
-
});
|
|
2537
2713
|
return await findArchiveObjects(document, query, {
|
|
2538
2714
|
...withoutOperationAndScope(options),
|
|
2539
2715
|
archiveKey: this.archiveKey,
|
|
@@ -2542,7 +2718,6 @@ var WikiGraphArchiveHandle = class {
|
|
|
2542
2718
|
});
|
|
2543
2719
|
},
|
|
2544
2720
|
{
|
|
2545
|
-
searchIndexWritebackPolicy: "cache",
|
|
2546
2721
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2547
2722
|
}
|
|
2548
2723
|
);
|
|
@@ -2647,6 +2822,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2647
2822
|
async (document) => {
|
|
2648
2823
|
const chapters = await this.#resolveScope(document, options);
|
|
2649
2824
|
await ensureArchiveSearchIndex(document, {
|
|
2825
|
+
rebuild: true,
|
|
2650
2826
|
...chapters === void 0 ? {} : { chapters },
|
|
2651
2827
|
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
2652
2828
|
});
|
|
@@ -2897,13 +3073,16 @@ var WikiGraphArchiveHandle = class {
|
|
|
2897
3073
|
return await this.#runtime.run(
|
|
2898
3074
|
async () => await withConfiguredWikimediaResolver(
|
|
2899
3075
|
objectUri,
|
|
2900
|
-
async (wikimediaOptions) =>
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
3076
|
+
async (wikimediaOptions) => {
|
|
3077
|
+
const read2 = await this.#readDocument(
|
|
3078
|
+
async (document) => await prepareArchivePage(document, objectUri, {
|
|
3079
|
+
...options,
|
|
3080
|
+
...wikimediaOptions
|
|
3081
|
+
}),
|
|
3082
|
+
options
|
|
3083
|
+
);
|
|
3084
|
+
return await read2();
|
|
3085
|
+
}
|
|
2907
3086
|
),
|
|
2908
3087
|
options.signal
|
|
2909
3088
|
);
|
|
@@ -2936,15 +3115,11 @@ var WikiGraphArchiveHandle = class {
|
|
|
2936
3115
|
options.queryMode,
|
|
2937
3116
|
options.signal
|
|
2938
3117
|
);
|
|
2939
|
-
const result = await this.#
|
|
3118
|
+
const result = await this.#readDocument(
|
|
2940
3119
|
async (document) => {
|
|
2941
3120
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2942
3121
|
embeddingProvider
|
|
2943
3122
|
});
|
|
2944
|
-
await ensureArchiveSearchIndex(document, {
|
|
2945
|
-
...chapters === void 0 ? {} : { chapters },
|
|
2946
|
-
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
2947
|
-
});
|
|
2948
3123
|
return await listRelatedArchiveObjects(document, objectUri, {
|
|
2949
3124
|
...withoutOperation(options),
|
|
2950
3125
|
...embeddingProvider === void 0 ? {} : { embeddingProvider },
|
|
@@ -2952,7 +3127,6 @@ var WikiGraphArchiveHandle = class {
|
|
|
2952
3127
|
});
|
|
2953
3128
|
},
|
|
2954
3129
|
{
|
|
2955
|
-
searchIndexWritebackPolicy: "cache",
|
|
2956
3130
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2957
3131
|
}
|
|
2958
3132
|
);
|
|
@@ -2996,15 +3170,11 @@ var WikiGraphArchiveHandle = class {
|
|
|
2996
3170
|
options.queryMode,
|
|
2997
3171
|
options.signal
|
|
2998
3172
|
);
|
|
2999
|
-
const result = await this.#
|
|
3173
|
+
const result = await this.#readDocument(
|
|
3000
3174
|
async (document) => {
|
|
3001
3175
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
3002
3176
|
embeddingProvider
|
|
3003
3177
|
});
|
|
3004
|
-
await ensureArchiveSearchIndex(document, {
|
|
3005
|
-
...chapters === void 0 ? {} : { chapters },
|
|
3006
|
-
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
3007
|
-
});
|
|
3008
3178
|
return await listArchiveEvidence(document, objectUri, {
|
|
3009
3179
|
...withoutOperation(options),
|
|
3010
3180
|
...embeddingProvider === void 0 ? {} : { embeddingProvider },
|
|
@@ -3012,7 +3182,6 @@ var WikiGraphArchiveHandle = class {
|
|
|
3012
3182
|
});
|
|
3013
3183
|
},
|
|
3014
3184
|
{
|
|
3015
|
-
searchIndexWritebackPolicy: "cache",
|
|
3016
3185
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
3017
3186
|
}
|
|
3018
3187
|
);
|
|
@@ -3129,6 +3298,8 @@ var WikiGraphArchiveHandle = class {
|
|
|
3129
3298
|
this.#location.archiveFile
|
|
3130
3299
|
).readDocument(operation),
|
|
3131
3300
|
options.signal
|
|
3301
|
+
).catch(
|
|
3302
|
+
(error) => rethrowArchiveSchemaError(error, this.#location.target)
|
|
3132
3303
|
);
|
|
3133
3304
|
}
|
|
3134
3305
|
async #writeDocument(operation, options = {}) {
|
|
@@ -3140,33 +3311,32 @@ var WikiGraphArchiveHandle = class {
|
|
|
3140
3311
|
searchIndexWritebackPolicy: options.searchIndexWritebackPolicy
|
|
3141
3312
|
}
|
|
3142
3313
|
});
|
|
3143
|
-
}, options.signal)
|
|
3314
|
+
}, options.signal).catch(
|
|
3315
|
+
(error) => rethrowArchiveSchemaError(error, this.#location.target)
|
|
3316
|
+
);
|
|
3144
3317
|
}
|
|
3145
3318
|
async #resolveScope(document, options) {
|
|
3146
3319
|
if (options.chapters !== void 0) return options.chapters;
|
|
3147
3320
|
return (await resolveArchiveScope(document, this.objectUri, options.depth))?.chapterIds;
|
|
3148
3321
|
}
|
|
3149
3322
|
async #resolveQueryChapters(document, options, capabilities) {
|
|
3150
|
-
const
|
|
3323
|
+
const parsed = parseChapterScopePath(this.objectUri);
|
|
3324
|
+
const chapters = options.chapters ?? (parsed === void 0 || parsed.kind === "collection" && options.depth === void 0 ? void 0 : await resolveIndexedArchiveChapterScope(
|
|
3325
|
+
document,
|
|
3326
|
+
parsed.kind === "chapter" ? parsed.chapterPath : void 0,
|
|
3327
|
+
options.depth
|
|
3328
|
+
));
|
|
3151
3329
|
const coverageOptions = {
|
|
3152
3330
|
...chapters === void 0 ? {} : { chapters },
|
|
3153
3331
|
...capabilities.embeddingProvider === void 0 ? {} : { embeddingProvider: capabilities.embeddingProvider },
|
|
3154
3332
|
requireEmbeddingProvider: true,
|
|
3155
3333
|
...options.queryMode === void 0 ? {} : { queryMode: options.queryMode }
|
|
3156
3334
|
};
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
}
|
|
3161
|
-
const queryable = await listArchiveQueryableChapterIds(document, {
|
|
3162
|
-
...coverageOptions
|
|
3335
|
+
await assertArchiveQueryReady(document, {
|
|
3336
|
+
...coverageOptions,
|
|
3337
|
+
...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed }
|
|
3163
3338
|
});
|
|
3164
|
-
|
|
3165
|
-
throw new Error(
|
|
3166
|
-
"Wiki Graph query is not ready. No chapters in this scope have a current FTS artifact or source embedding artifact."
|
|
3167
|
-
);
|
|
3168
|
-
}
|
|
3169
|
-
return queryable;
|
|
3339
|
+
return chapters;
|
|
3170
3340
|
}
|
|
3171
3341
|
async #resolveQueryEmbeddingProvider(queryMode, signal) {
|
|
3172
3342
|
if (queryMode === "fts") return void 0;
|
|
@@ -3185,6 +3355,10 @@ var WikiGraphArchiveHandle = class {
|
|
|
3185
3355
|
async function ensureArchiveSearchIndex(document, options = {}) {
|
|
3186
3356
|
const scope = options.chapters === void 0 ? {} : { chapters: options.chapters };
|
|
3187
3357
|
if (await isArchiveSearchIndexCurrent2(document, scope)) return;
|
|
3358
|
+
if (options.rebuild !== true)
|
|
3359
|
+
throw new Error(
|
|
3360
|
+
"Archive search index is missing or dirty. Run `wg <archive-uri>/index sync` explicitly before querying."
|
|
3361
|
+
);
|
|
3188
3362
|
await rebuildArchiveSearchIndex(document, void 0, {
|
|
3189
3363
|
...scope,
|
|
3190
3364
|
...options.embeddingProvider === void 0 ? {} : { embeddingProvider: options.embeddingProvider }
|
|
@@ -3581,7 +3755,7 @@ async function continueArchiveCursor(cursor, limit) {
|
|
|
3581
3755
|
const location = await resolveWikiGraphArchiveLocation(
|
|
3582
3756
|
archiveTargetFromLogicalLocator(getCursorArchivePath(cursor))
|
|
3583
3757
|
);
|
|
3584
|
-
const
|
|
3758
|
+
const read2 = async (document) => {
|
|
3585
3759
|
switch (cursor.kind) {
|
|
3586
3760
|
case "source-locators":
|
|
3587
3761
|
return await listArchiveSourceLocators2(document, cursor.targetUri, {
|
|
@@ -3627,7 +3801,9 @@ async function continueArchiveCursor(cursor, limit) {
|
|
|
3627
3801
|
});
|
|
3628
3802
|
}
|
|
3629
3803
|
};
|
|
3630
|
-
return location.archiveFile.kind === "directory" ?
|
|
3804
|
+
return await (location.archiveFile.kind === "directory" ? new WikiGraphDirectoryFile3(location.archiveFile).readDocument(read2) : new WikiGraphArchiveFile3(location.archiveFile).readDocument(read2)).catch(
|
|
3805
|
+
(error) => rethrowArchiveSchemaError(error, location.target)
|
|
3806
|
+
);
|
|
3631
3807
|
}
|
|
3632
3808
|
async function continueLibraryCursor(cursor, limit) {
|
|
3633
3809
|
const embeddingProvider = cursor.kind === "evidence" || cursor.kind === "related" ? await resolveCursorEmbeddingProvider(cursor) : void 0;
|
|
@@ -4961,8 +5137,7 @@ async function readQueueReadinessReason(document, chapter, target) {
|
|
|
4961
5137
|
return "planned";
|
|
4962
5138
|
}
|
|
4963
5139
|
if (target === "index-embedding-summary") {
|
|
4964
|
-
|
|
4965
|
-
if (summary === void 0 || summary.trim() === "") {
|
|
5140
|
+
if (chapter.stage !== "summarized") {
|
|
4966
5141
|
return "missing summary";
|
|
4967
5142
|
}
|
|
4968
5143
|
}
|
|
@@ -5022,6 +5197,7 @@ function forwardAbort(source, target) {
|
|
|
5022
5197
|
// src/libraries.ts
|
|
5023
5198
|
import {
|
|
5024
5199
|
addWikiGraphLibraryArchive,
|
|
5200
|
+
ensureWikiGraphArchiveSchemaCurrent as ensureWikiGraphArchiveSchemaCurrent2,
|
|
5025
5201
|
assertWikiGraphLibrarySchemaCurrent,
|
|
5026
5202
|
cleanWikiGraphLibraryIndex,
|
|
5027
5203
|
clearWikiGraphLibraryMetadata,
|
|
@@ -5035,8 +5211,8 @@ import {
|
|
|
5035
5211
|
getWikiGraphLibraryArchive,
|
|
5036
5212
|
getWikiGraphLibraryMetadata,
|
|
5037
5213
|
listRelatedWikiGraphLibraryObjects as listRelatedWikiGraphLibraryObjects2,
|
|
5038
|
-
listWikiGraphLibraries
|
|
5039
|
-
listWikiGraphLibraryArchives
|
|
5214
|
+
listWikiGraphLibraries,
|
|
5215
|
+
listWikiGraphLibraryArchives,
|
|
5040
5216
|
listWikiGraphLibraryArchiveMembers as listWikiGraphLibraryArchiveMembers2,
|
|
5041
5217
|
listWikiGraphLibraryEvidence as listWikiGraphLibraryEvidence2,
|
|
5042
5218
|
listWikiGraphLibraryObjects as listWikiGraphLibraryObjects2,
|
|
@@ -5150,20 +5326,27 @@ var WikiGraphLibraryManager = class {
|
|
|
5150
5326
|
throwIfAborted(options.signal);
|
|
5151
5327
|
const archive = await getWikiGraphLibraryArchive(parsedTarget);
|
|
5152
5328
|
const source = requireReadableLibraryArchiveFile(archive);
|
|
5329
|
+
await ensureWikiGraphArchiveSchemaCurrent2(source).catch(
|
|
5330
|
+
(error) => rethrowArchiveSchemaError(error, {
|
|
5331
|
+
kind: "library",
|
|
5332
|
+
uri: archive.uri
|
|
5333
|
+
})
|
|
5334
|
+
);
|
|
5153
5335
|
let temporaryDirectory;
|
|
5154
|
-
|
|
5155
|
-
temporaryDirectory = await mkdtemp2(
|
|
5156
|
-
join5(tmpdir2(), "wikigraph-library-read-")
|
|
5157
|
-
);
|
|
5158
|
-
const output = new NodeFile(
|
|
5159
|
-
join5(temporaryDirectory, "archive.wikg")
|
|
5160
|
-
);
|
|
5161
|
-
await writeWikgArchive2(source, output);
|
|
5162
|
-
return output;
|
|
5163
|
-
})() : source;
|
|
5164
|
-
const reader = await file.openReader();
|
|
5336
|
+
let reader;
|
|
5165
5337
|
let active = true;
|
|
5166
5338
|
try {
|
|
5339
|
+
const file = source.kind === "directory" ? await (async () => {
|
|
5340
|
+
temporaryDirectory = await mkdtemp2(
|
|
5341
|
+
join5(tmpdir2(), "wikigraph-library-read-")
|
|
5342
|
+
);
|
|
5343
|
+
const output = new NodeFile(
|
|
5344
|
+
join5(temporaryDirectory, "archive.wikg")
|
|
5345
|
+
);
|
|
5346
|
+
await writeWikgArchive2(source, output);
|
|
5347
|
+
return output;
|
|
5348
|
+
})() : source;
|
|
5349
|
+
reader = await file.openReader();
|
|
5167
5350
|
const content = {
|
|
5168
5351
|
mediaType: "application/vnd.wiki-graph.archive",
|
|
5169
5352
|
size: reader.size,
|
|
@@ -5180,9 +5363,12 @@ var WikiGraphLibraryManager = class {
|
|
|
5180
5363
|
);
|
|
5181
5364
|
} finally {
|
|
5182
5365
|
active = false;
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5366
|
+
try {
|
|
5367
|
+
await reader?.close();
|
|
5368
|
+
} finally {
|
|
5369
|
+
if (temporaryDirectory !== void 0)
|
|
5370
|
+
await rm4(temporaryDirectory, { force: true, recursive: true });
|
|
5371
|
+
}
|
|
5186
5372
|
}
|
|
5187
5373
|
},
|
|
5188
5374
|
options.signal === void 0 ? {} : { signal: options.signal }
|
|
@@ -5492,7 +5678,7 @@ var WikiGraphLibraryManager = class {
|
|
|
5492
5678
|
}
|
|
5493
5679
|
async list() {
|
|
5494
5680
|
const records = await this.#runtime.run(
|
|
5495
|
-
async () => await
|
|
5681
|
+
async () => await listWikiGraphLibraries()
|
|
5496
5682
|
);
|
|
5497
5683
|
return records.map((record) => new WikiGraphLibrary(this.#runtime, record));
|
|
5498
5684
|
}
|
|
@@ -5515,7 +5701,7 @@ var WikiGraphLibrary = class {
|
|
|
5515
5701
|
async archives() {
|
|
5516
5702
|
const target = requireLibraryTarget(this.uri);
|
|
5517
5703
|
return (await this.#runtime.run(
|
|
5518
|
-
async () => await
|
|
5704
|
+
async () => await listWikiGraphLibraryArchives(target)
|
|
5519
5705
|
)).map(toArchiveSnapshot);
|
|
5520
5706
|
}
|
|
5521
5707
|
async scan() {
|
|
@@ -5687,7 +5873,9 @@ var WikiGraphMaintenanceManager = class {
|
|
|
5687
5873
|
return await upgradeWikiGraphMaintenanceTarget({
|
|
5688
5874
|
file: new NodeFile(path),
|
|
5689
5875
|
kind: "archive"
|
|
5690
|
-
})
|
|
5876
|
+
}).catch(
|
|
5877
|
+
(error) => rethrowArchiveSchemaError(error, { kind: "standalone", path })
|
|
5878
|
+
);
|
|
5691
5879
|
},
|
|
5692
5880
|
void 0,
|
|
5693
5881
|
{ skipHomeBootstrap: target.kind === "home" }
|
|
@@ -5716,7 +5904,6 @@ function defaultWikgOutputPath(inputPath) {
|
|
|
5716
5904
|
import { ensureWikiGraphHomeSchemaCurrent } from "wiki-graph-core";
|
|
5717
5905
|
var WikiGraphSDK = class {
|
|
5718
5906
|
#context;
|
|
5719
|
-
#homeReady;
|
|
5720
5907
|
archives;
|
|
5721
5908
|
conversions;
|
|
5722
5909
|
config;
|
|
@@ -5747,13 +5934,7 @@ var WikiGraphSDK = class {
|
|
|
5747
5934
|
throwIfAborted2(signal);
|
|
5748
5935
|
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(this.#context, async () => {
|
|
5749
5936
|
if (options.skipHomeBootstrap !== true) {
|
|
5750
|
-
|
|
5751
|
-
(error) => {
|
|
5752
|
-
this.#homeReady = void 0;
|
|
5753
|
-
throw error;
|
|
5754
|
-
}
|
|
5755
|
-
);
|
|
5756
|
-
await this.#homeReady;
|
|
5937
|
+
await ensureWikiGraphHomeSchemaCurrent();
|
|
5757
5938
|
}
|
|
5758
5939
|
return await operation();
|
|
5759
5940
|
});
|
|
@@ -5784,6 +5965,8 @@ import {
|
|
|
5784
5965
|
LLMPaymentRequiredError,
|
|
5785
5966
|
WIKI_GRAPH_URI_PREFIX,
|
|
5786
5967
|
WikiGraphError,
|
|
5968
|
+
WikiGraphSchemaVersionError as WikiGraphSchemaVersionError2,
|
|
5969
|
+
isWikiGraphSchemaVersionError as isWikiGraphSchemaVersionError2,
|
|
5787
5970
|
formatError as formatError3,
|
|
5788
5971
|
formatLocatedChapterResourceUri,
|
|
5789
5972
|
formatLocatedChapterSourceCollectionUri,
|
|
@@ -5840,6 +6023,7 @@ export {
|
|
|
5840
6023
|
WikiGraphLibraryManager,
|
|
5841
6024
|
WikiGraphMaintenanceManager,
|
|
5842
6025
|
WikiGraphSDK,
|
|
6026
|
+
WikiGraphSchemaVersionError2 as WikiGraphSchemaVersionError,
|
|
5843
6027
|
buildSearchIndexEmbeddingProvider,
|
|
5844
6028
|
buildWikiGraphLLMOptions,
|
|
5845
6029
|
clearLocalConfigSection,
|
|
@@ -5882,6 +6066,7 @@ export {
|
|
|
5882
6066
|
isSourceLocatorScopeUri2 as isSourceLocatorScopeUri,
|
|
5883
6067
|
isWikiGraphJobUri,
|
|
5884
6068
|
isWikiGraphLibraryUri,
|
|
6069
|
+
isWikiGraphSchemaVersionError2 as isWikiGraphSchemaVersionError,
|
|
5885
6070
|
isWikiGraphUri,
|
|
5886
6071
|
iterateItems,
|
|
5887
6072
|
iteratePages,
|