strapi-cms-audit-log 1.1.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1026 -0
  4. package/dist/admin/App-BLt4lqEM.js +1284 -0
  5. package/dist/admin/App-ou5hy99f.mjs +1266 -0
  6. package/dist/admin/en-B0rPiE2W.mjs +87 -0
  7. package/dist/admin/en-BMlJxq3g.js +87 -0
  8. package/dist/admin/index-BYi8OPTw.js +80 -0
  9. package/dist/admin/index-DdmY-p3Q.mjs +81 -0
  10. package/dist/admin/index.js +4 -0
  11. package/dist/admin/index.mjs +4 -0
  12. package/dist/admin/src/components/AuditLogFilters.d.ts +18 -0
  13. package/dist/admin/src/components/AuditLogTable.d.ts +19 -0
  14. package/dist/admin/src/components/ChangeViewer.d.ts +14 -0
  15. package/dist/admin/src/components/JsonViewer.d.ts +20 -0
  16. package/dist/admin/src/components/PluginIcon.d.ts +3 -0
  17. package/dist/admin/src/components/WidgetDiff.d.ts +19 -0
  18. package/dist/admin/src/hooks/useAuditLogs.d.ts +36 -0
  19. package/dist/admin/src/index.d.ts +3 -0
  20. package/dist/admin/src/pages/App.d.ts +11 -0
  21. package/dist/admin/src/pages/AuditLogDetails.d.ts +10 -0
  22. package/dist/admin/src/pages/AuditLogs.d.ts +3 -0
  23. package/dist/admin/src/permissions.d.ts +26 -0
  24. package/dist/admin/src/pluginId.d.ts +2 -0
  25. package/dist/admin/src/types.d.ts +91 -0
  26. package/dist/admin/src/utils/format.d.ts +41 -0
  27. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  28. package/dist/admin/src/utils/widgets.d.ts +85 -0
  29. package/dist/server/index.js +1856 -0
  30. package/dist/server/index.mjs +1856 -0
  31. package/dist/server/src/bootstrap.d.ts +14 -0
  32. package/dist/server/src/config/index.d.ts +52 -0
  33. package/dist/server/src/constants.d.ts +140 -0
  34. package/dist/server/src/content-types/audit-log/index.d.ts +86 -0
  35. package/dist/server/src/content-types/audit-log/schema.d.ts +141 -0
  36. package/dist/server/src/content-types/index.d.ts +88 -0
  37. package/dist/server/src/controllers/audit-log.d.ts +31 -0
  38. package/dist/server/src/controllers/index.d.ts +42 -0
  39. package/dist/server/src/destroy.d.ts +19 -0
  40. package/dist/server/src/index.d.ts +328 -0
  41. package/dist/server/src/register.d.ts +31 -0
  42. package/dist/server/src/routes/admin.d.ts +26 -0
  43. package/dist/server/src/routes/index.d.ts +19 -0
  44. package/dist/server/src/services/access.d.ts +51 -0
  45. package/dist/server/src/services/audit.d.ts +25 -0
  46. package/dist/server/src/services/config.d.ts +30 -0
  47. package/dist/server/src/services/context.d.ts +33 -0
  48. package/dist/server/src/services/diff.d.ts +48 -0
  49. package/dist/server/src/services/immutability.d.ts +30 -0
  50. package/dist/server/src/services/index.d.ts +137 -0
  51. package/dist/server/src/services/retention.d.ts +22 -0
  52. package/dist/server/src/services/security.d.ts +54 -0
  53. package/dist/server/src/services/snapshot.d.ts +46 -0
  54. package/dist/server/src/services/tracker.d.ts +39 -0
  55. package/dist/server/src/types/index.d.ts +214 -0
  56. package/dist/server/src/utils/json.d.ts +17 -0
  57. package/dist/server/src/utils/paths.d.ts +34 -0
  58. package/dist/server/src/utils/sanitize.d.ts +16 -0
  59. package/package.json +112 -0
@@ -0,0 +1,41 @@
1
+ import { AuditAction } from '../types';
2
+ /** Badge colours per action, using design-system palette tokens. */
3
+ export declare const ACTION_COLORS: Record<string, {
4
+ background: string;
5
+ text: string;
6
+ }>;
7
+ export declare const actionColor: (action: string) => {
8
+ background: string;
9
+ text: string;
10
+ };
11
+ /** `api::page.page` -> `page`. Falls back to the raw uid for anything unexpected. */
12
+ export declare const shortContentTypeName: (uid: string) => string;
13
+ /**
14
+ * A short, unambiguous rendering of a value inside a diff cell.
15
+ *
16
+ * Long strings and structured values are truncated: the cell is a summary, and
17
+ * the full value is one click away in the JSON viewer. `null` and `undefined`
18
+ * are rendered as words rather than as an empty cell, because "this field was
19
+ * cleared" and "this field was not part of the change" look identical otherwise.
20
+ */
21
+ export declare const formatValue: (value: unknown, maxLength?: number) => string;
22
+ /** True when a value is worth offering the collapsible JSON viewer for. */
23
+ export declare const isStructured: (value: unknown) => boolean;
24
+ /** `2026-09-02T13:10:00.000Z` -> `02 Sep 2026, 13:10`, in the viewer's locale. */
25
+ export declare const formatDate: (value: string | null | undefined, locale?: string) => string;
26
+ /** Best label for the actor behind a record. */
27
+ export declare const formatUser: (log: {
28
+ userName: string | null;
29
+ userEmail: string | null;
30
+ userId: string | null;
31
+ source: string;
32
+ }) => string;
33
+ export declare const isAuditAction: (value: string) => value is AuditAction;
34
+ /**
35
+ * True for a record that is about security rather than content.
36
+ *
37
+ * Derived from the action name rather than from a list, so an action added on
38
+ * the server needs no matching edit here. Every content action is a bare verb;
39
+ * every security action is either namespaced with a dot or is `logout`.
40
+ */
41
+ export declare const isSecurityAction: (value: string) => boolean;
@@ -0,0 +1,2 @@
1
+ /** Namespaces a translation key, so plugin keys cannot collide with the admin's. */
2
+ export declare const getTranslation: (id: string) => string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Turns a pair of raw snapshots into a per-widget before/after view.
3
+ *
4
+ * ## The problem this solves
5
+ *
6
+ * The server's diff engine flattens everything into dotted paths, so editing one
7
+ * widget on a page produces entries like `widgets[3].heading` and
8
+ * `widgets[3].cta.label`. That is exactly right for a field-level question
9
+ * ("what text changed?") and exactly wrong for the question editors actually
10
+ * ask, which is "what did that widget look like before, and what does it look
11
+ * like now?". Answering it from a flat path list means reading an index out of a
12
+ * string and mentally reassembling a component.
13
+ *
14
+ * So the widgets are reassembled here instead: each changed slot yields the
15
+ * whole component as it was and the whole component as it now is, and the detail
16
+ * page renders the widget twice, once per side.
17
+ *
18
+ * ## Why this runs in the browser
19
+ *
20
+ * Everything it needs is already on the record — `before` and `after` are
21
+ * returned in full by `GET /audit-log/logs/:id`. Computing it server-side would
22
+ * mean either a new stored column (wrong for existing rows, which would show
23
+ * nothing) or a per-request pass over two JSON blobs to produce something only
24
+ * the detail page reads. Doing it here also means the feature works
25
+ * retroactively, on every record already in the table.
26
+ *
27
+ * ## Why it is not schema-aware
28
+ *
29
+ * Nothing here knows what a "widget" is in any particular project. A dynamic
30
+ * zone is recognised structurally — an array whose members are objects carrying
31
+ * `__component` — which is how Strapi itself marks them in a populated result.
32
+ * That covers `widgets` on a page, `blocks` on an article and any zone added
33
+ * later, on any content type, with no list to maintain.
34
+ */
35
+ /** One component instance inside a dynamic zone, as it appears in a snapshot. */
36
+ export interface WidgetInstance {
37
+ __component: string;
38
+ [field: string]: unknown;
39
+ }
40
+ export type WidgetStatus = 'changed' | 'added' | 'removed' | 'unchanged';
41
+ /** One slot of a dynamic zone, paired across the operation. */
42
+ export interface WidgetSlot {
43
+ /** Position in the zone. The slot is the unit of comparison — see {@link pairSlots}. */
44
+ index: number;
45
+ status: WidgetStatus;
46
+ /** Component uid, from whichever side exists. */
47
+ component: string;
48
+ /** The component uid on the other side, when the slot was replaced with a different widget. */
49
+ replacedComponent: string | null;
50
+ before: WidgetInstance | null;
51
+ after: WidgetInstance | null;
52
+ /** Dotted field paths that differ, relative to the widget — `heading`, `cta.label`. */
53
+ changedFields: string[];
54
+ }
55
+ /** A dynamic zone attribute, with its slots paired. */
56
+ export interface WidgetZone {
57
+ /** Attribute name on the content type — `widgets`, `blocks`. */
58
+ name: string;
59
+ slots: WidgetSlot[];
60
+ changedCount: number;
61
+ }
62
+ /**
63
+ * Every dynamic zone touched by an operation, with its slots paired.
64
+ *
65
+ * Returns an empty array when neither snapshot contains a zone, which is the
66
+ * signal for the detail page to omit the section entirely rather than render an
67
+ * empty heading. A zone identical on both sides is still returned — its slots
68
+ * are all `unchanged`, and the page shows them collapsed as context.
69
+ */
70
+ export declare const extractWidgetZones: (before: Record<string, unknown> | null | undefined, after: Record<string, unknown> | null | undefined) => WidgetZone[];
71
+ /** `home.hero` -> `Hero`. Falls back to the raw uid for anything unexpected. */
72
+ export declare const widgetLabel: (component: string) => string;
73
+ /**
74
+ * A widget flattened to the rows the card renders.
75
+ *
76
+ * Nested components are flattened into dotted paths so a card is a flat list of
77
+ * label/value pairs — the same shape whatever depth the field lives at, and the
78
+ * same shape the `changedFields` highlight is keyed by. Arrays and media objects
79
+ * stop the descent: below that point a card is the wrong tool and the raw JSON
80
+ * viewer is the right one.
81
+ */
82
+ export declare const widgetRows: (widget: WidgetInstance | null, prefix?: string) => Array<{
83
+ path: string;
84
+ value: unknown;
85
+ }>;