wiki-graph-sdk 0.9.3 → 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 +241 -29
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +1 -1
- package/dist/archives.js +245 -29
- 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 +244 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +248 -32
- 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,13 +45,16 @@ 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,
|
|
52
|
+
WikgCoordinator,
|
|
49
53
|
TOC_FILE_VERSION,
|
|
50
54
|
writeWikgArchive,
|
|
51
55
|
ObjectMetadataKind
|
|
52
56
|
} from "wiki-graph-core";
|
|
57
|
+
import { copyFileContent } from "wiki-graph-core/platform";
|
|
53
58
|
|
|
54
59
|
// src/conversions.ts
|
|
55
60
|
import { createHash } from "crypto";
|
|
@@ -165,7 +170,7 @@ var NodeFile = class {
|
|
|
165
170
|
}
|
|
166
171
|
path;
|
|
167
172
|
async getPhysicalIdentity() {
|
|
168
|
-
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
173
|
+
const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
|
|
169
174
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
170
175
|
return void 0;
|
|
171
176
|
throw error;
|
|
@@ -178,7 +183,7 @@ var NodeFile = class {
|
|
|
178
183
|
identity;
|
|
179
184
|
name;
|
|
180
185
|
async openReader() {
|
|
181
|
-
const handle = await fsPromises.open(this.path, "r");
|
|
186
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(this.path), "r");
|
|
182
187
|
let closed = false;
|
|
183
188
|
try {
|
|
184
189
|
const stats = await handle.stat();
|
|
@@ -218,7 +223,7 @@ var NodeFile = class {
|
|
|
218
223
|
}
|
|
219
224
|
async getLastModified() {
|
|
220
225
|
try {
|
|
221
|
-
return (await fsPromises.stat(this.path)).mtimeMs;
|
|
226
|
+
return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
|
|
222
227
|
} catch (error) {
|
|
223
228
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
224
229
|
return void 0;
|
|
@@ -227,9 +232,14 @@ var NodeFile = class {
|
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
234
|
async openWriter() {
|
|
230
|
-
await fsPromises.mkdir(
|
|
235
|
+
await fsPromises.mkdir(
|
|
236
|
+
toNodeFilesystemPath(pathModule.dirname(this.path)),
|
|
237
|
+
{
|
|
238
|
+
recursive: true
|
|
239
|
+
}
|
|
240
|
+
);
|
|
231
241
|
const temporary = `${this.path}.tmp-${crypto.randomUUID()}`;
|
|
232
|
-
const handle = await fsPromises.open(temporary, "wx");
|
|
242
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(temporary), "wx");
|
|
233
243
|
let closed = false;
|
|
234
244
|
return {
|
|
235
245
|
write: async (data) => {
|
|
@@ -244,14 +254,17 @@ var NodeFile = class {
|
|
|
244
254
|
commit: async () => {
|
|
245
255
|
if (!closed) {
|
|
246
256
|
await handle.close();
|
|
247
|
-
await fsPromises.rename(
|
|
257
|
+
await fsPromises.rename(
|
|
258
|
+
toNodeFilesystemPath(temporary),
|
|
259
|
+
toNodeFilesystemPath(this.path)
|
|
260
|
+
);
|
|
248
261
|
}
|
|
249
262
|
closed = true;
|
|
250
263
|
},
|
|
251
264
|
abort: async () => {
|
|
252
265
|
if (!closed) {
|
|
253
266
|
await handle.close();
|
|
254
|
-
await fsPromises.rm(temporary, { force: true });
|
|
267
|
+
await fsPromises.rm(toNodeFilesystemPath(temporary), { force: true });
|
|
255
268
|
}
|
|
256
269
|
closed = true;
|
|
257
270
|
}
|
|
@@ -298,7 +311,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
298
311
|
}
|
|
299
312
|
path;
|
|
300
313
|
async getPhysicalIdentity() {
|
|
301
|
-
const value = await fsPromises.stat(this.path).catch((error) => {
|
|
314
|
+
const value = await fsPromises.stat(toNodeFilesystemPath(this.path)).catch((error) => {
|
|
302
315
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
303
316
|
return void 0;
|
|
304
317
|
throw error;
|
|
@@ -314,7 +327,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
314
327
|
assertChildName(name);
|
|
315
328
|
const file = new NodeFile(pathModule.join(this.path, name));
|
|
316
329
|
try {
|
|
317
|
-
return (await fsPromises.stat(file.path)).isFile() ? file : void 0;
|
|
330
|
+
return (await fsPromises.stat(toNodeFilesystemPath(file.path))).isFile() ? file : void 0;
|
|
318
331
|
} catch (error) {
|
|
319
332
|
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
320
333
|
return void 0;
|
|
@@ -323,7 +336,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
323
336
|
}
|
|
324
337
|
async getLastModified() {
|
|
325
338
|
try {
|
|
326
|
-
return (await fsPromises.stat(this.path)).mtimeMs;
|
|
339
|
+
return (await fsPromises.stat(toNodeFilesystemPath(this.path))).mtimeMs;
|
|
327
340
|
} catch (error) {
|
|
328
341
|
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
329
342
|
return void 0;
|
|
@@ -335,7 +348,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
335
348
|
assertChildName(name);
|
|
336
349
|
const directory = new _NodeDirectory(pathModule.join(this.path, name));
|
|
337
350
|
try {
|
|
338
|
-
return (await fsPromises.stat(directory.path)).isDirectory() ? directory : void 0;
|
|
351
|
+
return (await fsPromises.stat(toNodeFilesystemPath(directory.path))).isDirectory() ? directory : void 0;
|
|
339
352
|
} catch (error) {
|
|
340
353
|
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
341
354
|
return void 0;
|
|
@@ -343,7 +356,7 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
343
356
|
}
|
|
344
357
|
}
|
|
345
358
|
async list() {
|
|
346
|
-
const entries = await fsPromises.readdir(this.path, {
|
|
359
|
+
const entries = await fsPromises.readdir(toNodeFilesystemPath(this.path), {
|
|
347
360
|
withFileTypes: true
|
|
348
361
|
});
|
|
349
362
|
return entries.map(
|
|
@@ -352,26 +365,45 @@ var NodeDirectory = class _NodeDirectory {
|
|
|
352
365
|
}
|
|
353
366
|
async createFile(name) {
|
|
354
367
|
assertChildName(name);
|
|
355
|
-
await fsPromises.mkdir(this.path, {
|
|
368
|
+
await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
|
|
369
|
+
recursive: true
|
|
370
|
+
});
|
|
356
371
|
const file = new NodeFile(pathModule.join(this.path, name));
|
|
357
|
-
await fsPromises.writeFile(file.path, "", {
|
|
372
|
+
await fsPromises.writeFile(toNodeFilesystemPath(file.path), "", {
|
|
373
|
+
flag: "wx"
|
|
374
|
+
});
|
|
358
375
|
return file;
|
|
359
376
|
}
|
|
360
377
|
async createDirectory(name) {
|
|
361
378
|
assertChildName(name);
|
|
362
|
-
await fsPromises.mkdir(this.path, {
|
|
379
|
+
await fsPromises.mkdir(toNodeFilesystemPath(this.path), {
|
|
380
|
+
recursive: true
|
|
381
|
+
});
|
|
363
382
|
const directory = new _NodeDirectory(pathModule.join(this.path, name));
|
|
364
|
-
await fsPromises.mkdir(directory.path);
|
|
383
|
+
await fsPromises.mkdir(toNodeFilesystemPath(directory.path));
|
|
365
384
|
return directory;
|
|
366
385
|
}
|
|
367
386
|
async remove(name, options) {
|
|
368
387
|
assertChildName(name);
|
|
369
|
-
await fsPromises.rm(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
388
|
+
await fsPromises.rm(
|
|
389
|
+
toNodeFilesystemPath(pathModule.join(this.path, name)),
|
|
390
|
+
{
|
|
391
|
+
force: true,
|
|
392
|
+
recursive: options?.recursive === true
|
|
393
|
+
}
|
|
394
|
+
);
|
|
373
395
|
}
|
|
374
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
|
+
}
|
|
375
407
|
function encodeNodeResourceIdentity(kind, path) {
|
|
376
408
|
return `node-${kind}:${Buffer.from(pathModule.resolve(path), "utf8").toString("base64url")}`;
|
|
377
409
|
}
|
|
@@ -457,10 +489,14 @@ async function openNativeNodeDatabase(file, flags) {
|
|
|
457
489
|
throw new TypeError("The Node database adapter requires a NodeFile");
|
|
458
490
|
}
|
|
459
491
|
return await new Promise((resolve4, reject) => {
|
|
460
|
-
const database = new nodeSqlite3.Database(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
492
|
+
const database = new nodeSqlite3.Database(
|
|
493
|
+
toNodeFilesystemPath(path),
|
|
494
|
+
flags,
|
|
495
|
+
(error) => {
|
|
496
|
+
if (error) reject(error);
|
|
497
|
+
else resolve4(database);
|
|
498
|
+
}
|
|
499
|
+
);
|
|
464
500
|
});
|
|
465
501
|
}
|
|
466
502
|
async function openNodeZip(file, options = {}) {
|
|
@@ -468,7 +504,7 @@ async function openNodeZip(file, options = {}) {
|
|
|
468
504
|
if (path === void 0) {
|
|
469
505
|
throw new TypeError("The Node ZIP adapter requires a NodeFile");
|
|
470
506
|
}
|
|
471
|
-
const handle = await fsPromises.open(path, "r");
|
|
507
|
+
const handle = await fsPromises.open(toNodeFilesystemPath(path), "r");
|
|
472
508
|
let size;
|
|
473
509
|
try {
|
|
474
510
|
size = (await handle.stat()).size;
|
|
@@ -783,6 +819,11 @@ async function writeNodeZip(file, entries) {
|
|
|
783
819
|
}
|
|
784
820
|
}
|
|
785
821
|
async function addNodeZipEntries(zipFile, iterator, state) {
|
|
822
|
+
const stableZipOptions = {
|
|
823
|
+
compress: false,
|
|
824
|
+
forceDosTimestamp: true,
|
|
825
|
+
mtime: new Date(1980, 0, 2)
|
|
826
|
+
};
|
|
786
827
|
while (!state.cancelled) {
|
|
787
828
|
const result = await iterator.next();
|
|
788
829
|
if (state.cancelled) return;
|
|
@@ -794,17 +835,17 @@ async function addNodeZipEntries(zipFile, iterator, state) {
|
|
|
794
835
|
zipFile.addReadStream(
|
|
795
836
|
createNodeFileReadStream(result.value.file),
|
|
796
837
|
result.value.name,
|
|
797
|
-
|
|
838
|
+
stableZipOptions
|
|
798
839
|
);
|
|
799
840
|
} else if ("data" in result.value) {
|
|
800
841
|
zipFile.addBuffer(Buffer.from(result.value.data), result.value.name, {
|
|
801
|
-
|
|
842
|
+
...stableZipOptions
|
|
802
843
|
});
|
|
803
844
|
} else {
|
|
804
845
|
zipFile.addReadStream(
|
|
805
846
|
createNodeRangeReadStream(result.value),
|
|
806
847
|
result.value.name,
|
|
807
|
-
{
|
|
848
|
+
{ ...stableZipOptions, size: result.value.size }
|
|
808
849
|
);
|
|
809
850
|
}
|
|
810
851
|
}
|
|
@@ -2628,7 +2669,10 @@ var WikiGraphArchiveManager = class {
|
|
|
2628
2669
|
});
|
|
2629
2670
|
}
|
|
2630
2671
|
if (options.replace === true) {
|
|
2631
|
-
await
|
|
2672
|
+
await new WikgCoordinator().withExclusiveArchiveReplacement(
|
|
2673
|
+
new NodeFile(path),
|
|
2674
|
+
async () => await rename2(outputPath, path)
|
|
2675
|
+
);
|
|
2632
2676
|
} else {
|
|
2633
2677
|
try {
|
|
2634
2678
|
await link(outputPath, path);
|
|
@@ -2657,6 +2701,18 @@ var WikiGraphArchiveManager = class {
|
|
|
2657
2701
|
}, options.signal);
|
|
2658
2702
|
return new WikiGraphArchiveHandle(this.#runtime, location);
|
|
2659
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
|
+
}
|
|
2660
2716
|
};
|
|
2661
2717
|
var WikiGraphArchiveHandle = class {
|
|
2662
2718
|
#runtime;
|
|
@@ -2683,6 +2739,19 @@ var WikiGraphArchiveHandle = class {
|
|
|
2683
2739
|
get target() {
|
|
2684
2740
|
return this.#location.target;
|
|
2685
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
|
+
}
|
|
2686
2755
|
async #persistCursor(cursor) {
|
|
2687
2756
|
return await this.#runtime.run(
|
|
2688
2757
|
async () => await createContinuationCursor(cursor)
|
|
@@ -3215,6 +3284,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
3215
3284
|
options
|
|
3216
3285
|
);
|
|
3217
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
|
+
}
|
|
3218
3319
|
async replaceBookMeta(meta, options = {}) {
|
|
3219
3320
|
return await this.#writeDocument(async (document) => {
|
|
3220
3321
|
await document.replaceBookMeta(meta);
|
|
@@ -3302,6 +3403,33 @@ var WikiGraphArchiveHandle = class {
|
|
|
3302
3403
|
(error) => rethrowArchiveSchemaError(error, this.#location.target)
|
|
3303
3404
|
);
|
|
3304
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
|
+
}
|
|
3305
3433
|
async #writeDocument(operation, options = {}) {
|
|
3306
3434
|
return await this.#runtime.run(async () => {
|
|
3307
3435
|
return await writeWikiGraphArchiveLocation(this.#location, operation, {
|
|
@@ -3496,6 +3624,94 @@ function requireChapter(chapters, chapterId) {
|
|
|
3496
3624
|
function asTextStream(text) {
|
|
3497
3625
|
return Readable2.from([text]);
|
|
3498
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
|
+
}
|
|
3499
3715
|
async function assertChapterResetAllowed(archive, chapterId, stage) {
|
|
3500
3716
|
if (stage === "planned") {
|
|
3501
3717
|
await assertNoActiveBuildJobs({
|
|
@@ -4036,7 +4252,7 @@ function createLibraryQueryPayload(context) {
|
|
|
4036
4252
|
// src/default-worker.ts
|
|
4037
4253
|
import {
|
|
4038
4254
|
getBuildJob,
|
|
4039
|
-
getChapterDetails,
|
|
4255
|
+
getChapterDetails as getChapterDetails2,
|
|
4040
4256
|
openWikimediaResolver as openWikimediaResolver2,
|
|
4041
4257
|
recordBuildJobInputRevision,
|
|
4042
4258
|
WikiGraphArchiveFile as WikiGraphArchiveFile5,
|
|
@@ -4380,7 +4596,7 @@ async function executeStep(job, kind, execution, reporter, context, inputOptions
|
|
|
4380
4596
|
const outputWorkspace = await stepWorkspace.createDirectory("output");
|
|
4381
4597
|
const revision = await new WikiGraphArchiveFile5(job.archive).readDocument(
|
|
4382
4598
|
async (document) => {
|
|
4383
|
-
await
|
|
4599
|
+
await getChapterDetails2(document, job.chapterId);
|
|
4384
4600
|
return await writeChapterJobInputFile3(
|
|
4385
4601
|
document,
|
|
4386
4602
|
job.chapterId,
|
|
@@ -4522,7 +4738,7 @@ async function resetStepWorkspace(workspace, kind) {
|
|
|
4522
4738
|
}
|
|
4523
4739
|
async function readChapterStage(job) {
|
|
4524
4740
|
return await new WikiGraphArchiveFile5(job.archive).readDocument(
|
|
4525
|
-
async (document) => (await
|
|
4741
|
+
async (document) => (await getChapterDetails2(document, job.chapterId)).stage
|
|
4526
4742
|
);
|
|
4527
4743
|
}
|
|
4528
4744
|
async function assertCurrentFtsArtifact(job) {
|