@ragable/sdk 0.6.2 → 0.6.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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -45,7 +45,34 @@ var RagableError = class extends RagableSdkError {
|
|
|
45
45
|
details: this.details
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
/** Stable string for logs — avoids `{}` when coercing or stringifying. */
|
|
49
|
+
toString() {
|
|
50
|
+
const bits = [`${this.name}: ${this.message}`];
|
|
51
|
+
if (this.status) bits.push(`status=${this.status}`);
|
|
52
|
+
if (this.code) bits.push(`code=${this.code}`);
|
|
53
|
+
return bits.join(" \xB7 ");
|
|
54
|
+
}
|
|
48
55
|
};
|
|
56
|
+
function formatSdkError(err) {
|
|
57
|
+
if (err instanceof RagableError) {
|
|
58
|
+
return `${err.message} (HTTP ${err.status}${err.code ? `, ${err.code}` : ""})`;
|
|
59
|
+
}
|
|
60
|
+
if (err instanceof RagableSdkError) {
|
|
61
|
+
return err.message;
|
|
62
|
+
}
|
|
63
|
+
if (err instanceof Error) {
|
|
64
|
+
return err.message || err.name;
|
|
65
|
+
}
|
|
66
|
+
if (typeof err === "string") return err;
|
|
67
|
+
if (err && typeof err === "object") {
|
|
68
|
+
try {
|
|
69
|
+
const s = JSON.stringify(err);
|
|
70
|
+
if (s !== "{}") return s;
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return String(err);
|
|
75
|
+
}
|
|
49
76
|
var RagableNetworkError = class extends RagableSdkError {
|
|
50
77
|
constructor(message, cause) {
|
|
51
78
|
super(message);
|
|
@@ -1376,7 +1403,14 @@ var PostgrestTableApi = class {
|
|
|
1376
1403
|
columns
|
|
1377
1404
|
);
|
|
1378
1405
|
}
|
|
1379
|
-
insert(values) {
|
|
1406
|
+
insert(values, ...rest) {
|
|
1407
|
+
if (rest.length > 0) {
|
|
1408
|
+
throw new RagableError(
|
|
1409
|
+
".insert() accepts only one argument: the row object or an array of rows. Do not pass readOnly, options, or a second object \u2014 those apply only to database.query({ sql, readOnly }). PostgREST inserts are writes by default.",
|
|
1410
|
+
400,
|
|
1411
|
+
{ code: "SDK_INSERT_EXTRA_ARGS" }
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1380
1414
|
const rows = Array.isArray(values) ? values : [values];
|
|
1381
1415
|
return new PostgrestInsertRootBuilder(
|
|
1382
1416
|
this.pgFetch,
|
|
@@ -2413,6 +2447,7 @@ export {
|
|
|
2413
2447
|
detectStorage,
|
|
2414
2448
|
extractErrorMessage,
|
|
2415
2449
|
formatRetrievalContext,
|
|
2450
|
+
formatSdkError,
|
|
2416
2451
|
generateIdempotencyKey,
|
|
2417
2452
|
normalizeBrowserApiBase,
|
|
2418
2453
|
parseSseDataLine,
|