@moh-sso/audit 0.0.0-stage → 1.3.2

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 (129) hide show
  1. package/README.md +24 -2
  2. package/dist/_types/apps/audit/src/api/audit.api.d.ts +376 -0
  3. package/dist/_types/apps/audit/src/api/index.d.ts +2 -0
  4. package/dist/_types/apps/audit/src/api/metrics.api.d.ts +559 -0
  5. package/dist/_types/apps/audit/src/components/AuditLogDrawer.d.ts +5 -0
  6. package/dist/_types/apps/audit/src/components/AuditLogFilters.d.ts +28 -0
  7. package/dist/_types/apps/audit/src/components/AuditMetricsPanel.d.ts +7 -0
  8. package/dist/_types/apps/audit/src/components/audit-log-actions-menu.component.d.ts +7 -0
  9. package/dist/_types/apps/audit/src/components/audit-log-bulk-actions.component.d.ts +8 -0
  10. package/dist/_types/apps/audit/src/index.d.ts +5 -0
  11. package/dist/_types/apps/audit/src/pages/audit_component.d.ts +1 -0
  12. package/dist/_types/apps/audit/src/root.component.d.ts +2 -0
  13. package/dist/_types/apps/audit/src/routes.d.ts +2 -0
  14. package/dist/_types/apps/audit/src/single-spa.d.ts +1 -0
  15. package/dist/_types/apps/audit/src/types/audit-metrics.types.d.ts +27 -0
  16. package/dist/_types/apps/audit/src/types/audit.types.d.ts +46 -0
  17. package/dist/_types/apps/audit/src/types/index.d.ts +2 -0
  18. package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
  19. package/dist/_types/packages/api/src/index.d.ts +1 -0
  20. package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
  21. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
  22. package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
  23. package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
  24. package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
  25. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
  26. package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
  27. package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
  28. package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
  29. package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
  30. package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
  31. package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
  32. package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
  33. package/dist/_types/packages/auth/src/index.d.ts +14 -0
  34. package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
  35. package/dist/_types/packages/config/src/index.d.ts +6 -0
  36. package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
  37. package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
  38. package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
  39. package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
  40. package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
  41. package/dist/_types/packages/microfrontend/src/basename.d.ts +1 -0
  42. package/dist/_types/packages/microfrontend/src/index.d.ts +6 -0
  43. package/dist/_types/packages/microfrontend/src/lifecycle.d.ts +6 -0
  44. package/dist/_types/packages/microfrontend/src/navigation.d.ts +2 -0
  45. package/dist/_types/packages/microfrontend/src/props.d.ts +44 -0
  46. package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +11 -0
  47. package/dist/_types/packages/microfrontend/src/routes.d.ts +13 -0
  48. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
  49. package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
  50. package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
  51. package/dist/_types/packages/state/src/index.d.ts +29 -0
  52. package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
  53. package/dist/_types/packages/types/src/index.d.ts +6 -0
  54. package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
  55. package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
  56. package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
  57. package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
  58. package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
  59. package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
  60. package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
  61. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
  62. package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
  63. package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
  64. package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
  65. package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
  66. package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
  67. package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
  68. package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
  69. package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
  70. package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
  71. package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
  72. package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
  73. package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
  74. package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
  75. package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
  76. package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
  77. package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
  78. package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
  79. package/dist/_types/packages/ui/src/index.d.ts +16 -0
  80. package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
  81. package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
  82. package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
  83. package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
  84. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
  85. package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
  86. package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
  87. package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
  88. package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
  89. package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
  90. package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
  91. package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
  92. package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
  93. package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
  94. package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
  95. package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
  96. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
  97. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
  98. package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
  99. package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
  100. package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
  101. package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
  102. package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
  103. package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
  104. package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
  105. package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
  106. package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
  107. package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
  108. package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
  109. package/dist/api.d.ts +1 -0
  110. package/dist/api.js +36 -0
  111. package/dist/api.js.map +1 -0
  112. package/dist/assets/audit-DOMMDzdo.css +1 -0
  113. package/dist/assets/metrics.api-X0YE7K-_.js +79 -0
  114. package/dist/assets/metrics.api-X0YE7K-_.js.map +1 -0
  115. package/dist/assets/root.component-CR6z_BUQ.js +629 -0
  116. package/dist/assets/root.component-CR6z_BUQ.js.map +1 -0
  117. package/dist/index.d.ts +1 -0
  118. package/dist/index.js +41 -0
  119. package/dist/index.js.map +1 -0
  120. package/dist/routes.d.ts +1 -0
  121. package/dist/routes.js +32 -0
  122. package/dist/routes.js.map +1 -0
  123. package/dist/single-spa.d.ts +1 -0
  124. package/dist/single-spa.js +32 -0
  125. package/dist/single-spa.js.map +1 -0
  126. package/dist/types.d.ts +1 -0
  127. package/dist/types.js +25 -0
  128. package/dist/types.js.map +1 -0
  129. package/package.json +61 -4
@@ -0,0 +1,629 @@
1
+ import { jsxs as a, jsx as t, Fragment as de } from "react/jsx-runtime";
2
+ import { Button as F, Tag as G, CodeSnippet as Ne, Stack as ue, DatePicker as Ke, DatePickerInput as fe, ComboBox as W, Search as $, OverflowMenu as ke, OverflowMenuItem as J, InlineLoading as Ye, Tile as He, DataTable as Qe, Table as Ge, TableHead as We, TableRow as me, TableSelectAll as Xe, TableHeader as Ze, TableBody as et, TableSelectRow as tt, TableCell as pe } from "@carbon/react";
3
+ import { useState as d, useMemo as P, useEffect as he } from "react";
4
+ import { Close as it } from "@carbon/react/icons";
5
+ import { d as nt, g as rt, f as st, b as at } from "./metrics.api-X0YE7K-_.js";
6
+ import { useToast as ot, useHeaderPanel as lt, DataTableShell as ct, TableStatusTag as dt, RowActionsCell as ut, ErrorState as ft } from "@moh-sso/ui";
7
+ const mt = /(authorization|cookie|password|secret|token|verifier|credential|session|refresh|access_token|id_token)/i, pt = ["request_id", "requestId", "correlation_id", "correlationId", "trace_id", "traceId"], ht = ["path", "url", "request_path", "requestPath", "route"], gt = ["method", "request_method", "requestMethod"], _t = ["status", "status_code", "statusCode"], yt = ["latency_ms", "latencyMs", "duration_ms", "durationMs"], ge = ["before", "before_state", "previous", "old", "old_value", "oldValue"], _e = ["after", "after_state", "current", "new", "new_value", "newValue"];
8
+ function bt({ log: e, onClose: n }) {
9
+ if (!e) return null;
10
+ const i = Y(e.metadata), l = typeof e.success == "boolean" ? e.success : Ct(i.success), o = j(i, pt), c = j(i, ht), D = j(i, gt), _ = j(i, _t), A = j(i, yt), h = be(i, ge), v = be(i, _e), y = At(h, v), T = St(R(i), [
11
+ ...ge,
12
+ ..._e
13
+ ]);
14
+ return /* @__PURE__ */ a("div", { className: "audit-log-panel", children: [
15
+ /* @__PURE__ */ a("div", { className: "audit-log-panel__header", children: [
16
+ /* @__PURE__ */ a("div", { children: [
17
+ /* @__PURE__ */ t("p", { className: "audit-log-panel__eyebrow", children: "Audit event" }),
18
+ /* @__PURE__ */ t("h3", { children: e.action }),
19
+ /* @__PURE__ */ t("p", { children: vt(e.createdAt) })
20
+ ] }),
21
+ /* @__PURE__ */ t(
22
+ F,
23
+ {
24
+ kind: "ghost",
25
+ size: "sm",
26
+ hasIconOnly: !0,
27
+ renderIcon: it,
28
+ iconDescription: "Close",
29
+ onClick: n
30
+ }
31
+ )
32
+ ] }),
33
+ /* @__PURE__ */ a("div", { className: "audit-log-panel__tags", children: [
34
+ l !== null && /* @__PURE__ */ t(G, { type: l ? "green" : "red", children: l ? "success" : "failure" }),
35
+ e.clientId && /* @__PURE__ */ t(G, { type: "cyan", children: e.clientId }),
36
+ o && /* @__PURE__ */ a(G, { type: "purple", children: [
37
+ "request ",
38
+ o
39
+ ] })
40
+ ] }),
41
+ /* @__PURE__ */ a("section", { className: "audit-log-panel__section", children: [
42
+ /* @__PURE__ */ t("h4", { children: "Event Summary" }),
43
+ /* @__PURE__ */ a("div", { className: "audit-log-panel__grid", children: [
44
+ /* @__PURE__ */ t(m, { label: "ID", value: e.id }),
45
+ /* @__PURE__ */ t(m, { label: "Actor", value: e.username || "System" }),
46
+ /* @__PURE__ */ t(m, { label: "User ID", value: e.userId || "-" }),
47
+ /* @__PURE__ */ t(m, { label: "Client", value: e.clientId || O(i.client_id) || "-" }),
48
+ /* @__PURE__ */ t(m, { label: "IP Address", value: e.ip || O(i.ip) || "-" }),
49
+ /* @__PURE__ */ t(m, { label: "User Agent", value: O(i.user_agent) || "-" })
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ a("section", { className: "audit-log-panel__section", children: [
53
+ /* @__PURE__ */ t("h4", { children: "Request Context" }),
54
+ /* @__PURE__ */ a("div", { className: "audit-log-panel__grid", children: [
55
+ /* @__PURE__ */ t(m, { label: "Request ID", value: o || "-" }),
56
+ /* @__PURE__ */ t(m, { label: "Method", value: D || "-" }),
57
+ /* @__PURE__ */ t(m, { label: "Path", value: c || "-" }),
58
+ /* @__PURE__ */ t(m, { label: "Status", value: _ || "-" }),
59
+ /* @__PURE__ */ t(m, { label: "Latency", value: A ? `${A} ms` : "-" }),
60
+ /* @__PURE__ */ t(
61
+ m,
62
+ {
63
+ label: "Location",
64
+ value: `${O(i.country) || "-"} / ${O(i.city) || "-"}`
65
+ }
66
+ )
67
+ ] })
68
+ ] }),
69
+ (h !== void 0 || v !== void 0) && /* @__PURE__ */ a("section", { className: "audit-log-panel__section", children: [
70
+ /* @__PURE__ */ t("h4", { children: "Before / After" }),
71
+ y.length > 0 && /* @__PURE__ */ t("div", { className: "audit-log-panel__changes", children: y.map((p) => /* @__PURE__ */ a("div", { className: "audit-log-panel__change", children: [
72
+ /* @__PURE__ */ t("strong", { children: p.path }),
73
+ /* @__PURE__ */ t("span", { children: ve(p.before) }),
74
+ /* @__PURE__ */ t("span", { children: ve(p.after) })
75
+ ] }, p.path)) }),
76
+ /* @__PURE__ */ a("div", { className: "audit-log-panel__diff", children: [
77
+ /* @__PURE__ */ t(ye, { title: "Before", value: h }),
78
+ /* @__PURE__ */ t(ye, { title: "After", value: v })
79
+ ] })
80
+ ] }),
81
+ /* @__PURE__ */ a("section", { className: "audit-log-panel__section", children: [
82
+ /* @__PURE__ */ t("h4", { children: "Safe Metadata" }),
83
+ /* @__PURE__ */ t(Ne, { type: "multi", children: JSON.stringify(T, null, 2) })
84
+ ] })
85
+ ] });
86
+ }
87
+ function m({ label: e, value: n }) {
88
+ return /* @__PURE__ */ a("div", { className: "audit-log-panel__field", children: [
89
+ /* @__PURE__ */ t("span", { children: e }),
90
+ /* @__PURE__ */ t("strong", { children: n })
91
+ ] });
92
+ }
93
+ function ye({ title: e, value: n }) {
94
+ return /* @__PURE__ */ a("div", { className: "audit-log-panel__diff-block", children: [
95
+ /* @__PURE__ */ t("span", { children: e }),
96
+ /* @__PURE__ */ t(Ne, { type: "multi", children: JSON.stringify(R(n), null, 2) })
97
+ ] });
98
+ }
99
+ function Y(e) {
100
+ return !e || typeof e != "object" || Array.isArray(e) ? {} : e;
101
+ }
102
+ function vt(e) {
103
+ const n = new Date(e);
104
+ return Number.isNaN(n.getTime()) ? "-" : n.toLocaleString();
105
+ }
106
+ function O(e) {
107
+ return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
108
+ }
109
+ function Ct(e) {
110
+ return typeof e == "boolean" ? e : e === "true" ? !0 : e === "false" ? !1 : null;
111
+ }
112
+ function j(e, n) {
113
+ for (const i of n) {
114
+ const l = O(e[i]);
115
+ if (l) return l;
116
+ }
117
+ return "";
118
+ }
119
+ function be(e, n) {
120
+ for (const i of n)
121
+ if (e[i] !== void 0 && e[i] !== null)
122
+ return e[i];
123
+ }
124
+ function St(e, n) {
125
+ const i = Y(e), l = new Set(n);
126
+ return Object.fromEntries(Object.entries(i).filter(([o]) => !l.has(o)));
127
+ }
128
+ function R(e) {
129
+ return Array.isArray(e) ? e.map(R) : !e || typeof e != "object" ? e : Object.fromEntries(
130
+ Object.entries(e).map(([n, i]) => [
131
+ n,
132
+ mt.test(n) ? "[redacted]" : R(i)
133
+ ])
134
+ );
135
+ }
136
+ function At(e, n) {
137
+ const i = Y(e), l = Y(n);
138
+ return Array.from(/* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(l)])).sort().filter((c) => JSON.stringify(i[c]) !== JSON.stringify(l[c])).slice(0, 12).map((c) => ({
139
+ path: c,
140
+ before: R(i[c]),
141
+ after: R(l[c])
142
+ }));
143
+ }
144
+ function ve(e) {
145
+ return e === void 0 ? "—" : e === null ? "null" : typeof e == "string" ? e || "—" : typeof e == "number" || typeof e == "boolean" ? String(e) : JSON.stringify(e);
146
+ }
147
+ const Ce = [
148
+ { id: "true", label: "Success" },
149
+ { id: "false", label: "Failure" }
150
+ ];
151
+ function Se(e) {
152
+ return e.toISOString();
153
+ }
154
+ function Tt({
155
+ action: e,
156
+ actor: n,
157
+ module: i,
158
+ clientId: l,
159
+ userId: o,
160
+ ip: c,
161
+ success: D,
162
+ actionOptions: _,
163
+ moduleOptions: A,
164
+ onFromChange: h,
165
+ onToChange: v,
166
+ onActionChange: y,
167
+ onActorChange: T,
168
+ onModuleChange: p,
169
+ onClientChange: U,
170
+ onUserChange: x,
171
+ onIpChange: q,
172
+ onSuccessChange: N,
173
+ onClear: V,
174
+ onExportLoadedCsv: k,
175
+ onExportLoadedJson: B,
176
+ onExportFilteredCsv: I,
177
+ onExportFilteredJson: z
178
+ }) {
179
+ const b = _.map(Ae), M = A.map(Ae);
180
+ return /* @__PURE__ */ a(
181
+ ue,
182
+ {
183
+ orientation: "horizontal",
184
+ gap: 5,
185
+ className: "audit-log-filters",
186
+ children: [
187
+ /* @__PURE__ */ a(
188
+ Ke,
189
+ {
190
+ datePickerType: "range",
191
+ onChange: (r) => {
192
+ Array.isArray(r) && (r[0] instanceof Date && h(Se(r[0])), r[1] instanceof Date && v(Se(r[1])));
193
+ },
194
+ children: [
195
+ /* @__PURE__ */ t(fe, { id: "audit-from", labelText: "From date", placeholder: "From" }),
196
+ /* @__PURE__ */ t(fe, { id: "audit-to", labelText: "To date", placeholder: "To" })
197
+ ]
198
+ }
199
+ ),
200
+ /* @__PURE__ */ t(
201
+ W,
202
+ {
203
+ id: "audit-action",
204
+ titleText: "Action",
205
+ placeholder: "Action",
206
+ className: "audit-log-filters__field--lg",
207
+ items: b,
208
+ itemToString: (r) => r?.label ?? "",
209
+ selectedItem: b.find((r) => r.id === e) ?? null,
210
+ onInputChange: (r) => y(r || void 0),
211
+ onChange: ({ selectedItem: r }) => {
212
+ y(r?.id);
213
+ }
214
+ }
215
+ ),
216
+ /* @__PURE__ */ t(
217
+ W,
218
+ {
219
+ id: "audit-module",
220
+ titleText: "Module",
221
+ placeholder: "Module",
222
+ className: "audit-log-filters__field--md",
223
+ items: M,
224
+ itemToString: (r) => r?.label ?? "",
225
+ selectedItem: M.find((r) => r.id === i) ?? null,
226
+ onInputChange: (r) => p(r || void 0),
227
+ onChange: ({ selectedItem: r }) => {
228
+ p(r?.id);
229
+ }
230
+ }
231
+ ),
232
+ /* @__PURE__ */ t(
233
+ $,
234
+ {
235
+ id: "audit-actor",
236
+ labelText: "Actor",
237
+ placeholder: "Actor",
238
+ value: n ?? "",
239
+ className: "audit-log-filters__field--md",
240
+ onChange: (r) => {
241
+ T(r.target.value || void 0);
242
+ }
243
+ }
244
+ ),
245
+ /* @__PURE__ */ t(
246
+ $,
247
+ {
248
+ id: "audit-client",
249
+ labelText: "System",
250
+ placeholder: "System/client",
251
+ value: l ?? "",
252
+ className: "audit-log-filters__field--lg",
253
+ onChange: (r) => {
254
+ U(r.target.value || void 0);
255
+ }
256
+ }
257
+ ),
258
+ /* @__PURE__ */ t(
259
+ $,
260
+ {
261
+ id: "audit-user",
262
+ labelText: "User ID",
263
+ placeholder: "User ID",
264
+ value: o ?? "",
265
+ className: "audit-log-filters__field--lg",
266
+ onChange: (r) => {
267
+ x(r.target.value || void 0);
268
+ }
269
+ }
270
+ ),
271
+ /* @__PURE__ */ t(
272
+ $,
273
+ {
274
+ id: "audit-ip",
275
+ labelText: "IP address",
276
+ placeholder: "IP address",
277
+ value: c ?? "",
278
+ className: "audit-log-filters__field--sm",
279
+ onChange: (r) => {
280
+ q(r.target.value || void 0);
281
+ }
282
+ }
283
+ ),
284
+ /* @__PURE__ */ t(
285
+ W,
286
+ {
287
+ id: "audit-result",
288
+ titleText: "Outcome",
289
+ placeholder: "Outcome",
290
+ className: "audit-log-filters__field--sm",
291
+ items: Ce,
292
+ itemToString: (r) => r?.label ?? "",
293
+ selectedItem: Ce.find((r) => r.id === D) ?? null,
294
+ onChange: ({ selectedItem: r }) => {
295
+ N(r?.id);
296
+ }
297
+ }
298
+ ),
299
+ /* @__PURE__ */ a(ue, { orientation: "horizontal", gap: 3, children: [
300
+ /* @__PURE__ */ t(F, { kind: "secondary", size: "md", onClick: V, children: "Clear filters" }),
301
+ /* @__PURE__ */ a(ke, { ariaLabel: "Export audit logs", flipped: !0, children: [
302
+ /* @__PURE__ */ t(J, { itemText: "Export filtered CSV", onClick: I }),
303
+ /* @__PURE__ */ t(J, { itemText: "Export filtered JSON", onClick: z }),
304
+ /* @__PURE__ */ t(J, { itemText: "Export loaded CSV", onClick: k }),
305
+ /* @__PURE__ */ t(J, { itemText: "Export loaded JSON", onClick: B })
306
+ ] })
307
+ ] })
308
+ ]
309
+ }
310
+ );
311
+ }
312
+ function Ae(e) {
313
+ return {
314
+ id: e,
315
+ label: e
316
+ };
317
+ }
318
+ const xt = ({ from: e, to: n }) => {
319
+ const { data: i, isLoading: l, isError: o } = nt(
320
+ { from: e, to: n },
321
+ {
322
+ skip: !e || !n
323
+ }
324
+ );
325
+ return l && !i ? /* @__PURE__ */ t(Ye, { description: "Loading metrics..." }) : o && !i ? /* @__PURE__ */ t("div", { className: "audit-metrics__error", children: "Failed to load audit metrics." }) : /* @__PURE__ */ a("div", { className: "audit-metrics", children: [
326
+ /* @__PURE__ */ t(K, { label: "Total Events", value: i?.total_events }),
327
+ /* @__PURE__ */ t(K, { label: "Total Failures", value: i?.total_failures }),
328
+ /* @__PURE__ */ t(K, { label: "Failed Logins", value: i?.failed_logins }),
329
+ /* @__PURE__ */ t(K, { label: "Successful Logins", value: i?.successful_logins })
330
+ ] });
331
+ };
332
+ function K({ label: e, value: n }) {
333
+ return /* @__PURE__ */ a(He, { children: [
334
+ /* @__PURE__ */ t("div", { className: "audit-metrics__label", children: e }),
335
+ /* @__PURE__ */ t("div", { className: "audit-metrics__value", children: n ?? "—" })
336
+ ] });
337
+ }
338
+ function Nt({ logs: e, onExportCsv: n, onExportJson: i }) {
339
+ return e.length === 0 ? null : /* @__PURE__ */ a("div", { className: "audit-log-bulk-actions", children: [
340
+ /* @__PURE__ */ a("strong", { children: [
341
+ e.length,
342
+ " selected"
343
+ ] }),
344
+ /* @__PURE__ */ a("div", { className: "audit-log-bulk-actions__buttons", children: [
345
+ /* @__PURE__ */ t(F, { size: "sm", kind: "secondary", onClick: n, children: "Export CSV" }),
346
+ /* @__PURE__ */ t(F, { size: "sm", kind: "ghost", onClick: i, children: "Export JSON" })
347
+ ] })
348
+ ] });
349
+ }
350
+ function kt({ onView: e }) {
351
+ return /* @__PURE__ */ t(ke, { size: "sm", flipped: !0, children: /* @__PURE__ */ t(J, { itemText: "View details", onClick: e }) });
352
+ }
353
+ const It = [
354
+ { key: "shortId", header: "ID" },
355
+ { key: "time", header: "Time" },
356
+ { key: "actor", header: "Actor" },
357
+ { key: "action", header: "Action" },
358
+ { key: "client", header: "Client" },
359
+ { key: "ip", header: "IP Address" },
360
+ { key: "result", header: "Result" },
361
+ { key: "actions", header: "" },
362
+ { key: "raw", header: "" }
363
+ // hidden
364
+ ];
365
+ function Te(e) {
366
+ return e.toISOString();
367
+ }
368
+ function Ie(e) {
369
+ if (!e.createdAt) return "—";
370
+ const n = new Date(e.createdAt);
371
+ return Number.isNaN(n.getTime()) ? "—" : n.toLocaleString();
372
+ }
373
+ function Et(e) {
374
+ const n = e.success ?? e.metadata?.success;
375
+ return typeof n == "boolean" ? n : null;
376
+ }
377
+ function Ee(e) {
378
+ const n = Et(e);
379
+ return n === !0 ? "success" : n === !1 ? "failure" : "—";
380
+ }
381
+ function we(e) {
382
+ return e.clientId || (typeof e.metadata?.client_id == "string" ? e.metadata.client_id : "—");
383
+ }
384
+ function xe(e) {
385
+ const n = e.metadata?.module;
386
+ if (typeof n == "string" && n.trim())
387
+ return n.trim();
388
+ const [i] = e.action.split(/[.:_]/);
389
+ return i || "platform";
390
+ }
391
+ function Le(e) {
392
+ return e.ip || (typeof e.metadata?.ip == "string" ? e.metadata.ip : "—");
393
+ }
394
+ function Oe(e, n, i) {
395
+ const l = new Blob([n], { type: i }), o = URL.createObjectURL(l), c = document.createElement("a");
396
+ c.href = o, c.download = e, c.click(), URL.revokeObjectURL(o);
397
+ }
398
+ function wt(e) {
399
+ return `"${String(e ?? "").replaceAll('"', '""')}"`;
400
+ }
401
+ function Lt(e) {
402
+ const n = ["id", "created_at", "actor", "user_id", "action", "client_id", "ip", "success"], i = e.map((o) => [
403
+ o.id,
404
+ Ie(o),
405
+ o.username ?? "System",
406
+ o.userId ?? "",
407
+ o.action,
408
+ we(o),
409
+ Le(o),
410
+ Ee(o)
411
+ ]), l = [n, ...i].map((o) => o.map(wt).join(",")).join(`
412
+ `);
413
+ Oe("audit-logs.csv", l, "text/csv;charset=utf-8");
414
+ }
415
+ function Ot(e) {
416
+ Oe("audit-logs.json", JSON.stringify(e, null, 2), "application/json;charset=utf-8");
417
+ }
418
+ function Ft(e, n) {
419
+ if (!e || typeof e != "object")
420
+ return n;
421
+ const i = e;
422
+ return typeof i.data?.message == "string" ? i.data.message : typeof i.data?.error?.message == "string" ? i.data.error.message : typeof i.error == "string" ? i.error : n;
423
+ }
424
+ function Rt() {
425
+ const e = /* @__PURE__ */ new Date(), n = new Date(e.getTime() - 10080 * 60 * 1e3), i = ot(), { openPanel: l, closePanel: o } = lt(), [c, D] = d(Te(n)), [_, A] = d(Te(e)), [h, v] = d(), [y, T] = d(), [p, U] = d(), [x, q] = d(), [N, V] = d(), [k, B] = d(), [I, z] = d(), [b, M] = d(null), [r, X] = d(null), [Fe, Z] = d(!0), [C, ee] = d([]), te = P(() => {
426
+ const s = {
427
+ from: c,
428
+ to: _,
429
+ action: h,
430
+ client_id: x,
431
+ user_id: k,
432
+ ip: I,
433
+ success: N,
434
+ limit: 50
435
+ };
436
+ return b && (s.cursor_id = b.cursor_id, s.cursor_created_at = b.cursor_created_at), s;
437
+ }, [c, _, h, x, k, I, N, b]), { data: E, isLoading: Re, isFetching: ie, isError: De, error: Me, refetch: Pe } = rt(
438
+ te,
439
+ {
440
+ skip: !c || !_
441
+ }
442
+ ), { data: ne } = st();
443
+ he(() => {
444
+ E && (ee((s) => {
445
+ if (!b) return E.items;
446
+ const g = new Set(s.map((w) => w.id)), S = E.items.filter((w) => !g.has(w.id));
447
+ return [...s, ...S];
448
+ }), Z(E.has_more), X(E.next_cursor ?? null));
449
+ }, [E, b]), he(() => {
450
+ M(null), X(null), Z(!0), ee([]);
451
+ }, [c, _, h, x, k, I, N]);
452
+ const je = P(
453
+ () => Array.from(/* @__PURE__ */ new Set([...ne?.actions ?? [], ...C.map((s) => s.action)])).sort(),
454
+ [ne?.actions, C]
455
+ ), Je = P(
456
+ () => Array.from(new Set(C.map(xe))).filter(Boolean).sort(),
457
+ [C]
458
+ ), re = P(() => {
459
+ const s = y?.trim().toLowerCase(), g = p?.trim().toLowerCase();
460
+ return C.filter((S) => !(s && !`${S.username ?? ""} ${S.userId ?? ""}`.toLowerCase().includes(s) || g && !xe(S).toLowerCase().includes(g)));
461
+ }, [y, C, p]), Ue = P(
462
+ () => re.map((s) => ({
463
+ id: s.id,
464
+ shortId: s.id.slice(0, 8),
465
+ time: Ie(s),
466
+ actor: s.username ?? "System",
467
+ action: s.action,
468
+ client: we(s),
469
+ ip: Le(s),
470
+ result: Ee(s),
471
+ actions: "",
472
+ raw: s
473
+ })),
474
+ [re]
475
+ );
476
+ function se() {
477
+ v(void 0), T(void 0), U(void 0), q(void 0), B(void 0), z(void 0), V(void 0);
478
+ }
479
+ function qe(s) {
480
+ l({
481
+ title: "Audit Log",
482
+ content: /* @__PURE__ */ t(bt, { log: s, onClose: o }),
483
+ size: "md"
484
+ });
485
+ }
486
+ function ae(s) {
487
+ Lt(s), i.success({
488
+ title: "Audit logs exported",
489
+ subtitle: `${s.length} audit log(s) exported as CSV.`
490
+ });
491
+ }
492
+ function oe(s) {
493
+ Ot(s), i.success({
494
+ title: "Audit logs exported",
495
+ subtitle: `${s.length} audit log(s) exported as JSON.`
496
+ });
497
+ }
498
+ function le(s) {
499
+ const g = document.createElement("a");
500
+ g.href = at(te, s), g.download = s === "csv" ? "audit-logs.csv" : "audit-logs.json", g.click(), i.success({
501
+ title: "Audit export started",
502
+ subtitle: `Filtered audit logs are being exported as ${s.toUpperCase()}.`
503
+ });
504
+ }
505
+ return /* @__PURE__ */ t(
506
+ ct,
507
+ {
508
+ title: "Audit Logs",
509
+ description: "Security and administrative activity across the platform. RBAC governance events remain in the RBAC audit tab.",
510
+ rows: Ue,
511
+ headers: It,
512
+ getRowId: (s) => s.id,
513
+ isLoading: Re,
514
+ loadingDescription: "Loading audit logs…",
515
+ emptyTitle: "No audit logs found",
516
+ emptyDescription: "No audit events match the selected filters.",
517
+ emptyActions: /* @__PURE__ */ t(F, { kind: "tertiary", onClick: se, children: "Clear filters" }),
518
+ tableState: De ? /* @__PURE__ */ t(
519
+ ft,
520
+ {
521
+ title: "Failed to load audit logs",
522
+ description: Ft(Me, "Failed to load audit logs"),
523
+ primaryAction: {
524
+ label: "Retry",
525
+ onClick: Pe
526
+ }
527
+ }
528
+ ) : void 0,
529
+ topContent: /* @__PURE__ */ t(xt, { from: c, to: _ }),
530
+ filters: /* @__PURE__ */ t(
531
+ Tt,
532
+ {
533
+ action: h,
534
+ actor: y,
535
+ module: p,
536
+ clientId: x,
537
+ userId: k,
538
+ ip: I,
539
+ success: N,
540
+ actionOptions: je,
541
+ moduleOptions: Je,
542
+ onFromChange: D,
543
+ onToChange: A,
544
+ onActionChange: v,
545
+ onActorChange: T,
546
+ onModuleChange: U,
547
+ onClientChange: q,
548
+ onUserChange: B,
549
+ onIpChange: z,
550
+ onSuccessChange: V,
551
+ onClear: se,
552
+ onExportLoadedCsv: () => ae(C),
553
+ onExportLoadedJson: () => oe(C),
554
+ onExportFilteredCsv: () => le("csv"),
555
+ onExportFilteredJson: () => le("json")
556
+ }
557
+ ),
558
+ children: ({ rows: s, headers: g }) => /* @__PURE__ */ a(de, { children: [
559
+ /* @__PURE__ */ t(Qe, { rows: s, headers: g, children: ({
560
+ rows: S,
561
+ headers: w,
562
+ getHeaderProps: Ve,
563
+ getRowProps: Be,
564
+ getSelectionProps: ce,
565
+ selectedRows: ze
566
+ }) => {
567
+ const H = ze.map(
568
+ (u) => u.cells.find((L) => L.info.header === "raw")?.value
569
+ );
570
+ return /* @__PURE__ */ a(de, { children: [
571
+ /* @__PURE__ */ t(
572
+ Nt,
573
+ {
574
+ logs: H,
575
+ onExportCsv: () => ae(H),
576
+ onExportJson: () => oe(H)
577
+ }
578
+ ),
579
+ /* @__PURE__ */ a(Ge, { size: "lg", children: [
580
+ /* @__PURE__ */ t(We, { children: /* @__PURE__ */ a(me, { children: [
581
+ /* @__PURE__ */ t(Xe, { ...ce() }),
582
+ w.filter((u) => u.key !== "raw").map((u) => {
583
+ const { key: L, ...Q } = Ve({ header: u });
584
+ return /* @__PURE__ */ t(Ze, { ...Q, children: u.header }, L);
585
+ })
586
+ ] }) }),
587
+ /* @__PURE__ */ t(et, { children: S.map((u) => {
588
+ const L = u.cells.find((f) => f.info.header === "raw")?.value, { key: Q, ...$e } = Be({ row: u });
589
+ return /* @__PURE__ */ a(me, { ...$e, children: [
590
+ /* @__PURE__ */ t(tt, { ...ce({ row: u }) }),
591
+ u.cells.map((f) => f.info.header === "raw" ? null : f.info.header === "result" ? /* @__PURE__ */ t(pe, { children: /* @__PURE__ */ t(
592
+ dt,
593
+ {
594
+ status: String(f.value),
595
+ kind: f.value === "success" ? "green" : f.value === "failure" ? "red" : "gray"
596
+ }
597
+ ) }, f.id) : f.info.header === "actions" ? /* @__PURE__ */ t(ut, { children: u.isSelected && /* @__PURE__ */ t(
598
+ kt,
599
+ {
600
+ log: L,
601
+ onView: () => qe(L)
602
+ }
603
+ ) }, f.id) : /* @__PURE__ */ t(pe, { children: f.value || "—" }, f.id))
604
+ ] }, Q);
605
+ }) })
606
+ ] })
607
+ ] });
608
+ } }),
609
+ Fe && /* @__PURE__ */ t("div", { className: "audit-page__load-more", children: /* @__PURE__ */ t(
610
+ F,
611
+ {
612
+ kind: "secondary",
613
+ disabled: ie || !r?.cursor_id || !r?.cursor_created_at,
614
+ onClick: () => M(r),
615
+ children: ie ? "Loading…" : "Load more"
616
+ }
617
+ ) })
618
+ ] })
619
+ }
620
+ );
621
+ }
622
+ function qt(e) {
623
+ return /* @__PURE__ */ t("div", { className: "moh-microfrontend-root", children: /* @__PURE__ */ t(Rt, {}) });
624
+ }
625
+ export {
626
+ Rt as A,
627
+ qt as a
628
+ };
629
+ //# sourceMappingURL=root.component-CR6z_BUQ.js.map