@marktiderman/genesis-core 2.16.0 → 2.17.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/README.md +3 -2
- package/dist/{aggregate-Y5IJ5aPn.d.ts → aggregate-v_r-nZbH.d.ts} +1 -1
- package/dist/{chunk-M5IX7C6U.js → chunk-24X4HWL5.js} +4 -4
- package/dist/{chunk-M5IX7C6U.js.map → chunk-24X4HWL5.js.map} +1 -1
- package/dist/chunk-2ORQLYVW.js +115 -0
- package/dist/chunk-2ORQLYVW.js.map +1 -0
- package/dist/{chunk-XPBS5YE4.js → chunk-4POVYF6P.js} +4 -4
- package/dist/{chunk-XPBS5YE4.js.map → chunk-4POVYF6P.js.map} +1 -1
- package/dist/{chunk-IYGVJFCV.js → chunk-5KLIFJYG.js} +3 -3
- package/dist/{chunk-IYGVJFCV.js.map → chunk-5KLIFJYG.js.map} +1 -1
- package/dist/{chunk-ALLWIK62.js → chunk-6B4CN2TC.js} +8 -6
- package/dist/chunk-6B4CN2TC.js.map +1 -0
- package/dist/chunk-6JOWGO2X.js +266 -0
- package/dist/chunk-6JOWGO2X.js.map +1 -0
- package/dist/{chunk-E3K2A3PK.js → chunk-6SHGMEA6.js} +3 -3
- package/dist/{chunk-E3K2A3PK.js.map → chunk-6SHGMEA6.js.map} +1 -1
- package/dist/chunk-6VNM6KAX.js +59 -0
- package/dist/chunk-6VNM6KAX.js.map +1 -0
- package/dist/{chunk-SOO54YYY.js → chunk-AQX5HQD6.js} +3 -3
- package/dist/{chunk-SOO54YYY.js.map → chunk-AQX5HQD6.js.map} +1 -1
- package/dist/chunk-BNKP2H7J.js +11 -0
- package/dist/chunk-BNKP2H7J.js.map +1 -0
- package/dist/{chunk-FXPODKCK.js → chunk-FBMKI22S.js} +6 -6
- package/dist/{chunk-FXPODKCK.js.map → chunk-FBMKI22S.js.map} +1 -1
- package/dist/{chunk-POUI7GAI.js → chunk-JF7FXSQB.js} +5 -5
- package/dist/{chunk-POUI7GAI.js.map → chunk-JF7FXSQB.js.map} +1 -1
- package/dist/chunk-JNWTHDGF.js +892 -0
- package/dist/chunk-JNWTHDGF.js.map +1 -0
- package/dist/chunk-K33LWVUF.js +31 -0
- package/dist/chunk-K33LWVUF.js.map +1 -0
- package/dist/chunk-KRRESUXT.js +192 -0
- package/dist/chunk-KRRESUXT.js.map +1 -0
- package/dist/{chunk-LB6FMQQM.js → chunk-KV2HW4G4.js} +3 -11
- package/dist/chunk-KV2HW4G4.js.map +1 -0
- package/dist/{chunk-42NVJJTT.js → chunk-MMMC37AP.js} +3 -3
- package/dist/{chunk-42NVJJTT.js.map → chunk-MMMC37AP.js.map} +1 -1
- package/dist/chunk-MZVFOTAE.js +96 -0
- package/dist/chunk-MZVFOTAE.js.map +1 -0
- package/dist/{chunk-R3YXYVWF.js → chunk-OIZNABG4.js} +5 -4
- package/dist/chunk-OIZNABG4.js.map +1 -0
- package/dist/{chunk-QGWQ6LK3.js → chunk-QJOKZZKY.js} +9 -6
- package/dist/chunk-QJOKZZKY.js.map +1 -0
- package/dist/chunk-TWLPC4S3.js +53 -0
- package/dist/chunk-TWLPC4S3.js.map +1 -0
- package/dist/{chunk-7EFTWOMA.js → chunk-UNEZF3ZP.js} +73 -15
- package/dist/chunk-UNEZF3ZP.js.map +1 -0
- package/dist/chunk-WNOCPV4A.js +220 -0
- package/dist/chunk-WNOCPV4A.js.map +1 -0
- package/dist/{chunk-ZYOJWU62.js → chunk-XIBQ5BTZ.js} +12 -53
- package/dist/chunk-XIBQ5BTZ.js.map +1 -0
- package/dist/chunk-YMFJLBIZ.js +159 -0
- package/dist/chunk-YMFJLBIZ.js.map +1 -0
- package/dist/{chunk-UDSTWXXZ.js → chunk-ZKLB2HB5.js} +3 -3
- package/dist/{chunk-UDSTWXXZ.js.map → chunk-ZKLB2HB5.js.map} +1 -1
- package/dist/csv.d.ts +12 -3
- package/dist/csv.js +4 -4
- package/dist/csv.js.map +1 -1
- package/dist/form-types.d.ts +1 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +16 -6
- package/dist/hooks/index.js +27 -15
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/mutation-mode.js +3 -3
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-aggregate.d.ts +2 -2
- package/dist/hooks/use-aggregate.js +3 -3
- package/dist/hooks/use-board-columns.d.ts +79 -0
- package/dist/hooks/use-board-columns.js +4 -0
- package/dist/hooks/use-board-columns.js.map +1 -0
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-capabilities.js +2 -2
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.js +3 -3
- package/dist/hooks/use-link-options.d.ts +1 -1
- package/dist/hooks/use-link-options.js +5 -5
- package/dist/hooks/use-list-state.d.ts +103 -0
- package/dist/hooks/use-list-state.js +21 -0
- package/dist/hooks/use-list-state.js.map +1 -0
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-live.js +2 -2
- package/dist/hooks/use-one.d.ts +7 -1
- package/dist/hooks/use-one.js +3 -3
- package/dist/hooks/use-persisted-ui-state.js +2 -2
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-relation-label.js +2 -2
- package/dist/hooks/use-resource-form.d.ts +1 -1
- package/dist/hooks/use-resource-form.js +7 -7
- package/dist/hooks/use-resource.d.ts +7 -1
- package/dist/hooks/use-resource.js +5 -5
- package/dist/hooks/use-segment-counts.d.ts +23 -0
- package/dist/hooks/use-segment-counts.js +19 -0
- package/dist/hooks/use-segment-counts.js.map +1 -0
- package/dist/hooks/use-view-board.d.ts +120 -0
- package/dist/hooks/use-view-board.js +29 -0
- package/dist/hooks/use-view-board.js.map +1 -0
- package/dist/hooks/use-view-calendar-range.d.ts +91 -0
- package/dist/hooks/use-view-calendar-range.js +22 -0
- package/dist/hooks/use-view-calendar-range.js.map +1 -0
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +41 -11
- package/dist/index.js +119 -26
- package/dist/index.js.map +1 -1
- package/dist/provider/index.d.ts +61 -8
- package/dist/provider/index.js +2 -2
- package/dist/resource-view/index.d.ts +162 -757
- package/dist/resource-view/index.js +31 -686
- package/dist/resource-view/index.js.map +1 -1
- package/dist/saved-views-C45lRm7i.d.ts +155 -0
- package/dist/schema/index.d.ts +3 -3
- package/dist/schema/index.js +2 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/types-BAhcze_-.d.ts +1063 -0
- package/dist/{types-BriIV4e_.d.ts → types-CiQY6hUy.d.ts} +11 -1
- package/dist/{viewer-scope-Dx0N9AYk.d.ts → viewer-oOk0ZZk9.d.ts} +36 -34
- package/dist/{workspaces-CxpiFu2-.d.ts → workspaces-DeaFix5Z.d.ts} +1 -1
- package/dist/workspaces.d.ts +2 -2
- package/dist/{write-outcome-CkQXgtJq.d.ts → write-outcome-DuwfsnyO.d.ts} +1 -1
- package/package.json +11 -1
- package/dist/chunk-7EFTWOMA.js.map +0 -1
- package/dist/chunk-ALLWIK62.js.map +0 -1
- package/dist/chunk-LB6FMQQM.js.map +0 -1
- package/dist/chunk-QGWQ6LK3.js.map +0 -1
- package/dist/chunk-R3YXYVWF.js.map +0 -1
- package/dist/chunk-ZYOJWU62.js.map +0 -1
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
import { fieldControl } from './chunk-BNKP2H7J.js';
|
|
2
|
+
import { keyFields, encodeRecordKey } from './chunk-KV2HW4G4.js';
|
|
3
|
+
import { filterProblems, segmentProblems, resolveFilters, filterValueParams, whereParams } from './chunk-6JOWGO2X.js';
|
|
4
|
+
import { NO_VIEWER } from './chunk-OZYF55E3.js';
|
|
5
|
+
import { isTimeZone } from './chunk-WXENWPWP.js';
|
|
6
|
+
import { isDevelopment, reportError } from './chunk-NOPS5EIH.js';
|
|
7
|
+
import { titleCase } from './chunk-RYEXWQFD.js';
|
|
8
|
+
|
|
9
|
+
// src/resource-view/errors.ts
|
|
10
|
+
var ViewDefinitionError = class extends Error {
|
|
11
|
+
problems;
|
|
12
|
+
constructor(resource, problems) {
|
|
13
|
+
super(`defineView(${resource}): ${problems.join("; ")}`);
|
|
14
|
+
this.name = "ViewDefinitionError";
|
|
15
|
+
this.problems = problems;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/resource-view/scope.ts
|
|
20
|
+
var camel = (key) => key.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
21
|
+
function scopeValues(view, scope) {
|
|
22
|
+
const out = {};
|
|
23
|
+
const missing = [];
|
|
24
|
+
for (const key of view.definition.scope ?? []) {
|
|
25
|
+
const value = scope && Object.hasOwn(scope, key) ? scope[key] : scope?.[camel(key)];
|
|
26
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
|
|
27
|
+
else missing.push(key);
|
|
28
|
+
}
|
|
29
|
+
if (missing.length && process.env.NODE_ENV !== "production") {
|
|
30
|
+
throw new ViewDefinitionError(
|
|
31
|
+
view.resource,
|
|
32
|
+
missing.map((key) => `scope "${key}" has no single value in ViewerScope's scope`)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return Object.freeze(out);
|
|
36
|
+
}
|
|
37
|
+
function scopeFilter(view, scope) {
|
|
38
|
+
const out = {};
|
|
39
|
+
if (!scope) return out;
|
|
40
|
+
for (const key of view.definition.scope ?? []) {
|
|
41
|
+
const value = Object.hasOwn(scope, key) ? scope[key] : scope[camel(key)];
|
|
42
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
|
|
43
|
+
else if (Array.isArray(value) && value.every((v) => typeof v === "string" || typeof v === "number")) out[key] = value;
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze(out);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/resource-view/link.ts
|
|
49
|
+
var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
50
|
+
function filterParams(filter) {
|
|
51
|
+
return Object.entries(filter ?? {}).map(
|
|
52
|
+
([field, value]) => value === null ? { field, operator: "is_null" } : Array.isArray(value) ? { field, operator: "in", value: [...value] } : { field, operator: "eq", value }
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function linkProblems(name, link, reference) {
|
|
56
|
+
if (link === void 0) return [];
|
|
57
|
+
const where = `fields.${name}.link`;
|
|
58
|
+
if (!reference) return [`${where} is set, but "${name}" isn't a link`];
|
|
59
|
+
if (!link || typeof link !== "object" || Array.isArray(link)) return [`${where} isn't an object`];
|
|
60
|
+
const l = link;
|
|
61
|
+
const problems = [];
|
|
62
|
+
if (l.view !== void 0 && typeof l.view !== "function") problems.push(...linkedViewProblems(where, l.view, reference, l.preset));
|
|
63
|
+
else if (l.view === void 0 && l.preset !== void 0) problems.push(`${where}.preset needs a view`);
|
|
64
|
+
if (l.preset !== void 0 && typeof l.preset !== "string") problems.push(`${where}.preset isn't a preset name`);
|
|
65
|
+
if (l.filter !== void 0 && typeof l.filter !== "function" && (!l.filter || typeof l.filter !== "object" || Array.isArray(l.filter))) {
|
|
66
|
+
problems.push(`${where}.filter isn't a filter or a function`);
|
|
67
|
+
}
|
|
68
|
+
if (l.searchFields !== void 0 && (!Array.isArray(l.searchFields) || l.searchFields.some((f) => typeof f !== "string" || !IDENTIFIER.test(f)))) {
|
|
69
|
+
problems.push(`${where}.searchFields isn't a list of field names`);
|
|
70
|
+
}
|
|
71
|
+
if (l.orderBy === "view") {
|
|
72
|
+
if (l.view === void 0) problems.push(`${where}.orderBy "view" needs a view`);
|
|
73
|
+
} else if (l.orderBy !== void 0) {
|
|
74
|
+
const o = l.orderBy;
|
|
75
|
+
if (!o || typeof o !== "object" || typeof o.field !== "string" || !IDENTIFIER.test(o.field)) {
|
|
76
|
+
problems.push(`${where}.orderBy isn't "view" or { field, direction }`);
|
|
77
|
+
} else if (o.direction !== void 0 && o.direction !== "asc" && o.direction !== "desc") {
|
|
78
|
+
problems.push(`${where}.orderBy.direction is "asc" or "desc", not ${String(o.direction)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return problems;
|
|
82
|
+
}
|
|
83
|
+
function linkedViewProblems(where, view, reference, preset) {
|
|
84
|
+
const v = view;
|
|
85
|
+
if (!v || typeof v !== "object" || typeof v.resource !== "string") return [`${where}.view isn't a view`];
|
|
86
|
+
if (v.resource !== reference.resource) return [`${where}.view is a view of "${v.resource}", but the link points at "${reference.resource}"`];
|
|
87
|
+
if (preset !== void 0 && !Object.hasOwn(v.definition.presets ?? {}, preset)) {
|
|
88
|
+
return [`${where}.preset "${preset}" isn't one of ${v.resource}'s presets`];
|
|
89
|
+
}
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
function resolveLink(owner, name, reference, link, labelField) {
|
|
93
|
+
let linked;
|
|
94
|
+
let read = false;
|
|
95
|
+
const linkedView = () => {
|
|
96
|
+
if (read) return linked;
|
|
97
|
+
read = true;
|
|
98
|
+
linked = typeof link?.view === "function" ? link.view() : link?.view;
|
|
99
|
+
if (linked && typeof link?.view === "function") {
|
|
100
|
+
const problems = linkedViewProblems(`fields.${name}.link`, linked, reference, link.preset);
|
|
101
|
+
if (problems.length) {
|
|
102
|
+
const error = new ViewDefinitionError(owner, problems);
|
|
103
|
+
if (isDevelopment()) throw error;
|
|
104
|
+
reportError(error, { source: "core:resource-view-link", tags: { resource: owner } });
|
|
105
|
+
linked = void 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return linked;
|
|
109
|
+
};
|
|
110
|
+
return Object.freeze({
|
|
111
|
+
resource: reference.resource,
|
|
112
|
+
field: reference.field,
|
|
113
|
+
// Read when asked: a view given as a function may not exist yet while this one is defined.
|
|
114
|
+
get labelField() {
|
|
115
|
+
return labelField ?? linkedView()?.labelField;
|
|
116
|
+
},
|
|
117
|
+
...link?.searchFields ? { searchFields: Object.freeze([...link.searchFields]) } : {},
|
|
118
|
+
// Read when asked, like the naming field: `"view"` reads a view given as a function.
|
|
119
|
+
get orderBy() {
|
|
120
|
+
const order = link?.orderBy === "view" ? linkedView()?.definition.orderBy : link?.orderBy;
|
|
121
|
+
if (!order || typeof order.field !== "string" || !IDENTIFIER.test(order.field)) return void 0;
|
|
122
|
+
const nulls = order.nulls;
|
|
123
|
+
return Object.freeze({
|
|
124
|
+
field: order.field,
|
|
125
|
+
direction: order.direction === "desc" ? "desc" : "asc",
|
|
126
|
+
...nulls === "first" || nulls === "last" ? { nulls } : {}
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
filters(scope, values = {}) {
|
|
130
|
+
const view = linkedView();
|
|
131
|
+
const preset = view ? view.definition.presets?.[link?.preset ?? "default"]?.filter : void 0;
|
|
132
|
+
const own2 = typeof link?.filter === "function" ? link.filter(values) : link?.filter;
|
|
133
|
+
return filterParams({ ...view ? scopeFilter(view, scope) : {}, ...preset, ...own2 });
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/resource-view/types.ts
|
|
139
|
+
var RECORD_OPEN_MODES = Object.freeze(["side-peek", "center-peek", "page"]);
|
|
140
|
+
|
|
141
|
+
// src/resource-view/define-view.ts
|
|
142
|
+
function deriveDisplay(field) {
|
|
143
|
+
if (field.references) return "relation";
|
|
144
|
+
switch (fieldControl(field)) {
|
|
145
|
+
case "url":
|
|
146
|
+
return "url";
|
|
147
|
+
case "email":
|
|
148
|
+
return "email";
|
|
149
|
+
case "image":
|
|
150
|
+
return "image";
|
|
151
|
+
case "textarea":
|
|
152
|
+
return "longText";
|
|
153
|
+
case "date":
|
|
154
|
+
return "date";
|
|
155
|
+
}
|
|
156
|
+
if (field.enumValues?.length) return "badge";
|
|
157
|
+
switch (field.type) {
|
|
158
|
+
case "boolean":
|
|
159
|
+
return "boolean";
|
|
160
|
+
case "number":
|
|
161
|
+
return "number";
|
|
162
|
+
case "json":
|
|
163
|
+
return "json";
|
|
164
|
+
case "relation":
|
|
165
|
+
return "relation";
|
|
166
|
+
case "datetime":
|
|
167
|
+
return /^date$/i.test(field.dbType ?? "") ? "date" : "datetime";
|
|
168
|
+
}
|
|
169
|
+
return "text";
|
|
170
|
+
}
|
|
171
|
+
var SAME_OR_IRREGULAR = {
|
|
172
|
+
series: "series",
|
|
173
|
+
species: "species",
|
|
174
|
+
movies: "movie",
|
|
175
|
+
cookies: "cookie",
|
|
176
|
+
ties: "tie",
|
|
177
|
+
pies: "pie",
|
|
178
|
+
people: "person"
|
|
179
|
+
};
|
|
180
|
+
function singular(word) {
|
|
181
|
+
const last = word.split(" ").pop();
|
|
182
|
+
const head = word.slice(0, word.length - last.length);
|
|
183
|
+
const lower = last.toLowerCase();
|
|
184
|
+
const one = (s) => head + s;
|
|
185
|
+
if (SAME_OR_IRREGULAR[lower]) return one(SAME_OR_IRREGULAR[lower]);
|
|
186
|
+
if (/[^aeiou]ies$/.test(lower)) return one(`${last.slice(0, -3)}y`);
|
|
187
|
+
if (/(?:s|x|z|ch|sh)es$/.test(lower)) return one(last.slice(0, -2));
|
|
188
|
+
if (/(?:ss|us|is)$/.test(lower) || !lower.endsWith("s")) return word;
|
|
189
|
+
return one(last.slice(0, -1));
|
|
190
|
+
}
|
|
191
|
+
var PLURAL_OF = Object.fromEntries(
|
|
192
|
+
Object.entries(SAME_OR_IRREGULAR).map(([many, one]) => [one, many])
|
|
193
|
+
);
|
|
194
|
+
function plural(word) {
|
|
195
|
+
const last = word.split(" ").pop();
|
|
196
|
+
const head = word.slice(0, word.length - last.length);
|
|
197
|
+
const lower = last.toLowerCase();
|
|
198
|
+
const many = (s) => head + s;
|
|
199
|
+
if (PLURAL_OF[lower]) return many(PLURAL_OF[lower]);
|
|
200
|
+
if (/[^aeiou]y$/.test(lower)) return many(`${last.slice(0, -1)}ies`);
|
|
201
|
+
if (/(?:s|x|z|ch|sh)$/.test(lower)) return many(`${last}es`);
|
|
202
|
+
return many(`${last}s`);
|
|
203
|
+
}
|
|
204
|
+
var RESERVED_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "delete"]);
|
|
205
|
+
var own = (record, key) => record && Object.hasOwn(record, key) ? record[key] : void 0;
|
|
206
|
+
function valueText(labels, value) {
|
|
207
|
+
const key = String(value);
|
|
208
|
+
return own(labels, key) ?? titleCase(key);
|
|
209
|
+
}
|
|
210
|
+
var KIND = { datetime: "date or timestamp", boolean: "yes/no", number: "number" };
|
|
211
|
+
var EMPHASES = ["title", "secondary", "muted"];
|
|
212
|
+
var BREAKPOINTS = ["sm", "md", "lg", "xl"];
|
|
213
|
+
var TOTALS = ["sum", "avg", "min", "max", "count"];
|
|
214
|
+
var LAYOUTS = ["month", "weeks", "agenda", "lanes"];
|
|
215
|
+
var CALENDAR_KEYS = [
|
|
216
|
+
"field",
|
|
217
|
+
"endField",
|
|
218
|
+
"durationField",
|
|
219
|
+
"durationUnit",
|
|
220
|
+
"maxDuration",
|
|
221
|
+
"allDayField",
|
|
222
|
+
"laneBy",
|
|
223
|
+
"layout",
|
|
224
|
+
"phoneLayout",
|
|
225
|
+
"weeks",
|
|
226
|
+
"weekStartsOn"
|
|
227
|
+
];
|
|
228
|
+
function calendarProblems(fields, calendar) {
|
|
229
|
+
const problems = [];
|
|
230
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
231
|
+
const typed = (name, where, type) => {
|
|
232
|
+
if (name === void 0) return;
|
|
233
|
+
const f = byName.get(name);
|
|
234
|
+
if (!f) problems.push(`${where} names "${name}", which isn't a field`);
|
|
235
|
+
else if (f.type !== type || f.array) problems.push(`${where} "${name}" isn't a ${KIND[type]} field`);
|
|
236
|
+
};
|
|
237
|
+
typed(calendar.field, "calendar.field", "datetime");
|
|
238
|
+
typed(calendar.endField, "calendar.endField", "datetime");
|
|
239
|
+
typed(calendar.durationField, "calendar.durationField", "number");
|
|
240
|
+
typed(calendar.allDayField, "calendar.allDayField", "boolean");
|
|
241
|
+
if (calendar.durationUnit !== void 0 && !["minutes", "hours", "days"].includes(calendar.durationUnit)) {
|
|
242
|
+
problems.push(`calendar.durationUnit "${String(calendar.durationUnit)}" isn't minutes, hours or days`);
|
|
243
|
+
}
|
|
244
|
+
if (calendar.durationUnit !== void 0 && calendar.durationField === void 0) problems.push("calendar.durationUnit needs a durationField");
|
|
245
|
+
if (calendar.maxDuration !== void 0) {
|
|
246
|
+
if (typeof calendar.maxDuration !== "number" || !Number.isFinite(calendar.maxDuration) || calendar.maxDuration <= 0) {
|
|
247
|
+
problems.push(`calendar.maxDuration is a number above 0, not ${JSON.stringify(calendar.maxDuration)}`);
|
|
248
|
+
} else if (calendar.durationField === void 0) problems.push("calendar.maxDuration needs a durationField");
|
|
249
|
+
}
|
|
250
|
+
if (calendar.laneBy !== void 0 && !byName.has(calendar.laneBy)) problems.push(`calendar.laneBy names "${calendar.laneBy}", which isn't a field`);
|
|
251
|
+
for (const key of ["layout", "phoneLayout"]) {
|
|
252
|
+
const value = calendar[key];
|
|
253
|
+
if (value !== void 0 && !LAYOUTS.includes(value)) problems.push(`calendar.${key} "${String(value)}" isn't month, weeks, agenda or lanes`);
|
|
254
|
+
}
|
|
255
|
+
if (calendar.weeks !== void 0 && ![1, 2, 3, 4].includes(calendar.weeks)) problems.push(`calendar.weeks is 1 to 4, not ${String(calendar.weeks)}`);
|
|
256
|
+
if (calendar.weekStartsOn !== void 0 && calendar.weekStartsOn !== 0 && calendar.weekStartsOn !== 1) {
|
|
257
|
+
problems.push(`calendar.weekStartsOn is 0 (Sunday) or 1 (Monday), not ${String(calendar.weekStartsOn)}`);
|
|
258
|
+
}
|
|
259
|
+
return problems;
|
|
260
|
+
}
|
|
261
|
+
var BOARD_KEYS = ["field", "columns", "cardFields", "limits"];
|
|
262
|
+
function boardChoices(field) {
|
|
263
|
+
if (!field || field.array) return void 0;
|
|
264
|
+
if (field.enumValues?.length) return field.enumValues;
|
|
265
|
+
if (field.type === "boolean") return ["true", "false"];
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
var INBOX_KEYS = ["title", "preview", "time", "from", "avatar", "unread", "badge", "rail", "doneAction", "markRead"];
|
|
269
|
+
function inboxProblems(fields, inbox, actions = []) {
|
|
270
|
+
const problems = [];
|
|
271
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
272
|
+
const named = (key, type) => {
|
|
273
|
+
const name = inbox[key];
|
|
274
|
+
if (name === void 0) return;
|
|
275
|
+
if (typeof name === "function" && (key === "title" || key === "preview" || key === "from")) return;
|
|
276
|
+
const field = typeof name === "string" ? byName.get(name) : void 0;
|
|
277
|
+
if (!field) problems.push(`inbox.${key} names "${String(name)}", which isn't a field`);
|
|
278
|
+
else if (type && (field.type !== type || field.array)) problems.push(`inbox.${key} "${name}" isn't a ${type === "datetime" ? "date or timestamp" : "text"} field`);
|
|
279
|
+
};
|
|
280
|
+
named("title");
|
|
281
|
+
named("preview");
|
|
282
|
+
named("time", "datetime");
|
|
283
|
+
named("from");
|
|
284
|
+
named("avatar", "string");
|
|
285
|
+
named("badge");
|
|
286
|
+
if (inbox.unread !== void 0 && typeof inbox.unread !== "function") {
|
|
287
|
+
const field = typeof inbox.unread === "string" ? byName.get(inbox.unread) : void 0;
|
|
288
|
+
if (!field) problems.push(`inbox.unread names "${String(inbox.unread)}", which isn't a field (or pass a function of the row)`);
|
|
289
|
+
else if (field.type !== "boolean") problems.push(`inbox.unread "${inbox.unread}" isn't a yes/no field`);
|
|
290
|
+
}
|
|
291
|
+
if (inbox.rail !== void 0 && inbox.rail !== "segments" && inbox.rail !== "none") problems.push(`inbox.rail is "segments" or "none", not ${JSON.stringify(inbox.rail)}`);
|
|
292
|
+
for (const key of ["doneAction", "markRead"]) {
|
|
293
|
+
const name = inbox[key];
|
|
294
|
+
if (name !== void 0 && (typeof name !== "string" || !actions.includes(name))) problems.push(`inbox.${key} names "${String(name)}", which isn't one of the view's actions`);
|
|
295
|
+
}
|
|
296
|
+
return problems;
|
|
297
|
+
}
|
|
298
|
+
var GALLERY_KEYS = ["image", "width", "height", "caption", "alt", "rowHeight"];
|
|
299
|
+
function galleryProblems(fields, gallery) {
|
|
300
|
+
const problems = [];
|
|
301
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
302
|
+
const named = (key, type) => {
|
|
303
|
+
const name = gallery[key];
|
|
304
|
+
if (name === void 0) return;
|
|
305
|
+
const field = byName.get(name);
|
|
306
|
+
if (!field) problems.push(`gallery.${key} names "${name}", which isn't a field`);
|
|
307
|
+
else if (type && (field.type !== type || field.array)) problems.push(`gallery.${key} "${name}" is a ${field.array ? "list" : field.type}, not a ${type === "string" ? "text" : "number"} field`);
|
|
308
|
+
};
|
|
309
|
+
named("image", "string");
|
|
310
|
+
named("width", "number");
|
|
311
|
+
named("height", "number");
|
|
312
|
+
named("caption");
|
|
313
|
+
named("alt");
|
|
314
|
+
if (gallery.width === void 0 !== (gallery.height === void 0)) problems.push("gallery.width and gallery.height go together: a ratio needs both");
|
|
315
|
+
const { rowHeight } = gallery;
|
|
316
|
+
if (rowHeight !== void 0 && !(typeof rowHeight === "number" && Number.isFinite(rowHeight) && rowHeight > 0)) problems.push(`gallery.rowHeight is a height above 0, not ${String(rowHeight)}`);
|
|
317
|
+
return problems;
|
|
318
|
+
}
|
|
319
|
+
function boardProblems(fields, board) {
|
|
320
|
+
const problems = [];
|
|
321
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
322
|
+
const field = board.field === void 0 ? void 0 : byName.get(board.field);
|
|
323
|
+
if (board.field !== void 0 && !field) problems.push(`board.field names "${board.field}", which isn't a field`);
|
|
324
|
+
const choices = boardChoices(field);
|
|
325
|
+
if (field && !choices) problems.push(`board.field "${board.field}" has no fixed values: use an enum or a yes/no field`);
|
|
326
|
+
if (board.columns !== void 0) {
|
|
327
|
+
if (!Array.isArray(board.columns) || board.columns.length === 0) problems.push("board.columns isn't a list of values");
|
|
328
|
+
else {
|
|
329
|
+
const seen = /* @__PURE__ */ new Set();
|
|
330
|
+
for (const value of board.columns) {
|
|
331
|
+
if (choices && !choices.includes(value)) problems.push(`board.columns lists "${String(value)}", which isn't a value of ${board.field}`);
|
|
332
|
+
if (seen.has(value)) problems.push(`board.columns lists "${String(value)}" twice`);
|
|
333
|
+
seen.add(value);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const name of board.cardFields ?? []) {
|
|
338
|
+
if (!byName.has(name)) problems.push(`board.cardFields names "${name}", which isn't a field`);
|
|
339
|
+
}
|
|
340
|
+
for (const [value, limit] of Object.entries(board.limits ?? {})) {
|
|
341
|
+
const columns = board.columns ?? choices;
|
|
342
|
+
if (columns && !columns.includes(value)) problems.push(`board.limits has "${value}", which isn't one of the board's columns`);
|
|
343
|
+
if (!Number.isInteger(limit) || limit < 1) problems.push(`board.limits.${value} is a whole number of cards, 1 or more, not ${String(limit)}`);
|
|
344
|
+
}
|
|
345
|
+
return problems;
|
|
346
|
+
}
|
|
347
|
+
function defineView(contract, definition = {}) {
|
|
348
|
+
const facts = contract;
|
|
349
|
+
const fields = contract.fields;
|
|
350
|
+
const byName = new Map(fields.map((f) => [f.name, f]));
|
|
351
|
+
const keys = new Set(keyFields(contract));
|
|
352
|
+
const scope = new Set(definition.scope ?? []);
|
|
353
|
+
const viewFields = Object.freeze(
|
|
354
|
+
Object.fromEntries(
|
|
355
|
+
Object.entries(definition.fields ?? {}).map(([k, v]) => {
|
|
356
|
+
const f = { ...v };
|
|
357
|
+
const map = (m) => Boolean(m) && typeof m === "object" && !Array.isArray(m);
|
|
358
|
+
if (map(f.tones)) f.tones = Object.freeze({ ...f.tones });
|
|
359
|
+
if (map(f.labels)) f.labels = Object.freeze({ ...f.labels });
|
|
360
|
+
return [k, Object.freeze(f)];
|
|
361
|
+
})
|
|
362
|
+
)
|
|
363
|
+
);
|
|
364
|
+
const columnLists = Object.freeze(
|
|
365
|
+
Object.fromEntries(
|
|
366
|
+
Object.entries(definition.columns ?? {}).map(([k, list]) => [
|
|
367
|
+
k,
|
|
368
|
+
Object.freeze((list ?? []).map((c) => typeof c === "string" ? c : Object.freeze({ ...c })))
|
|
369
|
+
])
|
|
370
|
+
)
|
|
371
|
+
);
|
|
372
|
+
const formItems = Object.freeze(
|
|
373
|
+
(definition.form ?? []).map((item) => typeof item === "string" ? item : Object.freeze({ ...item, fields: Object.freeze([...item.fields]) }))
|
|
374
|
+
);
|
|
375
|
+
const presets = Object.freeze(
|
|
376
|
+
Object.fromEntries(
|
|
377
|
+
Object.entries(definition.presets ?? {}).map(([k, p]) => [k, Object.freeze({ ...p, ...p.filter ? { filter: Object.freeze({ ...p.filter }) } : {} })])
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
const actionList = Object.freeze(
|
|
381
|
+
// Names are trimmed, so " archive" and "archive" are one name.
|
|
382
|
+
(Array.isArray(definition.actions) ? definition.actions : []).map(
|
|
383
|
+
(a) => a && typeof a === "object" ? Object.freeze({ ...a, ...typeof a.name === "string" ? { name: a.name.trim() } : {} }) : a
|
|
384
|
+
)
|
|
385
|
+
);
|
|
386
|
+
const problems = [];
|
|
387
|
+
const known = (name, where) => {
|
|
388
|
+
if (!byName.has(name)) problems.push(`${where} names "${name}", which isn't a field`);
|
|
389
|
+
};
|
|
390
|
+
for (const name of Object.keys(viewFields)) known(name, "fields");
|
|
391
|
+
for (const [name, v] of Object.entries(viewFields)) {
|
|
392
|
+
if (v?.labels === void 0) continue;
|
|
393
|
+
if (!v.labels || typeof v.labels !== "object" || Array.isArray(v.labels)) {
|
|
394
|
+
problems.push(`fields.${name}.labels isn't a map of values to words`);
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const values = byName.get(name)?.enumValues;
|
|
398
|
+
for (const [value, words2] of Object.entries(v.labels)) {
|
|
399
|
+
if (typeof words2 !== "string" || !words2.trim()) problems.push(`fields.${name}.labels.${value} isn't text`);
|
|
400
|
+
if (values?.length && !values.includes(value)) problems.push(`fields.${name}.labels names "${value}", which isn't one of its values`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
for (const [name, v] of Object.entries(viewFields)) {
|
|
404
|
+
const zone = v?.timeZone;
|
|
405
|
+
if (zone === void 0 || zone === "viewer" || zone === "scope") continue;
|
|
406
|
+
if (zone === "practice") {
|
|
407
|
+
problems.push(
|
|
408
|
+
`fields.${name}.timeZone "practice" was renamed "scope" in genesis-core 2; run \`genesis codemod genesis-core-2-scope-names\``
|
|
409
|
+
);
|
|
410
|
+
} else if (!isTimeZone(zone)) {
|
|
411
|
+
problems.push(`fields.${name}.timeZone "${String(zone)}" isn't "viewer", "scope" or a time zone this runtime knows`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
for (const [name, v] of Object.entries(viewFields)) {
|
|
415
|
+
if (v?.missingLabel === void 0) continue;
|
|
416
|
+
if (typeof v.missingLabel !== "string" || !v.missingLabel.trim()) problems.push(`fields.${name}.missingLabel isn't text`);
|
|
417
|
+
else if (!byName.get(name)?.references) problems.push(`fields.${name}.missingLabel is set, but "${name}" isn't a link`);
|
|
418
|
+
}
|
|
419
|
+
for (const [name, v] of Object.entries(viewFields)) problems.push(...linkProblems(name, v?.link, byName.get(name)?.references));
|
|
420
|
+
const titled = [];
|
|
421
|
+
for (const [name, v] of Object.entries(viewFields)) {
|
|
422
|
+
if (!v) continue;
|
|
423
|
+
if (v.emphasis !== void 0 && !EMPHASES.includes(v.emphasis)) problems.push(`fields.${name}.emphasis is title, secondary or muted, not ${JSON.stringify(v.emphasis)}`);
|
|
424
|
+
if (v.emphasis === "title") titled.push(name);
|
|
425
|
+
if (v.sortable !== void 0 && typeof v.sortable !== "boolean") problems.push(`fields.${name}.sortable isn't true or false`);
|
|
426
|
+
if (v.hideBelow !== void 0 && !BREAKPOINTS.includes(v.hideBelow)) problems.push(`fields.${name}.hideBelow is sm, md, lg or xl, not ${JSON.stringify(v.hideBelow)}`);
|
|
427
|
+
if (v.width !== void 0 && !(typeof v.width === "number" ? Number.isFinite(v.width) && v.width > 0 : typeof v.width === "string" && v.width.trim() !== "")) {
|
|
428
|
+
problems.push(`fields.${name}.width is a number of pixels or a CSS length, not ${JSON.stringify(v.width)}`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (titled.length > 1) problems.push(`fields: only one field is the row's title (emphasis "title"); ${titled.map((n) => `"${n}"`).join(" and ")} both are`);
|
|
432
|
+
if (definition.editLinks !== void 0 && typeof definition.editLinks !== "boolean") problems.push("editLinks isn't true or false");
|
|
433
|
+
for (const [name, v] of Object.entries(viewFields)) {
|
|
434
|
+
if (v?.labelField === void 0) continue;
|
|
435
|
+
if (typeof v.labelField !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(v.labelField)) {
|
|
436
|
+
problems.push(`fields.${name}.labelField isn't a field name`);
|
|
437
|
+
} else if (!byName.get(name)?.references) {
|
|
438
|
+
problems.push(`fields.${name}.labelField is set, but "${name}" isn't a link`);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
for (const [preset, list] of Object.entries(columnLists)) {
|
|
442
|
+
const seen = /* @__PURE__ */ new Set();
|
|
443
|
+
for (const column of list ?? []) {
|
|
444
|
+
const key = typeof column === "string" ? column : column.key;
|
|
445
|
+
if (typeof column === "string") known(column, `columns.${preset}`);
|
|
446
|
+
else if (byName.has(column.key)) problems.push(`columns.${preset}: computed "${column.key}" clashes with a field`);
|
|
447
|
+
if (seen.has(key)) problems.push(`columns.${preset} lists "${key}" twice`);
|
|
448
|
+
seen.add(key);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const formSeen = /* @__PURE__ */ new Set();
|
|
452
|
+
for (const item of formItems) {
|
|
453
|
+
for (const name of typeof item === "string" ? [item] : item.fields) {
|
|
454
|
+
known(name, "form");
|
|
455
|
+
if (formSeen.has(name)) problems.push(`form lists "${name}" twice`);
|
|
456
|
+
formSeen.add(name);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
for (const name of scope) known(name, "scope");
|
|
460
|
+
if (definition.groupBy) known(definition.groupBy, "groupBy");
|
|
461
|
+
const rawOpen = definition.open;
|
|
462
|
+
if (rawOpen !== void 0 && !RECORD_OPEN_MODES.includes(rawOpen)) {
|
|
463
|
+
problems.push(`open is ${RECORD_OPEN_MODES.map((m) => `"${m}"`).join(", ")}, not ${JSON.stringify(rawOpen)}`);
|
|
464
|
+
}
|
|
465
|
+
const rawRecordView = definition.recordView;
|
|
466
|
+
if (rawRecordView !== void 0 && typeof rawRecordView !== "function") problems.push("recordView is a function that returns the record view (`() => brandRecordView`)");
|
|
467
|
+
const rawCalendar = definition.calendar;
|
|
468
|
+
let calendar;
|
|
469
|
+
if (rawCalendar !== void 0) {
|
|
470
|
+
if (!rawCalendar || typeof rawCalendar !== "object" || Array.isArray(rawCalendar)) {
|
|
471
|
+
problems.push("calendar isn't an object");
|
|
472
|
+
} else {
|
|
473
|
+
for (const key of Object.keys(rawCalendar)) if (!CALENDAR_KEYS.includes(key)) problems.push(`calendar.${key} isn't a calendar setting`);
|
|
474
|
+
if (rawCalendar.field === void 0) problems.push("calendar.field is required");
|
|
475
|
+
calendar = Object.freeze({ ...rawCalendar });
|
|
476
|
+
problems.push(...calendarProblems(fields, calendar));
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
const rawBoard = definition.board;
|
|
480
|
+
let board;
|
|
481
|
+
if (rawBoard !== void 0) {
|
|
482
|
+
if (!rawBoard || typeof rawBoard !== "object" || Array.isArray(rawBoard)) {
|
|
483
|
+
problems.push("board isn't an object");
|
|
484
|
+
} else {
|
|
485
|
+
for (const key of Object.keys(rawBoard)) if (!BOARD_KEYS.includes(key)) problems.push(`board.${key} isn't a board setting`);
|
|
486
|
+
if (rawBoard.field === void 0) problems.push("board.field is required");
|
|
487
|
+
const given = rawBoard;
|
|
488
|
+
board = Object.freeze({
|
|
489
|
+
...given,
|
|
490
|
+
...given.columns ? { columns: Object.freeze([...given.columns]) } : {},
|
|
491
|
+
...given.cardFields ? { cardFields: Object.freeze([...given.cardFields]) } : {},
|
|
492
|
+
...given.limits ? { limits: Object.freeze({ ...given.limits }) } : {}
|
|
493
|
+
});
|
|
494
|
+
problems.push(...boardProblems(fields, board));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const rawGallery = definition.gallery;
|
|
498
|
+
let gallery;
|
|
499
|
+
if (rawGallery !== void 0) {
|
|
500
|
+
if (!rawGallery || typeof rawGallery !== "object" || Array.isArray(rawGallery)) {
|
|
501
|
+
problems.push("gallery isn't an object");
|
|
502
|
+
} else {
|
|
503
|
+
for (const key of Object.keys(rawGallery)) if (!GALLERY_KEYS.includes(key)) problems.push(`gallery.${key} isn't a gallery setting`);
|
|
504
|
+
if (rawGallery.image === void 0) problems.push("gallery.image is required");
|
|
505
|
+
gallery = Object.freeze({ ...rawGallery });
|
|
506
|
+
problems.push(...galleryProblems(fields, gallery));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const rawInbox = definition.inbox;
|
|
510
|
+
let inbox;
|
|
511
|
+
if (rawInbox !== void 0) {
|
|
512
|
+
if (!rawInbox || typeof rawInbox !== "object" || Array.isArray(rawInbox)) {
|
|
513
|
+
problems.push("inbox isn't an object");
|
|
514
|
+
} else {
|
|
515
|
+
for (const key of Object.keys(rawInbox)) if (!INBOX_KEYS.includes(key)) problems.push(`inbox.${key} isn't an inbox setting`);
|
|
516
|
+
inbox = Object.freeze({ ...rawInbox });
|
|
517
|
+
const actionNames2 = (Array.isArray(definition.actions) ? definition.actions : []).map((a) => a && typeof a.name === "string" ? a.name.trim() : "");
|
|
518
|
+
problems.push(...inboxProblems(fields, inbox, actionNames2));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (definition.orderBy) {
|
|
522
|
+
known(definition.orderBy.field, "orderBy");
|
|
523
|
+
const { nulls } = definition.orderBy;
|
|
524
|
+
if (nulls !== void 0 && nulls !== "first" && nulls !== "last") problems.push(`orderBy.nulls is "first" or "last", not ${String(nulls)}`);
|
|
525
|
+
}
|
|
526
|
+
for (const [name, preset] of Object.entries(presets)) {
|
|
527
|
+
if (preset.columns && preset.columns !== "default" && !own(columnLists, preset.columns)) {
|
|
528
|
+
problems.push(`presets.${name} uses columns "${preset.columns}", which isn't defined`);
|
|
529
|
+
}
|
|
530
|
+
for (const field of Object.keys(preset.filter ?? {})) known(field, `presets.${name}.filter`);
|
|
531
|
+
}
|
|
532
|
+
if (facts.labelField) known(facts.labelField, "the contract's labelField");
|
|
533
|
+
const actionSeen = /* @__PURE__ */ new Set();
|
|
534
|
+
if (definition.actions !== void 0 && !Array.isArray(definition.actions)) problems.push("actions isn't a list");
|
|
535
|
+
actionList.forEach((action, i) => {
|
|
536
|
+
const where = `actions[${i}]`;
|
|
537
|
+
if (!action || typeof action !== "object") {
|
|
538
|
+
problems.push(`${where} isn't an action`);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (typeof action.name !== "string" || !action.name.trim()) problems.push(`${where} has no name`);
|
|
542
|
+
else if (RESERVED_ACTIONS.has(action.name)) problems.push(`${where} is named "${action.name}", which is reserved for the view's own ${action.name}`);
|
|
543
|
+
else if (actionSeen.has(action.name)) problems.push(`actions lists "${action.name}" twice`);
|
|
544
|
+
else actionSeen.add(action.name);
|
|
545
|
+
if (typeof action.label !== "string" || !action.label.trim()) problems.push(`${where} has no label`);
|
|
546
|
+
if (action.confirm !== void 0 && typeof action.confirm !== "string") problems.push(`${where}.confirm isn't text`);
|
|
547
|
+
if (action.description !== void 0 && typeof action.description !== "string") {
|
|
548
|
+
problems.push(`${where}.description isn't text`);
|
|
549
|
+
}
|
|
550
|
+
if (action.can !== void 0 && typeof action.can !== "function") problems.push(`${where}.can isn't a function`);
|
|
551
|
+
if (action.destructive !== void 0 && typeof action.destructive !== "boolean") problems.push(`${where}.destructive isn't true or false`);
|
|
552
|
+
const bulk = action.bulk;
|
|
553
|
+
if (bulk !== void 0 && typeof bulk !== "boolean") {
|
|
554
|
+
if (!bulk || typeof bulk !== "object" || Array.isArray(bulk)) problems.push(`${where}.bulk is true or { label, confirm, run, matching }`);
|
|
555
|
+
else {
|
|
556
|
+
const b = bulk;
|
|
557
|
+
if (b.label !== void 0 && (typeof b.label !== "string" || !b.label.trim())) problems.push(`${where}.bulk.label isn't text`);
|
|
558
|
+
if (b.confirm !== void 0 && typeof b.confirm !== "string") problems.push(`${where}.bulk.confirm isn't text`);
|
|
559
|
+
if (b.run !== void 0 && typeof b.run !== "function") problems.push(`${where}.bulk.run isn't a function`);
|
|
560
|
+
if (b.matching !== void 0 && typeof b.matching !== "boolean") problems.push(`${where}.bulk.matching isn't true or false`);
|
|
561
|
+
if (b.matching === true && typeof b.run !== "function") problems.push(`${where}.bulk.matching needs a run that takes the list's filters`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
problems.push(...filterProblems(byName, definition.filters));
|
|
566
|
+
problems.push(...segmentProblems(byName, definition.segments, (name) => name === "default" || Boolean(own(columnLists, name))));
|
|
567
|
+
const rawTypes = definition.types;
|
|
568
|
+
if (rawTypes !== void 0) {
|
|
569
|
+
if (!Array.isArray(rawTypes) || rawTypes.length === 0) problems.push("types is a list of view types (table, list, grid, board, calendar, gallery or a registered one)");
|
|
570
|
+
else {
|
|
571
|
+
const seen = /* @__PURE__ */ new Set();
|
|
572
|
+
for (const t of rawTypes) {
|
|
573
|
+
if (typeof t !== "string" || !/^[a-z][a-z0-9-]{0,39}$/.test(t)) problems.push(`types lists ${JSON.stringify(t)}, which isn't a view type's id`);
|
|
574
|
+
else if (seen.has(t)) problems.push(`types lists "${t}" twice`);
|
|
575
|
+
else seen.add(t);
|
|
576
|
+
if (t === "board" && !definition.board) problems.push('types lists "board", which needs a board block');
|
|
577
|
+
if (t === "calendar" && !definition.calendar) problems.push('types lists "calendar", which needs a calendar block');
|
|
578
|
+
if (t === "gallery" && !definition.gallery) problems.push('types lists "gallery", which needs a gallery block');
|
|
579
|
+
if (t === "inbox" && !definition.inbox) problems.push('types lists "inbox", which needs an inbox block');
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const rawTotals = definition.totals;
|
|
584
|
+
if (rawTotals !== void 0) {
|
|
585
|
+
if (!rawTotals || typeof rawTotals !== "object" || Array.isArray(rawTotals)) problems.push("totals is a map of fields to sum, avg, min, max or count");
|
|
586
|
+
else
|
|
587
|
+
for (const [name, fn] of Object.entries(rawTotals)) {
|
|
588
|
+
const field = byName.get(name);
|
|
589
|
+
if (!field) problems.push(`totals names "${name}", which isn't a field`);
|
|
590
|
+
else if (!TOTALS.includes(fn)) problems.push(`totals.${name} is sum, avg, min, max or count, not ${JSON.stringify(fn)}`);
|
|
591
|
+
else if (fn !== "count" && field.type !== "number") problems.push(`totals.${name} is ${String(fn)}, but "${name}" isn't a number`);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (definition.rowTone !== void 0 && typeof definition.rowTone !== "function") problems.push("rowTone is a function of the row that returns a tone");
|
|
595
|
+
const rawExport = definition.export;
|
|
596
|
+
if (rawExport !== void 0 && typeof rawExport !== "boolean") {
|
|
597
|
+
if (!rawExport || typeof rawExport !== "object" || Array.isArray(rawExport)) problems.push("export is true or { columns, filename, maxRows, raw }");
|
|
598
|
+
else {
|
|
599
|
+
const e = rawExport;
|
|
600
|
+
if (e.columns !== void 0) {
|
|
601
|
+
if (!Array.isArray(e.columns) || e.columns.length === 0) problems.push("export.columns is a list of fields");
|
|
602
|
+
else for (const c of e.columns) if (typeof c !== "string" || !byName.has(c)) problems.push(`export.columns names ${JSON.stringify(c)}, which isn't a field`);
|
|
603
|
+
}
|
|
604
|
+
if (e.filename !== void 0 && (typeof e.filename !== "string" || !/^[\w .-]{1,100}$/.test(e.filename))) problems.push("export.filename is a plain file name (letters, digits, spaces, . - _)");
|
|
605
|
+
if (e.maxRows !== void 0 && !(Number.isInteger(e.maxRows) && e.maxRows > 0)) problems.push("export.maxRows is a whole number above 0");
|
|
606
|
+
if (e.raw !== void 0 && typeof e.raw !== "boolean") problems.push("export.raw isn't true or false");
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const rawRefusals = definition.refusals;
|
|
610
|
+
if (rawRefusals !== void 0 && rawRefusals !== "disable" && rawRefusals !== "hide") problems.push(`refusals is "disable" or "hide", not ${JSON.stringify(rawRefusals)}`);
|
|
611
|
+
if (problems.length) throw new ViewDefinitionError(contract.name, problems);
|
|
612
|
+
const copy = definition.copy ?? {};
|
|
613
|
+
const base = contract.name.split(".").pop() ?? contract.name;
|
|
614
|
+
const noun = copy.noun ?? facts.noun ?? singular(base.replace(/_/g, " "));
|
|
615
|
+
const labelWords = facts.label?.toLowerCase();
|
|
616
|
+
const nounPlural = copy.nounPlural ?? facts.nounPlural ?? (copy.noun || facts.noun ? plural(noun) : labelWords && singular(labelWords) !== labelWords ? labelWords : base.replace(/_/g, " "));
|
|
617
|
+
const title = copy.title ?? facts.label ?? titleCase(nounPlural);
|
|
618
|
+
const labelField = facts.labelField ?? fields.find((f) => /^(name|title|label|full_name|display_name)$/.test(f.name))?.name;
|
|
619
|
+
const label = (name) => own(viewFields, name)?.label ?? byName.get(name)?.label ?? titleCase(name);
|
|
620
|
+
const display = (name) => {
|
|
621
|
+
const field = byName.get(name);
|
|
622
|
+
return own(viewFields, name)?.display ?? (field ? deriveDisplay(field) : "text");
|
|
623
|
+
};
|
|
624
|
+
const valueLabel = (name, value) => valueText(own(viewFields, name)?.labels, value);
|
|
625
|
+
const readable = (name) => byName.get(name)?.permissions?.read !== false;
|
|
626
|
+
const editLinks = definition.editLinks === true;
|
|
627
|
+
const linkEditable = (f) => Boolean(f.references) && (editLinks || own(viewFields, f.name)?.link !== void 0);
|
|
628
|
+
const readOnly = (field) => Boolean(
|
|
629
|
+
field.generated || field.readOnly || field.references && !linkEditable(field) || field.permissions?.update === false || own(viewFields, field.name)?.readOnly
|
|
630
|
+
);
|
|
631
|
+
const quiet = (f) => keys.has(f.name) || scope.has(f.name) || Boolean(f.sensitive) || Boolean(f.references);
|
|
632
|
+
const neededLink = (f) => linkEditable(f) && !f.nullable && !f.optional && !f.hasDefault && !scope.has(f.name);
|
|
633
|
+
const defaultColumns = own(columnLists, "default") ?? fields.filter((f) => !quiet(f)).map((f) => f.name);
|
|
634
|
+
const presetNames = Object.freeze(["default", ...Object.keys(columnLists).filter((p) => p !== "default")]);
|
|
635
|
+
const titleField = Object.entries(viewFields).find(([, v]) => v?.emphasis === "title")?.[0] ?? labelField;
|
|
636
|
+
const emphasisOf = (name) => own(viewFields, name)?.emphasis ?? (name === titleField ? "title" : void 0);
|
|
637
|
+
const fieldColumns = /* @__PURE__ */ new Map();
|
|
638
|
+
const fieldColumn = (column) => {
|
|
639
|
+
const cached = fieldColumns.get(column);
|
|
640
|
+
if (cached) return cached;
|
|
641
|
+
const v = own(viewFields, column);
|
|
642
|
+
const resolved = Object.freeze({
|
|
643
|
+
key: column,
|
|
644
|
+
label: label(column),
|
|
645
|
+
display: display(column),
|
|
646
|
+
field: byName.get(column),
|
|
647
|
+
value: (row) => row[column],
|
|
648
|
+
...v?.tones ? { tones: v.tones } : {},
|
|
649
|
+
...v?.labels ? { labels: v.labels } : {},
|
|
650
|
+
...v?.labelField ? { labelField: v.labelField } : {},
|
|
651
|
+
...v?.missingLabel ? { missingLabel: v.missingLabel } : {},
|
|
652
|
+
...v?.when ? { when: (row, viewer = NO_VIEWER) => v.when(row, viewer) } : {},
|
|
653
|
+
...v?.timeZone ? { timeZone: v.timeZone } : {},
|
|
654
|
+
...emphasisOf(column) ? { emphasis: emphasisOf(column) } : {},
|
|
655
|
+
...v?.sortable === false ? { sortable: false } : {},
|
|
656
|
+
...v?.hideBelow ? { hideBelow: v.hideBelow } : {},
|
|
657
|
+
...v?.width !== void 0 ? { width: v.width } : {}
|
|
658
|
+
});
|
|
659
|
+
fieldColumns.set(column, resolved);
|
|
660
|
+
return resolved;
|
|
661
|
+
};
|
|
662
|
+
const resolvedColumns = /* @__PURE__ */ new Map();
|
|
663
|
+
const columns = (preset = "default") => {
|
|
664
|
+
const cached = resolvedColumns.get(preset);
|
|
665
|
+
if (cached) return cached;
|
|
666
|
+
const list = preset === "default" ? defaultColumns : own(columnLists, preset);
|
|
667
|
+
if (!list) throw new ViewDefinitionError(contract.name, [`no column preset "${preset}"`]);
|
|
668
|
+
const out = Object.freeze(
|
|
669
|
+
list.filter((column) => typeof column !== "string" || readable(column)).map((column) => {
|
|
670
|
+
if (typeof column !== "string") {
|
|
671
|
+
return Object.freeze({ key: column.key, label: column.label, display: column.display ?? "text", value: column.value, sortable: false });
|
|
672
|
+
}
|
|
673
|
+
return fieldColumn(column);
|
|
674
|
+
})
|
|
675
|
+
);
|
|
676
|
+
resolvedColumns.set(preset, out);
|
|
677
|
+
return out;
|
|
678
|
+
};
|
|
679
|
+
const links = new Map(
|
|
680
|
+
fields.filter((f) => linkEditable(f)).map((f) => [f.name, resolveLink(contract.name, f.name, f.references, own(viewFields, f.name)?.link, own(viewFields, f.name)?.labelField)])
|
|
681
|
+
);
|
|
682
|
+
const placed = definition.form ? formItems.flatMap(
|
|
683
|
+
(item) => typeof item === "string" ? [{ name: item, section: null, sectionTitle: null }] : item.fields.map((name) => ({ name, section: item.section, sectionTitle: item.title ?? titleCase(item.section) }))
|
|
684
|
+
) : fields.filter(
|
|
685
|
+
(f) => !readOnly(f) && (!quiet(f) || keys.has(f.name) && !f.hasDefault && !f.sensitive || neededLink(f) && !f.sensitive) && f.type !== "json" && !f.array
|
|
686
|
+
).map((f) => ({ name: f.name, section: null, sectionTitle: null }));
|
|
687
|
+
const serverKey = (f, mode) => keys.has(f.name) && (mode === "edit" || Boolean(f.hasDefault));
|
|
688
|
+
const resolvedForms = /* @__PURE__ */ new Map();
|
|
689
|
+
const form = (mode) => {
|
|
690
|
+
const cached = resolvedForms.get(mode);
|
|
691
|
+
if (cached) return cached;
|
|
692
|
+
const out = Object.freeze(placed.filter(({ name }) => !scope.has(name) && readable(name) && !serverKey(byName.get(name), mode)).map(({ name, section, sectionTitle }) => {
|
|
693
|
+
const field = byName.get(name);
|
|
694
|
+
const v = own(viewFields, name);
|
|
695
|
+
const locked = readOnly(field);
|
|
696
|
+
return Object.freeze({
|
|
697
|
+
field,
|
|
698
|
+
label: label(name),
|
|
699
|
+
display: display(name),
|
|
700
|
+
required: !locked && !field.nullable && !field.optional && (mode === "edit" || !field.hasDefault),
|
|
701
|
+
readOnly: locked,
|
|
702
|
+
section,
|
|
703
|
+
sectionTitle,
|
|
704
|
+
...v?.max !== void 0 ? { max: v.max } : {},
|
|
705
|
+
...v?.autoComplete ? { autoComplete: v.autoComplete } : {},
|
|
706
|
+
...v?.inputMode ? { inputMode: v.inputMode } : {},
|
|
707
|
+
...v?.enterKeyHint ? { enterKeyHint: v.enterKeyHint } : {},
|
|
708
|
+
...v?.labelField ? { labelField: v.labelField } : {},
|
|
709
|
+
...v?.missingLabel ? { missingLabel: v.missingLabel } : {},
|
|
710
|
+
...field.enumValues?.length ? { options: Object.freeze(field.enumValues.map((value) => Object.freeze({ value, label: valueLabel(name, value) }))) } : {},
|
|
711
|
+
...links.has(name) ? { link: links.get(name) } : {},
|
|
712
|
+
...v?.visible ? { visible: v.visible } : {}
|
|
713
|
+
});
|
|
714
|
+
}));
|
|
715
|
+
resolvedForms.set(mode, out);
|
|
716
|
+
return out;
|
|
717
|
+
};
|
|
718
|
+
const writable = (mode) => Object.freeze(form(mode).filter((f) => !f.readOnly).map((f) => f.field.name));
|
|
719
|
+
const guards = definition.can ?? {};
|
|
720
|
+
function can(action, rowOrViewer, maybeViewer) {
|
|
721
|
+
if (action === "create" && maybeViewer !== void 0) throw new TypeError(`[genesis-core] ${contract.name}: can("create", viewer) takes no row`);
|
|
722
|
+
if (action === "create") return guards.create?.(rowOrViewer ?? NO_VIEWER) ?? true;
|
|
723
|
+
const guard = guards[action];
|
|
724
|
+
const row = rowOrViewer;
|
|
725
|
+
return guard && row ? guard(row, maybeViewer ?? NO_VIEWER) : true;
|
|
726
|
+
}
|
|
727
|
+
const actionGuards = new Map(actionList.map((a) => [a.name, a.can]));
|
|
728
|
+
const resolvedActions = Object.freeze(
|
|
729
|
+
actionList.map(
|
|
730
|
+
(a) => Object.freeze({
|
|
731
|
+
name: a.name,
|
|
732
|
+
label: a.label,
|
|
733
|
+
...a.confirm !== void 0 ? { confirm: a.confirm } : {},
|
|
734
|
+
...a.description !== void 0 ? { description: a.description } : {},
|
|
735
|
+
...a.destructive ? { destructive: true } : {},
|
|
736
|
+
...a.bulk ? {
|
|
737
|
+
bulk: Object.freeze({
|
|
738
|
+
label: (typeof a.bulk === "object" ? a.bulk.label : void 0) ?? a.label,
|
|
739
|
+
...((typeof a.bulk === "object" ? a.bulk.confirm : void 0) ?? a.confirm) !== void 0 ? { confirm: (typeof a.bulk === "object" ? a.bulk.confirm : void 0) ?? a.confirm } : {},
|
|
740
|
+
matching: typeof a.bulk === "object" && a.bulk.matching === true,
|
|
741
|
+
batch: typeof a.bulk === "object" && typeof a.bulk.run === "function"
|
|
742
|
+
})
|
|
743
|
+
} : {}
|
|
744
|
+
})
|
|
745
|
+
)
|
|
746
|
+
);
|
|
747
|
+
function canAction(name, row, viewer = NO_VIEWER) {
|
|
748
|
+
if (!actionGuards.has(name)) throw new ViewDefinitionError(contract.name, [`no action "${name}"`]);
|
|
749
|
+
const guard = actionGuards.get(name);
|
|
750
|
+
if (!guard) return true;
|
|
751
|
+
const result = guard(row, viewer);
|
|
752
|
+
if (result === true) return true;
|
|
753
|
+
return typeof result === "string" && result.trim() ? result : "This isn't allowed.";
|
|
754
|
+
}
|
|
755
|
+
const summary = (row) => {
|
|
756
|
+
if (definition.summary) return definition.summary(row);
|
|
757
|
+
const value = labelField ? row[labelField] : void 0;
|
|
758
|
+
return { title: value === null || value === void 0 || value === "" ? titleCase(noun) : String(value) };
|
|
759
|
+
};
|
|
760
|
+
const galleryItem = (row, override) => {
|
|
761
|
+
const block = { ...gallery, ...override };
|
|
762
|
+
if (!block.image) return void 0;
|
|
763
|
+
const image = row[block.image];
|
|
764
|
+
const src = typeof image === "string" ? image : "";
|
|
765
|
+
const number = (name) => {
|
|
766
|
+
const value = name ? Number(row[name]) : NaN;
|
|
767
|
+
return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
768
|
+
};
|
|
769
|
+
const text = (name) => {
|
|
770
|
+
const value = name ? row[name] : void 0;
|
|
771
|
+
return value === null || value === void 0 || value === "" ? void 0 : String(value);
|
|
772
|
+
};
|
|
773
|
+
const width = number(block.width);
|
|
774
|
+
const height = number(block.height);
|
|
775
|
+
const caption = text(block.caption);
|
|
776
|
+
const alt = text(block.alt) ?? summary(row).title;
|
|
777
|
+
return {
|
|
778
|
+
id: String(encodeRecordKey(contract, row)),
|
|
779
|
+
src,
|
|
780
|
+
alt,
|
|
781
|
+
...width !== void 0 && height !== void 0 ? { width, height } : {},
|
|
782
|
+
...caption !== void 0 ? { caption } : {}
|
|
783
|
+
};
|
|
784
|
+
};
|
|
785
|
+
const resolvedFilters = resolveFilters(byName, definition.filters, label, (name) => own(viewFields, name), valueLabel);
|
|
786
|
+
const segmentList = Object.freeze((definition.segments ?? []).map((s) => Object.freeze({ ...s })));
|
|
787
|
+
const resolvedSegments = Object.freeze(
|
|
788
|
+
segmentList.map((s) => Object.freeze({ id: s.id, label: s.label, count: s.count === true, ...s.columns ? { columns: s.columns } : {} }))
|
|
789
|
+
);
|
|
790
|
+
const segmentFilters = (id, viewer = NO_VIEWER) => {
|
|
791
|
+
const segment = segmentList.find((s) => s.id === id);
|
|
792
|
+
if (!segment) throw new ViewDefinitionError(contract.name, [`no segment "${id}"`]);
|
|
793
|
+
const where = typeof segment.where === "function" ? segment.where(viewer) : segment.where;
|
|
794
|
+
return [...whereParams(where), ...whereParams(segment.args)];
|
|
795
|
+
};
|
|
796
|
+
const viewTypes = Object.freeze(
|
|
797
|
+
definition.types ? [...definition.types] : ["table", "list", "grid", ...gallery ? ["gallery"] : [], ...board ? ["board"] : [], ...calendar ? ["calendar"] : [], ...inbox ? ["inbox"] : []]
|
|
798
|
+
);
|
|
799
|
+
const rowTone = (row) => definition.rowTone?.(row) ?? void 0;
|
|
800
|
+
const exportPlan = (preset = "default") => {
|
|
801
|
+
if (!definition.export) return void 0;
|
|
802
|
+
const given = typeof definition.export === "object" ? definition.export : {};
|
|
803
|
+
const fromPreset = columns(own(columnLists, preset) || preset === "default" ? preset : "default").filter((c) => c.field && !c.field.sensitive);
|
|
804
|
+
const chosen = given.columns ? given.columns.map((name) => fieldColumn(name)).filter((c) => readable(c.key)) : fromPreset;
|
|
805
|
+
return Object.freeze({
|
|
806
|
+
columns: Object.freeze(chosen),
|
|
807
|
+
filename: given.filename ?? (nounPlural.replace(/[^\w .-]/g, "") || "export"),
|
|
808
|
+
maxRows: given.maxRows ?? 1e4,
|
|
809
|
+
raw: given.raw === true
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
const actionNames = new Set(actionList.map((a) => a.name));
|
|
813
|
+
const inboxActionNames = Object.freeze({
|
|
814
|
+
...inbox?.doneAction ?? ["done", "close"].find((n) => actionNames.has(n)) ? { done: inbox?.doneAction ?? ["done", "close"].find((n) => actionNames.has(n)) } : {},
|
|
815
|
+
...inbox?.markRead ?? (actionNames.has("markRead") ? "markRead" : void 0) ? { markRead: inbox?.markRead ?? "markRead" } : {}
|
|
816
|
+
});
|
|
817
|
+
const words = (value) => value === null || value === void 0 || value === "" ? void 0 : String(value);
|
|
818
|
+
const inboxText = (pick, row) => pick === void 0 ? void 0 : typeof pick === "function" ? words(pick(row)) : words(row[pick]);
|
|
819
|
+
const inboxRow = (row) => {
|
|
820
|
+
const block = inbox ?? {};
|
|
821
|
+
const title2 = inboxText(block.title, row) ?? summary(row).title;
|
|
822
|
+
const preview = inboxText(block.preview, row);
|
|
823
|
+
const from = inboxText(block.from, row);
|
|
824
|
+
const unread = typeof block.unread === "function" ? block.unread(row) === true : typeof block.unread === "string" ? row[block.unread] === true : false;
|
|
825
|
+
const badgeValue = block.badge ? row[block.badge] : void 0;
|
|
826
|
+
const badgeTones = block.badge ? own(viewFields, block.badge)?.tones : void 0;
|
|
827
|
+
const badgeTone = badgeValue !== void 0 && badgeValue !== null && badgeTones ? own(badgeTones, String(badgeValue)) : void 0;
|
|
828
|
+
const time = block.time ? row[block.time] : void 0;
|
|
829
|
+
return Object.freeze({
|
|
830
|
+
id: String(encodeRecordKey(contract, row)),
|
|
831
|
+
title: title2,
|
|
832
|
+
unread,
|
|
833
|
+
...preview ? { preview } : {},
|
|
834
|
+
...time instanceof Date ? { time: time.toISOString() } : words(time) ? { time: words(time) } : {},
|
|
835
|
+
...from ? { from } : {},
|
|
836
|
+
...block.avatar && words(row[block.avatar]) ? { avatar: words(row[block.avatar]) } : {},
|
|
837
|
+
...words(badgeValue) ? { badge: Object.freeze({ label: valueLabel(block.badge, badgeValue), ...badgeTone ? { tone: badgeTone } : {} }) } : {}
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
return Object.freeze({
|
|
841
|
+
contract,
|
|
842
|
+
definition: Object.freeze({
|
|
843
|
+
...definition,
|
|
844
|
+
fields: viewFields,
|
|
845
|
+
columns: columnLists,
|
|
846
|
+
presets,
|
|
847
|
+
...definition.form ? { form: formItems } : {},
|
|
848
|
+
...definition.scope ? { scope: Object.freeze([...definition.scope]) } : {},
|
|
849
|
+
...definition.actions ? { actions: actionList } : {},
|
|
850
|
+
...calendar ? { calendar } : {},
|
|
851
|
+
...board ? { board } : {},
|
|
852
|
+
...gallery ? { gallery } : {},
|
|
853
|
+
...inbox ? { inbox } : {},
|
|
854
|
+
...definition.filters ? { filters: Object.freeze(definition.filters.map((f) => Object.freeze({ ...f }))) } : {},
|
|
855
|
+
...definition.segments ? { segments: segmentList } : {},
|
|
856
|
+
...definition.types ? { types: viewTypes } : {},
|
|
857
|
+
...definition.totals ? { totals: Object.freeze({ ...definition.totals }) } : {}
|
|
858
|
+
}),
|
|
859
|
+
resource: contract.name,
|
|
860
|
+
noun,
|
|
861
|
+
nounPlural,
|
|
862
|
+
title,
|
|
863
|
+
labelField,
|
|
864
|
+
presets: presetNames,
|
|
865
|
+
field: (name) => byName.get(name),
|
|
866
|
+
column: (name) => byName.has(name) && readable(name) ? fieldColumn(name) : void 0,
|
|
867
|
+
label,
|
|
868
|
+
display,
|
|
869
|
+
valueLabel,
|
|
870
|
+
columns,
|
|
871
|
+
form,
|
|
872
|
+
writable,
|
|
873
|
+
can,
|
|
874
|
+
actions: () => resolvedActions,
|
|
875
|
+
canAction,
|
|
876
|
+
summary,
|
|
877
|
+
galleryItem,
|
|
878
|
+
filters: () => resolvedFilters,
|
|
879
|
+
segments: () => resolvedSegments,
|
|
880
|
+
segmentFilters,
|
|
881
|
+
filterParams: (values, zone) => filterValueParams(resolvedFilters, byName, values, zone),
|
|
882
|
+
types: () => viewTypes,
|
|
883
|
+
rowTone,
|
|
884
|
+
exportPlan,
|
|
885
|
+
inboxRow,
|
|
886
|
+
inboxActions: () => inboxActionNames
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
export { RECORD_OPEN_MODES, ViewDefinitionError, boardChoices, boardProblems, calendarProblems, defineView, deriveDisplay, filterParams, galleryProblems, inboxProblems, plural, scopeFilter, scopeValues, singular, valueText };
|
|
891
|
+
//# sourceMappingURL=chunk-JNWTHDGF.js.map
|
|
892
|
+
//# sourceMappingURL=chunk-JNWTHDGF.js.map
|