@hamak/smart-data-dico 1.9.0 → 1.9.2
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/backend/dist/server.mjs +29 -13
- package/backend/dist/validate.mjs +10559 -0
- package/bin/cli.js +113 -39
- package/frontend/dist/assets/{index-399555bb.js → index-5d106eea.js} +75 -75
- package/frontend/dist/index.html +1 -1
- package/package.json +2 -2
package/backend/dist/server.mjs
CHANGED
|
@@ -81365,13 +81365,14 @@ function getConfigSection(section) {
|
|
|
81365
81365
|
function setConfigSection(section, value) {
|
|
81366
81366
|
writeAppConfig({ [section]: value });
|
|
81367
81367
|
}
|
|
81368
|
-
var APP_DIR, CONFIG_FILE, STORAGE_DIR, CONVERSATIONS_DIR, PROMPTS_DIR, LEGACY_CONFIG, loosePermsWarned;
|
|
81368
|
+
var APP_DIR, CONFIG_FILE, ACTIVE_PROJECT_FILE, STORAGE_DIR, CONVERSATIONS_DIR, PROMPTS_DIR, LEGACY_CONFIG, loosePermsWarned;
|
|
81369
81369
|
var init_appDir = __esm({
|
|
81370
81370
|
"backend/src/utils/appDir.ts"() {
|
|
81371
81371
|
"use strict";
|
|
81372
81372
|
init_logger();
|
|
81373
81373
|
APP_DIR = path8.join(os.homedir(), ".dico-app");
|
|
81374
81374
|
CONFIG_FILE = path8.join(APP_DIR, "dico-app.json");
|
|
81375
|
+
ACTIVE_PROJECT_FILE = path8.join(APP_DIR, "active-project");
|
|
81375
81376
|
STORAGE_DIR = path8.join(APP_DIR, "storage");
|
|
81376
81377
|
CONVERSATIONS_DIR = path8.join(STORAGE_DIR, "conversations");
|
|
81377
81378
|
PROMPTS_DIR = path8.join(STORAGE_DIR, "prompts");
|
|
@@ -161603,7 +161604,31 @@ init_config();
|
|
|
161603
161604
|
import fs2 from "fs";
|
|
161604
161605
|
import path9 from "path";
|
|
161605
161606
|
import os2 from "os";
|
|
161607
|
+
init_appDir();
|
|
161608
|
+
init_logger();
|
|
161606
161609
|
var router25 = (0, import_express26.Router)();
|
|
161610
|
+
var RESTART_EXIT_CODE = 75;
|
|
161611
|
+
function applyProjectSwitch(req, res, dataDir, message) {
|
|
161612
|
+
if (process.env.SDD_MANAGED === "1") {
|
|
161613
|
+
try {
|
|
161614
|
+
fs2.mkdirSync(path9.dirname(ACTIVE_PROJECT_FILE), { recursive: true });
|
|
161615
|
+
fs2.writeFileSync(ACTIVE_PROJECT_FILE, dataDir, "utf-8");
|
|
161616
|
+
} catch (e) {
|
|
161617
|
+
logger.error(`Project switch: failed to persist target dir: ${e}`);
|
|
161618
|
+
res.status(500).json({ message: "Failed to switch project (could not persist target)." });
|
|
161619
|
+
return;
|
|
161620
|
+
}
|
|
161621
|
+
res.json({ message, data: { path: dataDir, name: path9.basename(path9.dirname(dataDir)) }, restarting: true });
|
|
161622
|
+
logger.info(`Project switch \u2192 restarting to load ${dataDir}`);
|
|
161623
|
+
setTimeout(() => process.exit(RESTART_EXIT_CODE), 250);
|
|
161624
|
+
return;
|
|
161625
|
+
}
|
|
161626
|
+
config.dataDir = dataDir;
|
|
161627
|
+
const roots = req.app.__workspaceRoots;
|
|
161628
|
+
if (roots) roots.set("dictionaries", dataDir);
|
|
161629
|
+
res.json({ message, data: { path: dataDir, name: path9.basename(path9.dirname(dataDir)) }, restarting: false });
|
|
161630
|
+
}
|
|
161631
|
+
__name(applyProjectSwitch, "applyProjectSwitch");
|
|
161607
161632
|
router25.get("/api/filesystem/browse", (req, res) => {
|
|
161608
161633
|
if (config.profile !== "local") {
|
|
161609
161634
|
return res.status(403).json({ message: "Filesystem browsing is only available in local mode" });
|
|
@@ -161668,10 +161693,7 @@ router25.post("/api/project/open", authorizeJwt(["admin" /* ADMIN */]), (req, re
|
|
|
161668
161693
|
message: `No dico.config.json found at ${resolved}. Use /api/project/init to create one.`
|
|
161669
161694
|
});
|
|
161670
161695
|
}
|
|
161671
|
-
|
|
161672
|
-
const roots = req.app.__workspaceRoots;
|
|
161673
|
-
if (roots) roots.set("dictionaries", dataDir);
|
|
161674
|
-
res.json({ message: `Project opened: ${dataDir}`, data: { path: dataDir, name: path9.basename(path9.dirname(dataDir)) } });
|
|
161696
|
+
applyProjectSwitch(req, res, dataDir, `Project opened: ${dataDir}`);
|
|
161675
161697
|
});
|
|
161676
161698
|
router25.post("/api/project/close", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
|
|
161677
161699
|
if (config.profile !== "local") {
|
|
@@ -161679,10 +161701,7 @@ router25.post("/api/project/close", authorizeJwt(["admin" /* ADMIN */]), (req, r
|
|
|
161679
161701
|
}
|
|
161680
161702
|
const emptyDir = path9.join(os2.tmpdir(), "smart-data-dico-closed");
|
|
161681
161703
|
if (!fs2.existsSync(emptyDir)) fs2.mkdirSync(emptyDir, { recursive: true });
|
|
161682
|
-
|
|
161683
|
-
const roots = req.app.__workspaceRoots;
|
|
161684
|
-
if (roots) roots.set("dictionaries", emptyDir);
|
|
161685
|
-
res.json({ message: "Project closed" });
|
|
161704
|
+
applyProjectSwitch(req, res, emptyDir, "Project closed");
|
|
161686
161705
|
});
|
|
161687
161706
|
router25.post("/api/project/init", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
|
|
161688
161707
|
if (config.profile !== "local") {
|
|
@@ -161705,10 +161724,7 @@ router25.post("/api/project/init", authorizeJwt(["admin" /* ADMIN */]), (req, re
|
|
|
161705
161724
|
if (!fs2.existsSync(stereotypesPath)) {
|
|
161706
161725
|
fs2.writeFileSync(stereotypesPath, "[]", "utf-8");
|
|
161707
161726
|
}
|
|
161708
|
-
|
|
161709
|
-
const roots = req.app.__workspaceRoots;
|
|
161710
|
-
if (roots) roots.set("dictionaries", dataDir);
|
|
161711
|
-
res.json({ message: `Project initialized and opened: ${dataDir}`, data: { path: dataDir } });
|
|
161727
|
+
applyProjectSwitch(req, res, dataDir, `Project initialized and opened: ${dataDir}`);
|
|
161712
161728
|
} catch (e) {
|
|
161713
161729
|
res.status(500).json({ message: `Failed to initialize project: ${e}` });
|
|
161714
161730
|
}
|