wiki-graph-sdk 0.8.2 → 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 +8 -3
- package/dist/archives.cjs +18 -19
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.js +6 -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 +6 -7
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +40 -17
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +37 -14
- 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 +6 -7
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +61 -9
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +1 -1
- package/dist/gc.js +61 -9
- package/dist/gc.js.map +1 -1
- package/dist/host-IbqJ8WSV.d.ts +18 -0
- package/dist/index.cjs +48 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -16
- 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 +6 -7
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js.map +1 -1
- package/dist/runtime-config.cjs +6 -7
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +6 -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 +6 -7
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +55 -31
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +61 -37
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
- package/dist/host-pQiVAKEY.d.ts +0 -10
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 ?? {};
|
|
@@ -781,6 +785,7 @@ async function withNodeWikiGraphStorage(stateRoot, operation) {
|
|
|
781
785
|
}
|
|
782
786
|
|
|
783
787
|
// src/local-config.ts
|
|
788
|
+
var import_promises2 = require("fs/promises");
|
|
784
789
|
var import_path = require("path");
|
|
785
790
|
var import_os = require("os");
|
|
786
791
|
var LOCAL_CONFIG_SCHEMA_SQL = `
|
|
@@ -810,13 +815,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
810
815
|
}
|
|
811
816
|
}
|
|
812
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 });
|
|
813
820
|
const database = await (0, import_wiki_graph_core.openSharedStateDatabase)(
|
|
814
|
-
new NodeFile(
|
|
815
|
-
(0, import_path.join)(
|
|
816
|
-
getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph"),
|
|
817
|
-
"core.sqlite"
|
|
818
|
-
)
|
|
819
|
-
),
|
|
821
|
+
new NodeFile((0, import_path.join)(stateDir, "core.sqlite")),
|
|
820
822
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
821
823
|
);
|
|
822
824
|
try {
|
|
@@ -1491,23 +1493,44 @@ function prepareWikiGraphSDKHost(host) {
|
|
|
1491
1493
|
(0, import_platform2.installWikiGraphPlatform)(host.platform);
|
|
1492
1494
|
}
|
|
1493
1495
|
function assertWikiGraphSDKHostOptions(options) {
|
|
1494
|
-
if (options.host?.storage !== void 0 && options.stateDir
|
|
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)) {
|
|
1495
1502
|
throw new TypeError(
|
|
1496
|
-
"Wiki Graph SDK host
|
|
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."
|
|
1497
1504
|
);
|
|
1498
1505
|
}
|
|
1499
1506
|
}
|
|
1500
1507
|
async function withWikiGraphSDKHost(options, operation) {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
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);
|
|
1505
1525
|
}
|
|
1506
|
-
return await withNodeWikiGraphStorage(
|
|
1526
|
+
return await withNodeWikiGraphStorage(
|
|
1527
|
+
effective.host?.stateDir ?? effective.stateDir,
|
|
1528
|
+
runWithContext
|
|
1529
|
+
);
|
|
1507
1530
|
}
|
|
1508
1531
|
|
|
1509
1532
|
// src/archive/target.ts
|
|
1510
|
-
var
|
|
1533
|
+
var import_promises3 = require("fs/promises");
|
|
1511
1534
|
var import_path3 = require("path");
|
|
1512
1535
|
var import_wiki_graph_core5 = require("wiki-graph-core");
|
|
1513
1536
|
|
|
@@ -1635,7 +1658,7 @@ async function resolveLibraryLocation(target) {
|
|
|
1635
1658
|
}
|
|
1636
1659
|
async function canonicalPath(path) {
|
|
1637
1660
|
try {
|
|
1638
|
-
return await (0,
|
|
1661
|
+
return await (0, import_promises3.realpath)(path);
|
|
1639
1662
|
} catch {
|
|
1640
1663
|
const absolute = (0, import_path3.resolve)(path);
|
|
1641
1664
|
const parent = (0, import_path3.dirname)(absolute);
|
|
@@ -1686,7 +1709,7 @@ function requireUnambiguousManagedMatch(path, matches) {
|
|
|
1686
1709
|
}
|
|
1687
1710
|
async function readFileIdentity(path) {
|
|
1688
1711
|
try {
|
|
1689
|
-
const value = await (0,
|
|
1712
|
+
const value = await (0, import_promises3.stat)(path);
|
|
1690
1713
|
return `${value.dev}:${value.ino}`;
|
|
1691
1714
|
} catch {
|
|
1692
1715
|
return void 0;
|