@ai-matrx/records 0.83.2 → 0.84.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 +11 -0
- package/dist/data/index.cjs +9 -1
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.js +9 -1
- package/dist/data/index.js.map +1 -1
- package/dist/react/index.cjs +9 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +9 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +4 -4
package/dist/react/index.cjs
CHANGED
|
@@ -10378,6 +10378,9 @@ function compileSort(sort, shape) {
|
|
|
10378
10378
|
for (const s of sort ?? []) {
|
|
10379
10379
|
const column = shape.columns.find((c) => c.key === s.column);
|
|
10380
10380
|
if (!column) return { ok: false, error: noSuchColumn(s.column) };
|
|
10381
|
+
if (column.type === "relation") {
|
|
10382
|
+
return { ok: false, error: refusal2(`"${column.label}" is a link, so the store cannot sort by it.`, "Sort the rows on the page by each link's label. Nothing was read.") };
|
|
10383
|
+
}
|
|
10381
10384
|
const as = isNumberColumn(column.type) ? "number" : isDateColumn(column.type) ? "date" : "text";
|
|
10382
10385
|
out.push({ field: column.key, direction: s.direction === "desc" ? "desc" : "asc", as });
|
|
10383
10386
|
}
|
|
@@ -10421,6 +10424,11 @@ function relationIdsOf(value) {
|
|
|
10421
10424
|
}
|
|
10422
10425
|
return out;
|
|
10423
10426
|
}
|
|
10427
|
+
var WORD_TYPES = /* @__PURE__ */ new Set(["text", "long_text", "rich_text", "email", "url", "phone", "markdown"]);
|
|
10428
|
+
function blankToNull(type, value) {
|
|
10429
|
+
if (typeof value === "string" && value.trim() === "" && !WORD_TYPES.has(type)) return null;
|
|
10430
|
+
return value;
|
|
10431
|
+
}
|
|
10424
10432
|
function createTableDataPort({ client, aliases }) {
|
|
10425
10433
|
const shapes = /* @__PURE__ */ new Map();
|
|
10426
10434
|
let warnedNotLive2 = false;
|
|
@@ -10494,7 +10502,7 @@ function createTableDataPort({ client, aliases }) {
|
|
|
10494
10502
|
if (!column) return refuse2("invalid_argument", `This table has no column "${key}".`, "Ask columns() for the keys this table has now. Nothing was saved.");
|
|
10495
10503
|
if (column.readOnly) return refuse2("invalid_argument", `"${column.label}" is worked out by the table, so it cannot be written.`, "Nothing was saved.");
|
|
10496
10504
|
const kinds = column.type === "relation" ? entityKindsOf(shape.fields.get(key)) : [];
|
|
10497
|
-
out[key] = kinds.length ? entityRefsOf2(value, kinds) : column.type === "relation" ? relationIdsOf(value) : value;
|
|
10505
|
+
out[key] = kinds.length ? entityRefsOf2(value, kinds) : column.type === "relation" ? relationIdsOf(value) : blankToNull(column.type, value);
|
|
10498
10506
|
}
|
|
10499
10507
|
return { ok: true, data: out };
|
|
10500
10508
|
}
|