@nivaro/react 0.3.124 → 0.3.126
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.
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const j = "$step", B = "Pipeline step";
|
|
2
|
+
const M = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), f = (e) => e.timestamp ? new Date(e.timestamp).getTime() : 0, V = (e, o) => {
|
|
3
3
|
const a = (t) => t == null || t === "" ? "" : typeof t == "object" ? JSON.stringify(t) : String(t);
|
|
4
4
|
return a(e) === a(o);
|
|
5
5
|
};
|
|
6
|
-
function
|
|
6
|
+
function F(e) {
|
|
7
7
|
return [e.first_name, e.last_name].filter(Boolean).join(" ").trim() || e.user_email || (e.user_id ? "Someone" : "System");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
function K(e, o = {}) {
|
|
10
|
+
var p, k;
|
|
11
|
+
const a = o.name ?? F, t = [...e].sort((n, u) => f(u) - f(n)), s = t.filter(M), l = t.filter((n) => /^o2m-/.test(String(n.action ?? "")) && n.o2m), i = t.filter((n) => n.event && !n.event.addendum && n.event.to_label).sort((n, u) => f(n) - f(u)), c = (n) => {
|
|
12
|
+
var m;
|
|
13
|
+
let u = null;
|
|
14
|
+
for (const b of i) {
|
|
15
|
+
if (f(b) > n) break;
|
|
16
|
+
u = ((m = b.event) == null ? void 0 : m.to_label) ?? u;
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
for (const
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
|
|
18
|
+
return u;
|
|
19
|
+
}, r = s.map((n, u) => {
|
|
20
|
+
const m = s[u + 1], b = n.data ?? {}, y = n.action === "create" ? "created" : n.action === "delete" ? "deleted" : n.action === "restore" ? "restored" : "changed", A = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
|
|
21
|
+
if (m && y !== "created") {
|
|
22
|
+
const T = m.data ?? {}, R = new Set(Object.keys(n.delta ?? {}));
|
|
23
|
+
for (const w of /* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(b)])) {
|
|
24
|
+
if (w === "id" || V(T[w], b[w]) || !(w in T) && !R.has(w)) continue;
|
|
25
|
+
if (R.has(w)) {
|
|
26
|
+
A.add(w);
|
|
26
27
|
continue;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
var
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
}).map((
|
|
34
|
-
var
|
|
29
|
+
I.add(w);
|
|
30
|
+
const G = f(m), P = f(n), C = l.filter(($) => {
|
|
31
|
+
var O;
|
|
32
|
+
const v = f($);
|
|
33
|
+
return v > G && v <= P && (((O = $.o2m) == null ? void 0 : O.totals) ?? []).some((D) => D.field === w);
|
|
34
|
+
}).map(($) => {
|
|
35
|
+
var v, O, D, N;
|
|
35
36
|
return {
|
|
36
|
-
name: a(
|
|
37
|
-
userId:
|
|
38
|
-
row: ((
|
|
39
|
-
delta: ((
|
|
37
|
+
name: a($),
|
|
38
|
+
userId: $.user_id ?? null,
|
|
39
|
+
row: ((v = $.o2m) == null ? void 0 : v.row_label) || ((O = $.o2m) == null ? void 0 : O.collection_label) || "a related row",
|
|
40
|
+
delta: ((N = (((D = $.o2m) == null ? void 0 : D.totals) ?? []).find((x) => x.field === w)) == null ? void 0 : N.delta) ?? 0
|
|
40
41
|
};
|
|
41
42
|
}).reverse();
|
|
42
|
-
|
|
43
|
+
C.length && h.set(w, C);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
return {
|
|
@@ -47,94 +48,106 @@ function U(e, o = {}) {
|
|
|
47
48
|
timestamp: n.timestamp,
|
|
48
49
|
who: a(n),
|
|
49
50
|
userId: n.user_id ?? null,
|
|
50
|
-
action:
|
|
51
|
-
values:
|
|
52
|
-
changed:
|
|
53
|
-
recalculated:
|
|
54
|
-
via:
|
|
51
|
+
action: y,
|
|
52
|
+
values: i.length ? { ...b, [j]: c(f(n)) } : b,
|
|
53
|
+
changed: A,
|
|
54
|
+
recalculated: I,
|
|
55
|
+
via: h
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
|
-
if (!o.withMoves ||
|
|
58
|
-
const d = t.filter((n) => n.user_id && (
|
|
59
|
-
var
|
|
60
|
-
const
|
|
58
|
+
if (!o.withMoves || i.length === 0) return r;
|
|
59
|
+
const d = t.filter((n) => n.user_id && (M(n) || n.event || n.o2m)), g = i.map((n) => {
|
|
60
|
+
var A, I;
|
|
61
|
+
const u = f(n), m = r.find((h) => (h.timestamp ? new Date(h.timestamp).getTime() : 0) <= u), b = !n.user_id, y = b ? d.filter((h) => h !== n && f(h) <= u + 2e3 && u - f(h) <= 15e3).sort((h, T) => Math.abs(u - f(h)) - Math.abs(u - f(T)))[0] : void 0;
|
|
61
62
|
return {
|
|
62
|
-
key: `move|${n.timestamp ?? ""}|${((
|
|
63
|
+
key: `move|${n.timestamp ?? ""}|${((A = n.event) == null ? void 0 : A.to_label) ?? ""}`,
|
|
63
64
|
timestamp: n.timestamp,
|
|
64
|
-
who:
|
|
65
|
+
who: b ? "Automatic" : a(n),
|
|
65
66
|
userId: n.user_id ?? null,
|
|
66
|
-
trigger:
|
|
67
|
+
trigger: y ? { name: a(y), userId: y.user_id ?? null } : null,
|
|
68
|
+
linkedTo: y && M(y) ? `${y.id}|${y.timestamp ?? ""}` : null,
|
|
67
69
|
action: "moved",
|
|
68
|
-
values: { ...(
|
|
69
|
-
changed: /* @__PURE__ */ new Set([
|
|
70
|
+
values: { ...(m == null ? void 0 : m.values) ?? {}, [j]: ((I = n.event) == null ? void 0 : I.to_label) ?? null },
|
|
71
|
+
changed: /* @__PURE__ */ new Set([j]),
|
|
70
72
|
recalculated: /* @__PURE__ */ new Set(),
|
|
71
73
|
via: /* @__PURE__ */ new Map()
|
|
72
74
|
};
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
}), _ = new Map(r.map((n) => [n.key, n])), S = [];
|
|
76
|
+
for (const [n, u] of g.entries()) {
|
|
77
|
+
const m = u.linkedTo ? _.get(u.linkedTo) : void 0;
|
|
78
|
+
if (!m) {
|
|
79
|
+
S.push(u);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
m.values = { ...m.values, [j]: u.values[j] ?? null }, m.changed = /* @__PURE__ */ new Set([...m.changed, j]), m.autoMove = {
|
|
83
|
+
from: ((p = i[n].event) == null ? void 0 : p.from_label) ?? null,
|
|
84
|
+
to: ((k = i[n].event) == null ? void 0 : k.to_label) ?? null
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return [...r, ...S].sort(
|
|
88
|
+
(n, u) => (u.timestamp ? new Date(u.timestamp).getTime() : 0) - (n.timestamp ? new Date(n.timestamp).getTime() : 0)
|
|
76
89
|
);
|
|
77
90
|
}
|
|
78
|
-
function
|
|
91
|
+
function Z(e, o) {
|
|
79
92
|
const a = /* @__PURE__ */ new Map();
|
|
80
93
|
for (const s of e) {
|
|
81
|
-
for (const
|
|
82
|
-
for (const
|
|
94
|
+
for (const l of Object.keys(s.values)) a.has(l) || a.set(l, 0);
|
|
95
|
+
for (const l of [...s.changed, ...s.recalculated]) a.set(l, (a.get(l) ?? 0) + 1);
|
|
83
96
|
}
|
|
84
|
-
const t = (s) => s ===
|
|
85
|
-
return [...a].filter(([s]) => s !== "id" && !t(s).system).map(([s,
|
|
86
|
-
const
|
|
87
|
-
return
|
|
97
|
+
const t = (s) => s === j ? { label: B, system: !1, order: -1 } : o(s);
|
|
98
|
+
return [...a].filter(([s]) => s !== "id" && !t(s).system).map(([s, l]) => ({ field: s, label: t(s).label, changes: l })).sort((s, l) => {
|
|
99
|
+
const i = t(s.field).order ?? Number.POSITIVE_INFINITY, c = t(l.field).order ?? Number.POSITIVE_INFINITY;
|
|
100
|
+
return i - c || s.label.localeCompare(l.label);
|
|
88
101
|
});
|
|
89
102
|
}
|
|
90
|
-
function
|
|
103
|
+
function q(e, o) {
|
|
91
104
|
return e.filter(
|
|
92
105
|
(a) => a.action !== "changed" && a.action !== "moved" || o.some((t) => a.changed.has(t) || a.recalculated.has(t))
|
|
93
106
|
);
|
|
94
107
|
}
|
|
95
|
-
function
|
|
108
|
+
function E(e) {
|
|
96
109
|
const o = Math.abs(e).toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
97
110
|
return `${e > 0 ? "+" : e < 0 ? "−" : ""}${o}`;
|
|
98
111
|
}
|
|
99
|
-
function
|
|
100
|
-
return e != null && e.length ? `Recalculated after ${e.map((o) => `${o.name} · ${o.row} ${
|
|
112
|
+
function J(e) {
|
|
113
|
+
return e != null && e.length ? `Recalculated after ${e.map((o) => `${o.name} · ${o.row} ${E(o.delta)}`).join(", ")}` : "Recalculated";
|
|
101
114
|
}
|
|
102
|
-
const
|
|
115
|
+
const U = {
|
|
103
116
|
created: "Created",
|
|
104
117
|
changed: "Changed",
|
|
105
118
|
deleted: "Deleted",
|
|
106
119
|
restored: "Restored",
|
|
107
120
|
moved: "Moved"
|
|
108
|
-
},
|
|
109
|
-
function
|
|
121
|
+
}, Y = (e) => U[e];
|
|
122
|
+
function z(e) {
|
|
110
123
|
let o = e;
|
|
111
124
|
return /^[=+\-@\t\r]/.test(o) && !/^-?\d[\d,]*(\.\d+)?$/.test(o) && (o = `'${o}`), /[",\n\r]/.test(o) ? `"${o.replace(/"/g, '""')}"` : o;
|
|
112
125
|
}
|
|
113
|
-
function
|
|
114
|
-
const s =
|
|
115
|
-
for (const
|
|
116
|
-
const
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
if (!t) return `${
|
|
120
|
-
const
|
|
121
|
-
return `${
|
|
126
|
+
function Q(e, o, a, t) {
|
|
127
|
+
const s = z, i = [["When", "Changed by", "Action", ...o.map((c) => c.label), "Recalculated"].map(s).join(",")];
|
|
128
|
+
for (const c of e) {
|
|
129
|
+
const r = [...c.recalculated].filter((d) => o.some((g) => g.field === d)).map((d) => {
|
|
130
|
+
var S;
|
|
131
|
+
const g = ((S = o.find((p) => p.field === d)) == null ? void 0 : S.label) ?? d;
|
|
132
|
+
if (!t) return `${g}: ${J(c.via.get(d))}`;
|
|
133
|
+
const _ = t(d, c);
|
|
134
|
+
return `${g}: ${_.why}${_.because ? ` — ${_.because}` : ""}`;
|
|
122
135
|
}).join("; ");
|
|
123
|
-
|
|
136
|
+
i.push(
|
|
124
137
|
[
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...o.map((d) => a(d.field,
|
|
129
|
-
|
|
138
|
+
c.timestamp ? new Date(c.timestamp).toLocaleString("en-US") : "",
|
|
139
|
+
c.who,
|
|
140
|
+
Y(c.action),
|
|
141
|
+
...o.map((d) => a(d.field, c.values[d.field])),
|
|
142
|
+
r
|
|
130
143
|
].map((d) => s(String(d ?? ""))).join(",")
|
|
131
144
|
);
|
|
132
145
|
}
|
|
133
|
-
return `${
|
|
146
|
+
return `${i.join(`\r
|
|
134
147
|
`)}\r
|
|
135
148
|
`;
|
|
136
149
|
}
|
|
137
|
-
const
|
|
150
|
+
const W = (e) => {
|
|
138
151
|
if (e && typeof e == "object" && !Array.isArray(e)) return e;
|
|
139
152
|
if (typeof e != "string" || !e.trim()) return null;
|
|
140
153
|
try {
|
|
@@ -144,19 +157,19 @@ const N = (e) => {
|
|
|
144
157
|
return null;
|
|
145
158
|
}
|
|
146
159
|
};
|
|
147
|
-
function
|
|
160
|
+
function X(e, o) {
|
|
148
161
|
const a = String(e ?? "");
|
|
149
162
|
if (a === "rollup") {
|
|
150
|
-
const t =
|
|
151
|
-
collection: String(
|
|
152
|
-
field: String(
|
|
153
|
-
aggregate: String(
|
|
154
|
-
filtered: !!
|
|
163
|
+
const t = W(o), l = (Array.isArray(t == null ? void 0 : t.sources) ? t == null ? void 0 : t.sources : []).filter((i) => typeof i.related_collection == "string").map((i) => ({
|
|
164
|
+
collection: String(i.related_collection),
|
|
165
|
+
field: String(i.value_field ?? ""),
|
|
166
|
+
aggregate: String(i.aggregate ?? "sum"),
|
|
167
|
+
filtered: !!i.filter && Object.keys(i.filter).length > 0
|
|
155
168
|
}));
|
|
156
|
-
return
|
|
169
|
+
return l.length ? { kind: "rollup", sources: l } : null;
|
|
157
170
|
}
|
|
158
171
|
if (a === "lookup") {
|
|
159
|
-
const t =
|
|
172
|
+
const t = W(o);
|
|
160
173
|
return !(t != null && t.fk_field) || !(t != null && t.source_field) ? null : { kind: "lookup", fk: String(t.fk_field), source: String(t.source_field) };
|
|
161
174
|
}
|
|
162
175
|
return a === "write" || a === "read" ? { kind: "formula", inputs: [
|
|
@@ -165,7 +178,7 @@ function Z(e, o) {
|
|
|
165
178
|
)
|
|
166
179
|
] } : null;
|
|
167
180
|
}
|
|
168
|
-
const
|
|
181
|
+
const H = {
|
|
169
182
|
sum: "Sum",
|
|
170
183
|
count: "Count",
|
|
171
184
|
avg: "Average",
|
|
@@ -174,22 +187,22 @@ const J = {
|
|
|
174
187
|
median: "Median",
|
|
175
188
|
distinct_count: "Distinct count",
|
|
176
189
|
weighted_avg: "Weighted average"
|
|
177
|
-
},
|
|
178
|
-
function
|
|
179
|
-
const
|
|
190
|
+
}, L = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
191
|
+
function ee(e, o, a, t, s = E) {
|
|
192
|
+
const l = o.via.get(e), i = l != null && l.length ? l.map((c) => `${c.name} changed ${c.row} (${s(c.delta)})`).join("; ") : void 0;
|
|
180
193
|
if ((a == null ? void 0 : a.kind) === "rollup")
|
|
181
194
|
return {
|
|
182
|
-
why: a.sources.map((
|
|
183
|
-
const d =
|
|
184
|
-
return `${d} of ${
|
|
195
|
+
why: a.sources.map((r) => {
|
|
196
|
+
const d = H[r.aggregate] ?? "Total", g = r.aggregate === "count" ? t(r.collection) : `${t(r.collection)} · ${t(r.collection, r.field)}`;
|
|
197
|
+
return `${d} of ${g}${r.filtered ? " (filtered)" : ""}`;
|
|
185
198
|
}).join(" + "),
|
|
186
|
-
because:
|
|
199
|
+
because: i ?? "Its rows changed between these two saves"
|
|
187
200
|
};
|
|
188
201
|
if ((a == null ? void 0 : a.kind) === "formula") {
|
|
189
|
-
const
|
|
202
|
+
const c = a.inputs.filter((r) => o.changed.has(r) || o.recalculated.has(r));
|
|
190
203
|
return {
|
|
191
|
-
why: a.inputs.length ? `Worked out from ${
|
|
192
|
-
because:
|
|
204
|
+
why: a.inputs.length ? `Worked out from ${L(a.inputs.map((r) => t(null, r)))}` : "Worked out by a formula",
|
|
205
|
+
because: c.length ? `${L(c.map((r) => t(null, r)))} changed` : i ?? void 0
|
|
193
206
|
};
|
|
194
207
|
}
|
|
195
208
|
return (a == null ? void 0 : a.kind) === "lookup" ? {
|
|
@@ -197,10 +210,10 @@ function q(e, o, a, t, s = C) {
|
|
|
197
210
|
because: o.changed.has(a.fk) ? `${t(null, a.fk)} changed` : void 0
|
|
198
211
|
} : {
|
|
199
212
|
why: "Set automatically (rule, job or integration)",
|
|
200
|
-
because:
|
|
213
|
+
because: i
|
|
201
214
|
};
|
|
202
215
|
}
|
|
203
|
-
function
|
|
216
|
+
function te(e, o) {
|
|
204
217
|
if (!o) return null;
|
|
205
218
|
const a = new Date(o).getTime();
|
|
206
219
|
let t = null;
|
|
@@ -210,20 +223,42 @@ function K(e, o) {
|
|
|
210
223
|
}
|
|
211
224
|
return t;
|
|
212
225
|
}
|
|
226
|
+
function ne(e, o) {
|
|
227
|
+
const a = (o == null ? void 0 : o.fields) ?? {}, t = Object.keys(a);
|
|
228
|
+
return t.length === 0 ? e : e.map((s) => {
|
|
229
|
+
if (!s.data) return s;
|
|
230
|
+
let l = null;
|
|
231
|
+
for (const i of t) {
|
|
232
|
+
const c = s.data[i];
|
|
233
|
+
if (!Array.isArray(c)) continue;
|
|
234
|
+
const r = a[i], d = [];
|
|
235
|
+
let g = 0;
|
|
236
|
+
for (const p of c) {
|
|
237
|
+
const k = p && typeof p == "object" ? p.id : p, n = k == null ? void 0 : r[String(k)];
|
|
238
|
+
n ? d.push(n.label) : g++;
|
|
239
|
+
}
|
|
240
|
+
d.sort((p, k) => p.localeCompare(k));
|
|
241
|
+
const _ = g === 0 ? [] : d.length === 0 ? [`${g} linked`] : [`+${g} more`], S = [...new Set(d), ..._].join(", ");
|
|
242
|
+
l = l ?? { ...s.data }, l[i] = c.length === 0 ? null : S;
|
|
243
|
+
}
|
|
244
|
+
return l ? { ...s, data: l } : s;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
213
247
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
248
|
+
j as STEP_FIELD,
|
|
249
|
+
B as STEP_LABEL,
|
|
250
|
+
K as buildSaveRows,
|
|
251
|
+
z as csvCell,
|
|
252
|
+
X as deriveOf,
|
|
253
|
+
Z as matrixColumns,
|
|
254
|
+
Q as matrixCsv,
|
|
255
|
+
F as personName,
|
|
256
|
+
ee as recalcReason,
|
|
257
|
+
q as rowsChanging,
|
|
258
|
+
V as sameValue,
|
|
259
|
+
Y as saveActionLabel,
|
|
260
|
+
E as signedAmount,
|
|
261
|
+
te as valueAt,
|
|
262
|
+
J as viaText,
|
|
263
|
+
ne as withLinkLabels
|
|
229
264
|
};
|