totalum-sdk 0.1.0-dev.2 → 0.1.0-dev.3
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/d1/libsql.js +16 -3
- package/package.json +1 -1
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
|
-
/**
|
|
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' ||
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.1.0-dev.3",
|
|
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",
|