totalum-sdk 0.1.0-dev.2 → 0.1.0-dev.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.
Files changed (2) hide show
  1. package/dist/d1/libsql.js +16 -3
  2. package/package.json +2 -5
package/dist/d1/libsql.js CHANGED
@@ -79,12 +79,25 @@ function fromLibsqlValue(v) {
79
79
  return Array.from(new Uint8Array(v));
80
80
  return v;
81
81
  }
82
- /** `LibsqlError { code, message: '<CODE>: <sqlite message>' }` → the `D1_ERROR: <sqlite message>: <CODE>` shape. */
82
+ /**
83
+ * `LibsqlError { code, message: '<CODE>: <sqlite message>' }` → the `D1_ERROR: <sqlite message>: <CODE>` shape. A
84
+ * remote Turso database (recorded 2026-09-23) also prefixes `SQLite error: `, answers `SQLITE_UNKNOWN` where SQLite
85
+ * says `SQLITE_ERROR`, reports name resolution as `SQL_INPUT_ERROR` (`SQLite input error: … (at offset N)`) and its own
86
+ * parser's failures as `SQL_PARSE_ERROR` (wording not SQLite's).
87
+ */
83
88
  function mapLibsqlError(e) {
84
89
  const err = e;
85
- if (typeof err.code !== 'string' || !err.code.startsWith('SQLITE_') || typeof err.message !== 'string')
90
+ if (typeof err.code !== 'string' || typeof err.message !== 'string')
91
+ return e;
92
+ const remote = err.code === 'SQL_PARSE_ERROR' || err.code === 'SQL_INPUT_ERROR';
93
+ if (!remote && !err.code.startsWith('SQLITE_'))
86
94
  return e;
87
- const sqliteMessage = `${err.message.replace(/^(SQLITE_\w+: )+/, '')}: ${err.code}`;
95
+ const code = remote || err.code === 'SQLITE_UNKNOWN' ? 'SQLITE_ERROR' : err.code;
96
+ const text = err.message
97
+ .replace(/^((SQLITE_\w+|SQL_PARSE_ERROR|SQL_INPUT_ERROR): )+/, '')
98
+ .replace(/^SQLite (input )?error: /, '')
99
+ .replace(/ \(at offset (\d+)\)$/, ' at offset $1');
100
+ const sqliteMessage = `${text}: ${code}`;
88
101
  return new TotalumD1Error('SQL_ERROR', `D1_ERROR: ${sqliteMessage}`, {
89
102
  status: 400,
90
103
  details: { sqliteMessage },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-sdk",
3
- "version": "0.1.0-dev.2",
3
+ "version": "0.1.0-dev.4",
4
4
  "description": "The SDK generated Totalum apps import: totalum-sdk/d1 (D1 driver — native binding in a Worker, HTTPS to SDK-API elsewhere)",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -8,10 +8,6 @@
8
8
  "engines": {
9
9
  "node": ">=22 <23"
10
10
  },
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/francesc-commits/totalum-sdk.git"
14
- },
15
11
  "files": [
16
12
  "dist"
17
13
  ],
@@ -24,6 +20,7 @@
24
20
  "sideEffects": false,
25
21
  "scripts": {
26
22
  "build": "tsc -p tsconfig.build.json",
23
+ "release:dev": "rm -rf dist && pnpm build && npm publish --tag dev",
27
24
  "typecheck": "tsc --noEmit",
28
25
  "lint": "eslint . && prettier --check .",
29
26
  "format": "prettier --write .",