@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.js
CHANGED
|
@@ -10093,6 +10093,9 @@ function compileSort(sort, shape) {
|
|
|
10093
10093
|
for (const s of sort ?? []) {
|
|
10094
10094
|
const column = shape.columns.find((c) => c.key === s.column);
|
|
10095
10095
|
if (!column) return { ok: false, error: noSuchColumn(s.column) };
|
|
10096
|
+
if (column.type === "relation") {
|
|
10097
|
+
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.") };
|
|
10098
|
+
}
|
|
10096
10099
|
const as = isNumberColumn(column.type) ? "number" : isDateColumn(column.type) ? "date" : "text";
|
|
10097
10100
|
out.push({ field: column.key, direction: s.direction === "desc" ? "desc" : "asc", as });
|
|
10098
10101
|
}
|
|
@@ -10136,6 +10139,11 @@ function relationIdsOf(value) {
|
|
|
10136
10139
|
}
|
|
10137
10140
|
return out;
|
|
10138
10141
|
}
|
|
10142
|
+
var WORD_TYPES = /* @__PURE__ */ new Set(["text", "long_text", "rich_text", "email", "url", "phone", "markdown"]);
|
|
10143
|
+
function blankToNull(type, value) {
|
|
10144
|
+
if (typeof value === "string" && value.trim() === "" && !WORD_TYPES.has(type)) return null;
|
|
10145
|
+
return value;
|
|
10146
|
+
}
|
|
10139
10147
|
function createTableDataPort({ client, aliases }) {
|
|
10140
10148
|
const shapes = /* @__PURE__ */ new Map();
|
|
10141
10149
|
let warnedNotLive2 = false;
|
|
@@ -10209,7 +10217,7 @@ function createTableDataPort({ client, aliases }) {
|
|
|
10209
10217
|
if (!column) return refuse2("invalid_argument", `This table has no column "${key}".`, "Ask columns() for the keys this table has now. Nothing was saved.");
|
|
10210
10218
|
if (column.readOnly) return refuse2("invalid_argument", `"${column.label}" is worked out by the table, so it cannot be written.`, "Nothing was saved.");
|
|
10211
10219
|
const kinds = column.type === "relation" ? entityKindsOf(shape.fields.get(key)) : [];
|
|
10212
|
-
out[key] = kinds.length ? entityRefsOf2(value, kinds) : column.type === "relation" ? relationIdsOf(value) : value;
|
|
10220
|
+
out[key] = kinds.length ? entityRefsOf2(value, kinds) : column.type === "relation" ? relationIdsOf(value) : blankToNull(column.type, value);
|
|
10213
10221
|
}
|
|
10214
10222
|
return { ok: true, data: out };
|
|
10215
10223
|
}
|