swarm-mail 0.3.3 → 0.3.4
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/dist/index.js +36 -9
- package/dist/pglite.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18912,6 +18912,18 @@ function getDatabasePath2(projectPath) {
|
|
|
18912
18912
|
return join4(globalTmpDir, "streams");
|
|
18913
18913
|
}
|
|
18914
18914
|
var instances2 = new Map;
|
|
18915
|
+
var initPromises = new Map;
|
|
18916
|
+
function formatError2(error45) {
|
|
18917
|
+
if (error45 instanceof Error)
|
|
18918
|
+
return error45.message;
|
|
18919
|
+
if (typeof error45 === "string")
|
|
18920
|
+
return error45;
|
|
18921
|
+
try {
|
|
18922
|
+
return JSON.stringify(error45, Object.getOwnPropertyNames(error45));
|
|
18923
|
+
} catch {
|
|
18924
|
+
return String(error45);
|
|
18925
|
+
}
|
|
18926
|
+
}
|
|
18915
18927
|
function isWasmAbortError(error45) {
|
|
18916
18928
|
if (error45 instanceof Error) {
|
|
18917
18929
|
const message = error45.message.toLowerCase();
|
|
@@ -18927,16 +18939,18 @@ async function createPGliteWithRecovery(dbPath) {
|
|
|
18927
18939
|
} catch (error45) {
|
|
18928
18940
|
if (isWasmAbortError(error45)) {
|
|
18929
18941
|
console.warn(`[swarm-mail] PGLite WASM abort detected, recovering by deleting corrupted database: ${dbPath}`);
|
|
18930
|
-
if (existsSync4(dbPath)) {
|
|
18942
|
+
if (!existsSync4(dbPath)) {
|
|
18943
|
+
console.log("[swarm-mail] Database already cleaned up by another process");
|
|
18944
|
+
} else {
|
|
18931
18945
|
rmSync(dbPath, { recursive: true, force: true });
|
|
18932
18946
|
}
|
|
18933
18947
|
try {
|
|
18934
18948
|
const pglite = new PGlite2(dbPath);
|
|
18935
18949
|
await pglite.query("SELECT 1");
|
|
18936
|
-
console.log(
|
|
18950
|
+
console.log(`[swarm-mail] Successfully recovered from corrupted database: ${dbPath}`);
|
|
18937
18951
|
return pglite;
|
|
18938
18952
|
} catch (retryError) {
|
|
18939
|
-
throw new Error(`Failed to recover PGLite database after deleting corrupted data: ${
|
|
18953
|
+
throw new Error(`Failed to recover PGLite database after deleting corrupted data: ${formatError2(retryError)}`);
|
|
18940
18954
|
}
|
|
18941
18955
|
}
|
|
18942
18956
|
throw error45;
|
|
@@ -18945,7 +18959,13 @@ async function createPGliteWithRecovery(dbPath) {
|
|
|
18945
18959
|
async function getSwarmMail(projectPath) {
|
|
18946
18960
|
const dbPath = getDatabasePath2(projectPath);
|
|
18947
18961
|
const projectKey = projectPath || dbPath;
|
|
18948
|
-
if (
|
|
18962
|
+
if (instances2.has(dbPath)) {
|
|
18963
|
+
return instances2.get(dbPath).adapter;
|
|
18964
|
+
}
|
|
18965
|
+
if (initPromises.has(dbPath)) {
|
|
18966
|
+
return initPromises.get(dbPath);
|
|
18967
|
+
}
|
|
18968
|
+
const initPromise = (async () => {
|
|
18949
18969
|
const useSocket = process.env.SWARM_MAIL_SOCKET === "true";
|
|
18950
18970
|
if (useSocket) {
|
|
18951
18971
|
try {
|
|
@@ -18961,8 +18981,15 @@ async function getSwarmMail(projectPath) {
|
|
|
18961
18981
|
const adapter = createSwarmMailAdapter(db, projectKey);
|
|
18962
18982
|
await adapter.runMigrations();
|
|
18963
18983
|
instances2.set(dbPath, { adapter, pglite });
|
|
18984
|
+
return adapter;
|
|
18985
|
+
})();
|
|
18986
|
+
initPromises.set(dbPath, initPromise);
|
|
18987
|
+
try {
|
|
18988
|
+
const adapter = await initPromise;
|
|
18989
|
+
return adapter;
|
|
18990
|
+
} finally {
|
|
18991
|
+
initPromises.delete(dbPath);
|
|
18964
18992
|
}
|
|
18965
|
-
return instances2.get(dbPath).adapter;
|
|
18966
18993
|
}
|
|
18967
18994
|
async function getSwarmMailSocket(projectPath) {
|
|
18968
18995
|
const dbPath = getDatabasePath2(projectPath);
|
|
@@ -19296,7 +19323,7 @@ async function getInProgressCells(db, projectKey) {
|
|
|
19296
19323
|
async function getBlockedCells(db, projectKey) {
|
|
19297
19324
|
const result = await db.query(`SELECT b.*, bbc.blocker_ids
|
|
19298
19325
|
FROM beads b
|
|
19299
|
-
JOIN blocked_beads_cache bbc ON b.id =
|
|
19326
|
+
JOIN blocked_beads_cache bbc ON b.id = bbc.cell_id
|
|
19300
19327
|
WHERE b.project_key = $1 AND b.deleted_at IS NULL
|
|
19301
19328
|
ORDER BY b.priority DESC, b.created_at ASC`, [projectKey]);
|
|
19302
19329
|
return result.rows.map((r) => {
|
|
@@ -20154,7 +20181,7 @@ async function importDependencies(adapter, projectKey, cellExport) {
|
|
|
20154
20181
|
return;
|
|
20155
20182
|
}
|
|
20156
20183
|
const db = await adapter.getDatabase();
|
|
20157
|
-
await db.query("DELETE FROM
|
|
20184
|
+
await db.query("DELETE FROM bead_dependencies WHERE cell_id = $1", [
|
|
20158
20185
|
cellExport.id
|
|
20159
20186
|
]);
|
|
20160
20187
|
for (const dep of cellExport.dependencies) {
|
|
@@ -20166,7 +20193,7 @@ async function importLabels(adapter, projectKey, cellExport) {
|
|
|
20166
20193
|
return;
|
|
20167
20194
|
}
|
|
20168
20195
|
const db = await adapter.getDatabase();
|
|
20169
|
-
await db.query("DELETE FROM
|
|
20196
|
+
await db.query("DELETE FROM bead_labels WHERE cell_id = $1", [
|
|
20170
20197
|
cellExport.id
|
|
20171
20198
|
]);
|
|
20172
20199
|
for (const label of cellExport.labels) {
|
|
@@ -20178,7 +20205,7 @@ async function importComments(adapter, projectKey, cellExport) {
|
|
|
20178
20205
|
return;
|
|
20179
20206
|
}
|
|
20180
20207
|
const db = await adapter.getDatabase();
|
|
20181
|
-
await db.query("DELETE FROM
|
|
20208
|
+
await db.query("DELETE FROM bead_comments WHERE cell_id = $1", [
|
|
20182
20209
|
cellExport.id
|
|
20183
20210
|
]);
|
|
20184
20211
|
for (const comment of cellExport.comments) {
|
package/dist/pglite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../src/pglite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAQ1D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQjE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB5D;
|
|
1
|
+
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../src/pglite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAQ1D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQjE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB5D;AAoHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,YAAY,CAChC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAmD3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAS3B;AA0DD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,SAAS,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAUvD;AAGD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|