@lumerahq/ui 0.13.0 → 0.14.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 (36) hide show
  1. package/README.md +27 -29
  2. package/dist/{RecordSheet-BGs3rudM.js → RecordSheet-aoDqWNaZ.js} +7397 -10728
  3. package/dist/audit-log-B2-PFKpH.js +128 -0
  4. package/dist/components/index.d.ts +0 -1
  5. package/dist/components/index.d.ts.map +1 -1
  6. package/dist/components/index.js +5 -6
  7. package/dist/{highlighted-body-OFNGDK62-V6FEuBTg.js → highlighted-body-OFNGDK62-B9aPs2O1.js} +1 -1
  8. package/dist/hooks/index.d.ts +2 -1
  9. package/dist/hooks/index.d.ts.map +1 -1
  10. package/dist/hooks/index.js +7 -6
  11. package/dist/hooks/use-record-audit-log-snapshot.d.ts +15 -0
  12. package/dist/hooks/use-record-audit-log-snapshot.d.ts.map +1 -0
  13. package/dist/hooks/use-record-audit-log.d.ts +23 -0
  14. package/dist/hooks/use-record-audit-log.d.ts.map +1 -0
  15. package/dist/index.js +33 -21
  16. package/dist/lib/audit-log-core.d.ts +40 -46
  17. package/dist/lib/audit-log-core.d.ts.map +1 -1
  18. package/dist/lib/audit-log.d.ts +5 -5
  19. package/dist/lib/audit-log.d.ts.map +1 -1
  20. package/dist/lib/index.d.ts +1 -0
  21. package/dist/lib/index.d.ts.map +1 -1
  22. package/dist/lib/index.js +12 -0
  23. package/dist/mermaid-GHXKKRXX-RyLkx3ak.js +4 -0
  24. package/dist/ui.css +1 -185
  25. package/dist/{use-automation-run-D6DIaHy3.js → use-automation-run-BeBkcUQz.js} +3 -189
  26. package/dist/{use-sql-table-BfA0A-w3.js → use-sql-table-BpMNl9bf.js} +71 -2
  27. package/package.json +1 -1
  28. package/dist/components/audit-log/AuditLog.d.ts +0 -51
  29. package/dist/components/audit-log/AuditLog.d.ts.map +0 -1
  30. package/dist/components/audit-log/AuditLogEntry.d.ts +0 -19
  31. package/dist/components/audit-log/AuditLogEntry.d.ts.map +0 -1
  32. package/dist/components/audit-log/index.d.ts +0 -2
  33. package/dist/components/audit-log/index.d.ts.map +0 -1
  34. package/dist/hooks/use-audit-log.d.ts +0 -18
  35. package/dist/hooks/use-audit-log.d.ts.map +0 -1
  36. package/dist/mermaid-GHXKKRXX-AvjGDhsO.js +0 -4
package/dist/lib/index.js CHANGED
@@ -1,10 +1,15 @@
1
1
  import { B, E, C, b, D, F, G, c, H, I, J, K, g, L, M, N, f, O, Q, P, a, h, R, i, S, T, U, V, W, l, o, p, d, j, k, m, n, q, t, u, v, w, x, y, X, Y, e, r, z, s, A } from "../automations-DGUEnAYR.js";
2
2
  import { o as o2, f as f2, a as a2, b as b2, c as c2, d as d2, e as e2, g as g2, h as h2, i as i2, j as j2, k as k2, l as l2, m as m2, n as n2, s as s2 } from "../formatters-D4T821Dv.js";
3
3
  import { q as q2 } from "../query-client-DdOWay4_.js";
4
+ import { R as R2, e as e3, b as b3, a as a3, f as f3, g as g3, l as l3, n as n3, c as c3, d as d3, r as r2 } from "../audit-log-B2-PFKpH.js";
4
5
  export {
5
6
  B as BridgeError,
6
7
  E as EXPECTED_PARENT_ORIGIN,
8
+ R2 as RECORD_AUDIT_EXPORT_LIMIT,
9
+ e3 as RECORD_AUDIT_MAX_COLLECTIONS,
7
10
  C as automationStatuses,
11
+ b3 as buildRecordAuditCsv,
12
+ a3 as buildRecordAuditLogPath,
8
13
  b as buildShareableAppUrl,
9
14
  D as cancelAutomationRun,
10
15
  F as cancelRun,
@@ -15,6 +20,7 @@ export {
15
20
  I as createRun,
16
21
  J as ensureAutomationRun,
17
22
  K as ensureRun,
23
+ f3 as fetchRecordAuditLogCsv,
18
24
  f2 as formatBoolean,
19
25
  a2 as formatCellValue,
20
26
  b2 as formatCurrency,
@@ -34,6 +40,7 @@ export {
34
40
  M as getAutomationRun,
35
41
  N as getAutomationRunFileDownloadUrl,
36
42
  f as getDownloadUrl,
43
+ g3 as getRecordAuditLogSnapshot,
37
44
  O as getRun,
38
45
  Q as getRunFileUrl,
39
46
  P as getRunFiles,
@@ -43,10 +50,14 @@ export {
43
50
  i as isEmbedded,
44
51
  S as isTerminalStatus,
45
52
  T as listAutomationRunFiles,
53
+ l3 as listRecordAuditLog,
46
54
  U as listRuns,
47
55
  V as listRunsByAgent,
48
56
  W as listRunsByExternalId,
49
57
  l as logout,
58
+ n3 as normalizeRecordAuditCollections,
59
+ c3 as normalizeRecordAuditExportLimit,
60
+ d3 as normalizeRecordAuditPageSize,
50
61
  o as onInitMessage,
51
62
  p as parentApiRequest,
52
63
  d as parentApiStream,
@@ -65,6 +76,7 @@ export {
65
76
  Y as pollRun,
66
77
  e as postReadyMessage,
67
78
  q2 as queryClient,
79
+ r2 as recordAuditActorLabel,
68
80
  r as redirectToLogin,
69
81
  z as sendEmail,
70
82
  s as serializeBridgeRuntimeConfig,
@@ -0,0 +1,4 @@
1
+ import { r } from "./RecordSheet-aoDqWNaZ.js";
2
+ export {
3
+ r as Mermaid
4
+ };
package/dist/ui.css CHANGED
@@ -11,7 +11,6 @@
11
11
  --tw-skew-x: initial;
12
12
  --tw-skew-y: initial;
13
13
  --tw-space-y-reverse: 0;
14
- --tw-divide-y-reverse: 0;
15
14
  --tw-border-style: solid;
16
15
  --tw-gradient-position: initial;
17
16
  --tw-gradient-from: #0000;
@@ -105,23 +104,18 @@
105
104
  --color-amber-500: oklch(76.9% .188 70.08);
106
105
  --color-amber-600: oklch(66.6% .179 58.318);
107
106
  --color-amber-800: oklch(47.3% .137 46.201);
108
- --color-amber-950: oklch(27.9% .077 45.635);
109
107
  --color-green-600: oklch(62.7% .194 149.214);
110
108
  --color-emerald-50: oklch(97.9% .021 166.113);
111
109
  --color-emerald-200: oklch(90.5% .093 164.15);
112
110
  --color-emerald-500: oklch(69.6% .17 162.48);
113
111
  --color-emerald-600: oklch(59.6% .145 163.225);
114
112
  --color-emerald-800: oklch(43.2% .095 166.913);
115
- --color-emerald-950: oklch(26.2% .051 172.552);
116
- --color-sky-500: oklch(68.5% .169 237.323);
117
113
  --color-blue-50: oklch(97% .014 254.604);
118
114
  --color-blue-200: oklch(88.2% .059 254.128);
119
115
  --color-blue-600: oklch(54.6% .245 262.881);
120
116
  --color-blue-800: oklch(42.4% .199 265.638);
121
- --color-rose-50: oklch(96.9% .015 12.422);
122
117
  --color-rose-100: oklch(94.1% .03 12.58);
123
118
  --color-rose-500: oklch(64.5% .246 16.439);
124
- --color-rose-950: oklch(27.1% .105 12.094);
125
119
  --color-slate-500: oklch(55.4% .046 257.417);
126
120
  --color-slate-800: oklch(27.9% .041 260.031);
127
121
  --color-black: #000;
@@ -615,10 +609,6 @@
615
609
  margin-inline: calc(var(--spacing) * .5);
616
610
  }
617
611
 
618
- .mx-1\.5 {
619
- margin-inline: calc(var(--spacing) * 1.5);
620
- }
621
-
622
612
  .mx-2 {
623
613
  margin-inline: calc(var(--spacing) * 2);
624
614
  }
@@ -707,10 +697,6 @@
707
697
  margin-bottom: calc(var(--spacing) * 4);
708
698
  }
709
699
 
710
- .mb-px {
711
- margin-bottom: 1px;
712
- }
713
-
714
700
  .-ml-1 {
715
701
  margin-left: calc(var(--spacing) * -1);
716
702
  }
@@ -804,11 +790,6 @@
804
790
  height: calc(var(--spacing) * 1.5);
805
791
  }
806
792
 
807
- .size-2 {
808
- width: calc(var(--spacing) * 2);
809
- height: calc(var(--spacing) * 2);
810
- }
811
-
812
793
  .size-2\.5 {
813
794
  width: calc(var(--spacing) * 2.5);
814
795
  height: calc(var(--spacing) * 2.5);
@@ -918,10 +899,6 @@
918
899
  height: calc(var(--spacing) * 24);
919
900
  }
920
901
 
921
- .h-48 {
922
- height: calc(var(--spacing) * 48);
923
- }
924
-
925
902
  .h-56 {
926
903
  height: calc(var(--spacing) * 56);
927
904
  }
@@ -1046,10 +1023,6 @@
1046
1023
  width: calc(var(--spacing) * 2);
1047
1024
  }
1048
1025
 
1049
- .w-2\/3 {
1050
- width: 66.6667%;
1051
- }
1052
-
1053
1026
  .w-3 {
1054
1027
  width: calc(var(--spacing) * 3);
1055
1028
  }
@@ -1070,34 +1043,6 @@
1070
1043
  width: calc(var(--spacing) * 8);
1071
1044
  }
1072
1045
 
1073
- .w-12 {
1074
- width: calc(var(--spacing) * 12);
1075
- }
1076
-
1077
- .w-20 {
1078
- width: calc(var(--spacing) * 20);
1079
- }
1080
-
1081
- .w-24 {
1082
- width: calc(var(--spacing) * 24);
1083
- }
1084
-
1085
- .w-28 {
1086
- width: calc(var(--spacing) * 28);
1087
- }
1088
-
1089
- .w-32 {
1090
- width: calc(var(--spacing) * 32);
1091
- }
1092
-
1093
- .w-36 {
1094
- width: calc(var(--spacing) * 36);
1095
- }
1096
-
1097
- .w-48 {
1098
- width: calc(var(--spacing) * 48);
1099
- }
1100
-
1101
1046
  .w-56 {
1102
1047
  width: calc(var(--spacing) * 56);
1103
1048
  }
@@ -1106,26 +1051,6 @@
1106
1051
  width: calc(var(--spacing) * 60);
1107
1052
  }
1108
1053
 
1109
- .w-64 {
1110
- width: calc(var(--spacing) * 64);
1111
- }
1112
-
1113
- .w-\[8\.5rem\] {
1114
- width: 8.5rem;
1115
- }
1116
-
1117
- .w-\[10rem\] {
1118
- width: 10rem;
1119
- }
1120
-
1121
- .w-\[11rem\] {
1122
- width: 11rem;
1123
- }
1124
-
1125
- .w-\[12rem\] {
1126
- width: 12rem;
1127
- }
1128
-
1129
1054
  .w-\[70px\] {
1130
1055
  width: 70px;
1131
1056
  }
@@ -1170,10 +1095,6 @@
1170
1095
  max-width: calc(var(--spacing) * 40);
1171
1096
  }
1172
1097
 
1173
- .max-w-48 {
1174
- max-width: calc(var(--spacing) * 48);
1175
- }
1176
-
1177
1098
  .max-w-\[82\%\] {
1178
1099
  max-width: 82%;
1179
1100
  }
@@ -1234,10 +1155,6 @@
1234
1155
  min-width: calc(var(--spacing) * 48);
1235
1156
  }
1236
1157
 
1237
- .min-w-64 {
1238
- min-width: calc(var(--spacing) * 64);
1239
- }
1240
-
1241
1158
  .min-w-\[calc\(var\(--anchor-width\)\+--spacing\(7\)\)\] {
1242
1159
  min-width: calc(var(--anchor-width) + calc(var(--spacing) * 7));
1243
1160
  }
@@ -1291,10 +1208,6 @@
1291
1208
  rotate: 45deg;
1292
1209
  }
1293
1210
 
1294
- .rotate-180 {
1295
- rotate: 180deg;
1296
- }
1297
-
1298
1211
  .transform {
1299
1212
  transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );
1300
1213
  }
@@ -1531,24 +1444,6 @@
1531
1444
  margin-block-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));
1532
1445
  }
1533
1446
 
1534
- :where(.divide-y > :not(:last-child)) {
1535
- --tw-divide-y-reverse: 0;
1536
- border-bottom-style: var(--tw-border-style);
1537
- border-top-style: var(--tw-border-style);
1538
- border-top-width: calc(1px * var(--tw-divide-y-reverse));
1539
- border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
1540
- }
1541
-
1542
- :where(.divide-border\/70 > :not(:last-child)) {
1543
- border-color: var(--border);
1544
- }
1545
-
1546
- @supports (color: color-mix(in lab, red, red)) {
1547
- :where(.divide-border\/70 > :not(:last-child)) {
1548
- border-color: color-mix(in oklab, var(--border) 70%, transparent);
1549
- }
1550
- }
1551
-
1552
1447
  .self-start {
1553
1448
  align-self: flex-start;
1554
1449
  }
@@ -1831,10 +1726,6 @@
1831
1726
  background-color: var(--color-emerald-50);
1832
1727
  }
1833
1728
 
1834
- .bg-emerald-500 {
1835
- background-color: var(--color-emerald-500);
1836
- }
1837
-
1838
1729
  .bg-emerald-500\/20 {
1839
1730
  background-color: #00bb7f33;
1840
1731
  }
@@ -1859,17 +1750,7 @@
1859
1750
  }
1860
1751
  }
1861
1752
 
1862
- .bg-muted, .bg-muted\/10 {
1863
- background-color: var(--muted);
1864
- }
1865
-
1866
- @supports (color: color-mix(in lab, red, red)) {
1867
- .bg-muted\/10 {
1868
- background-color: color-mix(in oklab, var(--muted) 10%, transparent);
1869
- }
1870
- }
1871
-
1872
- .bg-muted\/20 {
1753
+ .bg-muted, .bg-muted\/20 {
1873
1754
  background-color: var(--muted);
1874
1755
  }
1875
1756
 
@@ -1927,14 +1808,6 @@
1927
1808
  background-color: var(--color-red-50);
1928
1809
  }
1929
1810
 
1930
- .bg-rose-50 {
1931
- background-color: var(--color-rose-50);
1932
- }
1933
-
1934
- .bg-rose-500 {
1935
- background-color: var(--color-rose-500);
1936
- }
1937
-
1938
1811
  .bg-rose-500\/10 {
1939
1812
  background-color: #ff23571a;
1940
1813
  }
@@ -1957,10 +1830,6 @@
1957
1830
  background-color: var(--sidebar-border);
1958
1831
  }
1959
1832
 
1960
- .bg-sky-500 {
1961
- background-color: var(--color-sky-500);
1962
- }
1963
-
1964
1833
  .bg-slate-500\/20 {
1965
1834
  background-color: #62748e33;
1966
1835
  }
@@ -2038,10 +1907,6 @@
2038
1907
  padding: calc(var(--spacing) * 4);
2039
1908
  }
2040
1909
 
2041
- .p-5 {
2042
- padding: calc(var(--spacing) * 5);
2043
- }
2044
-
2045
1910
  .p-6 {
2046
1911
  padding: calc(var(--spacing) * 6);
2047
1912
  }
@@ -2078,10 +1943,6 @@
2078
1943
  padding-inline: calc(var(--spacing) * 4);
2079
1944
  }
2080
1945
 
2081
- .px-5 {
2082
- padding-inline: calc(var(--spacing) * 5);
2083
- }
2084
-
2085
1946
  .px-6 {
2086
1947
  padding-inline: calc(var(--spacing) * 6);
2087
1948
  }
@@ -2298,10 +2159,6 @@
2298
2159
  overflow-wrap: break-word;
2299
2160
  }
2300
2161
 
2301
- .whitespace-normal {
2302
- white-space: normal;
2303
- }
2304
-
2305
2162
  .whitespace-nowrap {
2306
2163
  white-space: nowrap;
2307
2164
  }
@@ -2318,10 +2175,6 @@
2318
2175
  color: var(--color-amber-800);
2319
2176
  }
2320
2177
 
2321
- .text-amber-950 {
2322
- color: var(--color-amber-950);
2323
- }
2324
-
2325
2178
  .text-background {
2326
2179
  color: var(--background);
2327
2180
  }
@@ -2354,10 +2207,6 @@
2354
2207
  color: var(--color-emerald-800);
2355
2208
  }
2356
2209
 
2357
- .text-emerald-950 {
2358
- color: var(--color-emerald-950);
2359
- }
2360
-
2361
2210
  .text-foreground, .text-foreground\/80 {
2362
2211
  color: var(--foreground);
2363
2212
  }
@@ -2452,10 +2301,6 @@
2452
2301
  color: var(--color-rose-100);
2453
2302
  }
2454
2303
 
2455
- .text-rose-950 {
2456
- color: var(--color-rose-950);
2457
- }
2458
-
2459
2304
  .text-secondary-foreground {
2460
2305
  color: var(--secondary-foreground);
2461
2306
  }
@@ -3234,16 +3079,6 @@
3234
3079
  }
3235
3080
  }
3236
3081
 
3237
- .focus-visible\:ring-ring\/40:focus-visible {
3238
- --tw-ring-color: var(--ring);
3239
- }
3240
-
3241
- @supports (color: color-mix(in lab, red, red)) {
3242
- .focus-visible\:ring-ring\/40:focus-visible {
3243
- --tw-ring-color: color-mix(in oklab, var(--ring) 40%, transparent);
3244
- }
3245
- }
3246
-
3247
3082
  .focus-visible\:ring-ring\/50:focus-visible {
3248
3083
  --tw-ring-color: var(--ring);
3249
3084
  }
@@ -3254,11 +3089,6 @@
3254
3089
  }
3255
3090
  }
3256
3091
 
3257
- .focus-visible\:outline-none:focus-visible {
3258
- --tw-outline-style: none;
3259
- outline-style: none;
3260
- }
3261
-
3262
3092
  .active\:scale-95:active {
3263
3093
  --tw-scale-x: 95%;
3264
3094
  --tw-scale-y: 95%;
@@ -4067,10 +3897,6 @@
4067
3897
  grid-template-columns: repeat(2, minmax(0, 1fr));
4068
3898
  }
4069
3899
 
4070
- .sm\:grid-cols-\[9rem_1fr\] {
4071
- grid-template-columns: 9rem 1fr;
4072
- }
4073
-
4074
3900
  .sm\:flex-row {
4075
3901
  flex-direction: row;
4076
3902
  }
@@ -4079,10 +3905,6 @@
4079
3905
  justify-content: flex-end;
4080
3906
  }
4081
3907
 
4082
- .sm\:gap-4 {
4083
- gap: calc(var(--spacing) * 4);
4084
- }
4085
-
4086
3908
  .sm\:gap-12 {
4087
3909
  gap: calc(var(--spacing) * 12);
4088
3910
  }
@@ -5164,12 +4986,6 @@
5164
4986
  initial-value: 0;
5165
4987
  }
5166
4988
 
5167
- @property --tw-divide-y-reverse {
5168
- syntax: "*";
5169
- inherits: false;
5170
- initial-value: 0;
5171
- }
5172
-
5173
4989
  @property --tw-border-style {
5174
4990
  syntax: "*";
5175
4991
  inherits: false;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState, useRef, useCallback, useMemo } from "react";
2
- import { useInfiniteQuery, useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
3
- import { Z as requestApi, J as ensureAutomationRun, H as createAutomationRun, D as cancelAutomationRun, C as automationStatuses, M as getAutomationRun } from "./automations-DGUEnAYR.js";
2
+ import { useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
3
+ import { J as ensureAutomationRun, H as createAutomationRun, D as cancelAutomationRun, C as automationStatuses, M as getAutomationRun } from "./automations-DGUEnAYR.js";
4
4
  const QUEUED_DISCOVERY_POLL_MS = 2e3;
5
5
  const IDLE_DISCOVERY_POLL_MS = 1e4;
6
6
  const HIDDEN_DISCOVERY_POLL_MS = 3e4;
@@ -954,182 +954,6 @@ function replaceSession(sessions, next) {
954
954
  });
955
955
  return found ? updated : [next, ...updated];
956
956
  }
957
- const AUDIT_LOG_EXPORT_LIMIT = 1e4;
958
- const AUDIT_LOG_MAX_COLLECTIONS = 20;
959
- const normalizeAuditLogPageSize = (value = 50) => Math.min(200, Math.max(1, Math.trunc(value) || 50));
960
- const normalizeAuditLogExportLimit = (value = AUDIT_LOG_EXPORT_LIMIT) => Math.min(AUDIT_LOG_EXPORT_LIMIT, Math.max(1, Math.trunc(value) || AUDIT_LOG_EXPORT_LIMIT));
961
- const auditLogActorLabel = (actor) => actor.name?.trim() || actor.email?.trim() || actor.type_label;
962
- function normalizeRecordAuditCollections(collections) {
963
- const normalized = [];
964
- const seen = /* @__PURE__ */ new Set();
965
- for (const value of collections) {
966
- const collection = value.trim();
967
- if (!collection || seen.has(collection)) continue;
968
- seen.add(collection);
969
- normalized.push(collection);
970
- }
971
- return normalized;
972
- }
973
- function normalizeAuditLogFilterState(collections, filters = {}) {
974
- const available = normalizeRecordAuditCollections(collections);
975
- const allowed = new Set(available);
976
- const selected = normalizeRecordAuditCollections(filters.collections ?? available).filter(
977
- (name) => allowed.has(name)
978
- );
979
- return {
980
- collections: selected.length > 0 ? selected : available,
981
- event: filters.event,
982
- actor: filters.actor?.trim() || void 0,
983
- since: filters.since?.trim() || void 0,
984
- until: filters.until?.trim() || void 0
985
- };
986
- }
987
- function buildRecordAuditLogPath(params) {
988
- const collections = normalizeRecordAuditCollections(params.collections);
989
- if (collections.length === 0) {
990
- throw new Error("At least one collection is required");
991
- }
992
- if (collections.length > AUDIT_LOG_MAX_COLLECTIONS) {
993
- throw new Error(`At most ${AUDIT_LOG_MAX_COLLECTIONS} collections can be requested`);
994
- }
995
- const query = new URLSearchParams({
996
- domain: "record",
997
- limit: String(normalizeAuditLogPageSize(params.limit))
998
- });
999
- for (const collection of collections) query.append("collection", collection);
1000
- if (params.cursor?.trim()) query.set("cursor", params.cursor.trim());
1001
- if (params.event) query.set("event", params.event);
1002
- if (params.actor?.trim()) query.set("actor", params.actor.trim());
1003
- if (params.since?.trim()) query.set("since", params.since.trim());
1004
- if (params.until?.trim()) query.set("until", params.until.trim());
1005
- return `/audit-log?${query.toString()}`;
1006
- }
1007
- const auditLogDetailValue = (entry, label) => entry.details.find((field) => field.label === label)?.value ?? "";
1008
- function auditLogSummaryWithCollectionLabel(entry, collectionLabel) {
1009
- const label = collectionLabel.trim();
1010
- if (!label) return entry.summary;
1011
- const recordSegment = entry.summary.find((segment) => segment.emphasis === "strong");
1012
- const suffixSegments = entry.summary.filter(
1013
- (segment) => segment.emphasis === "none" && /^\(.+\)$/.test(segment.text.trim())
1014
- );
1015
- const eventLabel = entry.event[0].toUpperCase() + entry.event.slice(1);
1016
- return [
1017
- { text: `${eventLabel} ${label}`, emphasis: "none" },
1018
- ...recordSegment ? [recordSegment] : [],
1019
- ...suffixSegments
1020
- ];
1021
- }
1022
- const collectionLabelFor = (collection, options = {}) => options.collectionLabels?.[collection]?.trim() || collection;
1023
- const activityLabelFor = (collection, options = {}) => options.activityNouns?.[collection]?.trim() || options.collectionLabels?.[collection]?.trim() || "";
1024
- const summaryText = (entry, options = {}) => {
1025
- const collection = auditLogDetailValue(entry, "Collection");
1026
- const collectionLabel = collection ? activityLabelFor(collection, options) : "";
1027
- const summary = collectionLabel ? auditLogSummaryWithCollectionLabel(entry, collectionLabel) : entry.summary;
1028
- return summary.map((segment) => segment.text).join(" ");
1029
- };
1030
- const protectSpreadsheetCell = (value) => /^[\t\r ]*[=+\-@]/.test(value) ? `'${value}` : value;
1031
- const csvCell = (value) => `"${protectSpreadsheetCell(value).replaceAll('"', '""')}"`;
1032
- function buildAuditLogCsv(entries, options = {}) {
1033
- const rows = entries.map((entry) => {
1034
- const collectionApiName = auditLogDetailValue(entry, "Collection");
1035
- return [
1036
- entry.occurred_at,
1037
- collectionApiName ? collectionLabelFor(collectionApiName, options) : "",
1038
- collectionApiName,
1039
- auditLogActorLabel(entry.actor),
1040
- entry.actor.type,
1041
- entry.event,
1042
- auditLogDetailValue(entry, "Record ID"),
1043
- summaryText(entry, options)
1044
- ].map(csvCell).join(",");
1045
- });
1046
- return [
1047
- ["time", "collection_label", "collection_api_name", "actor", "actor_type", "event", "record_id", "summary"].map(csvCell).join(","),
1048
- ...rows
1049
- ].join("\n");
1050
- }
1051
- async function listRecordAuditLog(params) {
1052
- return requestApi(buildRecordAuditLogPath(params), { method: "GET" });
1053
- }
1054
- async function getRecordAuditLogSnapshot(id, store) {
1055
- const normalizedID = id.trim();
1056
- if (!normalizedID) {
1057
- throw new Error("Audit log ID is required");
1058
- }
1059
- return requestApi(
1060
- `/audit-log/${encodeURIComponent(normalizedID)}/snapshot?store=${encodeURIComponent(store)}`,
1061
- { method: "GET" }
1062
- );
1063
- }
1064
- async function fetchRecordAuditLogCsv(params, maxRows = AUDIT_LOG_EXPORT_LIMIT, options = {}) {
1065
- const limit = normalizeAuditLogExportLimit(maxRows);
1066
- const entries = [];
1067
- let cursor = "";
1068
- let truncated = false;
1069
- while (entries.length < limit) {
1070
- const page = await listRecordAuditLog({
1071
- ...params,
1072
- cursor: cursor || void 0,
1073
- limit: Math.min(200, limit - entries.length)
1074
- });
1075
- entries.push(...page.audit_logs.slice(0, limit - entries.length));
1076
- if (!page.pagination.has_more) break;
1077
- const nextCursor = page.pagination.next_cursor?.trim();
1078
- if (!nextCursor || nextCursor === cursor) {
1079
- throw new Error("Audit log export could not continue");
1080
- }
1081
- if (entries.length >= limit) {
1082
- truncated = true;
1083
- break;
1084
- }
1085
- cursor = nextCursor;
1086
- }
1087
- return { csv: buildAuditLogCsv(entries, options), count: entries.length, truncated };
1088
- }
1089
- function useAuditLog(collections, filters = {}, options = {}) {
1090
- const normalizedCollections = normalizeRecordAuditCollections(collections);
1091
- const pageSize = normalizeAuditLogPageSize(options.pageSize);
1092
- const normalizedFilters = useMemo(
1093
- () => ({
1094
- event: filters.event,
1095
- actor: filters.actor?.trim() || void 0,
1096
- since: filters.since?.trim() || void 0,
1097
- until: filters.until?.trim() || void 0
1098
- }),
1099
- [filters.actor, filters.event, filters.since, filters.until]
1100
- );
1101
- const query = useInfiniteQuery({
1102
- queryKey: ["audit-log", normalizedCollections, normalizedFilters, pageSize],
1103
- queryFn: ({ pageParam }) => listRecordAuditLog({
1104
- collections: normalizedCollections,
1105
- ...normalizedFilters,
1106
- cursor: typeof pageParam === "string" && pageParam ? pageParam : void 0,
1107
- limit: pageSize
1108
- }),
1109
- initialPageParam: "",
1110
- getNextPageParam: (lastPage) => lastPage.pagination.has_more ? lastPage.pagination.next_cursor || void 0 : void 0,
1111
- enabled: (options.enabled ?? true) && normalizedCollections.length > 0,
1112
- retry: (failureCount, error) => {
1113
- const status = error.status;
1114
- return !status || status >= 500 ? failureCount < 2 : false;
1115
- }
1116
- });
1117
- return {
1118
- entries: query.data?.pages.flatMap((page) => page.audit_logs) ?? [],
1119
- collectionStatus: query.data?.pages[0]?.record_collections ?? [],
1120
- error: query.error,
1121
- isLoading: query.isLoading,
1122
- isFetching: query.isFetching,
1123
- isLoadingMore: query.isFetchingNextPage,
1124
- hasMore: Boolean(query.hasNextPage),
1125
- loadMore: async () => {
1126
- await query.fetchNextPage();
1127
- },
1128
- refresh: async () => {
1129
- await query.refetch();
1130
- }
1131
- };
1132
- }
1133
957
  function useAutomationRun(options) {
1134
958
  const {
1135
959
  agentId,
@@ -1259,17 +1083,7 @@ function useAutomationRun(options) {
1259
1083
  };
1260
1084
  }
1261
1085
  export {
1262
- AUDIT_LOG_MAX_COLLECTIONS as A,
1263
1086
  useAgentChatSessions as a,
1264
- useAuditLog as b,
1265
- useAutomationRun as c,
1266
- auditLogSummaryWithCollectionLabel as d,
1267
- auditLogDetailValue as e,
1268
- auditLogActorLabel as f,
1269
- getRecordAuditLogSnapshot as g,
1270
- normalizeAuditLogFilterState as h,
1271
- fetchRecordAuditLogCsv as i,
1272
- normalizeAuditLogExportLimit as j,
1273
- normalizeRecordAuditCollections as n,
1087
+ useAutomationRun as b,
1274
1088
  useAgentChat as u
1275
1089
  };