wiki-graph-sdk 0.9.4 → 0.9.5
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 +237 -28
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +1 -1
- package/dist/archives.js +240 -28
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +64 -28
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +64 -28
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +64 -28
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +64 -28
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs +64 -28
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +64 -28
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +64 -28
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.js +64 -28
- package/dist/gc.js.map +1 -1
- package/dist/{index-DQzLAnjf.d.ts → index-4YX4dv6Y.d.ts} +38 -2
- package/dist/index.cjs +240 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +243 -31
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs +64 -28
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +64 -28
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs +64 -28
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +64 -28
- package/dist/maintenance.js.map +1 -1
- package/dist/node-platform.cjs +64 -28
- package/dist/node-platform.cjs.map +1 -1
- package/dist/node-platform.js +64 -28
- package/dist/node-platform.js.map +1 -1
- package/dist/runtime-config.cjs +64 -28
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +64 -28
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs +64 -28
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +64 -28
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +64 -28
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +64 -28
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ArchiveFindPage, L as LibraryBucketPage, a as ArchiveCollectionPage, b as ArchiveRelatedPage, c as ArchiveEvidencePage, W as WikiGraphArchiveManager } from './index-
|
|
2
|
-
export { d as ArchiveSourceLocatorPage, C as CursorImplementation, e as CursorNextOptions, I as ICursor, f as IPage, P as PageClass, g as PageCursorImplementation, h as
|
|
1
|
+
import { A as ArchiveFindPage, L as LibraryBucketPage, a as ArchiveCollectionPage, b as ArchiveRelatedPage, c as ArchiveEvidencePage, W as WikiGraphArchiveManager } from './index-4YX4dv6Y.js';
|
|
2
|
+
export { d as ArchiveSourceLocatorPage, C as CursorImplementation, e as CursorNextOptions, I as ICursor, f as IPage, P as PageClass, g as PageCursorImplementation, h as WikiGraphArchiveChapterData, i as WikiGraphArchiveChapterInspection, j as WikiGraphArchiveCover, k as WikiGraphArchiveCreateOptions, l as WikiGraphArchiveCreateResult, m as WikiGraphArchiveEvidenceOptions, n as WikiGraphArchiveExistsError, o as WikiGraphArchiveExportResult, p as WikiGraphArchiveHandle, q as WikiGraphArchiveIndexArtifactInspection, r as WikiGraphArchiveIndexStatus, s as WikiGraphArchiveIndexSyncOptions, t as WikiGraphArchiveInspection, u as WikiGraphArchiveListOptions, v as WikiGraphArchiveOverview, w as WikiGraphArchivePageOptions, x as WikiGraphArchiveRelatedOptions, y as WikiGraphArchiveSchemaInspection, z as WikiGraphArchiveScope, B as WikiGraphArchiveScopeOptions, D as WikiGraphArchiveSearchOptions, E as WikiGraphArchiveTocFile, F as WikiGraphArchiveTocItem, G as WikiGraphArchiveWriteOptions, H as WikiGraphChapterArtifactStatus, J as WikiGraphChapterMoveOptions, K as WikiGraphChapterResetStage, M as WikiGraphChapterSourceOptions, N as WikiGraphChapterTreeInput, O as WikiGraphOperationOptions, Q as createArchiveCollectionPage, R as createArchiveEvidencePage, S as createArchiveFindPage, T as createArchiveRelatedPage, U as createArchiveSourceLocatorPage, V as createCursor, X as createLibraryBucketPage, Y as createPageCursor, Z as inspectWikiGraphArchive, _ as iterateItems, $ as iteratePages } from './index-4YX4dv6Y.js';
|
|
3
3
|
import { W as WikiGraphArchiveTarget } from './target-CZ7elwmj.js';
|
|
4
4
|
export { a as WikiGraphArchiveOwnershipError } from './target-CZ7elwmj.js';
|
|
5
5
|
import { LocalConfigSection, LocalConfigObject } from './local-config.js';
|
|
@@ -7,7 +7,7 @@ export { LOCAL_CONFIG_SECTIONS, clearLocalConfigSection, deleteLocalConfigValue,
|
|
|
7
7
|
import { W as WikiGraphJobRuntime, a as WikiGraphJobManager } from './jobs-CRK-DZ40.js';
|
|
8
8
|
export { b as WikiGraphJob, c as WikiGraphJobBackend, d as WikiGraphJobChapterReference, e as WikiGraphJobCreateOptions, f as WikiGraphJobEnqueueOptions, g as WikiGraphJobEnqueuePlan, h as WikiGraphJobEnqueueResult, i as WikiGraphJobEventListener, j as WikiGraphJobEventsOptions, k as WikiGraphJobListOptions, l as WikiGraphJobSnapshot, m as WikiGraphJobSubscriptionOptions } from './jobs-CRK-DZ40.js';
|
|
9
9
|
import { ContinuationCursor, QueryIndexScope, SearchIndexQueryMode, ArchiveSourceLocatorResult, ArchiveCollectionResult, ArchiveFindResult, ArchiveEvidence, ArchiveRelatedResult, WikiGraphLibraryRecord, WikiGraphLibraryArchiveRecord, ParsedWikiGraphLibraryUri, WikiGraphLibraryBucketContinuationOptions as WikiGraphLibraryBucketContinuationOptions$1, WikiGraphLibraryBucketSearchOptions as WikiGraphLibraryBucketSearchOptions$1, listWikiGraphLibraryEvidence, WikiGraphLibraryIndexState, rebuildWikiGraphLibraryIndex, ArchiveFindOptions, ArchiveCollectionOptions, readWikiGraphLibraryPage, ArchivePage, listRelatedWikiGraphLibraryObjects, ArchivePack } from 'wiki-graph-core';
|
|
10
|
-
export { ArchiveBacklinkBucket, ArchiveBacklinks, ArchiveCollectionOptions, ArchiveCollectionResult, ArchiveEvidence, ArchiveEvidenceItem, ArchiveFindEvidencePreview, ArchiveFindHit, ArchiveFindOptions, ArchiveFindResult, ArchiveListItem, ArchivePack, ArchivePage, ArchiveRelatedResult, ArchiveSearchMatch, ArchiveSourceLocator, ArchiveSourceLocatorResult, ArchiveTriplePattern, BookMeta, BuildJobEvent, BuildJobProgressCounter, BuildJobTarget, ChapterDetails, ChapterEntry, ChapterStage, ChapterTree, ChapterTreeApplyResult, ContinuationCursor, DEFAULT_EXTRACTION_PROMPT, DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT, Directory, File, FileReader, FileWriter, IndexArtifactKind, LLMPaymentRequiredError, LocatedWikiGraphUri, ParsedSourceLocatorFragment, ParsedWikiGraphLibraryUri, ParsedWikiGraphUri, QueryIndexScope, ReadonlyFile, SchemaVersionTarget, SearchIndexEmbeddingProvider, SearchIndexQueryMode, SourceArtifactInput, WIKI_GRAPH_URI_PREFIX, WikiGraphArtifactDetails, WikiGraphChapterState, WikiGraphChapterStateTarget, WikiGraphChapterStateValue, WikiGraphChunkDetails, WikiGraphChunkSummary, WikiGraphEntityDetails, WikiGraphEntitySummary, WikiGraphError, WikiGraphLLMOptions, WikiGraphLibraryBucketSearchResult, WikiGraphLibraryIndexState, WikiGraphLibrarySearchBucketDefinition, WikiGraphLibrarySearchBucketPage, WikiGraphLibrarySource, WikiGraphLibrarySourceFields, WikiGraphMaintenanceUpgradeResult, WikiGraphObject, WikiGraphObjectDetails, WikiGraphObjectIdentity, WikiGraphObjectKind, WikiGraphObjectListItem, WikiGraphObjectSummary, WikiGraphPlatform, WikiGraphProgressCallback, WikiGraphProgressEvent, WikiGraphRetrievalSignals, WikiGraphSchemaVersionError, WikiGraphSchemaVersionErrorInfo, WikiGraphScopeIdentity, WikiGraphScopeSummary, WikiGraphSearchableKind, WikiGraphSearchableSummary, WikiGraphSourceSentenceSummary, WikiGraphStorage, WikiGraphSummarySentenceSummary, WikiGraphTripleDetails, WikiGraphTripleSummary, WikispineProvider, formatError, formatLocatedChapterResourceUri, formatLocatedChapterSourceCollectionUri, formatLocatedChapterUri, formatLocatedWikiGraphUri, formatSourceArtifactUri, formatSourceLocatorFragment, formatWikiGraphCommandUri, formatWikiGraphLibraryUri, isSourceLocatorScopeUri, isWikiGraphJobUri, isWikiGraphLibraryUri, isWikiGraphSchemaVersionError, isWikiGraphUri, parseChapterPath, parseChapterTreeInput, parseChapterUriPath, parseLocatedWikiGraphUri, parseSourceLocatorFragment, parseSourceTextJsonl, parseWikiGraphLibraryUri, parseWikiGraphUriSyntax, requireArchiveUri, requireLocatedObjectOrArchiveUri, requireLocatedObjectUri, resolveExtractionPrompt, resolveKnowledgeGraphRecallPrompt } from 'wiki-graph-core';
|
|
10
|
+
export { ArchiveBacklinkBucket, ArchiveBacklinks, ArchiveCollectionOptions, ArchiveCollectionResult, ArchiveEvidence, ArchiveEvidenceItem, ArchiveFindEvidencePreview, ArchiveFindHit, ArchiveFindOptions, ArchiveFindResult, ArchiveListItem, ArchivePack, ArchivePage, ArchiveRelatedResult, ArchiveSearchMatch, ArchiveSourceLocator, ArchiveSourceLocatorResult, ArchiveTriplePattern, BookMeta, BuildJobEvent, BuildJobProgressCounter, BuildJobTarget, ChapterDetails, ChapterEntry, ChapterStage, ChapterTree, ChapterTreeApplyResult, ContinuationCursor, DEFAULT_EXTRACTION_PROMPT, DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT, Directory, File, FileReader, FileWriter, HostDatabaseConnection, HostDatabaseOpenOptions, HostDatabaseProvider, HostDatabaseRow, HostDatabaseValue, IndexArtifactKind, LLMPaymentRequiredError, LocatedWikiGraphUri, ParsedSourceLocatorFragment, ParsedWikiGraphLibraryUri, ParsedWikiGraphUri, QueryIndexScope, ReadonlyFile, SchemaVersionTarget, SearchIndexEmbeddingProvider, SearchIndexQueryMode, SourceArtifactInput, WIKI_GRAPH_URI_PREFIX, WikgObject, WikiGraphArtifactDetails, WikiGraphChapterState, WikiGraphChapterStateTarget, WikiGraphChapterStateValue, WikiGraphChunkDetails, WikiGraphChunkSummary, WikiGraphEntityDetails, WikiGraphEntitySummary, WikiGraphError, WikiGraphLLMOptions, WikiGraphLibraryBucketSearchResult, WikiGraphLibraryIndexState, WikiGraphLibrarySearchBucketDefinition, WikiGraphLibrarySearchBucketPage, WikiGraphLibrarySource, WikiGraphLibrarySourceFields, WikiGraphMaintenanceUpgradeResult, WikiGraphObject, WikiGraphObjectDetails, WikiGraphObjectIdentity, WikiGraphObjectKind, WikiGraphObjectListItem, WikiGraphObjectSummary, WikiGraphPlatform, WikiGraphProgressCallback, WikiGraphProgressEvent, WikiGraphRetrievalSignals, WikiGraphSchemaVersionError, WikiGraphSchemaVersionErrorInfo, WikiGraphScopeIdentity, WikiGraphScopeSummary, WikiGraphSearchableKind, WikiGraphSearchableSummary, WikiGraphSerialEntry, WikiGraphSourceSentenceSummary, WikiGraphStorage, WikiGraphSummarySentenceSummary, WikiGraphTripleDetails, WikiGraphTripleSummary, WikispineProvider, formatError, formatLocatedChapterResourceUri, formatLocatedChapterSourceCollectionUri, formatLocatedChapterUri, formatLocatedWikiGraphUri, formatSourceArtifactUri, formatSourceLocatorFragment, formatWikiGraphCommandUri, formatWikiGraphLibraryUri, isSourceLocatorScopeUri, isWikiGraphJobUri, isWikiGraphLibraryUri, isWikiGraphSchemaVersionError, isWikiGraphUri, parseChapterPath, parseChapterTreeInput, parseChapterUriPath, parseLocatedWikiGraphUri, parseSourceLocatorFragment, parseSourceTextJsonl, parseWikiGraphLibraryUri, parseWikiGraphUriSyntax, requireArchiveUri, requireLocatedObjectOrArchiveUri, requireLocatedObjectUri, resolveExtractionPrompt, resolveKnowledgeGraphRecallPrompt } from 'wiki-graph-core';
|
|
11
11
|
import { WikiGraphConversionManager } from './conversions.js';
|
|
12
12
|
export { WikiGraphConversionFormat, WikiGraphConversionInput, WikiGraphConversionOptions, WikiGraphConversionResult, WikiGraphSourceFormat } from './conversions.js';
|
|
13
13
|
export { WikiGraphQueueWorkerOptions, requireKnowledgeGraphWikispineConfig, runWikiGraphQueueWorker } from './default-worker.js';
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,12 @@ import {
|
|
|
14
14
|
assertArchiveQueryReady,
|
|
15
15
|
resolveIndexedArchiveChapterScope,
|
|
16
16
|
ensureWikiGraphArchiveSchemaCurrent,
|
|
17
|
+
readWikiGraphArchiveSchemaVersion,
|
|
17
18
|
assertNoActiveBuildJobConflicts,
|
|
18
19
|
assertNoActiveBuildJobs,
|
|
19
20
|
deleteArchiveSearchSessions,
|
|
20
21
|
createContinuationCursor,
|
|
22
|
+
createChapterReadingGraphObjectStream,
|
|
21
23
|
deleteContinuationCursor,
|
|
22
24
|
DirectoryDocument,
|
|
23
25
|
findArchiveObjects,
|
|
@@ -43,6 +45,7 @@ import {
|
|
|
43
45
|
setChapterSummary,
|
|
44
46
|
setChapterTitle,
|
|
45
47
|
getChapterTree,
|
|
48
|
+
getChapterDetails,
|
|
46
49
|
WikiGraph as WikiGraph2,
|
|
47
50
|
WikiGraphArchiveFile as WikiGraphArchiveFile2,
|
|
48
51
|
WikiGraphDirectoryFile as WikiGraphDirectoryFile2,
|
|
@@ -51,6 +54,7 @@ import {
|
|
|
51
54
|
writeWikgArchive,
|
|
52
55
|
ObjectMetadataKind
|
|
53
56
|
} from "wiki-graph-core";
|
|
57
|
+
import { copyFileContent } from "wiki-graph-core/platform";
|
|
54
58
|
|
|
55
59
|
// src/conversions.ts
|
|
56
60
|
import { createHash } from "crypto";
|
|
@@ -166,7 +170,7 @@ var NodeFile = class {
|
|
|
166
170
|
}
|
|
167
171
|
path;
|
|
168
172
|
async getPhysicalIdentity() {
|
|
169
|
-
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
173
|
+
const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
|
|
170
174
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
171
175
|
return void 0;
|
|
172
176
|
throw error;
|
|
@@ -179,7 +183,7 @@ var NodeFile = class {
|
|
|
179
183
|
identity;
|
|
180
184
|
name;
|
|
181
185
|
async openReader() {
|
|
182
|
-
const handle = await fsPromises.open(this.path, "r");
|
|
186
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(this.path), "r");
|
|
183
187
|
let closed = false;
|
|
184
188
|
try {
|
|
185
189
|
const stats = await handle.stat();
|
|
@@ -219,7 +223,7 @@ var NodeFile = class {
|
|
|
219
223
|
}
|
|
220
224
|
async getLastModified() {
|
|
221
225
|
try {
|
|
222
|
-
return (await fsPromises.stat(this.path)).mtimeMs;
|
|
226
|
+
return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
|
|
223
227
|
} catch (error) {
|
|
224
228
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
225
229
|
return void 0;
|
|
@@ -228,9 +232,14 @@ var NodeFile = class {
|
|
|
228
232
|
}
|
|
229
233
|
}
|
|
230
234
|
async openWriter() {
|
|
231
|
-
await fsPromises.mkdir(
|
|
235
|
+
await fsPromises.mkdir(
|
|
236
|
+
toNodeFilesystemPath(pathModule.dirname(this.path)),
|
|
237
|
+
{
|
|
238
|
+
recursive: true
|
|
239
|
+
}
|
|
240
|
+
);
|
|
232
241
|
const temporary = `${this.path}.tmp-${crypto.randomUUID()}`;
|
|
233
|
-
const handle = await fsPromises.open(temporary, "wx");
|
|
242
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(temporary), "wx");
|
|
234
243
|
let closed = false;
|
|
235
244
|
return {
|
|
236
245
|
write: async (data) => {
|
|
@@ -245,14 +254,17 @@ var NodeFile = class {
|
|
|
245
254
|
commit: async () => {
|
|
246
255
|
if (!closed) {
|
|
247
256
|
await handle.close();
|
|
248
|
-
await fsPromises.rename(
|
|
257
|
+
await fsPromises.rename(
|
|
258
|
+
toNodeFilesystemPath(temporary),
|
|
259
|
+
toNodeFilesystemPath(this.path)
|
|
260
|
+
);
|
|
249
261
|
}
|
|
250
262
|
closed = true;
|
|
251
263
|
},
|
|
252
264
|
abort: async () => {
|
|
253
265
|
if (!closed) {
|
|
254
266
|
await handle.close();
|
|
255
|
-
await fsPromises.rm(temporary, { force: true });
|
|
267
|
+
await fsPromises.rm(toNodeFilesystemPath(temporary), { force: true });
|
|
256
268
|
}
|
|
257
269
|
closed = true;
|
|
258
270
|
}
|
|
@@ -299,7 +311,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
299
311
|
}
|
|
300
312
|
path;
|
|
301
313
|
async getPhysicalIdentity() {
|
|
302
|
-
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
314
|
+
const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
|
|
303
315
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
304
316
|
return void 0;
|
|
305
317
|
throw error;
|
|
@@ -315,7 +327,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
315
327
|
assertChildName(name);
|
|
316
328
|
const file = new NodeFile(pathModule.join(this.path, name));
|
|
317
329
|
try {
|
|
318
|
-
return (await fsPromises.stat(file.path)).isFile() ? file : void 0;
|
|
330
|
+
return (await fsPromises.stat(toNodeFilesystemPath(file.path))).isFile() ? file : void 0;
|
|
319
331
|
} catch (error) {
|
|
320
332
|
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
321
333
|
return void 0;
|
|
@@ -324,7 +336,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
324
336
|
}
|
|
325
337
|
async getLastModified() {
|
|
326
338
|
try {
|
|
327
|
-
return (await fsPromises.stat(this.path)).mtimeMs;
|
|
339
|
+
return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
|
|
328
340
|
} catch (error) {
|
|
329
341
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
330
342
|
return void 0;
|
|
@@ -336,7 +348,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
336
348
|
assertChildName(name);
|
|
337
349
|
const directory = new _NodeDirectory(pathModule.join(this.path, name));
|
|
338
350
|
try {
|
|
339
|
-
return (await fsPromises.stat(directory.path)).isDirectory() ? directory : void 0;
|
|
351
|
+
return (await fsPromises.stat(toNodeFilesystemPath(directory.path))).isDirectory() ? directory : void 0;
|
|
340
352
|
} catch (error) {
|
|
341
353
|
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
342
354
|
return void 0;
|
|
@@ -344,7 +356,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
344
356
|
}
|
|
345
357
|
}
|
|
346
358
|
async list() {
|
|
347
|
-
const entries = await fsPromises.readdir(this.path, {
|
|
359
|
+
const entries = await fsPromises.readdir(toNodeFilesystemPath(this.path), {
|
|
348
360
|
withFileTypes: true
|
|
349
361
|
});
|
|
350
362
|
return entries.map(
|
|
@@ -353,26 +365,45 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
353
365
|
}
|
|
354
366
|
async createFile(name) {
|
|
355
367
|
assertChildName(name);
|
|
356
|
-
await fsPromises.mkdir(this.path, {
|
|
368
|
+
await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
|
|
369
|
+
recursive: true
|
|
370
|
+
});
|
|
357
371
|
const file = new NodeFile(pathModule.join(this.path, name));
|
|
358
|
-
await fsPromises.writeFile(file.path, "", {
|
|
372
|
+
await fsPromises.writeFile(toNodeFilesystemPath(file.path), "", {
|
|
373
|
+
flag: "wx"
|
|
374
|
+
});
|
|
359
375
|
return file;
|
|
360
376
|
}
|
|
361
377
|
async createDirectory(name) {
|
|
362
378
|
assertChildName(name);
|
|
363
|
-
await fsPromises.mkdir(this.path, {
|
|
379
|
+
await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
|
|
380
|
+
recursive: true
|
|
381
|
+
});
|
|
364
382
|
const directory = new _NodeDirectory(pathModule.join(this.path, name));
|
|
365
|
-
await fsPromises.mkdir(directory.path);
|
|
383
|
+
await fsPromises.mkdir(toNodeFilesystemPath(directory.path));
|
|
366
384
|
return directory;
|
|
367
385
|
}
|
|
368
386
|
async remove(name, options) {
|
|
369
387
|
assertChildName(name);
|
|
370
|
-
await fsPromises.rm(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
388
|
+
await fsPromises.rm(
|
|
389
|
+
toNodeFilesystemPath(pathModule.join(this.path, name)),
|
|
390
|
+
{
|
|
391
|
+
force: true,
|
|
392
|
+
recursive: options?.recursive === true
|
|
393
|
+
}
|
|
394
|
+
);
|
|
374
395
|
}
|
|
375
396
|
};
|
|
397
|
+
function toNodeFilesystemPath(path) {
|
|
398
|
+
if (nodeProcess.platform !== "win32" || path.startsWith("\\\\?\\")) {
|
|
399
|
+
return path;
|
|
400
|
+
}
|
|
401
|
+
const absolute = pathModule.resolve(path);
|
|
402
|
+
if (absolute.startsWith("\\\\")) {
|
|
403
|
+
return `\\\\?\\UNC\\${absolute.slice(2)}`;
|
|
404
|
+
}
|
|
405
|
+
return `\\\\?\\${absolute}`;
|
|
406
|
+
}
|
|
376
407
|
function encodeNodeResourceIdentity(kind, path) {
|
|
377
408
|
return `node-${kind}:${Buffer.from(pathModule.resolve(path), "utf8").toString("base64url")}`;
|
|
378
409
|
}
|
|
@@ -458,10 +489,14 @@ async function openNativeNodeDatabase(file, flags) {
|
|
|
458
489
|
throw new TypeError("The Node database adapter requires a NodeFile");
|
|
459
490
|
}
|
|
460
491
|
return await new Promise((resolve4, reject) => {
|
|
461
|
-
const database = new nodeSqlite3.Database(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
492
|
+
const database = new nodeSqlite3.Database(
|
|
493
|
+
toNodeFilesystemPath(path),
|
|
494
|
+
flags,
|
|
495
|
+
(error) => {
|
|
496
|
+
if (error) reject(error);
|
|
497
|
+
else resolve4(database);
|
|
498
|
+
}
|
|
499
|
+
);
|
|
465
500
|
});
|
|
466
501
|
}
|
|
467
502
|
async function openNodeZip(file, options = {}) {
|
|
@@ -469,7 +504,7 @@ async function openNodeZip(file, options = {}) {
|
|
|
469
504
|
if (path === void 0) {
|
|
470
505
|
throw new TypeError("The Node ZIP adapter requires a NodeFile");
|
|
471
506
|
}
|
|
472
|
-
const handle = await fsPromises.open(path, "r");
|
|
507
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(path), "r");
|
|
473
508
|
let size;
|
|
474
509
|
try {
|
|
475
510
|
size = (await handle.stat()).size;
|
|
@@ -784,6 +819,11 @@ async function writeNodeZip(file, entries) {
|
|
|
784
819
|
}
|
|
785
820
|
}
|
|
786
821
|
async function addNodeZipEntries(zipFile, iterator, state) {
|
|
822
|
+
const stableZipOptions = {
|
|
823
|
+
compress: false,
|
|
824
|
+
forceDosTimestamp: true,
|
|
825
|
+
mtime: new Date(1980, 0, 2)
|
|
826
|
+
};
|
|
787
827
|
while (!state.cancelled) {
|
|
788
828
|
const result = await iterator.next();
|
|
789
829
|
if (state.cancelled) return;
|
|
@@ -795,17 +835,17 @@ async function addNodeZipEntries(zipFile, iterator, state) {
|
|
|
795
835
|
zipFile.addReadStream(
|
|
796
836
|
createNodeFileReadStream(result.value.file),
|
|
797
837
|
result.value.name,
|
|
798
|
-
|
|
838
|
+
stableZipOptions
|
|
799
839
|
);
|
|
800
840
|
} else if ("data" in result.value) {
|
|
801
841
|
zipFile.addBuffer(Buffer.from(result.value.data), result.value.name, {
|
|
802
|
-
|
|
842
|
+
...stableZipOptions
|
|
803
843
|
});
|
|
804
844
|
} else {
|
|
805
845
|
zipFile.addReadStream(
|
|
806
846
|
createNodeRangeReadStream(result.value),
|
|
807
847
|
result.value.name,
|
|
808
|
-
{
|
|
848
|
+
{ ...stableZipOptions, size: result.value.size }
|
|
809
849
|
);
|
|
810
850
|
}
|
|
811
851
|
}
|
|
@@ -2661,6 +2701,18 @@ var WikiGraphArchiveManager = class {
|
|
|
2661
2701
|
}, options.signal);
|
|
2662
2702
|
return new WikiGraphArchiveHandle(this.#runtime, location);
|
|
2663
2703
|
}
|
|
2704
|
+
async inspectSchema(target, options = {}) {
|
|
2705
|
+
return await this.#runtime.run(
|
|
2706
|
+
async () => ({
|
|
2707
|
+
schemaVersion: await readWikiGraphArchiveSchemaVersion(
|
|
2708
|
+
await resolveWikiGraphArchiveLocation(target).then(
|
|
2709
|
+
(location) => location.archiveFile
|
|
2710
|
+
)
|
|
2711
|
+
)
|
|
2712
|
+
}),
|
|
2713
|
+
options.signal
|
|
2714
|
+
);
|
|
2715
|
+
}
|
|
2664
2716
|
};
|
|
2665
2717
|
var WikiGraphArchiveHandle = class {
|
|
2666
2718
|
#runtime;
|
|
@@ -2687,6 +2739,19 @@ var WikiGraphArchiveHandle = class {
|
|
|
2687
2739
|
get target() {
|
|
2688
2740
|
return this.#location.target;
|
|
2689
2741
|
}
|
|
2742
|
+
/** Export this archive through the SDK without exposing core file adapters. */
|
|
2743
|
+
async export(path) {
|
|
2744
|
+
return await this.#runtime.run(async () => {
|
|
2745
|
+
const outputPath = await assertStandaloneWikiGraphArchivePath(path);
|
|
2746
|
+
const output = new NodeFile(outputPath);
|
|
2747
|
+
if (this.#location.archiveFile.kind === "directory") {
|
|
2748
|
+
await writeWikgArchive(this.#location.archiveFile, output);
|
|
2749
|
+
} else {
|
|
2750
|
+
await copyFileContent(this.#location.archiveFile, output);
|
|
2751
|
+
}
|
|
2752
|
+
return { path: outputPath };
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2690
2755
|
async #persistCursor(cursor) {
|
|
2691
2756
|
return await this.#runtime.run(
|
|
2692
2757
|
async () => await createContinuationCursor(cursor)
|
|
@@ -3219,6 +3284,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
3219
3284
|
options
|
|
3220
3285
|
);
|
|
3221
3286
|
}
|
|
3287
|
+
/** Read archive-level data without exposing the underlying Core reader. */
|
|
3288
|
+
async readOverview(options = {}) {
|
|
3289
|
+
return await this.#readDocument(async (document) => {
|
|
3290
|
+
const [metadata, cover, toc] = await Promise.all([
|
|
3291
|
+
document.readBookMeta(),
|
|
3292
|
+
document.readCover(),
|
|
3293
|
+
document.readToc()
|
|
3294
|
+
]);
|
|
3295
|
+
const serials = toc === void 0 ? [] : await collectArchiveSerials(document, toc.items);
|
|
3296
|
+
return {
|
|
3297
|
+
...metadata === void 0 ? {} : { metadata },
|
|
3298
|
+
...cover === void 0 ? {} : { cover },
|
|
3299
|
+
...toc === void 0 ? {} : { toc },
|
|
3300
|
+
serials
|
|
3301
|
+
};
|
|
3302
|
+
}, options);
|
|
3303
|
+
}
|
|
3304
|
+
/** Read a chapter and expose its graph as the stable WikgObject stream. */
|
|
3305
|
+
async readChapterData(serialId, options = {}) {
|
|
3306
|
+
const result = await this.#readDocument(async (document) => {
|
|
3307
|
+
const [chapter, summary] = await Promise.all([
|
|
3308
|
+
getChapterDetails(document, serialId),
|
|
3309
|
+
document.readSummary(serialId)
|
|
3310
|
+
]);
|
|
3311
|
+
return { chapter, summary };
|
|
3312
|
+
}, options);
|
|
3313
|
+
return {
|
|
3314
|
+
chapter: result.chapter,
|
|
3315
|
+
...result.summary === void 0 ? {} : { summary: result.summary },
|
|
3316
|
+
objects: this.#readChapterObjects(serialId, options)
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3222
3319
|
async replaceBookMeta(meta, options = {}) {
|
|
3223
3320
|
return await this.#writeDocument(async (document) => {
|
|
3224
3321
|
await document.replaceBookMeta(meta);
|
|
@@ -3306,6 +3403,33 @@ var WikiGraphArchiveHandle = class {
|
|
|
3306
3403
|
(error) => rethrowArchiveSchemaError(error, this.#location.target)
|
|
3307
3404
|
);
|
|
3308
3405
|
}
|
|
3406
|
+
async *#readChapterObjects(serialId, options) {
|
|
3407
|
+
const queue = createAsyncValueQueue();
|
|
3408
|
+
const producer = this.#readDocument(async (document) => {
|
|
3409
|
+
try {
|
|
3410
|
+
for await (const object of createChapterReadingGraphObjectStream({
|
|
3411
|
+
chapterId: serialId,
|
|
3412
|
+
document
|
|
3413
|
+
})) {
|
|
3414
|
+
if (!await queue.push(object)) break;
|
|
3415
|
+
}
|
|
3416
|
+
queue.end();
|
|
3417
|
+
} catch (error) {
|
|
3418
|
+
queue.fail(error);
|
|
3419
|
+
throw error;
|
|
3420
|
+
}
|
|
3421
|
+
}, options).catch((error) => {
|
|
3422
|
+
queue.fail(error);
|
|
3423
|
+
throw error;
|
|
3424
|
+
});
|
|
3425
|
+
try {
|
|
3426
|
+
for await (const object of queue) yield object;
|
|
3427
|
+
await producer;
|
|
3428
|
+
} finally {
|
|
3429
|
+
queue.cancel();
|
|
3430
|
+
await producer.catch(() => void 0);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3309
3433
|
async #writeDocument(operation, options = {}) {
|
|
3310
3434
|
return await this.#runtime.run(async () => {
|
|
3311
3435
|
return await writeWikiGraphArchiveLocation(this.#location, operation, {
|
|
@@ -3500,6 +3624,94 @@ function requireChapter(chapters, chapterId) {
|
|
|
3500
3624
|
function asTextStream(text) {
|
|
3501
3625
|
return Readable2.from([text]);
|
|
3502
3626
|
}
|
|
3627
|
+
async function collectArchiveSerials(document, items, ancestorTitles = []) {
|
|
3628
|
+
const entries = [];
|
|
3629
|
+
for (const item of items) {
|
|
3630
|
+
const title = item.title?.trim() || `Chapter ${item.serialId ?? "group"}`;
|
|
3631
|
+
const tocPath = [...ancestorTitles, title];
|
|
3632
|
+
if (item.serialId !== void 0) {
|
|
3633
|
+
entries.push({
|
|
3634
|
+
fragmentCount: (await document.getSerialFragments(item.serialId).listFragmentIds()).length,
|
|
3635
|
+
serialId: item.serialId,
|
|
3636
|
+
title,
|
|
3637
|
+
tocPath
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
entries.push(
|
|
3641
|
+
...await collectArchiveSerials(document, item.children, tocPath)
|
|
3642
|
+
);
|
|
3643
|
+
}
|
|
3644
|
+
return entries;
|
|
3645
|
+
}
|
|
3646
|
+
function createAsyncValueQueue() {
|
|
3647
|
+
const values = [];
|
|
3648
|
+
const readers = [];
|
|
3649
|
+
const writers = [];
|
|
3650
|
+
let cancelled = false;
|
|
3651
|
+
let ended = false;
|
|
3652
|
+
let failure;
|
|
3653
|
+
const settleReaders = () => {
|
|
3654
|
+
while (readers.length > 0) {
|
|
3655
|
+
const reader = readers.shift();
|
|
3656
|
+
if (failure !== void 0) reader.reject(failure);
|
|
3657
|
+
else if (values.length > 0) {
|
|
3658
|
+
reader.resolve({ done: false, value: values.shift() });
|
|
3659
|
+
writers.shift()?.();
|
|
3660
|
+
} else if (ended) reader.resolve({ done: true, value: void 0 });
|
|
3661
|
+
else {
|
|
3662
|
+
readers.unshift(reader);
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
};
|
|
3667
|
+
return {
|
|
3668
|
+
[Symbol.asyncIterator]: () => ({
|
|
3669
|
+
next: async () => {
|
|
3670
|
+
if (failure !== void 0) throw failure;
|
|
3671
|
+
if (values.length > 0) {
|
|
3672
|
+
const value = values.shift();
|
|
3673
|
+
writers.shift()?.();
|
|
3674
|
+
return { done: false, value };
|
|
3675
|
+
}
|
|
3676
|
+
if (ended) return { done: true, value: void 0 };
|
|
3677
|
+
return await new Promise((resolve4, reject) => {
|
|
3678
|
+
readers.push({ reject, resolve: resolve4 });
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
}),
|
|
3682
|
+
cancel: () => {
|
|
3683
|
+
cancelled = true;
|
|
3684
|
+
ended = true;
|
|
3685
|
+
values.length = 0;
|
|
3686
|
+
while (writers.length > 0) writers.shift()();
|
|
3687
|
+
settleReaders();
|
|
3688
|
+
},
|
|
3689
|
+
end: () => {
|
|
3690
|
+
ended = true;
|
|
3691
|
+
settleReaders();
|
|
3692
|
+
},
|
|
3693
|
+
fail: (error) => {
|
|
3694
|
+
failure = error instanceof Error ? error : new Error(String(error));
|
|
3695
|
+
ended = true;
|
|
3696
|
+
values.length = 0;
|
|
3697
|
+
while (writers.length > 0) writers.shift()();
|
|
3698
|
+
settleReaders();
|
|
3699
|
+
},
|
|
3700
|
+
push: async (value) => {
|
|
3701
|
+
if (cancelled || ended || failure !== void 0) return false;
|
|
3702
|
+
if (readers.length > 0) {
|
|
3703
|
+
readers.shift().resolve({ done: false, value });
|
|
3704
|
+
return true;
|
|
3705
|
+
}
|
|
3706
|
+
if (values.length > 0) {
|
|
3707
|
+
await new Promise((resolve4) => writers.push(resolve4));
|
|
3708
|
+
if (cancelled || ended || failure !== void 0) return false;
|
|
3709
|
+
}
|
|
3710
|
+
values.push(value);
|
|
3711
|
+
return true;
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3503
3715
|
async function assertChapterResetAllowed(archive, chapterId, stage) {
|
|
3504
3716
|
if (stage === "planned") {
|
|
3505
3717
|
await assertNoActiveBuildJobs({
|
|
@@ -4040,7 +4252,7 @@ function createLibraryQueryPayload(context) {
|
|
|
4040
4252
|
// src/default-worker.ts
|
|
4041
4253
|
import {
|
|
4042
4254
|
getBuildJob,
|
|
4043
|
-
getChapterDetails,
|
|
4255
|
+
getChapterDetails as getChapterDetails2,
|
|
4044
4256
|
openWikimediaResolver as openWikimediaResolver2,
|
|
4045
4257
|
recordBuildJobInputRevision,
|
|
4046
4258
|
WikiGraphArchiveFile as WikiGraphArchiveFile5,
|
|
@@ -4384,7 +4596,7 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
4384
4596
|
const outputWorkspace = await stepWorkspace.createDirectory("output");
|
|
4385
4597
|
const revision = await new WikiGraphArchiveFile5(job.archive).readDocument(
|
|
4386
4598
|
async (document) => {
|
|
4387
|
-
await
|
|
4599
|
+
await getChapterDetails2(document, job.chapterId);
|
|
4388
4600
|
return await writeChapterJobInputFile3(
|
|
4389
4601
|
document,
|
|
4390
4602
|
job.chapterId,
|
|
@@ -4526,7 +4738,7 @@ async function resetStepWorkspace(workspace, kind) {
|
|
|
4526
4738
|
}
|
|
4527
4739
|
async function readChapterStage(job) {
|
|
4528
4740
|
return await new WikiGraphArchiveFile5(job.archive).readDocument(
|
|
4529
|
-
async (document) => (await
|
|
4741
|
+
async (document) => (await getChapterDetails2(document, job.chapterId)).stage
|
|
4530
4742
|
);
|
|
4531
4743
|
}
|
|
4532
4744
|
async function assertCurrentFtsArtifact(job) {
|