@lumerahq/ui 0.13.0-dev.2 → 0.13.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 (39) hide show
  1. package/README.md +29 -21
  2. package/dist/{RecordSheet-CawHELpB.js → RecordSheet-BGs3rudM.js} +9146 -5815
  3. package/dist/{automations-EgDXJ43_.js → automations-DGUEnAYR.js} +199 -38
  4. package/dist/components/audit-log/AuditLog.d.ts +51 -0
  5. package/dist/components/audit-log/AuditLog.d.ts.map +1 -0
  6. package/dist/components/audit-log/AuditLogEntry.d.ts +19 -0
  7. package/dist/components/audit-log/AuditLogEntry.d.ts.map +1 -0
  8. package/dist/components/audit-log/index.d.ts +2 -0
  9. package/dist/components/audit-log/index.d.ts.map +1 -0
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/index.d.ts.map +1 -1
  12. package/dist/components/index.js +6 -5
  13. package/dist/{highlighted-body-OFNGDK62-TFNZl-GI.js → highlighted-body-OFNGDK62-V6FEuBTg.js} +1 -1
  14. package/dist/hooks/index.d.ts +1 -2
  15. package/dist/hooks/index.d.ts.map +1 -1
  16. package/dist/hooks/index.js +6 -7
  17. package/dist/hooks/use-audit-log.d.ts +18 -0
  18. package/dist/hooks/use-audit-log.d.ts.map +1 -0
  19. package/dist/index.js +55 -65
  20. package/dist/lib/audit-log-core.d.ts +46 -40
  21. package/dist/lib/audit-log-core.d.ts.map +1 -1
  22. package/dist/lib/audit-log.d.ts +5 -5
  23. package/dist/lib/audit-log.d.ts.map +1 -1
  24. package/dist/lib/bridge.d.ts +28 -0
  25. package/dist/lib/bridge.d.ts.map +1 -1
  26. package/dist/lib/index.d.ts +1 -2
  27. package/dist/lib/index.d.ts.map +1 -1
  28. package/dist/lib/index.js +36 -46
  29. package/dist/mermaid-GHXKKRXX-AvjGDhsO.js +4 -0
  30. package/dist/ui.css +185 -1
  31. package/dist/{use-automation-run-IypX1vtN.js → use-automation-run-D6DIaHy3.js} +189 -3
  32. package/dist/{use-sql-table-By700ZAo.js → use-sql-table-BfA0A-w3.js} +3 -72
  33. package/package.json +1 -1
  34. package/dist/audit-log-BPvip04_.js +0 -128
  35. package/dist/hooks/use-record-audit-log-snapshot.d.ts +0 -15
  36. package/dist/hooks/use-record-audit-log-snapshot.d.ts.map +0 -1
  37. package/dist/hooks/use-record-audit-log.d.ts +0 -23
  38. package/dist/hooks/use-record-audit-log.d.ts.map +0 -1
  39. package/dist/mermaid-GHXKKRXX-9ec0sPET.js +0 -4
package/dist/ui.css CHANGED
@@ -11,6 +11,7 @@
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;
14
15
  --tw-border-style: solid;
15
16
  --tw-gradient-position: initial;
16
17
  --tw-gradient-from: #0000;
@@ -104,18 +105,23 @@
104
105
  --color-amber-500: oklch(76.9% .188 70.08);
105
106
  --color-amber-600: oklch(66.6% .179 58.318);
106
107
  --color-amber-800: oklch(47.3% .137 46.201);
108
+ --color-amber-950: oklch(27.9% .077 45.635);
107
109
  --color-green-600: oklch(62.7% .194 149.214);
108
110
  --color-emerald-50: oklch(97.9% .021 166.113);
109
111
  --color-emerald-200: oklch(90.5% .093 164.15);
110
112
  --color-emerald-500: oklch(69.6% .17 162.48);
111
113
  --color-emerald-600: oklch(59.6% .145 163.225);
112
114
  --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);
113
117
  --color-blue-50: oklch(97% .014 254.604);
114
118
  --color-blue-200: oklch(88.2% .059 254.128);
115
119
  --color-blue-600: oklch(54.6% .245 262.881);
116
120
  --color-blue-800: oklch(42.4% .199 265.638);
121
+ --color-rose-50: oklch(96.9% .015 12.422);
117
122
  --color-rose-100: oklch(94.1% .03 12.58);
118
123
  --color-rose-500: oklch(64.5% .246 16.439);
124
+ --color-rose-950: oklch(27.1% .105 12.094);
119
125
  --color-slate-500: oklch(55.4% .046 257.417);
120
126
  --color-slate-800: oklch(27.9% .041 260.031);
121
127
  --color-black: #000;
@@ -609,6 +615,10 @@
609
615
  margin-inline: calc(var(--spacing) * .5);
610
616
  }
611
617
 
618
+ .mx-1\.5 {
619
+ margin-inline: calc(var(--spacing) * 1.5);
620
+ }
621
+
612
622
  .mx-2 {
613
623
  margin-inline: calc(var(--spacing) * 2);
614
624
  }
@@ -697,6 +707,10 @@
697
707
  margin-bottom: calc(var(--spacing) * 4);
698
708
  }
699
709
 
710
+ .mb-px {
711
+ margin-bottom: 1px;
712
+ }
713
+
700
714
  .-ml-1 {
701
715
  margin-left: calc(var(--spacing) * -1);
702
716
  }
@@ -790,6 +804,11 @@
790
804
  height: calc(var(--spacing) * 1.5);
791
805
  }
792
806
 
807
+ .size-2 {
808
+ width: calc(var(--spacing) * 2);
809
+ height: calc(var(--spacing) * 2);
810
+ }
811
+
793
812
  .size-2\.5 {
794
813
  width: calc(var(--spacing) * 2.5);
795
814
  height: calc(var(--spacing) * 2.5);
@@ -899,6 +918,10 @@
899
918
  height: calc(var(--spacing) * 24);
900
919
  }
901
920
 
921
+ .h-48 {
922
+ height: calc(var(--spacing) * 48);
923
+ }
924
+
902
925
  .h-56 {
903
926
  height: calc(var(--spacing) * 56);
904
927
  }
@@ -1023,6 +1046,10 @@
1023
1046
  width: calc(var(--spacing) * 2);
1024
1047
  }
1025
1048
 
1049
+ .w-2\/3 {
1050
+ width: 66.6667%;
1051
+ }
1052
+
1026
1053
  .w-3 {
1027
1054
  width: calc(var(--spacing) * 3);
1028
1055
  }
@@ -1043,6 +1070,34 @@
1043
1070
  width: calc(var(--spacing) * 8);
1044
1071
  }
1045
1072
 
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
+
1046
1101
  .w-56 {
1047
1102
  width: calc(var(--spacing) * 56);
1048
1103
  }
@@ -1051,6 +1106,26 @@
1051
1106
  width: calc(var(--spacing) * 60);
1052
1107
  }
1053
1108
 
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
+
1054
1129
  .w-\[70px\] {
1055
1130
  width: 70px;
1056
1131
  }
@@ -1095,6 +1170,10 @@
1095
1170
  max-width: calc(var(--spacing) * 40);
1096
1171
  }
1097
1172
 
1173
+ .max-w-48 {
1174
+ max-width: calc(var(--spacing) * 48);
1175
+ }
1176
+
1098
1177
  .max-w-\[82\%\] {
1099
1178
  max-width: 82%;
1100
1179
  }
@@ -1155,6 +1234,10 @@
1155
1234
  min-width: calc(var(--spacing) * 48);
1156
1235
  }
1157
1236
 
1237
+ .min-w-64 {
1238
+ min-width: calc(var(--spacing) * 64);
1239
+ }
1240
+
1158
1241
  .min-w-\[calc\(var\(--anchor-width\)\+--spacing\(7\)\)\] {
1159
1242
  min-width: calc(var(--anchor-width) + calc(var(--spacing) * 7));
1160
1243
  }
@@ -1208,6 +1291,10 @@
1208
1291
  rotate: 45deg;
1209
1292
  }
1210
1293
 
1294
+ .rotate-180 {
1295
+ rotate: 180deg;
1296
+ }
1297
+
1211
1298
  .transform {
1212
1299
  transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );
1213
1300
  }
@@ -1444,6 +1531,24 @@
1444
1531
  margin-block-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));
1445
1532
  }
1446
1533
 
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
+
1447
1552
  .self-start {
1448
1553
  align-self: flex-start;
1449
1554
  }
@@ -1726,6 +1831,10 @@
1726
1831
  background-color: var(--color-emerald-50);
1727
1832
  }
1728
1833
 
1834
+ .bg-emerald-500 {
1835
+ background-color: var(--color-emerald-500);
1836
+ }
1837
+
1729
1838
  .bg-emerald-500\/20 {
1730
1839
  background-color: #00bb7f33;
1731
1840
  }
@@ -1750,7 +1859,17 @@
1750
1859
  }
1751
1860
  }
1752
1861
 
1753
- .bg-muted, .bg-muted\/20 {
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 {
1754
1873
  background-color: var(--muted);
1755
1874
  }
1756
1875
 
@@ -1808,6 +1927,14 @@
1808
1927
  background-color: var(--color-red-50);
1809
1928
  }
1810
1929
 
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
+
1811
1938
  .bg-rose-500\/10 {
1812
1939
  background-color: #ff23571a;
1813
1940
  }
@@ -1830,6 +1957,10 @@
1830
1957
  background-color: var(--sidebar-border);
1831
1958
  }
1832
1959
 
1960
+ .bg-sky-500 {
1961
+ background-color: var(--color-sky-500);
1962
+ }
1963
+
1833
1964
  .bg-slate-500\/20 {
1834
1965
  background-color: #62748e33;
1835
1966
  }
@@ -1907,6 +2038,10 @@
1907
2038
  padding: calc(var(--spacing) * 4);
1908
2039
  }
1909
2040
 
2041
+ .p-5 {
2042
+ padding: calc(var(--spacing) * 5);
2043
+ }
2044
+
1910
2045
  .p-6 {
1911
2046
  padding: calc(var(--spacing) * 6);
1912
2047
  }
@@ -1943,6 +2078,10 @@
1943
2078
  padding-inline: calc(var(--spacing) * 4);
1944
2079
  }
1945
2080
 
2081
+ .px-5 {
2082
+ padding-inline: calc(var(--spacing) * 5);
2083
+ }
2084
+
1946
2085
  .px-6 {
1947
2086
  padding-inline: calc(var(--spacing) * 6);
1948
2087
  }
@@ -2159,6 +2298,10 @@
2159
2298
  overflow-wrap: break-word;
2160
2299
  }
2161
2300
 
2301
+ .whitespace-normal {
2302
+ white-space: normal;
2303
+ }
2304
+
2162
2305
  .whitespace-nowrap {
2163
2306
  white-space: nowrap;
2164
2307
  }
@@ -2175,6 +2318,10 @@
2175
2318
  color: var(--color-amber-800);
2176
2319
  }
2177
2320
 
2321
+ .text-amber-950 {
2322
+ color: var(--color-amber-950);
2323
+ }
2324
+
2178
2325
  .text-background {
2179
2326
  color: var(--background);
2180
2327
  }
@@ -2207,6 +2354,10 @@
2207
2354
  color: var(--color-emerald-800);
2208
2355
  }
2209
2356
 
2357
+ .text-emerald-950 {
2358
+ color: var(--color-emerald-950);
2359
+ }
2360
+
2210
2361
  .text-foreground, .text-foreground\/80 {
2211
2362
  color: var(--foreground);
2212
2363
  }
@@ -2301,6 +2452,10 @@
2301
2452
  color: var(--color-rose-100);
2302
2453
  }
2303
2454
 
2455
+ .text-rose-950 {
2456
+ color: var(--color-rose-950);
2457
+ }
2458
+
2304
2459
  .text-secondary-foreground {
2305
2460
  color: var(--secondary-foreground);
2306
2461
  }
@@ -3079,6 +3234,16 @@
3079
3234
  }
3080
3235
  }
3081
3236
 
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
+
3082
3247
  .focus-visible\:ring-ring\/50:focus-visible {
3083
3248
  --tw-ring-color: var(--ring);
3084
3249
  }
@@ -3089,6 +3254,11 @@
3089
3254
  }
3090
3255
  }
3091
3256
 
3257
+ .focus-visible\:outline-none:focus-visible {
3258
+ --tw-outline-style: none;
3259
+ outline-style: none;
3260
+ }
3261
+
3092
3262
  .active\:scale-95:active {
3093
3263
  --tw-scale-x: 95%;
3094
3264
  --tw-scale-y: 95%;
@@ -3897,6 +4067,10 @@
3897
4067
  grid-template-columns: repeat(2, minmax(0, 1fr));
3898
4068
  }
3899
4069
 
4070
+ .sm\:grid-cols-\[9rem_1fr\] {
4071
+ grid-template-columns: 9rem 1fr;
4072
+ }
4073
+
3900
4074
  .sm\:flex-row {
3901
4075
  flex-direction: row;
3902
4076
  }
@@ -3905,6 +4079,10 @@
3905
4079
  justify-content: flex-end;
3906
4080
  }
3907
4081
 
4082
+ .sm\:gap-4 {
4083
+ gap: calc(var(--spacing) * 4);
4084
+ }
4085
+
3908
4086
  .sm\:gap-12 {
3909
4087
  gap: calc(var(--spacing) * 12);
3910
4088
  }
@@ -4986,6 +5164,12 @@
4986
5164
  initial-value: 0;
4987
5165
  }
4988
5166
 
5167
+ @property --tw-divide-y-reverse {
5168
+ syntax: "*";
5169
+ inherits: false;
5170
+ initial-value: 0;
5171
+ }
5172
+
4989
5173
  @property --tw-border-style {
4990
5174
  syntax: "*";
4991
5175
  inherits: false;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState, useRef, useCallback, useMemo } from "react";
2
- import { useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
3
- import { H as ensureAutomationRun, F as createAutomationRun, A as cancelAutomationRun, z as automationStatuses, K as getAutomationRun } from "./automations-EgDXJ43_.js";
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";
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,6 +954,182 @@ 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
+ }
957
1133
  function useAutomationRun(options) {
958
1134
  const {
959
1135
  agentId,
@@ -1083,7 +1259,17 @@ function useAutomationRun(options) {
1083
1259
  };
1084
1260
  }
1085
1261
  export {
1262
+ AUDIT_LOG_MAX_COLLECTIONS as A,
1086
1263
  useAgentChatSessions as a,
1087
- useAutomationRun as b,
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,
1088
1274
  useAgentChat as u
1089
1275
  };
@@ -1,7 +1,6 @@
1
- import { useQueryClient, useQuery, useMutation, useInfiniteQuery } from "@tanstack/react-query";
1
+ import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
2
2
  import { useState, useCallback, useEffect, useMemo } from "react";
3
- import { T as listRunsByAgent, z as automationStatuses, F as createAutomationRun, y as uploadFile, o as onInitMessage, t as pbSql, v as pbUpdateRecord } from "./automations-EgDXJ43_.js";
4
- import { n as normalizeRecordAuditCollections, d as normalizeRecordAuditPageSize, l as listRecordAuditLog, g as getRecordAuditLogSnapshot } from "./audit-log-BPvip04_.js";
3
+ import { V as listRunsByAgent, C as automationStatuses, H as createAutomationRun, A as uploadFile, o as onInitMessage, v as pbSql, x as pbUpdateRecord } from "./automations-DGUEnAYR.js";
5
4
  function useAutomationAgent({
6
5
  agentId,
7
6
  limit = 5,
@@ -152,72 +151,6 @@ function useLumeraUser() {
152
151
  }, []);
153
152
  return hostData;
154
153
  }
155
- function useRecordAuditLog(params) {
156
- const normalizedCollections = normalizeRecordAuditCollections(params.collections);
157
- const pageSize = normalizeRecordAuditPageSize(params.pageSize);
158
- const filters = useMemo(
159
- () => ({
160
- event: params.event,
161
- actor: params.actor?.trim() || void 0,
162
- since: params.since?.trim() || void 0,
163
- until: params.until?.trim() || void 0
164
- }),
165
- [params.actor, params.event, params.since, params.until]
166
- );
167
- const query = useInfiniteQuery({
168
- queryKey: ["record-audit-log", normalizedCollections, filters, pageSize],
169
- queryFn: ({ pageParam }) => listRecordAuditLog({
170
- collections: normalizedCollections,
171
- ...filters,
172
- cursor: typeof pageParam === "string" && pageParam ? pageParam : void 0,
173
- limit: pageSize
174
- }),
175
- initialPageParam: "",
176
- getNextPageParam: (lastPage) => lastPage.pagination.has_more ? lastPage.pagination.next_cursor || void 0 : void 0,
177
- enabled: (params.enabled ?? true) && normalizedCollections.length > 0,
178
- retry: (failureCount, error) => {
179
- const status = error.status;
180
- return !status || status >= 500 ? failureCount < 2 : false;
181
- }
182
- });
183
- return {
184
- entries: query.data?.pages.flatMap((page) => page.audit_logs) ?? [],
185
- collectionStatus: query.data?.pages[0]?.record_collections ?? [],
186
- error: query.error,
187
- isLoading: query.isLoading,
188
- isFetching: query.isFetching,
189
- isLoadingMore: query.isFetchingNextPage,
190
- hasMore: Boolean(query.hasNextPage),
191
- loadMore: async () => {
192
- await query.fetchNextPage();
193
- },
194
- refresh: async () => {
195
- await query.refetch();
196
- }
197
- };
198
- }
199
- function useRecordAuditLogSnapshot(params) {
200
- const id = params.id?.trim() || "";
201
- const store = params.store ?? "tenant";
202
- const query = useQuery({
203
- queryKey: ["record-audit-log-snapshot", id, store],
204
- queryFn: () => getRecordAuditLogSnapshot(id, store),
205
- enabled: (params.enabled ?? true) && id !== "",
206
- retry: (failureCount, error) => {
207
- const status = error.status;
208
- return !status || status >= 500 ? failureCount < 2 : false;
209
- }
210
- });
211
- return {
212
- snapshot: query.data?.snapshot ?? null,
213
- error: query.error,
214
- isLoading: query.isLoading,
215
- isFetching: query.isFetching,
216
- refresh: async () => {
217
- await query.refetch();
218
- }
219
- };
220
- }
221
154
  function buildFilterClause(filters) {
222
155
  if (filters.length === 0) {
223
156
  return { clause: "", args: [] };
@@ -404,8 +337,6 @@ export {
404
337
  useLumeraUser as b,
405
338
  usePbSql as c,
406
339
  usePbUpdate as d,
407
- useRecordAuditLog as e,
408
- useRecordAuditLogSnapshot as f,
409
- useSqlTable as g,
340
+ useSqlTable as e,
410
341
  useAutomationAgent as u
411
342
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumerahq/ui",
3
- "version": "0.13.0-dev.2",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "*.css"