@nivaro/react 0.3.131 → 0.3.133
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/item-edit/RecordInsights.js +186 -167
- package/dist/shared/components/pipeline/PipelineEditorView.js +2899 -2639
- package/dist/shared/components/pipeline/open-when-draft.js +45 -0
- package/dist/shared/lib/config-sentences.js +261 -209
- package/package.json +1 -1
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { choiceLabel as
|
|
2
|
-
import { formulaInputs as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
var t, s,
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
1
|
+
import { choiceLabel as W, titleCase as y } from "./utils.js";
|
|
2
|
+
import { formulaInputs as R } from "./write-formula.js";
|
|
3
|
+
const J = /* @__PURE__ */ new Set(["integer", "bigInteger", "float", "decimal", "number"]);
|
|
4
|
+
function O(e, n = {}) {
|
|
5
|
+
var t, s, i;
|
|
6
|
+
const r = (t = n.fields) == null ? void 0 : t[e];
|
|
7
|
+
if (r != null && r.trim()) return r.trim();
|
|
8
8
|
if (e.includes(".")) {
|
|
9
|
-
const
|
|
10
|
-
return [((
|
|
9
|
+
const o = e.split(".");
|
|
10
|
+
return [((i = (s = n.fields) == null ? void 0 : s[o[0]]) == null ? void 0 : i.trim()) || y(o[0]), ...o.slice(1).map((u) => y(u))].join("’s ");
|
|
11
11
|
}
|
|
12
12
|
return y(e);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function k(e, n = {}) {
|
|
15
15
|
var t;
|
|
16
|
-
const
|
|
17
|
-
return
|
|
16
|
+
const r = (t = n.collections) == null ? void 0 : t[e];
|
|
17
|
+
return r != null && r.trim() ? r.trim() : y(e);
|
|
18
18
|
}
|
|
19
|
-
function w(e, n,
|
|
20
|
-
var s,
|
|
21
|
-
const t = (
|
|
19
|
+
function w(e, n, r) {
|
|
20
|
+
var s, i;
|
|
21
|
+
const t = (i = (s = r.relatedFields) == null ? void 0 : s[e]) == null ? void 0 : i[n];
|
|
22
22
|
return t != null && t.trim() ? t.trim() : y(n);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
24
|
+
const A = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
25
|
+
function M(e, n) {
|
|
26
26
|
return n === "money" ? `${e < 0 ? "-" : ""}$${Math.abs(e).toLocaleString("en-US", { maximumFractionDigits: 2 })}` : n === "percent" ? `${e.toLocaleString("en-US", { maximumFractionDigits: 2 })}%` : e.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
var u,
|
|
30
|
-
if (
|
|
31
|
-
const t = String(n), s = (
|
|
32
|
-
if (s != null) return
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
if (typeof n == "boolean" || ((
|
|
28
|
+
function v(e, n, r = {}) {
|
|
29
|
+
var u, c, h, a, f, m, d;
|
|
30
|
+
if (A(n)) return "empty";
|
|
31
|
+
const t = String(n), s = (c = (u = r.choices) == null ? void 0 : u[e]) == null ? void 0 : c[t];
|
|
32
|
+
if (s != null) return W(s);
|
|
33
|
+
const i = (a = (h = r.records) == null ? void 0 : h[e]) == null ? void 0 : a[t];
|
|
34
|
+
if (i != null) return i;
|
|
35
|
+
if (typeof n == "boolean" || ((f = r.types) == null ? void 0 : f[e]) === "boolean") {
|
|
36
36
|
if (n === !0 || t === "true" || t === "1") return "Yes";
|
|
37
37
|
if (n === !1 || t === "false" || t === "0") return "No";
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
return (typeof n == "number" || /^\s*-?\d+(\.\d+)?\s*$/.test(t)) && (
|
|
39
|
+
const o = (m = r.formats) == null ? void 0 : m[e];
|
|
40
|
+
return (typeof n == "number" || /^\s*-?\d+(\.\d+)?\s*$/.test(t)) && (o || J.has(((d = r.types) == null ? void 0 : d[e]) ?? "")) ? M(Number(t), o) : typeof n == "object" ? JSON.stringify(n) : W(t);
|
|
41
41
|
}
|
|
42
42
|
function _(e) {
|
|
43
43
|
return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} or ${e[e.length - 1]}`;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function N(e) {
|
|
46
46
|
return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (Array.isArray(e)) return e.map((
|
|
48
|
+
function T(e) {
|
|
49
|
+
if (Array.isArray(e)) return e.map((r) => String(r));
|
|
50
50
|
if (e == null) return null;
|
|
51
51
|
const n = String(e).trim();
|
|
52
52
|
if (!n) return null;
|
|
53
53
|
if (n.startsWith("["))
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
56
|
-
return Array.isArray(
|
|
55
|
+
const r = JSON.parse(n);
|
|
56
|
+
return Array.isArray(r) ? r.map((t) => String(t)) : null;
|
|
57
57
|
} catch {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
|
-
return n.split(",").map((
|
|
60
|
+
return n.split(",").map((r) => r.trim()).filter(Boolean);
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
function
|
|
62
|
+
const I = (e) => e && e[0].toUpperCase() + e.slice(1);
|
|
63
|
+
function b(e, n, r, t = {}) {
|
|
64
64
|
if (!e) return null;
|
|
65
|
-
const s =
|
|
66
|
-
switch (
|
|
65
|
+
const s = O(e, t), i = n ?? "eq";
|
|
66
|
+
switch (i) {
|
|
67
67
|
case "null":
|
|
68
68
|
return `${s} is empty`;
|
|
69
69
|
case "nnull":
|
|
70
70
|
return `${s} is set`;
|
|
71
71
|
case "eq":
|
|
72
|
-
return
|
|
72
|
+
return A(r) ? `${s} is empty` : `${s} is ${v(e, r, t)}`;
|
|
73
73
|
case "neq":
|
|
74
|
-
return
|
|
74
|
+
return A(r) ? `${s} is set` : `${s} is not ${v(e, r, t)} (or is empty)`;
|
|
75
75
|
case "gt":
|
|
76
76
|
case "gte":
|
|
77
77
|
case "lt":
|
|
78
78
|
case "lte": {
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
return `${s} ${
|
|
79
|
+
if (A(r)) return null;
|
|
80
|
+
const o = { gt: "is over", gte: "is at least", lt: "is under", lte: "is at most" }[i];
|
|
81
|
+
return `${s} ${o} ${v(e, r, t)}`;
|
|
82
82
|
}
|
|
83
83
|
case "contains":
|
|
84
|
-
return
|
|
84
|
+
return A(r) ? null : `${s} contains “${String(r)}”`;
|
|
85
85
|
case "in": {
|
|
86
|
-
const
|
|
87
|
-
return
|
|
86
|
+
const o = T(r);
|
|
87
|
+
return o != null && o.length ? `${s} is ${_(o.map((l) => v(e, l, t)))}` : null;
|
|
88
88
|
}
|
|
89
89
|
default:
|
|
90
90
|
return null;
|
|
@@ -92,16 +92,16 @@ function A(e, n, o, t = {}) {
|
|
|
92
92
|
}
|
|
93
93
|
function U(e, n = {}) {
|
|
94
94
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
95
|
-
const
|
|
95
|
+
const r = [];
|
|
96
96
|
for (const t of e) {
|
|
97
97
|
if (!t || typeof t != "object" || !t.field) continue;
|
|
98
|
-
const s =
|
|
98
|
+
const s = b(t.field, t.op, t.value, n);
|
|
99
99
|
if (!s) return null;
|
|
100
|
-
|
|
100
|
+
r.push(s);
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return r.length ? r.join(" and ") : null;
|
|
103
103
|
}
|
|
104
|
-
const
|
|
104
|
+
const P = {
|
|
105
105
|
_eq: "eq",
|
|
106
106
|
_neq: "neq",
|
|
107
107
|
_gt: "gt",
|
|
@@ -111,44 +111,44 @@ const I = {
|
|
|
111
111
|
_in: "in",
|
|
112
112
|
_contains: "contains"
|
|
113
113
|
};
|
|
114
|
-
function
|
|
114
|
+
function q(e, n = {}, r = "") {
|
|
115
115
|
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
116
116
|
const t = [];
|
|
117
|
-
for (const [s,
|
|
117
|
+
for (const [s, i] of Object.entries(e)) {
|
|
118
118
|
if (s === "_and" || s === "_or") {
|
|
119
|
-
if (!Array.isArray(
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
119
|
+
if (!Array.isArray(i) || i.length === 0) return null;
|
|
120
|
+
const c = i.map((h) => q(h, n, r));
|
|
121
|
+
if (c.some((h) => !h)) return null;
|
|
122
122
|
t.push(
|
|
123
|
-
s === "_and" ?
|
|
123
|
+
s === "_and" ? c.join(" and ") : `either ${_(c)}`
|
|
124
124
|
);
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
127
|
if (s.startsWith("_")) return null;
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
t.push(
|
|
128
|
+
const o = r ? `${r}.${s}` : s;
|
|
129
|
+
if (i === null || typeof i != "object" || Array.isArray(i)) {
|
|
130
|
+
const c = b(o, Array.isArray(i) ? "in" : "eq", i, n);
|
|
131
|
+
if (!c) return null;
|
|
132
|
+
t.push(c);
|
|
133
133
|
continue;
|
|
134
134
|
}
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
if (!
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
t.push(
|
|
135
|
+
const l = Object.entries(i);
|
|
136
|
+
if (l.length === 0) return null;
|
|
137
|
+
if (!l.every(([c]) => c.startsWith("_"))) {
|
|
138
|
+
const c = q(i, n, o);
|
|
139
|
+
if (!c) return null;
|
|
140
|
+
t.push(c);
|
|
141
141
|
continue;
|
|
142
142
|
}
|
|
143
|
-
for (const [
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
146
|
-
t.push(
|
|
143
|
+
for (const [c, h] of l) {
|
|
144
|
+
let a;
|
|
145
|
+
if (c === "_null" ? a = b(o, h === !1 ? "nnull" : "null", null, n) : c === "_nnull" ? a = b(o, h === !1 ? "null" : "nnull", null, n) : P[c] ? a = b(o, P[c], h, n) : a = null, !a) return null;
|
|
146
|
+
t.push(a);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
return t.length ? t.join(" and ") : null;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function S(e) {
|
|
152
152
|
if (!e) return null;
|
|
153
153
|
if (typeof e == "object" && !Array.isArray(e)) return e;
|
|
154
154
|
if (typeof e != "string") return null;
|
|
@@ -159,16 +159,16 @@ function k(e) {
|
|
|
159
159
|
return null;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
var
|
|
164
|
-
const t = (
|
|
162
|
+
function Q(e, n, r = {}) {
|
|
163
|
+
var m, d;
|
|
164
|
+
const t = (m = e.parent_field) == null ? void 0 : m.trim(), s = (d = e.filter_column) == null ? void 0 : d.trim();
|
|
165
165
|
if (!t || !s || !n.field) return null;
|
|
166
|
-
const
|
|
167
|
-
return e.clear_on_parent_change !== !1 &&
|
|
168
|
-
e.show_all_if_no_parent === !1 ? `${
|
|
169
|
-
), e.upstream &&
|
|
166
|
+
const i = O(n.field, r), o = O(t, r), l = n.relatedCollection ?? null, u = l ? k(l, r) : "records", c = l ? s.split(".").map((p, $) => $ === 0 ? w(l, p, r) : y(p)).join("’s ") : y(s), a = e.value_map && Object.keys(e.value_map).length > 0 ? `whose ${c} is mapped from this record’s ${o}` : e.filter_is_m2m ? `whose ${c} is one of this record’s ${o}` : `whose ${c} is this record’s ${o}`, f = [`${i} only offers ${u} ${a}.`];
|
|
167
|
+
return e.clear_on_parent_change !== !1 && f.push(`Changing ${o} clears ${i}.`), e.clear_on_unavailable && f.push(`A ${i} that no longer fits is cleared.`), f.push(
|
|
168
|
+
e.show_all_if_no_parent === !1 ? `${i} stays locked until ${o} is picked.` : `With no ${o} picked, it offers every one.`
|
|
169
|
+
), e.upstream && f.push(`Picking a ${i} fills ${o} from it.`), f;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function z(e) {
|
|
172
172
|
return [e.first_name, e.last_name].filter(Boolean).join(" ").trim() || e.email || "someone";
|
|
173
173
|
}
|
|
174
174
|
function j(e) {
|
|
@@ -181,35 +181,80 @@ function j(e) {
|
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const
|
|
185
|
-
function
|
|
184
|
+
const D = /* @__PURE__ */ new Set(["eq", "neq", "gt", "gte", "lt", "lte", "in"]);
|
|
185
|
+
function X(e, n, r = {}) {
|
|
186
186
|
const t = j(e.filters);
|
|
187
187
|
if (!t) return null;
|
|
188
188
|
const s = [
|
|
189
|
-
...(e.users ?? []).map(
|
|
190
|
-
...(e.teams ?? []).map((
|
|
191
|
-
],
|
|
192
|
-
if (e.is_default) return `When no other group matches, ${
|
|
193
|
-
if (t.length === 0 || t.some((
|
|
189
|
+
...(e.users ?? []).map(z),
|
|
190
|
+
...(e.teams ?? []).map((c) => c.name ? `the ${c.name} team` : "a team")
|
|
191
|
+
], i = s.length ? s.length > 4 ? `${s.slice(0, 3).join(", ")} and ${s.length - 3} others` : N(s) : "nobody", o = s.length === 1 && !(e.teams ?? []).length ? "owns" : "own", l = n.stateLabel ? `${n.stateLabel}` : "this step";
|
|
192
|
+
if (e.is_default) return `When no other group matches, ${i} ${o} ${l}.`;
|
|
193
|
+
if (t.length === 0 || t.some((c) => !D.has(c.op ?? "eq"))) return null;
|
|
194
194
|
const u = U(
|
|
195
|
-
t.map((
|
|
196
|
-
|
|
195
|
+
t.map((c) => ({ field: c.field, op: c.op ?? "eq", value: c.value })),
|
|
196
|
+
r
|
|
197
197
|
);
|
|
198
|
-
return u ? `When ${u}, ${
|
|
198
|
+
return u ? `When ${u}, ${i} ${o} ${l}.` : null;
|
|
199
|
+
}
|
|
200
|
+
function Z(e, n = {}) {
|
|
201
|
+
const r = e.op ?? "eq";
|
|
202
|
+
if (e.field === "$state") {
|
|
203
|
+
const s = (T(e.value) ?? []).flatMap((i) => i.split(",")).map((i) => i.trim()).filter(Boolean).map((i) => {
|
|
204
|
+
var o;
|
|
205
|
+
return ((o = n.states) == null ? void 0 : o[i]) ?? i;
|
|
206
|
+
});
|
|
207
|
+
return s.length ? r === "eq" ? `the record is at ${s[0]}` : r === "neq" ? `the record is not at ${s[0]}` : r === "in" ? `the record is at ${_(s)}` : null : null;
|
|
208
|
+
}
|
|
209
|
+
if (e.field === "$addendum_active") {
|
|
210
|
+
if (!["true", "false"].includes(String(e.value)) || r !== "eq" && r !== "neq") return null;
|
|
211
|
+
const t = String(e.value) === "true";
|
|
212
|
+
return (r === "neq" ? !t : t) ? "an addendum is going through approval" : "no addendum is going through approval";
|
|
213
|
+
}
|
|
214
|
+
if (r === "related_none" || r === "related_some") {
|
|
215
|
+
const t = k(e.field.split(":")[0] ?? e.field, n);
|
|
216
|
+
return r === "related_none" ? `it has no linked ${t}` : `it has linked ${t}`;
|
|
217
|
+
}
|
|
218
|
+
return b(e.field, r, e.value, n);
|
|
219
|
+
}
|
|
220
|
+
function G(e, n = {}) {
|
|
221
|
+
if (!e) return [];
|
|
222
|
+
const r = (s) => {
|
|
223
|
+
const i = s.map((o) => Z(o, n));
|
|
224
|
+
return i.some((o) => !o) ? null : N(i);
|
|
225
|
+
};
|
|
226
|
+
if (Array.isArray(e)) {
|
|
227
|
+
if (!e.length) return [];
|
|
228
|
+
const s = r(e);
|
|
229
|
+
return s ? [`Anyone can make it while ${s}.`] : null;
|
|
230
|
+
}
|
|
231
|
+
const t = [];
|
|
232
|
+
for (const [s, i] of Object.entries(e)) {
|
|
233
|
+
const o = `On ${k(s, n)}`;
|
|
234
|
+
if (!Array.isArray(i)) return null;
|
|
235
|
+
if (!i.length) {
|
|
236
|
+
t.push(`${o}, anyone can make it.`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const l = r(i);
|
|
240
|
+
if (!l) return null;
|
|
241
|
+
t.push(`${o}, anyone can make it while ${l}.`);
|
|
242
|
+
}
|
|
243
|
+
return t;
|
|
199
244
|
}
|
|
200
|
-
function
|
|
201
|
-
var
|
|
202
|
-
const
|
|
245
|
+
function L(e, n = {}) {
|
|
246
|
+
var f, m, d;
|
|
247
|
+
const r = ((f = e.to_states) != null && f.length ? e.to_states : e.to_state ? [e.to_state] : []).map(
|
|
203
248
|
(p) => {
|
|
204
249
|
var $;
|
|
205
250
|
return (($ = n.states) == null ? void 0 : $[p]) ?? p;
|
|
206
251
|
}
|
|
207
252
|
);
|
|
208
|
-
if (!
|
|
209
|
-
const t = e.from_state ? ((
|
|
210
|
-
if (!s || !
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
253
|
+
if (!r.length) return null;
|
|
254
|
+
const t = e.from_state ? ((m = n.states) == null ? void 0 : m[e.from_state]) ?? e.from_state : null, s = j(e.required_roles), i = j(e.condition_rules), o = j(e.requirements);
|
|
255
|
+
if (!s || !i || !o) return null;
|
|
256
|
+
const l = i.length ? U(i, n) : null;
|
|
257
|
+
if (i.length && !l) return null;
|
|
213
258
|
let u;
|
|
214
259
|
if (s.length) {
|
|
215
260
|
const p = s.map(($) => {
|
|
@@ -219,25 +264,30 @@ function Q(e, n = {}) {
|
|
|
219
264
|
u = p.length === s.length ? _(p) : `people in ${s.length === 1 ? "one chosen role" : `one of ${s.length} chosen roles`}`;
|
|
220
265
|
} else u = "anyone who can edit the record";
|
|
221
266
|
e.require_owner && (u = e.allow_creator ? `the step’s owner or the record’s creator${s.length ? ` (in ${u})` : ""}` : `the step’s owner${s.length ? ` (in ${u})` : ""}`);
|
|
222
|
-
const
|
|
223
|
-
e.auto_trigger ?
|
|
224
|
-
|
|
225
|
-
) :
|
|
226
|
-
for (const p of
|
|
227
|
-
if ((p == null ? void 0 : p.type) !== "child_fields" || !p.collection || !((
|
|
267
|
+
const c = e.to_previous ? `back to the step it came from (${_(r)} when that is not known)` : `to ${_(r)}`, h = `move it ${t ? `from ${t} ` : "from any step "}${c}`, a = [];
|
|
268
|
+
e.auto_trigger ? a.push(
|
|
269
|
+
I(`${l ? `when ${l}, ` : ""}it moves by itself ${t ? `from ${t} ` : ""}${c}.`)
|
|
270
|
+
) : a.push(I(`${l ? `when ${l}, ` : ""}${u} can ${h}.`));
|
|
271
|
+
for (const p of o) {
|
|
272
|
+
if ((p == null ? void 0 : p.type) !== "child_fields" || !p.collection || !((d = p.fields) != null && d.length)) return null;
|
|
228
273
|
const $ = p.fields.map(
|
|
229
274
|
(g) => {
|
|
230
|
-
var
|
|
231
|
-
return ((
|
|
275
|
+
var C;
|
|
276
|
+
return ((C = p.labels) == null ? void 0 : C[g]) ?? w(p.collection, g, n);
|
|
232
277
|
}
|
|
233
278
|
);
|
|
234
|
-
|
|
235
|
-
`Before it moves, every ${
|
|
279
|
+
a.push(
|
|
280
|
+
`Before it moves, every ${k(p.collection, n)} line needs ${N($)}.`
|
|
236
281
|
);
|
|
237
282
|
}
|
|
238
|
-
|
|
283
|
+
if (e.require_owner && !e.auto_trigger) {
|
|
284
|
+
const p = G(e.open_when ?? null, n);
|
|
285
|
+
if (!p) return null;
|
|
286
|
+
a.push(...p);
|
|
287
|
+
}
|
|
288
|
+
return e.comment_mode === "required" && a.push("A comment is required."), a;
|
|
239
289
|
}
|
|
240
|
-
const
|
|
290
|
+
const F = {
|
|
241
291
|
sum: "Sum of",
|
|
242
292
|
count: "Number of",
|
|
243
293
|
avg: "Average of",
|
|
@@ -247,121 +297,121 @@ const q = {
|
|
|
247
297
|
distinct_count: "Number of different",
|
|
248
298
|
weighted_avg: "Weighted average of"
|
|
249
299
|
};
|
|
250
|
-
function
|
|
251
|
-
return e.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, (
|
|
300
|
+
function B(e, n) {
|
|
301
|
+
return e.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, (r, t) => n(t)).replace(/\bitem\.([A-Za-z_][A-Za-z0-9_]*)/g, (r, t) => n(t)).replace(/\s*\*\s*/g, " × ").replace(/\s*\/\s*/g, " ÷ ").replace(/\s+/g, " ").trim();
|
|
252
302
|
}
|
|
253
|
-
function
|
|
254
|
-
var
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
257
|
-
const s =
|
|
258
|
-
let
|
|
303
|
+
function Y(e, n) {
|
|
304
|
+
var a, f;
|
|
305
|
+
const r = typeof e.related_collection == "string" ? e.related_collection : null, t = typeof e.aggregate == "string" ? e.aggregate : null;
|
|
306
|
+
if (!r || !t || !F[t]) return null;
|
|
307
|
+
const s = k(r, n), i = (m) => w(r, m, n), o = [];
|
|
308
|
+
let l;
|
|
259
309
|
if (t === "count")
|
|
260
|
-
|
|
310
|
+
l = `${s} records`;
|
|
261
311
|
else {
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
else if (
|
|
266
|
-
|
|
312
|
+
const m = typeof e.value_formula == "string" ? e.value_formula.trim() : "", d = typeof e.value_field == "string" ? e.value_field : "";
|
|
313
|
+
if (m)
|
|
314
|
+
l = `(${B(m, i)})`, o.push(...R(m).map(i));
|
|
315
|
+
else if (d)
|
|
316
|
+
l = i(d), o.push(l);
|
|
267
317
|
else return null;
|
|
268
318
|
if (t === "weighted_avg") {
|
|
269
319
|
const p = typeof e.weight_field == "string" ? e.weight_field : "";
|
|
270
320
|
if (!p) return null;
|
|
271
|
-
|
|
321
|
+
l = `${l} weighted by ${i(p)}`, o.push(i(p));
|
|
272
322
|
}
|
|
273
|
-
|
|
323
|
+
l = `${l} on ${s}`;
|
|
274
324
|
}
|
|
275
|
-
const u = t === "distinct_count" ? `${
|
|
276
|
-
let
|
|
325
|
+
const u = t === "distinct_count" ? `${F[t]} ${l}` : `${F[t]} ${l}`;
|
|
326
|
+
let c = "";
|
|
277
327
|
if (e.filter && typeof e.filter == "object" && Object.keys(e.filter).length > 0) {
|
|
278
|
-
const
|
|
279
|
-
fields: ((
|
|
280
|
-
choices: ((
|
|
328
|
+
const m = {
|
|
329
|
+
fields: ((a = n.relatedFields) == null ? void 0 : a[r]) ?? {},
|
|
330
|
+
choices: ((f = n.relatedChoices) == null ? void 0 : f[r]) ?? {},
|
|
281
331
|
collections: n.collections,
|
|
282
332
|
relatedFields: n.relatedFields
|
|
283
|
-
},
|
|
284
|
-
if (!
|
|
285
|
-
|
|
333
|
+
}, d = q(e.filter, m);
|
|
334
|
+
if (!d) return null;
|
|
335
|
+
c = ` where ${d}`;
|
|
286
336
|
}
|
|
287
337
|
const h = e.recursive ? ", counting every level below" : "";
|
|
288
|
-
return { text: `${u}${
|
|
338
|
+
return { text: `${u}${c}${h}`, inputs: o };
|
|
289
339
|
}
|
|
290
|
-
function
|
|
291
|
-
var
|
|
292
|
-
const t = (
|
|
340
|
+
function x(e, n = {}, r = []) {
|
|
341
|
+
var i;
|
|
342
|
+
const t = (o) => O(o, n), s = e.computed_store === !0 || e.computed_store === 1;
|
|
293
343
|
switch (e.computed_type) {
|
|
294
344
|
case "rollup": {
|
|
295
|
-
const
|
|
296
|
-
if (!
|
|
297
|
-
const u = (Array.isArray(
|
|
298
|
-
if (!u.length || u.some((
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
if (!
|
|
305
|
-
h.push(`Only for records where ${
|
|
345
|
+
const o = S(e.computed_formula);
|
|
346
|
+
if (!o) return null;
|
|
347
|
+
const u = (Array.isArray(o.sources) ? o.sources : [o]).map((f) => Y(f, n));
|
|
348
|
+
if (!u.length || u.some((f) => !f)) return null;
|
|
349
|
+
const c = u, h = [];
|
|
350
|
+
c.length > 1 && h.push("The figures above are added together.");
|
|
351
|
+
const a = o.parent_filter;
|
|
352
|
+
if (a && typeof a == "object" && Object.keys(a).length > 0) {
|
|
353
|
+
const f = q(a, n);
|
|
354
|
+
if (!f) return null;
|
|
355
|
+
h.push(`Only for records where ${f}; on other records it is typed in by hand.`);
|
|
306
356
|
}
|
|
307
357
|
return e.computed_store != null && h.push(
|
|
308
358
|
s ? "Saved on the record and recalculated when one of those records changes." : "Worked out each time the record is read."
|
|
309
359
|
), {
|
|
310
|
-
sentence: `${
|
|
360
|
+
sentence: `${c.map((f) => f.text).join(", plus ")}.`,
|
|
311
361
|
notes: h,
|
|
312
|
-
inputs: [...new Set(
|
|
362
|
+
inputs: [...new Set(c.flatMap((f) => f.inputs))]
|
|
313
363
|
};
|
|
314
364
|
}
|
|
315
365
|
case "lookup": {
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
318
|
-
const
|
|
366
|
+
const o = S(e.computed_formula), l = typeof (o == null ? void 0 : o.fk_field) == "string" ? o.fk_field : null, u = typeof (o == null ? void 0 : o.source_field) == "string" ? o.source_field : null;
|
|
367
|
+
if (!l || !u) return null;
|
|
368
|
+
const c = (i = n.links) == null ? void 0 : i[l], h = c ? w(c, u, n) : y(u);
|
|
319
369
|
return {
|
|
320
|
-
sentence: `Copied from the ${t(
|
|
370
|
+
sentence: `Copied from the ${t(l)}’s ${h} when ${t(l)} is set.`,
|
|
321
371
|
notes: [
|
|
322
|
-
`It keeps the value it copied, even if the ${t(
|
|
372
|
+
`It keeps the value it copied, even if the ${t(l)} changes later; clearing ${t(l)} clears it.`
|
|
323
373
|
],
|
|
324
|
-
inputs: [t(
|
|
374
|
+
inputs: [t(l)]
|
|
325
375
|
};
|
|
326
376
|
}
|
|
327
377
|
case "read":
|
|
328
378
|
case "write": {
|
|
329
|
-
const
|
|
330
|
-
if (!
|
|
331
|
-
const
|
|
379
|
+
const o = String(e.computed_formula ?? "").trim();
|
|
380
|
+
if (!o) return null;
|
|
381
|
+
const l = R(o).map(t);
|
|
332
382
|
return {
|
|
333
|
-
sentence: `Worked out as ${
|
|
383
|
+
sentence: `Worked out as ${B(o, t)}.`,
|
|
334
384
|
notes: [
|
|
335
|
-
e.computed_type === "read" ? "Worked out each time the record is read; it is never saved." : `Saved on the record; worked out again when ${
|
|
385
|
+
e.computed_type === "read" ? "Worked out each time the record is read; it is never saved." : `Saved on the record; worked out again when ${l.length ? _(l) : "an input"} changes.`
|
|
336
386
|
],
|
|
337
|
-
inputs:
|
|
387
|
+
inputs: l
|
|
338
388
|
};
|
|
339
389
|
}
|
|
340
390
|
}
|
|
341
|
-
for (const { field:
|
|
342
|
-
const u =
|
|
343
|
-
if (!
|
|
344
|
-
const
|
|
345
|
-
if (typeof
|
|
346
|
-
const
|
|
347
|
-
(g) => g === "id" ? `the picked ${t(
|
|
348
|
-
), p =
|
|
391
|
+
for (const { field: o, config: l } of r) {
|
|
392
|
+
const u = S(l), c = S(u == null ? void 0 : u.field_map), h = typeof (u == null ? void 0 : u.source_collection) == "string" ? u.source_collection : null;
|
|
393
|
+
if (!c || !h) continue;
|
|
394
|
+
const a = c[e.field];
|
|
395
|
+
if (typeof a != "string" || !a.trim()) continue;
|
|
396
|
+
const f = typeof (u == null ? void 0 : u.source_fk_field) == "string" ? u.source_fk_field : o, m = a.split("||").map((g) => g.trim()).filter(Boolean), d = m.map(
|
|
397
|
+
(g) => g === "id" ? `the picked ${t(f)} itself` : w(h, g, n)
|
|
398
|
+
), p = d.length === 1 ? m[0] === "id" ? d[0] : `the ${t(f)}’s ${d[0]}` : `the ${t(f)}’s ${d[0]} (or ${_(d.slice(1))} when that is empty)`, $ = (u == null ? void 0 : u.on_write) === !1 ? "picked on the form" : "set, on the form or through the API";
|
|
349
399
|
return {
|
|
350
|
-
sentence: `Filled from ${p} when ${t(
|
|
400
|
+
sentence: `Filled from ${p} when ${t(f)} is ${$}.`,
|
|
351
401
|
notes: ["You can change it afterwards; a value someone typed is never overwritten."],
|
|
352
|
-
inputs: [t(
|
|
402
|
+
inputs: [t(f)]
|
|
353
403
|
};
|
|
354
404
|
}
|
|
355
405
|
return null;
|
|
356
406
|
}
|
|
357
|
-
const
|
|
358
|
-
function
|
|
407
|
+
const E = (e, n, r = `${n}s`) => `${e.toLocaleString("en-US")} ${e === 1 ? n : r}`;
|
|
408
|
+
function V(e) {
|
|
359
409
|
if (e.length === 0) return "";
|
|
360
|
-
const n = e.slice(0, 3).map((t) => `“${t}”`),
|
|
361
|
-
return `${
|
|
410
|
+
const n = e.slice(0, 3).map((t) => `“${t}”`), r = e.length - n.length;
|
|
411
|
+
return `${E(e.length, "form")} (${n.join(", ")}${r > 0 ? ` and ${r} more` : ""})`;
|
|
362
412
|
}
|
|
363
|
-
function
|
|
364
|
-
var
|
|
413
|
+
function ee(e, n = [], r, t = {}) {
|
|
414
|
+
var i;
|
|
365
415
|
const s = {
|
|
366
416
|
...t,
|
|
367
417
|
fields: { ...t.fields ?? {} },
|
|
@@ -369,50 +419,52 @@ function L(e, n = [], o, t = {}) {
|
|
|
369
419
|
choices: { ...t.choices ?? {} },
|
|
370
420
|
links: { ...t.links ?? {} }
|
|
371
421
|
};
|
|
372
|
-
for (const
|
|
373
|
-
(
|
|
374
|
-
let
|
|
375
|
-
if (typeof
|
|
422
|
+
for (const o of e) {
|
|
423
|
+
(i = o.label) != null && i.trim() && (s.fields[o.field] = o.label.trim()), o.type && (s.types[o.field] = o.type);
|
|
424
|
+
let l = o.options;
|
|
425
|
+
if (typeof l == "string")
|
|
376
426
|
try {
|
|
377
|
-
|
|
427
|
+
l = JSON.parse(l);
|
|
378
428
|
} catch {
|
|
379
|
-
|
|
429
|
+
l = null;
|
|
380
430
|
}
|
|
381
|
-
const u = Array.isArray(
|
|
431
|
+
const u = Array.isArray(l) ? l : l && typeof l == "object" ? l.choices : null;
|
|
382
432
|
if (!Array.isArray(u)) continue;
|
|
383
|
-
const
|
|
433
|
+
const c = {};
|
|
384
434
|
for (const h of u) {
|
|
385
435
|
if (!h || typeof h != "object") continue;
|
|
386
|
-
const { value:
|
|
387
|
-
|
|
436
|
+
const { value: a, text: f } = h;
|
|
437
|
+
a != null && (c[String(a)] = W(f == null ? String(a) : String(f)));
|
|
388
438
|
}
|
|
389
|
-
Object.keys(
|
|
439
|
+
Object.keys(c).length && (s.choices[o.field] = c);
|
|
390
440
|
}
|
|
391
|
-
for (const
|
|
392
|
-
(!
|
|
441
|
+
for (const o of n)
|
|
442
|
+
(!r || o.many_collection === r) && o.many_field && o.one_collection && !o.junction_field && (s.links[o.many_field] = o.one_collection);
|
|
393
443
|
return s;
|
|
394
444
|
}
|
|
395
|
-
function
|
|
445
|
+
function te(e) {
|
|
396
446
|
var t;
|
|
397
447
|
const n = [];
|
|
398
|
-
e.forms.length && n.push(`It is on ${
|
|
399
|
-
const
|
|
400
|
-
return e.records &&
|
|
448
|
+
e.forms.length && n.push(`It is on ${V(e.forms)}`);
|
|
449
|
+
const r = ((t = e.records) == null ? void 0 : t.with_value) ?? 0;
|
|
450
|
+
return e.records && r > 0 && n.push(`${E(r, "record")} ${r === 1 ? "has" : "have"} a ${e.fieldLabel}`), n.length ? `${n.join(" and ")}.` : null;
|
|
401
451
|
}
|
|
402
452
|
export {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
453
|
+
N as andList,
|
|
454
|
+
k as collectionLabelOf,
|
|
455
|
+
Q as describeCascadeFilter,
|
|
456
|
+
b as describeCondition,
|
|
407
457
|
U as describeConditionList,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
458
|
+
te as describeFieldReach,
|
|
459
|
+
x as describeFieldSource,
|
|
460
|
+
q as describeFilterObject,
|
|
461
|
+
G as describeOpenWhen,
|
|
462
|
+
Z as describeOpenWhenRule,
|
|
463
|
+
X as describeOwnerGroup,
|
|
464
|
+
L as describeTransition,
|
|
465
|
+
O as fieldLabelOf,
|
|
466
|
+
B as formulaInWords,
|
|
415
467
|
_ as orList,
|
|
416
|
-
|
|
417
|
-
|
|
468
|
+
ee as sentenceLabelsFromFields,
|
|
469
|
+
v as valueTextOf
|
|
418
470
|
};
|