@asteby/metacore-runtime-react 18.13.0 → 18.13.1
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/CHANGELOG.md +6 -0
- package/dist/activity-diff.d.ts.map +1 -1
- package/dist/activity-diff.js +32 -10
- package/package.json +1 -1
- package/src/activity-diff.tsx +31 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 18.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6b8f7b2: ActivityDiff: drop noise rows from history diffs — raw FK keys (`created_by_id`) are hidden when their resolved sibling (`created_by: {name,…}`) is present in the same snapshot (covers before/after and the changes {from,to} shape), and `deleted_at` joins the meta-key filter alongside id/created_at/updated_at/organization_id.
|
|
8
|
+
|
|
3
9
|
## 18.13.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-diff.d.ts","sourceRoot":"","sources":["../src/activity-diff.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,I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A;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI,CAAA;IAC/D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAC9B,oCAAoC;IACpC,KAAK,EAAE,aAAa,CAAA;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAuGD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmJpD,CAAA"}
|
package/dist/activity-diff.js
CHANGED
|
@@ -23,20 +23,42 @@ import { ActivityValueRenderer } from './activity-value-renderer';
|
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
24
24
|
// Helpers
|
|
25
25
|
// ---------------------------------------------------------------------------
|
|
26
|
+
// Meta-level keys that are always present and never meaningful in a
|
|
27
|
+
// human-readable diff.
|
|
28
|
+
const META_KEYS = new Set(['id', 'created_at', 'updated_at', 'organization_id', 'org_id', 'deleted_at']);
|
|
29
|
+
/** True when an object is a backend-resolved sibling ({value,label} relation, {name,…} user). */
|
|
30
|
+
function isResolvedObject(v) {
|
|
31
|
+
if (!v || typeof v !== 'object' || Array.isArray(v))
|
|
32
|
+
return false;
|
|
33
|
+
const o = v;
|
|
34
|
+
return typeof o.label === 'string' || typeof o.name === 'string';
|
|
35
|
+
}
|
|
26
36
|
/** Returns all field keys that appear in the diff. */
|
|
27
37
|
function diffKeys(event) {
|
|
28
|
-
if (event.changes && Object.keys(event.changes).length > 0) {
|
|
29
|
-
return Object.keys(event.changes);
|
|
30
|
-
}
|
|
31
38
|
const before = event.before ?? {};
|
|
32
39
|
const after = event.after ?? {};
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
const source = event.changes && Object.keys(event.changes).length > 0
|
|
41
|
+
? new Set(Object.keys(event.changes))
|
|
42
|
+
: new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
43
|
+
META_KEYS.forEach((k) => source.delete(k));
|
|
44
|
+
// A resolved FK appears twice: the raw UUID key (created_by_id) and the
|
|
45
|
+
// resolved sibling (created_by: {name/label,…}). Drop the raw key — the
|
|
46
|
+
// sibling row already shows the human value. The sibling's value may live
|
|
47
|
+
// in before/after or inside changes[sibling] ({from,to}/{before,after}).
|
|
48
|
+
const siblingResolved = (sibling) => {
|
|
49
|
+
if (isResolvedObject(before[sibling]) || isResolvedObject(after[sibling]))
|
|
50
|
+
return true;
|
|
51
|
+
const ch = event.changes?.[sibling];
|
|
52
|
+
if (!ch || typeof ch !== 'object')
|
|
53
|
+
return false;
|
|
54
|
+
return isResolvedObject(ch.from) || isResolvedObject(ch.to) || isResolvedObject(ch.before) || isResolvedObject(ch.after);
|
|
55
|
+
};
|
|
56
|
+
return Array.from(source).filter((k) => {
|
|
57
|
+
if (!k.endsWith('_id'))
|
|
58
|
+
return true;
|
|
59
|
+
const sibling = k.slice(0, -3);
|
|
60
|
+
return !(source.has(sibling) && siblingResolved(sibling));
|
|
61
|
+
});
|
|
40
62
|
}
|
|
41
63
|
/** Returns the set of keys where the value actually changed. */
|
|
42
64
|
function changedKeys(event) {
|
package/package.json
CHANGED
package/src/activity-diff.tsx
CHANGED
|
@@ -74,19 +74,41 @@ export interface ActivityDiffProps {
|
|
|
74
74
|
// Helpers
|
|
75
75
|
// ---------------------------------------------------------------------------
|
|
76
76
|
|
|
77
|
+
// Meta-level keys that are always present and never meaningful in a
|
|
78
|
+
// human-readable diff.
|
|
79
|
+
const META_KEYS = new Set(['id', 'created_at', 'updated_at', 'organization_id', 'org_id', 'deleted_at'])
|
|
80
|
+
|
|
81
|
+
/** True when an object is a backend-resolved sibling ({value,label} relation, {name,…} user). */
|
|
82
|
+
function isResolvedObject(v: unknown): boolean {
|
|
83
|
+
if (!v || typeof v !== 'object' || Array.isArray(v)) return false
|
|
84
|
+
const o = v as Record<string, unknown>
|
|
85
|
+
return typeof o.label === 'string' || typeof o.name === 'string'
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
/** Returns all field keys that appear in the diff. */
|
|
78
89
|
function diffKeys(event: ActivityEvent): string[] {
|
|
79
|
-
if (event.changes && Object.keys(event.changes).length > 0) {
|
|
80
|
-
return Object.keys(event.changes)
|
|
81
|
-
}
|
|
82
90
|
const before = event.before ?? {}
|
|
83
91
|
const after = event.after ?? {}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
const source =
|
|
93
|
+
event.changes && Object.keys(event.changes).length > 0
|
|
94
|
+
? new Set(Object.keys(event.changes))
|
|
95
|
+
: new Set([...Object.keys(before), ...Object.keys(after)])
|
|
96
|
+
META_KEYS.forEach((k) => source.delete(k))
|
|
97
|
+
// A resolved FK appears twice: the raw UUID key (created_by_id) and the
|
|
98
|
+
// resolved sibling (created_by: {name/label,…}). Drop the raw key — the
|
|
99
|
+
// sibling row already shows the human value. The sibling's value may live
|
|
100
|
+
// in before/after or inside changes[sibling] ({from,to}/{before,after}).
|
|
101
|
+
const siblingResolved = (sibling: string): boolean => {
|
|
102
|
+
if (isResolvedObject(before[sibling]) || isResolvedObject(after[sibling])) return true
|
|
103
|
+
const ch = (event.changes as Record<string, Record<string, unknown>> | undefined)?.[sibling]
|
|
104
|
+
if (!ch || typeof ch !== 'object') return false
|
|
105
|
+
return isResolvedObject(ch.from) || isResolvedObject(ch.to) || isResolvedObject(ch.before) || isResolvedObject(ch.after)
|
|
106
|
+
}
|
|
107
|
+
return Array.from(source).filter((k) => {
|
|
108
|
+
if (!k.endsWith('_id')) return true
|
|
109
|
+
const sibling = k.slice(0, -3)
|
|
110
|
+
return !(source.has(sibling) && siblingResolved(sibling))
|
|
111
|
+
})
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
/** Returns the set of keys where the value actually changed. */
|