wiki-graph-sdk 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/archives.cjs +25 -19
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +2 -0
- package/dist/archives.js +14 -7
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +11 -12
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +7 -7
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +83 -20
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +84 -17
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs +6 -7
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +7 -7
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +106 -12
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +3 -0
- package/dist/gc.js +110 -12
- package/dist/gc.js.map +1 -1
- package/dist/host-IbqJ8WSV.d.ts +18 -0
- package/dist/index.cjs +127 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +119 -21
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs +6 -7
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +7 -7
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +1 -0
- package/dist/maintenance.js.map +1 -1
- package/dist/node-platform.cjs +18 -4
- package/dist/node-platform.cjs.map +1 -1
- package/dist/node-platform.d.ts +12 -3
- package/dist/node-platform.js +18 -4
- package/dist/node-platform.js.map +1 -1
- package/dist/runtime-config.cjs +6 -7
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +7 -7
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs +6 -7
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +7 -7
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +113 -50
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +7 -2
- package/dist/worker.js +125 -58
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/default-worker.cjs
CHANGED
|
@@ -65,6 +65,9 @@ function getRuntimeContextStorage() {
|
|
|
65
65
|
});
|
|
66
66
|
return storage;
|
|
67
67
|
}
|
|
68
|
+
async function withWikiGraphSDKRuntimeContext(context, operation) {
|
|
69
|
+
return await runtimeContext.run(context, operation);
|
|
70
|
+
}
|
|
68
71
|
function getWikiGraphSDKRuntimeContext() {
|
|
69
72
|
return runtimeContext.getStore() ?? {
|
|
70
73
|
cwd: process.cwd(),
|
|
@@ -74,7 +77,8 @@ function getWikiGraphSDKRuntimeContext() {
|
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
function getWikiGraphSDKStateDir() {
|
|
77
|
-
|
|
80
|
+
const context = getWikiGraphSDKRuntimeContext();
|
|
81
|
+
return context.host?.stateDir ?? context.stateDir;
|
|
78
82
|
}
|
|
79
83
|
function getWikiGraphSDKProviders() {
|
|
80
84
|
return getWikiGraphSDKRuntimeContext().providers ?? {};
|
|
@@ -750,15 +754,28 @@ function resolveNodeDataDirectory() {
|
|
|
750
754
|
directory = parent;
|
|
751
755
|
}
|
|
752
756
|
}
|
|
753
|
-
function createNodeWikiGraphStorage(
|
|
757
|
+
function createNodeWikiGraphStorage(stateRootOrOptions = pathModule.join(
|
|
758
|
+
os.homedir(),
|
|
759
|
+
".wikigraph"
|
|
760
|
+
)) {
|
|
761
|
+
const libraryRoot = typeof stateRootOrOptions === "string" ? stateRootOrOptions : stateRootOrOptions.libraryRoot;
|
|
762
|
+
const documentStoreRoot = typeof stateRootOrOptions === "string" ? pathModule.join(stateRootOrOptions, "documents") : stateRootOrOptions.documentStoreRoot;
|
|
754
763
|
return {
|
|
755
|
-
library: new NodeDirectory(
|
|
756
|
-
documentStore: new NodeDirectory(
|
|
764
|
+
library: new NodeDirectory(libraryRoot),
|
|
765
|
+
documentStore: new NodeDirectory(documentStoreRoot)
|
|
757
766
|
};
|
|
758
767
|
}
|
|
759
|
-
function
|
|
760
|
-
|
|
761
|
-
|
|
768
|
+
function ensureNodeWikiGraphPlatform() {
|
|
769
|
+
try {
|
|
770
|
+
(0, import_platform.getWikiGraphPlatform)();
|
|
771
|
+
} catch {
|
|
772
|
+
(0, import_platform.installWikiGraphPlatform)(nodeWikiGraphPlatform);
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
(0, import_platform.getWikiGraphStorage)();
|
|
776
|
+
} catch {
|
|
777
|
+
(0, import_platform.installWikiGraphStorage)(createNodeWikiGraphStorage());
|
|
778
|
+
}
|
|
762
779
|
}
|
|
763
780
|
async function withNodeWikiGraphStorage(stateRoot, operation) {
|
|
764
781
|
return await (0, import_platform.withWikiGraphStorage)(
|
|
@@ -768,6 +785,7 @@ async function withNodeWikiGraphStorage(stateRoot, operation) {
|
|
|
768
785
|
}
|
|
769
786
|
|
|
770
787
|
// src/local-config.ts
|
|
788
|
+
var import_promises2 = require("fs/promises");
|
|
771
789
|
var import_path = require("path");
|
|
772
790
|
var import_os = require("os");
|
|
773
791
|
var LOCAL_CONFIG_SCHEMA_SQL = `
|
|
@@ -797,13 +815,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
797
815
|
}
|
|
798
816
|
}
|
|
799
817
|
async function withLocalConfigDatabase(operation) {
|
|
818
|
+
const stateDir = getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph");
|
|
819
|
+
await (0, import_promises2.mkdir)(stateDir, { recursive: true });
|
|
800
820
|
const database = await (0, import_wiki_graph_core.openSharedStateDatabase)(
|
|
801
|
-
new NodeFile(
|
|
802
|
-
(0, import_path.join)(
|
|
803
|
-
getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph"),
|
|
804
|
-
"core.sqlite"
|
|
805
|
-
)
|
|
806
|
-
),
|
|
821
|
+
new NodeFile((0, import_path.join)(stateDir, "core.sqlite")),
|
|
807
822
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
808
823
|
);
|
|
809
824
|
try {
|
|
@@ -1468,8 +1483,54 @@ function abortError(signal) {
|
|
|
1468
1483
|
var import_worker = require("wiki-graph-core/worker");
|
|
1469
1484
|
var import_wiki_graph_core7 = require("wiki-graph-core");
|
|
1470
1485
|
|
|
1486
|
+
// src/host.ts
|
|
1487
|
+
var import_platform2 = require("wiki-graph-core/platform");
|
|
1488
|
+
function prepareWikiGraphSDKHost(host) {
|
|
1489
|
+
if (host?.platform === void 0) {
|
|
1490
|
+
ensureNodeWikiGraphPlatform();
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
(0, import_platform2.installWikiGraphPlatform)(host.platform);
|
|
1494
|
+
}
|
|
1495
|
+
function assertWikiGraphSDKHostOptions(options) {
|
|
1496
|
+
if (options.host?.storage !== void 0 && options.host.stateDir === void 0) {
|
|
1497
|
+
throw new TypeError(
|
|
1498
|
+
"Wiki Graph SDK host.storage requires host.stateDir so SDK configuration cannot fall back to the default user state directory."
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
if (options.stateDir !== void 0 && (options.host?.stateDir !== void 0 || options.host?.storage !== void 0)) {
|
|
1502
|
+
throw new TypeError(
|
|
1503
|
+
"Wiki Graph SDK host state/storage and top-level stateDir cannot be used together. Put the state directory in host.stateDir when providing host.storage."
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
async function withWikiGraphSDKHost(options, operation) {
|
|
1508
|
+
const current = getWikiGraphSDKRuntimeContext();
|
|
1509
|
+
const effective = {
|
|
1510
|
+
...options.host === void 0 ? current.host === void 0 ? {} : { host: current.host } : { host: options.host },
|
|
1511
|
+
...options.stateDir === void 0 ? current.stateDir === void 0 ? {} : { stateDir: current.stateDir } : { stateDir: options.stateDir }
|
|
1512
|
+
};
|
|
1513
|
+
assertWikiGraphSDKHostOptions(effective);
|
|
1514
|
+
prepareWikiGraphSDKHost(effective.host);
|
|
1515
|
+
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(
|
|
1516
|
+
{
|
|
1517
|
+
...current,
|
|
1518
|
+
...effective.host === void 0 ? {} : { host: effective.host },
|
|
1519
|
+
...effective.stateDir === void 0 ? {} : { stateDir: effective.stateDir }
|
|
1520
|
+
},
|
|
1521
|
+
operation
|
|
1522
|
+
);
|
|
1523
|
+
if (effective.host?.storage !== void 0) {
|
|
1524
|
+
return await (0, import_platform2.withWikiGraphStorage)(effective.host.storage, runWithContext);
|
|
1525
|
+
}
|
|
1526
|
+
return await withNodeWikiGraphStorage(
|
|
1527
|
+
effective.host?.stateDir ?? effective.stateDir,
|
|
1528
|
+
runWithContext
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1471
1532
|
// src/archive/target.ts
|
|
1472
|
-
var
|
|
1533
|
+
var import_promises3 = require("fs/promises");
|
|
1473
1534
|
var import_path3 = require("path");
|
|
1474
1535
|
var import_wiki_graph_core5 = require("wiki-graph-core");
|
|
1475
1536
|
|
|
@@ -1597,7 +1658,7 @@ async function resolveLibraryLocation(target) {
|
|
|
1597
1658
|
}
|
|
1598
1659
|
async function canonicalPath(path) {
|
|
1599
1660
|
try {
|
|
1600
|
-
return await (0,
|
|
1661
|
+
return await (0, import_promises3.realpath)(path);
|
|
1601
1662
|
} catch {
|
|
1602
1663
|
const absolute = (0, import_path3.resolve)(path);
|
|
1603
1664
|
const parent = (0, import_path3.dirname)(absolute);
|
|
@@ -1648,7 +1709,7 @@ function requireUnambiguousManagedMatch(path, matches) {
|
|
|
1648
1709
|
}
|
|
1649
1710
|
async function readFileIdentity(path) {
|
|
1650
1711
|
try {
|
|
1651
|
-
const value = await (0,
|
|
1712
|
+
const value = await (0, import_promises3.stat)(path);
|
|
1652
1713
|
return `${value.dev}:${value.ino}`;
|
|
1653
1714
|
} catch {
|
|
1654
1715
|
return void 0;
|
|
@@ -1683,10 +1744,12 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
|
|
|
1683
1744
|
// src/worker.ts
|
|
1684
1745
|
var import_worker2 = require("wiki-graph-core/worker");
|
|
1685
1746
|
async function runBuildJobWorker(options) {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1747
|
+
const { host, stateDir, ...coreOptions } = options;
|
|
1748
|
+
await withWikiGraphSDKHost(
|
|
1749
|
+
{
|
|
1750
|
+
...host === void 0 ? {} : { host },
|
|
1751
|
+
...stateDir === void 0 ? {} : { stateDir }
|
|
1752
|
+
},
|
|
1690
1753
|
async () => await (0, import_worker.runBuildJobWorker)(coreOptions)
|
|
1691
1754
|
);
|
|
1692
1755
|
}
|