@zaclinley/dsh-mailharbor 0.7.0 → 0.7.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/CHANGELOG.md +23 -0
- package/lib/client.js +327 -7
- package/lib/client.js.map +2 -2
- package/lib/index.js +66 -1
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -878,6 +878,27 @@ async function pickDirectory(defaultPath) {
|
|
|
878
878
|
throw new Error("\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u6253\u5F00\u76EE\u5F55\u9009\u62E9\u5668\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u8DEF\u5F84");
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
|
+
async function openPath(path) {
|
|
882
|
+
try {
|
|
883
|
+
const require2 = createRequire(import.meta.url);
|
|
884
|
+
const electron = require2("electron");
|
|
885
|
+
if (electron.shell !== void 0) {
|
|
886
|
+
const error = await electron.shell.openPath(path);
|
|
887
|
+
if (error !== "") throw new Error(error);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
} catch {
|
|
891
|
+
}
|
|
892
|
+
if (process.platform === "darwin") {
|
|
893
|
+
await run("open", [path]);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (process.platform === "win32") {
|
|
897
|
+
await run("explorer", [path]);
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
await run("xdg-open", [path]);
|
|
901
|
+
}
|
|
881
902
|
|
|
882
903
|
// src/host/backup.ts
|
|
883
904
|
init_address();
|
|
@@ -2171,6 +2192,14 @@ var ProjectStore = class {
|
|
|
2171
2192
|
this.flush();
|
|
2172
2193
|
return project;
|
|
2173
2194
|
}
|
|
2195
|
+
remove(id) {
|
|
2196
|
+
const data = this.load();
|
|
2197
|
+
const index = data.projects.findIndex((project) => project.id === id);
|
|
2198
|
+
if (index < 0) return false;
|
|
2199
|
+
data.projects.splice(index, 1);
|
|
2200
|
+
this.flush();
|
|
2201
|
+
return true;
|
|
2202
|
+
}
|
|
2174
2203
|
addThread(id, thread) {
|
|
2175
2204
|
const project = this.get(id);
|
|
2176
2205
|
if (project === void 0) return void 0;
|
|
@@ -2309,7 +2338,7 @@ ${conversation.trim()}
|
|
|
2309
2338
|
}
|
|
2310
2339
|
|
|
2311
2340
|
// src/host/version.ts
|
|
2312
|
-
var VERSION = "0.7.
|
|
2341
|
+
var VERSION = "0.7.2";
|
|
2313
2342
|
|
|
2314
2343
|
// src/host/api.ts
|
|
2315
2344
|
init_smtp();
|
|
@@ -2958,6 +2987,37 @@ function buildRouter(runtime) {
|
|
|
2958
2987
|
});
|
|
2959
2988
|
return { project: projectView(result.project), warnings: result.warnings };
|
|
2960
2989
|
});
|
|
2990
|
+
router.patch("/projects/:id", async ({ params, body }) => {
|
|
2991
|
+
const payload = await body();
|
|
2992
|
+
const name2 = String(payload.name ?? "").trim();
|
|
2993
|
+
if (name2 === "") throw new HttpError(400, "\u9879\u76EE\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A");
|
|
2994
|
+
const project = runtime.projects().update(String(params.id ?? ""), { name: name2 });
|
|
2995
|
+
if (project === void 0) throw new HttpError(404, "\u9879\u76EE\u4E0D\u5B58\u5728");
|
|
2996
|
+
return { project: projectView(project) };
|
|
2997
|
+
});
|
|
2998
|
+
router.delete("/projects/:id", ({ params }) => {
|
|
2999
|
+
const id = String(params.id ?? "");
|
|
3000
|
+
const project = runtime.projects().get(id);
|
|
3001
|
+
if (project === void 0) throw new HttpError(404, "\u9879\u76EE\u4E0D\u5B58\u5728");
|
|
3002
|
+
const removed = runtime.projects().remove(id);
|
|
3003
|
+
const unlinked = runtime.tasks().clearProject(id);
|
|
3004
|
+
return {
|
|
3005
|
+
ok: removed,
|
|
3006
|
+
path: project.path,
|
|
3007
|
+
unlinkedTasks: unlinked,
|
|
3008
|
+
workspaceKept: project.workspaceId !== ""
|
|
3009
|
+
};
|
|
3010
|
+
});
|
|
3011
|
+
router.post("/projects/:id/open", async ({ params }) => {
|
|
3012
|
+
const project = runtime.projects().get(String(params.id ?? ""));
|
|
3013
|
+
if (project === void 0) throw new HttpError(404, "\u9879\u76EE\u4E0D\u5B58\u5728");
|
|
3014
|
+
try {
|
|
3015
|
+
await openPath(project.path);
|
|
3016
|
+
return { path: project.path };
|
|
3017
|
+
} catch (error) {
|
|
3018
|
+
throw new HttpError(400, error instanceof Error ? error.message : String(error));
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
2961
3021
|
router.post("/projects/:id/messages", async ({ params, body }) => {
|
|
2962
3022
|
const payload = await body();
|
|
2963
3023
|
const account = accountFromPayload(runtime, payload);
|
|
@@ -3854,6 +3914,11 @@ var TaskStore = class {
|
|
|
3854
3914
|
if (task === void 0) throw new Error("\u4EFB\u52A1\u66F4\u65B0\u5931\u8D25");
|
|
3855
3915
|
return task;
|
|
3856
3916
|
}
|
|
3917
|
+
/** Unlink tasks when their project is deleted. */
|
|
3918
|
+
clearProject(projectId) {
|
|
3919
|
+
const result = this.open().prepare("UPDATE tasks SET project_id = NULL, dirty = 1, updated_at = ? WHERE project_id = ?").run(now(), projectId);
|
|
3920
|
+
return Number(result.changes);
|
|
3921
|
+
}
|
|
3857
3922
|
remove(id) {
|
|
3858
3923
|
const current = this.get(id);
|
|
3859
3924
|
if (current === void 0) return false;
|