@marktiderman/genesis-core 2.9.0 → 2.10.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/dist/{chunk-X6EVE7W4.js → chunk-KXVDDDJY.js} +9 -8
- package/dist/chunk-KXVDDDJY.js.map +1 -0
- package/dist/{chunk-IQVIHN7C.js → chunk-VDS6REM3.js} +16 -10
- package/dist/chunk-VDS6REM3.js.map +1 -0
- package/dist/csv.d.ts +1 -1
- package/dist/form-types.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-link-options.d.ts +10 -2
- package/dist/hooks/use-link-options.js +1 -1
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-resource-form.d.ts +7 -1
- package/dist/hooks/use-resource-form.js +1 -1
- package/dist/hooks/use-resource.d.ts +1 -1
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/provider/index.d.ts +4 -4
- package/dist/resource-view/index.d.ts +36 -2
- package/dist/resource-view/index.js +42 -6
- package/dist/resource-view/index.js.map +1 -1
- package/dist/schema/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-r_Rlw7BB.d.ts → types-9WnGxZhj.d.ts} +14 -0
- package/dist/{write-outcome-BWV34wh5.d.ts → write-outcome-ZWlhhzRW.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-IQVIHN7C.js.map +0 -1
- package/dist/chunk-X6EVE7W4.js.map +0 -1
|
@@ -50,6 +50,7 @@ function scopeFilter(view, scope) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// src/resource-view/link.ts
|
|
53
|
+
var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
53
54
|
function filterParams(filter) {
|
|
54
55
|
return Object.entries(filter ?? {}).map(
|
|
55
56
|
([field, value]) => value === null ? { field, operator: "is_null" } : Array.isArray(value) ? { field, operator: "in", value: [...value] } : { field, operator: "eq", value }
|
|
@@ -68,9 +69,19 @@ function linkProblems(name, link, reference) {
|
|
|
68
69
|
if (l.filter !== void 0 && typeof l.filter !== "function" && (!l.filter || typeof l.filter !== "object" || Array.isArray(l.filter))) {
|
|
69
70
|
problems.push(`${where}.filter isn't a filter or a function`);
|
|
70
71
|
}
|
|
71
|
-
if (l.searchFields !== void 0 && (!Array.isArray(l.searchFields) || l.searchFields.some((f) => typeof f !== "string" ||
|
|
72
|
+
if (l.searchFields !== void 0 && (!Array.isArray(l.searchFields) || l.searchFields.some((f) => typeof f !== "string" || !IDENTIFIER.test(f)))) {
|
|
72
73
|
problems.push(`${where}.searchFields isn't a list of field names`);
|
|
73
74
|
}
|
|
75
|
+
if (l.orderBy === "view") {
|
|
76
|
+
if (l.view === void 0) problems.push(`${where}.orderBy "view" needs a view`);
|
|
77
|
+
} else if (l.orderBy !== void 0) {
|
|
78
|
+
const o = l.orderBy;
|
|
79
|
+
if (!o || typeof o !== "object" || typeof o.field !== "string" || !IDENTIFIER.test(o.field)) {
|
|
80
|
+
problems.push(`${where}.orderBy isn't "view" or { field, direction }`);
|
|
81
|
+
} else if (o.direction !== void 0 && o.direction !== "asc" && o.direction !== "desc") {
|
|
82
|
+
problems.push(`${where}.orderBy.direction is "asc" or "desc", not ${String(o.direction)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
74
85
|
return problems;
|
|
75
86
|
}
|
|
76
87
|
function linkedViewProblems(where, view, reference, preset) {
|
|
@@ -108,6 +119,12 @@ function resolveLink(owner, name, reference, link, labelField) {
|
|
|
108
119
|
return labelField ?? linkedView()?.labelField;
|
|
109
120
|
},
|
|
110
121
|
...link?.searchFields ? { searchFields: Object.freeze([...link.searchFields]) } : {},
|
|
122
|
+
// Read when asked, like the naming field: `"view"` reads a view given as a function.
|
|
123
|
+
get orderBy() {
|
|
124
|
+
const order = link?.orderBy === "view" ? linkedView()?.definition.orderBy : link?.orderBy;
|
|
125
|
+
if (!order || typeof order.field !== "string" || !IDENTIFIER.test(order.field)) return void 0;
|
|
126
|
+
return Object.freeze({ field: order.field, direction: order.direction === "desc" ? "desc" : "asc" });
|
|
127
|
+
},
|
|
111
128
|
filters(scope, values = {}) {
|
|
112
129
|
const view = linkedView();
|
|
113
130
|
const preset = view ? view.definition.presets?.[link?.preset ?? "default"]?.filter : void 0;
|
|
@@ -186,6 +203,20 @@ function valueText(labels, value) {
|
|
|
186
203
|
const key = String(value);
|
|
187
204
|
return own(labels, key) ?? titleCase(key);
|
|
188
205
|
}
|
|
206
|
+
var KIND = { datetime: "date or timestamp", boolean: "yes/no", number: "number" };
|
|
207
|
+
var LAYOUTS = ["month", "weeks", "agenda", "lanes"];
|
|
208
|
+
var CALENDAR_KEYS = [
|
|
209
|
+
"field",
|
|
210
|
+
"endField",
|
|
211
|
+
"durationField",
|
|
212
|
+
"durationUnit",
|
|
213
|
+
"allDayField",
|
|
214
|
+
"laneBy",
|
|
215
|
+
"layout",
|
|
216
|
+
"phoneLayout",
|
|
217
|
+
"weeks",
|
|
218
|
+
"weekStartsOn"
|
|
219
|
+
];
|
|
189
220
|
function calendarProblems(fields, calendar) {
|
|
190
221
|
const problems = [];
|
|
191
222
|
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
@@ -193,14 +224,20 @@ function calendarProblems(fields, calendar) {
|
|
|
193
224
|
if (name === void 0) return;
|
|
194
225
|
const f = byName.get(name);
|
|
195
226
|
if (!f) problems.push(`${where} names "${name}", which isn't a field`);
|
|
196
|
-
else if (f.type !== type || f.array) problems.push(`${where} "${name}" isn't a ${type
|
|
227
|
+
else if (f.type !== type || f.array) problems.push(`${where} "${name}" isn't a ${KIND[type]} field`);
|
|
197
228
|
};
|
|
198
229
|
typed(calendar.field, "calendar.field", "datetime");
|
|
199
230
|
typed(calendar.endField, "calendar.endField", "datetime");
|
|
231
|
+
typed(calendar.durationField, "calendar.durationField", "number");
|
|
200
232
|
typed(calendar.allDayField, "calendar.allDayField", "boolean");
|
|
233
|
+
if (calendar.durationUnit !== void 0 && !["minutes", "hours", "days"].includes(calendar.durationUnit)) {
|
|
234
|
+
problems.push(`calendar.durationUnit "${String(calendar.durationUnit)}" isn't minutes, hours or days`);
|
|
235
|
+
}
|
|
236
|
+
if (calendar.durationUnit !== void 0 && calendar.durationField === void 0) problems.push("calendar.durationUnit needs a durationField");
|
|
201
237
|
if (calendar.laneBy !== void 0 && !byName.has(calendar.laneBy)) problems.push(`calendar.laneBy names "${calendar.laneBy}", which isn't a field`);
|
|
202
|
-
|
|
203
|
-
|
|
238
|
+
for (const key of ["layout", "phoneLayout"]) {
|
|
239
|
+
const value = calendar[key];
|
|
240
|
+
if (value !== void 0 && !LAYOUTS.includes(value)) problems.push(`calendar.${key} "${String(value)}" isn't month, weeks, agenda or lanes`);
|
|
204
241
|
}
|
|
205
242
|
if (calendar.weeks !== void 0 && ![1, 2, 3, 4].includes(calendar.weeks)) problems.push(`calendar.weeks is 1 to 4, not ${String(calendar.weeks)}`);
|
|
206
243
|
if (calendar.weekStartsOn !== void 0 && calendar.weekStartsOn !== 0 && calendar.weekStartsOn !== 1) {
|
|
@@ -316,8 +353,7 @@ function defineView(contract, definition = {}) {
|
|
|
316
353
|
if (!rawCalendar || typeof rawCalendar !== "object" || Array.isArray(rawCalendar)) {
|
|
317
354
|
problems.push("calendar isn't an object");
|
|
318
355
|
} else {
|
|
319
|
-
const
|
|
320
|
-
for (const key of Object.keys(rawCalendar)) if (!known2.includes(key)) problems.push(`calendar.${key} isn't a calendar setting`);
|
|
356
|
+
for (const key of Object.keys(rawCalendar)) if (!CALENDAR_KEYS.includes(key)) problems.push(`calendar.${key} isn't a calendar setting`);
|
|
321
357
|
if (rawCalendar.field === void 0) problems.push("calendar.field is required");
|
|
322
358
|
calendar = Object.freeze({ ...rawCalendar });
|
|
323
359
|
problems.push(...calendarProblems(fields, calendar));
|