@nubitio/crud 0.5.3 → 0.5.5
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/index.cjs +21 -3
- package/dist/index.mjs +21 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5323,8 +5323,12 @@ function createAuditFieldLabelResolver(config, fields) {
|
|
|
5323
5323
|
return fieldLabelByName.get(field) ?? field;
|
|
5324
5324
|
};
|
|
5325
5325
|
}
|
|
5326
|
+
function normalizeAuditScalar(value) {
|
|
5327
|
+
if (value == null || value === "") return null;
|
|
5328
|
+
return value;
|
|
5329
|
+
}
|
|
5326
5330
|
function auditValuesEqual(before, after) {
|
|
5327
|
-
return JSON.stringify(before) === JSON.stringify(after);
|
|
5331
|
+
return JSON.stringify(normalizeAuditScalar(before)) === JSON.stringify(normalizeAuditScalar(after));
|
|
5328
5332
|
}
|
|
5329
5333
|
function mergeAuditEntryGroup(entries) {
|
|
5330
5334
|
const chronological = [...entries].sort((left, right) => {
|
|
@@ -5380,7 +5384,21 @@ function consolidateAuditEntries(entries) {
|
|
|
5380
5384
|
group.push(entry);
|
|
5381
5385
|
}
|
|
5382
5386
|
flushGroup();
|
|
5383
|
-
return consolidated;
|
|
5387
|
+
return filterMeaningfulAuditEntries(consolidated);
|
|
5388
|
+
}
|
|
5389
|
+
function filterMeaningfulAuditEntries(entries) {
|
|
5390
|
+
return entries.flatMap((entry) => {
|
|
5391
|
+
const changes = Object.fromEntries(Object.entries(entry.changes).filter(([, change]) => !auditValuesEqual(change.before, change.after)));
|
|
5392
|
+
if (Object.keys(changes).length === 0) return [];
|
|
5393
|
+
return [{
|
|
5394
|
+
...entry,
|
|
5395
|
+
changes
|
|
5396
|
+
}];
|
|
5397
|
+
});
|
|
5398
|
+
}
|
|
5399
|
+
/** Consolidates burst rows and removes fields whose net diff is empty. */
|
|
5400
|
+
function prepareAuditEntries(entries) {
|
|
5401
|
+
return filterMeaningfulAuditEntries(consolidateAuditEntries(entries));
|
|
5384
5402
|
}
|
|
5385
5403
|
//#endregion
|
|
5386
5404
|
//#region packages/crud/crud/AuditTrailPanel.tsx
|
|
@@ -5507,7 +5525,7 @@ function AuditTrailPanel({ url, renderEntry, visible, onClose, recordSubtitle, r
|
|
|
5507
5525
|
httpClient.get(url).then((response) => {
|
|
5508
5526
|
setFetchState({
|
|
5509
5527
|
status: "success",
|
|
5510
|
-
entries:
|
|
5528
|
+
entries: prepareAuditEntries(response.data)
|
|
5511
5529
|
});
|
|
5512
5530
|
}).catch(() => {
|
|
5513
5531
|
setFetchState({ status: "error" });
|
package/dist/index.mjs
CHANGED
|
@@ -5299,8 +5299,12 @@ function createAuditFieldLabelResolver(config, fields) {
|
|
|
5299
5299
|
return fieldLabelByName.get(field) ?? field;
|
|
5300
5300
|
};
|
|
5301
5301
|
}
|
|
5302
|
+
function normalizeAuditScalar(value) {
|
|
5303
|
+
if (value == null || value === "") return null;
|
|
5304
|
+
return value;
|
|
5305
|
+
}
|
|
5302
5306
|
function auditValuesEqual(before, after) {
|
|
5303
|
-
return JSON.stringify(before) === JSON.stringify(after);
|
|
5307
|
+
return JSON.stringify(normalizeAuditScalar(before)) === JSON.stringify(normalizeAuditScalar(after));
|
|
5304
5308
|
}
|
|
5305
5309
|
function mergeAuditEntryGroup(entries) {
|
|
5306
5310
|
const chronological = [...entries].sort((left, right) => {
|
|
@@ -5356,7 +5360,21 @@ function consolidateAuditEntries(entries) {
|
|
|
5356
5360
|
group.push(entry);
|
|
5357
5361
|
}
|
|
5358
5362
|
flushGroup();
|
|
5359
|
-
return consolidated;
|
|
5363
|
+
return filterMeaningfulAuditEntries(consolidated);
|
|
5364
|
+
}
|
|
5365
|
+
function filterMeaningfulAuditEntries(entries) {
|
|
5366
|
+
return entries.flatMap((entry) => {
|
|
5367
|
+
const changes = Object.fromEntries(Object.entries(entry.changes).filter(([, change]) => !auditValuesEqual(change.before, change.after)));
|
|
5368
|
+
if (Object.keys(changes).length === 0) return [];
|
|
5369
|
+
return [{
|
|
5370
|
+
...entry,
|
|
5371
|
+
changes
|
|
5372
|
+
}];
|
|
5373
|
+
});
|
|
5374
|
+
}
|
|
5375
|
+
/** Consolidates burst rows and removes fields whose net diff is empty. */
|
|
5376
|
+
function prepareAuditEntries(entries) {
|
|
5377
|
+
return filterMeaningfulAuditEntries(consolidateAuditEntries(entries));
|
|
5360
5378
|
}
|
|
5361
5379
|
//#endregion
|
|
5362
5380
|
//#region packages/crud/crud/AuditTrailPanel.tsx
|
|
@@ -5483,7 +5501,7 @@ function AuditTrailPanel({ url, renderEntry, visible, onClose, recordSubtitle, r
|
|
|
5483
5501
|
httpClient.get(url).then((response) => {
|
|
5484
5502
|
setFetchState({
|
|
5485
5503
|
status: "success",
|
|
5486
|
-
entries:
|
|
5504
|
+
entries: prepareAuditEntries(response.data)
|
|
5487
5505
|
});
|
|
5488
5506
|
}).catch(() => {
|
|
5489
5507
|
setFetchState({ status: "error" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/crud",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Declarative CRUD engine with field DSL, forms, datagrids, RBAC, conditional logic and pluggable adapters (Hydra/REST).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"react-dom": "^19.0.0",
|
|
57
57
|
"react-i18next": "^14.0.0",
|
|
58
58
|
"react-router-dom": "^6.0.0",
|
|
59
|
-
"@nubitio/core": "^0.5.
|
|
60
|
-
"@nubitio/ui": "^0.5.
|
|
59
|
+
"@nubitio/core": "^0.5.5",
|
|
60
|
+
"@nubitio/ui": "^0.5.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"react-dropzone": "^15.0.0"
|