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.js
CHANGED
|
@@ -45,6 +45,9 @@ function getRuntimeContextStorage() {
|
|
|
45
45
|
});
|
|
46
46
|
return storage;
|
|
47
47
|
}
|
|
48
|
+
async function withWikiGraphSDKRuntimeContext(context, operation) {
|
|
49
|
+
return await runtimeContext.run(context, operation);
|
|
50
|
+
}
|
|
48
51
|
function getWikiGraphSDKRuntimeContext() {
|
|
49
52
|
return runtimeContext.getStore() ?? {
|
|
50
53
|
cwd: process.cwd(),
|
|
@@ -54,7 +57,8 @@ function getWikiGraphSDKRuntimeContext() {
|
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
function getWikiGraphSDKStateDir() {
|
|
57
|
-
|
|
60
|
+
const context = getWikiGraphSDKRuntimeContext();
|
|
61
|
+
return context.host?.stateDir ?? context.stateDir;
|
|
58
62
|
}
|
|
59
63
|
function getWikiGraphSDKProviders() {
|
|
60
64
|
return getWikiGraphSDKRuntimeContext().providers ?? {};
|
|
@@ -768,6 +772,7 @@ async function withNodeWikiGraphStorage(stateRoot, operation) {
|
|
|
768
772
|
}
|
|
769
773
|
|
|
770
774
|
// src/local-config.ts
|
|
775
|
+
import { mkdir as mkdir2 } from "fs/promises";
|
|
771
776
|
import { join as join2 } from "path";
|
|
772
777
|
import { homedir as homedir2 } from "os";
|
|
773
778
|
var LOCAL_CONFIG_SCHEMA_SQL = `
|
|
@@ -797,13 +802,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
797
802
|
}
|
|
798
803
|
}
|
|
799
804
|
async function withLocalConfigDatabase(operation) {
|
|
805
|
+
const stateDir = getWikiGraphSDKStateDir() ?? join2(homedir2(), ".wikigraph");
|
|
806
|
+
await mkdir2(stateDir, { recursive: true });
|
|
800
807
|
const database = await openSharedStateDatabase(
|
|
801
|
-
new NodeFile(
|
|
802
|
-
join2(
|
|
803
|
-
getWikiGraphSDKStateDir() ?? join2(homedir2(), ".wikigraph"),
|
|
804
|
-
"core.sqlite"
|
|
805
|
-
)
|
|
806
|
-
),
|
|
808
|
+
new NodeFile(join2(stateDir, "core.sqlite")),
|
|
807
809
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
808
810
|
);
|
|
809
811
|
try {
|
|
@@ -1493,19 +1495,40 @@ function prepareWikiGraphSDKHost(host) {
|
|
|
1493
1495
|
installWikiGraphPlatform2(host.platform);
|
|
1494
1496
|
}
|
|
1495
1497
|
function assertWikiGraphSDKHostOptions(options) {
|
|
1496
|
-
if (options.host?.storage !== void 0 && options.stateDir
|
|
1498
|
+
if (options.host?.storage !== void 0 && options.host.stateDir === void 0) {
|
|
1499
|
+
throw new TypeError(
|
|
1500
|
+
"Wiki Graph SDK host.storage requires host.stateDir so SDK configuration cannot fall back to the default user state directory."
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
if (options.stateDir !== void 0 && (options.host?.stateDir !== void 0 || options.host?.storage !== void 0)) {
|
|
1497
1504
|
throw new TypeError(
|
|
1498
|
-
"Wiki Graph SDK host
|
|
1505
|
+
"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."
|
|
1499
1506
|
);
|
|
1500
1507
|
}
|
|
1501
1508
|
}
|
|
1502
1509
|
async function withWikiGraphSDKHost(options, operation) {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1510
|
+
const current = getWikiGraphSDKRuntimeContext();
|
|
1511
|
+
const effective = {
|
|
1512
|
+
...options.host === void 0 ? current.host === void 0 ? {} : { host: current.host } : { host: options.host },
|
|
1513
|
+
...options.stateDir === void 0 ? current.stateDir === void 0 ? {} : { stateDir: current.stateDir } : { stateDir: options.stateDir }
|
|
1514
|
+
};
|
|
1515
|
+
assertWikiGraphSDKHostOptions(effective);
|
|
1516
|
+
prepareWikiGraphSDKHost(effective.host);
|
|
1517
|
+
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(
|
|
1518
|
+
{
|
|
1519
|
+
...current,
|
|
1520
|
+
...effective.host === void 0 ? {} : { host: effective.host },
|
|
1521
|
+
...effective.stateDir === void 0 ? {} : { stateDir: effective.stateDir }
|
|
1522
|
+
},
|
|
1523
|
+
operation
|
|
1524
|
+
);
|
|
1525
|
+
if (effective.host?.storage !== void 0) {
|
|
1526
|
+
return await withWikiGraphStorage2(effective.host.storage, runWithContext);
|
|
1507
1527
|
}
|
|
1508
|
-
return await withNodeWikiGraphStorage(
|
|
1528
|
+
return await withNodeWikiGraphStorage(
|
|
1529
|
+
effective.host?.stateDir ?? effective.stateDir,
|
|
1530
|
+
runWithContext
|
|
1531
|
+
);
|
|
1509
1532
|
}
|
|
1510
1533
|
|
|
1511
1534
|
// src/archive/target.ts
|