@nivaro/react 0.3.124 → 0.3.125
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 $ = "$step", V = "Pipeline step";
|
|
2
|
+
const D = (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, x = (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 v, M;
|
|
11
|
+
const a = o.name ?? F, t = [...e].sort((n, i) => f(i) - f(n)), s = t.filter(D), c = t.filter((n) => /^o2m-/.test(String(n.action ?? "")) && n.o2m), l = t.filter((n) => n.event && !n.event.addendum && n.event.to_label).sort((n, i) => f(n) - f(i)), r = (n) => {
|
|
12
|
+
var d;
|
|
13
|
+
let i = null;
|
|
14
|
+
for (const h of l) {
|
|
15
|
+
if (f(h) > n) break;
|
|
16
|
+
i = ((d = h.event) == null ? void 0 : d.to_label) ?? i;
|
|
16
17
|
}
|
|
17
|
-
return
|
|
18
|
-
}, u = s.map((n,
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
for (const p of /* @__PURE__ */ new Set([...Object.keys(
|
|
23
|
-
if (p === "id" ||
|
|
24
|
-
if (
|
|
25
|
-
|
|
18
|
+
return i;
|
|
19
|
+
}, u = s.map((n, i) => {
|
|
20
|
+
const d = s[i + 1], h = n.data ?? {}, w = n.action === "create" ? "created" : n.action === "delete" ? "deleted" : n.action === "restore" ? "restored" : "changed", k = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
|
|
21
|
+
if (d && w !== "created") {
|
|
22
|
+
const T = d.data ?? {}, R = new Set(Object.keys(n.delta ?? {}));
|
|
23
|
+
for (const p of /* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(h)])) {
|
|
24
|
+
if (p === "id" || x(T[p], h[p]) || !(p in T) && !R.has(p)) continue;
|
|
25
|
+
if (R.has(p)) {
|
|
26
|
+
k.add(p);
|
|
26
27
|
continue;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
var
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
}).map((
|
|
34
|
-
var
|
|
29
|
+
I.add(p);
|
|
30
|
+
const G = f(d), P = f(n), N = c.filter((_) => {
|
|
31
|
+
var A;
|
|
32
|
+
const j = f(_);
|
|
33
|
+
return j > G && j <= P && (((A = _.o2m) == null ? void 0 : A.totals) ?? []).some((O) => O.field === p);
|
|
34
|
+
}).map((_) => {
|
|
35
|
+
var j, A, O, W;
|
|
35
36
|
return {
|
|
36
|
-
name: a(
|
|
37
|
-
userId:
|
|
38
|
-
row: ((
|
|
39
|
-
delta: ((
|
|
37
|
+
name: a(_),
|
|
38
|
+
userId: _.user_id ?? null,
|
|
39
|
+
row: ((j = _.o2m) == null ? void 0 : j.row_label) || ((A = _.o2m) == null ? void 0 : A.collection_label) || "a related row",
|
|
40
|
+
delta: ((W = (((O = _.o2m) == null ? void 0 : O.totals) ?? []).find((B) => B.field === p)) == null ? void 0 : W.delta) ?? 0
|
|
40
41
|
};
|
|
41
42
|
}).reverse();
|
|
42
|
-
|
|
43
|
+
N.length && g.set(p, N);
|
|
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:
|
|
51
|
+
action: w,
|
|
52
|
+
values: l.length ? { ...h, [$]: r(f(n)) } : h,
|
|
53
|
+
changed: k,
|
|
54
|
+
recalculated: I,
|
|
54
55
|
via: g
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
|
-
if (!o.withMoves ||
|
|
58
|
-
const
|
|
59
|
-
var
|
|
60
|
-
const
|
|
58
|
+
if (!o.withMoves || l.length === 0) return u;
|
|
59
|
+
const m = t.filter((n) => n.user_id && (D(n) || n.event || n.o2m)), b = l.map((n) => {
|
|
60
|
+
var k, I;
|
|
61
|
+
const i = f(n), d = u.find((g) => (g.timestamp ? new Date(g.timestamp).getTime() : 0) <= i), h = !n.user_id, w = h ? m.filter((g) => g !== n && f(g) <= i + 2e3 && i - f(g) <= 15e3).sort((g, T) => Math.abs(i - f(g)) - Math.abs(i - f(T)))[0] : void 0;
|
|
61
62
|
return {
|
|
62
|
-
key: `move|${n.timestamp ?? ""}|${((
|
|
63
|
+
key: `move|${n.timestamp ?? ""}|${((k = n.event) == null ? void 0 : k.to_label) ?? ""}`,
|
|
63
64
|
timestamp: n.timestamp,
|
|
64
65
|
who: h ? "Automatic" : a(n),
|
|
65
66
|
userId: n.user_id ?? null,
|
|
66
|
-
trigger:
|
|
67
|
+
trigger: w ? { name: a(w), userId: w.user_id ?? null } : null,
|
|
68
|
+
linkedTo: w && D(w) ? `${w.id}|${w.timestamp ?? ""}` : null,
|
|
67
69
|
action: "moved",
|
|
68
|
-
values: { ...(
|
|
69
|
-
changed: /* @__PURE__ */ new Set([
|
|
70
|
+
values: { ...(d == null ? void 0 : d.values) ?? {}, [$]: ((I = n.event) == null ? void 0 : I.to_label) ?? null },
|
|
71
|
+
changed: /* @__PURE__ */ new Set([$]),
|
|
70
72
|
recalculated: /* @__PURE__ */ new Set(),
|
|
71
73
|
via: /* @__PURE__ */ new Map()
|
|
72
74
|
};
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
}), y = new Map(u.map((n) => [n.key, n])), S = [];
|
|
76
|
+
for (const [n, i] of b.entries()) {
|
|
77
|
+
const d = i.linkedTo ? y.get(i.linkedTo) : void 0;
|
|
78
|
+
if (!d) {
|
|
79
|
+
S.push(i);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
d.values = { ...d.values, [$]: i.values[$] ?? null }, d.changed = /* @__PURE__ */ new Set([...d.changed, $]), d.autoMove = {
|
|
83
|
+
from: ((v = l[n].event) == null ? void 0 : v.from_label) ?? null,
|
|
84
|
+
to: ((M = l[n].event) == null ? void 0 : M.to_label) ?? null
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return [...u, ...S].sort(
|
|
88
|
+
(n, i) => (i.timestamp ? new Date(i.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 c of Object.keys(s.values)) a.has(c) || a.set(c, 0);
|
|
95
|
+
for (const c of [...s.changed, ...s.recalculated]) a.set(c, (a.get(c) ?? 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 === $ ? { label: V, system: !1, order: -1 } : o(s);
|
|
98
|
+
return [...a].filter(([s]) => s !== "id" && !t(s).system).map(([s, c]) => ({ field: s, label: t(s).label, changes: c })).sort((s, c) => {
|
|
99
|
+
const l = t(s.field).order ?? Number.POSITIVE_INFINITY, r = t(c.field).order ?? Number.POSITIVE_INFINITY;
|
|
100
|
+
return l - r || s.label.localeCompare(c.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 L(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} ${L(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 u = [...
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
if (!t) return `${
|
|
120
|
-
const
|
|
121
|
-
return `${
|
|
126
|
+
function Q(e, o, a, t) {
|
|
127
|
+
const s = z, l = [["When", "Changed by", "Action", ...o.map((r) => r.label), "Recalculated"].map(s).join(",")];
|
|
128
|
+
for (const r of e) {
|
|
129
|
+
const u = [...r.recalculated].filter((m) => o.some((b) => b.field === m)).map((m) => {
|
|
130
|
+
var S;
|
|
131
|
+
const b = ((S = o.find((v) => v.field === m)) == null ? void 0 : S.label) ?? m;
|
|
132
|
+
if (!t) return `${b}: ${J(r.via.get(m))}`;
|
|
133
|
+
const y = t(m, r);
|
|
134
|
+
return `${b}: ${y.why}${y.because ? ` — ${y.because}` : ""}`;
|
|
122
135
|
}).join("; ");
|
|
123
|
-
|
|
136
|
+
l.push(
|
|
124
137
|
[
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...o.map((
|
|
138
|
+
r.timestamp ? new Date(r.timestamp).toLocaleString("en-US") : "",
|
|
139
|
+
r.who,
|
|
140
|
+
Y(r.action),
|
|
141
|
+
...o.map((m) => a(m.field, r.values[m.field])),
|
|
129
142
|
u
|
|
130
|
-
].map((
|
|
143
|
+
].map((m) => s(String(m ?? ""))).join(",")
|
|
131
144
|
);
|
|
132
145
|
}
|
|
133
|
-
return `${
|
|
146
|
+
return `${l.join(`\r
|
|
134
147
|
`)}\r
|
|
135
148
|
`;
|
|
136
149
|
}
|
|
137
|
-
const
|
|
150
|
+
const C = (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 = C(o), c = (Array.isArray(t == null ? void 0 : t.sources) ? t == null ? void 0 : t.sources : []).filter((l) => typeof l.related_collection == "string").map((l) => ({
|
|
164
|
+
collection: String(l.related_collection),
|
|
165
|
+
field: String(l.value_field ?? ""),
|
|
166
|
+
aggregate: String(l.aggregate ?? "sum"),
|
|
167
|
+
filtered: !!l.filter && Object.keys(l.filter).length > 0
|
|
155
168
|
}));
|
|
156
|
-
return
|
|
169
|
+
return c.length ? { kind: "rollup", sources: c } : null;
|
|
157
170
|
}
|
|
158
171
|
if (a === "lookup") {
|
|
159
|
-
const t =
|
|
172
|
+
const t = C(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
|
+
}, E = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
191
|
+
function ee(e, o, a, t, s = L) {
|
|
192
|
+
const c = o.via.get(e), l = c != null && c.length ? c.map((r) => `${r.name} changed ${r.row} (${s(r.delta)})`).join("; ") : void 0;
|
|
180
193
|
if ((a == null ? void 0 : a.kind) === "rollup")
|
|
181
194
|
return {
|
|
182
195
|
why: a.sources.map((u) => {
|
|
183
|
-
const
|
|
184
|
-
return `${
|
|
196
|
+
const m = H[u.aggregate] ?? "Total", b = u.aggregate === "count" ? t(u.collection) : `${t(u.collection)} · ${t(u.collection, u.field)}`;
|
|
197
|
+
return `${m} of ${b}${u.filtered ? " (filtered)" : ""}`;
|
|
185
198
|
}).join(" + "),
|
|
186
|
-
because:
|
|
199
|
+
because: l ?? "Its rows changed between these two saves"
|
|
187
200
|
};
|
|
188
201
|
if ((a == null ? void 0 : a.kind) === "formula") {
|
|
189
|
-
const
|
|
202
|
+
const r = a.inputs.filter((u) => o.changed.has(u) || o.recalculated.has(u));
|
|
190
203
|
return {
|
|
191
|
-
why: a.inputs.length ? `Worked out from ${
|
|
192
|
-
because:
|
|
204
|
+
why: a.inputs.length ? `Worked out from ${E(a.inputs.map((u) => t(null, u)))}` : "Worked out by a formula",
|
|
205
|
+
because: r.length ? `${E(r.map((u) => t(null, u)))} changed` : l ?? 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: l
|
|
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;
|
|
@@ -211,19 +224,19 @@ function K(e, o) {
|
|
|
211
224
|
return t;
|
|
212
225
|
}
|
|
213
226
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
$ as STEP_FIELD,
|
|
228
|
+
V as STEP_LABEL,
|
|
229
|
+
K as buildSaveRows,
|
|
230
|
+
z as csvCell,
|
|
231
|
+
X as deriveOf,
|
|
232
|
+
Z as matrixColumns,
|
|
233
|
+
Q as matrixCsv,
|
|
234
|
+
F as personName,
|
|
235
|
+
ee as recalcReason,
|
|
236
|
+
q as rowsChanging,
|
|
237
|
+
x as sameValue,
|
|
238
|
+
Y as saveActionLabel,
|
|
239
|
+
L as signedAmount,
|
|
240
|
+
te as valueAt,
|
|
241
|
+
J as viaText
|
|
229
242
|
};
|