ework-web 0.10.22 → 0.10.23

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/db.ts +31 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.22",
3
+ "version": "0.10.23",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/db.ts CHANGED
@@ -375,7 +375,8 @@ class MysqlDriver implements AsyncDatabase {
375
375
  try {
376
376
  await pool.query(stmt);
377
377
  } catch (e) {
378
- if (e && typeof e === "object" && "errno" in e && (e as { errno: number }).errno === 1061) continue;
378
+ const errno = (e as { errno?: number }).errno;
379
+ if (errno === 1061 || errno === 30000) continue;
379
380
  throw e;
380
381
  }
381
382
  }
@@ -456,10 +457,17 @@ export function getDB(): AsyncDatabase {
456
457
  export async function getConfigAll(): Promise<Record<string, string>> {
457
458
  try {
458
459
  const driver = getDB();
459
- const rows = await driver.all<{ akey: string; value: string }>("SELECT akey, value FROM {{config}}");
460
- const out: Record<string, string> = {};
461
- for (const r of rows) out[r.akey] = r.value;
462
- return out;
460
+ try {
461
+ const rows = await driver.all<{ akey: string; value: string }>("SELECT akey, value FROM {{config}}");
462
+ const out: Record<string, string> = {};
463
+ for (const r of rows) out[r.akey] = r.value;
464
+ return out;
465
+ } catch {
466
+ const rows = await driver.all<{ key: string; value: string }>("SELECT key, value FROM {{config}}");
467
+ const out: Record<string, string> = {};
468
+ for (const r of rows) out[r.key] = r.value;
469
+ return out;
470
+ }
463
471
  } catch {
464
472
  return {};
465
473
  }
@@ -467,13 +475,25 @@ export async function getConfigAll(): Promise<Record<string, string>> {
467
475
 
468
476
  export async function setConfig(key: string, value: string): Promise<void> {
469
477
  const now = new Date().toISOString();
470
- await getDB().run(
471
- "INSERT INTO {{config}} (akey, value, updated_at) VALUES (?, ?, ?) " +
472
- "ON CONFLICT(akey) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at",
473
- [key, value, now]
474
- );
478
+ try {
479
+ await getDB().run(
480
+ "INSERT INTO {{config}} (akey, value, updated_at) VALUES (?, ?, ?) " +
481
+ "ON CONFLICT(akey) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at",
482
+ [key, value, now]
483
+ );
484
+ } catch {
485
+ await getDB().run(
486
+ "INSERT INTO {{config}} (key, value, updated_at) VALUES (?, ?, ?) " +
487
+ "ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at",
488
+ [key, value, now]
489
+ );
490
+ }
475
491
  }
476
492
 
477
493
  export async function deleteConfig(key: string): Promise<void> {
478
- await getDB().run("DELETE FROM {{config}} WHERE akey = ?", [key]);
494
+ try {
495
+ await getDB().run("DELETE FROM {{config}} WHERE akey = ?", [key]);
496
+ } catch {
497
+ await getDB().run("DELETE FROM {{config}} WHERE key = ?", [key]);
498
+ }
479
499
  }