@objectstack/types 17.0.0 → 17.1.0
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/CHANGELOG.md +349 -0
- package/dist/index.d.mts +98 -18
- package/dist/index.d.ts +98 -18
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -149,7 +149,29 @@ var DIALECT_LEAK_PHRASINGS = [
|
|
|
149
149
|
// SQLite/libsql, message-only form. The `sqlite_` limb below catches these
|
|
150
150
|
// only when the driver prefixed its code; `better-sqlite3` and libsql both
|
|
151
151
|
// raise them bare, which is the shape measured across this repo.
|
|
152
|
-
/\bno such (?:table|column):/i
|
|
152
|
+
/\bno such (?:table|column):/i,
|
|
153
|
+
// [#8739] MySQL/MariaDB ER_NO_SUCH_TABLE (1146): `Table 'app.t' doesn't
|
|
154
|
+
// exist`. Its own template, not a spelling of the Postgres one — MySQL
|
|
155
|
+
// contracts the verb and quotes `db.table` as a single identifier — so the
|
|
156
|
+
// `relation|column … does not exist` limb above cannot reach it. The quotes
|
|
157
|
+
// are required for the same reason they are there: the driver always emits
|
|
158
|
+
// them and prose about a table usually does not.
|
|
159
|
+
/\btable\s+["'`][^"'`]+["'`]\s+doesn't exist/i,
|
|
160
|
+
// [#8739] MySQL/MariaDB ER_BAD_FIELD_ERROR (1054): `Unknown column 'c' in
|
|
161
|
+
// 'field list'`. BOTH quoted parts are required. The second is MySQL's clause
|
|
162
|
+
// name — `field list`, `where clause`, `order clause`, `on clause` — and it
|
|
163
|
+
// is the half that makes this the driver's template rather than a sentence
|
|
164
|
+
// that merely calls a column unknown, which an import or mapping feature has
|
|
165
|
+
// every right to say.
|
|
166
|
+
/\bunknown column\s+["'`][^"'`]+["'`]\s+in\s+["'`][^"'`]+["'`]/i,
|
|
167
|
+
// [#8739] MySQL/MariaDB ER_DUP_ENTRY (1062): `Duplicate entry
|
|
168
|
+
// 'acme@example.com' for key 'crm_account.email'`. `for key` + a quoted index
|
|
169
|
+
// is the anchor; the VALUE half is matched loosely and lazily because it is
|
|
170
|
+
// the caller's own text and MySQL does not escape a quote inside it
|
|
171
|
+
// (`Duplicate entry 'O'Brien' for key 'i'` is a real shape). A bare
|
|
172
|
+
// `duplicate entry` with no `for key '…'` tail is not this template and is
|
|
173
|
+
// left alone.
|
|
174
|
+
/\bduplicate entry\s+["'`].*?["'`]\s+for key\s+["'`][^"'`]+["'`]/i
|
|
153
175
|
];
|
|
154
176
|
function looksLikeInternalErrorLeak(message) {
|
|
155
177
|
if (!message) return false;
|
|
@@ -285,15 +307,24 @@ function resolveThrownHttpError(error, fallbackStatus = 500) {
|
|
|
285
307
|
...issues ? { issues } : {},
|
|
286
308
|
...validation ? { fields: validation.fields } : {}
|
|
287
309
|
};
|
|
310
|
+
const userMessage = declaredUserMessage(error);
|
|
288
311
|
return {
|
|
289
312
|
status,
|
|
290
313
|
...declaredStatus !== void 0 ? { declaredStatus } : {},
|
|
291
314
|
code,
|
|
292
315
|
...declaredCode !== void 0 ? { declaredCode } : {},
|
|
293
316
|
message: typeof e?.message === "string" ? e.message : String(error),
|
|
317
|
+
...userMessage !== void 0 ? { userMessage } : {},
|
|
294
318
|
...Object.keys(details).length > 0 ? { details } : {}
|
|
295
319
|
};
|
|
296
320
|
}
|
|
321
|
+
function declaredUserMessage(error) {
|
|
322
|
+
const declared = error?.userMessage;
|
|
323
|
+
return typeof declared === "string" && declared.trim().length > 0 ? declared : void 0;
|
|
324
|
+
}
|
|
325
|
+
function demotedDeclaredCode(thrown) {
|
|
326
|
+
return thrown.declaredCode !== void 0 && thrown.declaredCode !== thrown.code ? thrown.declaredCode : void 0;
|
|
327
|
+
}
|
|
297
328
|
|
|
298
329
|
// src/relation-sub-object.ts
|
|
299
330
|
function matchMissingColumnOfRelation(message) {
|
|
@@ -309,7 +340,7 @@ var RELATION_SUB_OBJECT = /["'`][^"'`]+["'`]\s+of relation\s/i;
|
|
|
309
340
|
var UNIQUE_VIOLATION = {
|
|
310
341
|
codes: /* @__PURE__ */ new Set(["23505", "ER_DUP_ENTRY", "SQLITE_CONSTRAINT_UNIQUE"]),
|
|
311
342
|
errnos: /* @__PURE__ */ new Set([1062]),
|
|
312
|
-
message: /unique constraint|unique violation|duplicate key|duplicate entry/i
|
|
343
|
+
message: /unique constraint failed|violates unique constraint|unique violation|duplicate key|duplicate entry/i
|
|
313
344
|
};
|
|
314
345
|
var MAX_CAUSE_DEPTH = 4;
|
|
315
346
|
function isUniqueViolationError(error) {
|
|
@@ -495,7 +526,9 @@ export {
|
|
|
495
526
|
collectConfiguredLocales,
|
|
496
527
|
collectGlobalUniques,
|
|
497
528
|
declaredIndexUniqueIsGlobal,
|
|
529
|
+
declaredUserMessage,
|
|
498
530
|
declaresServerFault,
|
|
531
|
+
demotedDeclaredCode,
|
|
499
532
|
describeGlobalUniqueFinding,
|
|
500
533
|
emitDegradedBootBanner,
|
|
501
534
|
fieldUniqueIsGlobal,
|