@lumerahq/ui 0.11.3 → 0.12.0-dev.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.
- package/dist/{RecordSheet-SDw564xp.js → RecordSheet-DJoKhb3u.js} +9509 -6680
- package/dist/{automations-DP-uLpqG.js → automations-EgDXJ43_.js} +2 -0
- package/dist/components/audit-log/AuditLog.d.ts +12 -0
- package/dist/components/audit-log/AuditLog.d.ts.map +1 -0
- package/dist/components/audit-log/AuditLogEntry.d.ts +5 -0
- package/dist/components/audit-log/AuditLogEntry.d.ts.map +1 -0
- package/dist/components/audit-log/index.d.ts +2 -0
- package/dist/components/audit-log/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -5
- package/dist/{highlighted-body-OFNGDK62-7xB8r9be.js → highlighted-body-OFNGDK62-DD5EYZQR.js} +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +5 -4
- package/dist/hooks/use-audit-log.d.ts +17 -0
- package/dist/hooks/use-audit-log.d.ts.map +1 -0
- package/dist/index.js +16 -14
- package/dist/lib/api.d.ts +7 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/audit-log-core.d.ts +77 -0
- package/dist/lib/audit-log-core.d.ts.map +1 -0
- package/dist/lib/audit-log.d.ts +7 -0
- package/dist/lib/audit-log.d.ts.map +1 -0
- package/dist/lib/index.js +1 -1
- package/dist/mermaid-GHXKKRXX-BdrbO7XD.js +4 -0
- package/dist/ui.css +131 -0
- package/dist/{use-automation-run-BLpS4iVw.js → use-automation-run-BrghacFY.js} +148 -3
- package/dist/{use-sql-table-E2BSyNpX.js → use-sql-table-DWHMqSIq.js} +1 -1
- package/package.json +1 -1
- package/dist/mermaid-GHXKKRXX-D3I6gc8h.js +0 -4
|
@@ -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-
|
|
2
|
+
import { useInfiniteQuery, useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { X as requestApi, H as ensureAutomationRun, F as createAutomationRun, A as cancelAutomationRun, z as automationStatuses, K as getAutomationRun } from "./automations-EgDXJ43_.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,143 @@ 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 auditLogActorLabel = (actor) => actor.name?.trim() || actor.email?.trim() || actor.type_label;
|
|
961
|
+
function normalizeRecordAuditCollections(collections) {
|
|
962
|
+
const normalized = [];
|
|
963
|
+
const seen = /* @__PURE__ */ new Set();
|
|
964
|
+
for (const value of collections) {
|
|
965
|
+
const collection = value.trim();
|
|
966
|
+
if (!collection || seen.has(collection)) continue;
|
|
967
|
+
seen.add(collection);
|
|
968
|
+
normalized.push(collection);
|
|
969
|
+
}
|
|
970
|
+
return normalized;
|
|
971
|
+
}
|
|
972
|
+
function buildRecordAuditLogPath(params) {
|
|
973
|
+
const collections = normalizeRecordAuditCollections(params.collections);
|
|
974
|
+
if (collections.length === 0) {
|
|
975
|
+
throw new Error("At least one collection is required");
|
|
976
|
+
}
|
|
977
|
+
if (collections.length > AUDIT_LOG_MAX_COLLECTIONS) {
|
|
978
|
+
throw new Error(`At most ${AUDIT_LOG_MAX_COLLECTIONS} collections can be requested`);
|
|
979
|
+
}
|
|
980
|
+
const query = new URLSearchParams({
|
|
981
|
+
domain: "record",
|
|
982
|
+
limit: String(normalizeAuditLogPageSize(params.limit))
|
|
983
|
+
});
|
|
984
|
+
for (const collection of collections) query.append("collection", collection);
|
|
985
|
+
if (params.cursor?.trim()) query.set("cursor", params.cursor.trim());
|
|
986
|
+
if (params.event) query.set("event", params.event);
|
|
987
|
+
if (params.actor?.trim()) query.set("actor", params.actor.trim());
|
|
988
|
+
if (params.since?.trim()) query.set("since", params.since.trim());
|
|
989
|
+
if (params.until?.trim()) query.set("until", params.until.trim());
|
|
990
|
+
return `/audit-log?${query.toString()}`;
|
|
991
|
+
}
|
|
992
|
+
const summaryText = (entry) => entry.summary.map((segment) => segment.text).join(" ");
|
|
993
|
+
const auditLogDetailValue = (entry, label) => entry.details.find((field) => field.label === label)?.value ?? "";
|
|
994
|
+
const protectSpreadsheetCell = (value) => /^[\t\r ]*[=+\-@]/.test(value) ? `'${value}` : value;
|
|
995
|
+
const csvCell = (value) => `"${protectSpreadsheetCell(value).replaceAll('"', '""')}"`;
|
|
996
|
+
function buildAuditLogCsv(entries) {
|
|
997
|
+
const rows = entries.map(
|
|
998
|
+
(entry) => [
|
|
999
|
+
entry.occurred_at,
|
|
1000
|
+
auditLogDetailValue(entry, "Collection"),
|
|
1001
|
+
auditLogActorLabel(entry.actor),
|
|
1002
|
+
entry.actor.type,
|
|
1003
|
+
entry.event,
|
|
1004
|
+
auditLogDetailValue(entry, "Record ID"),
|
|
1005
|
+
summaryText(entry)
|
|
1006
|
+
].map(csvCell).join(",")
|
|
1007
|
+
);
|
|
1008
|
+
return [
|
|
1009
|
+
["time", "collection", "actor", "actor_type", "event", "record_id", "summary"].map(csvCell).join(","),
|
|
1010
|
+
...rows
|
|
1011
|
+
].join("\n");
|
|
1012
|
+
}
|
|
1013
|
+
async function listRecordAuditLog(params) {
|
|
1014
|
+
return requestApi(buildRecordAuditLogPath(params), { method: "GET" });
|
|
1015
|
+
}
|
|
1016
|
+
async function getRecordAuditLogSnapshot(id, store) {
|
|
1017
|
+
const normalizedID = id.trim();
|
|
1018
|
+
if (!normalizedID) {
|
|
1019
|
+
throw new Error("Audit log ID is required");
|
|
1020
|
+
}
|
|
1021
|
+
return requestApi(
|
|
1022
|
+
`/audit-log/${encodeURIComponent(normalizedID)}/snapshot?store=${encodeURIComponent(store)}`,
|
|
1023
|
+
{ method: "GET" }
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
async function fetchRecordAuditLogCsv(params, maxRows = AUDIT_LOG_EXPORT_LIMIT) {
|
|
1027
|
+
const limit = Math.min(AUDIT_LOG_EXPORT_LIMIT, Math.max(1, Math.trunc(maxRows) || AUDIT_LOG_EXPORT_LIMIT));
|
|
1028
|
+
const entries = [];
|
|
1029
|
+
let cursor = "";
|
|
1030
|
+
let truncated = false;
|
|
1031
|
+
while (entries.length < limit) {
|
|
1032
|
+
const page = await listRecordAuditLog({
|
|
1033
|
+
...params,
|
|
1034
|
+
cursor: cursor || void 0,
|
|
1035
|
+
limit: Math.min(200, limit - entries.length)
|
|
1036
|
+
});
|
|
1037
|
+
entries.push(...page.audit_logs.slice(0, limit - entries.length));
|
|
1038
|
+
if (!page.pagination.has_more) break;
|
|
1039
|
+
const nextCursor = page.pagination.next_cursor?.trim();
|
|
1040
|
+
if (!nextCursor || nextCursor === cursor) {
|
|
1041
|
+
throw new Error("Audit log export could not continue");
|
|
1042
|
+
}
|
|
1043
|
+
if (entries.length >= limit) {
|
|
1044
|
+
truncated = true;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
cursor = nextCursor;
|
|
1048
|
+
}
|
|
1049
|
+
return { csv: buildAuditLogCsv(entries), count: entries.length, truncated };
|
|
1050
|
+
}
|
|
1051
|
+
function useAuditLog(collections, filters = {}, options = {}) {
|
|
1052
|
+
const normalizedCollections = normalizeRecordAuditCollections(collections);
|
|
1053
|
+
const pageSize = normalizeAuditLogPageSize(options.pageSize);
|
|
1054
|
+
const normalizedFilters = useMemo(
|
|
1055
|
+
() => ({
|
|
1056
|
+
event: filters.event,
|
|
1057
|
+
actor: filters.actor?.trim() || void 0,
|
|
1058
|
+
since: filters.since?.trim() || void 0,
|
|
1059
|
+
until: filters.until?.trim() || void 0
|
|
1060
|
+
}),
|
|
1061
|
+
[filters.actor, filters.event, filters.since, filters.until]
|
|
1062
|
+
);
|
|
1063
|
+
const query = useInfiniteQuery({
|
|
1064
|
+
queryKey: ["audit-log", normalizedCollections, normalizedFilters, pageSize],
|
|
1065
|
+
queryFn: ({ pageParam }) => listRecordAuditLog({
|
|
1066
|
+
collections: normalizedCollections,
|
|
1067
|
+
...normalizedFilters,
|
|
1068
|
+
cursor: typeof pageParam === "string" && pageParam ? pageParam : void 0,
|
|
1069
|
+
limit: pageSize
|
|
1070
|
+
}),
|
|
1071
|
+
initialPageParam: "",
|
|
1072
|
+
getNextPageParam: (lastPage) => lastPage.pagination.has_more ? lastPage.pagination.next_cursor || void 0 : void 0,
|
|
1073
|
+
enabled: (options.enabled ?? true) && normalizedCollections.length > 0,
|
|
1074
|
+
retry: (failureCount, error) => {
|
|
1075
|
+
const status = error.status;
|
|
1076
|
+
return !status || status >= 500 ? failureCount < 2 : false;
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
return {
|
|
1080
|
+
entries: query.data?.pages.flatMap((page) => page.audit_logs) ?? [],
|
|
1081
|
+
error: query.error,
|
|
1082
|
+
isLoading: query.isLoading,
|
|
1083
|
+
isFetching: query.isFetching,
|
|
1084
|
+
isLoadingMore: query.isFetchingNextPage,
|
|
1085
|
+
hasMore: Boolean(query.hasNextPage),
|
|
1086
|
+
loadMore: async () => {
|
|
1087
|
+
await query.fetchNextPage();
|
|
1088
|
+
},
|
|
1089
|
+
refresh: async () => {
|
|
1090
|
+
await query.refetch();
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
957
1094
|
function useAutomationRun(options) {
|
|
958
1095
|
const {
|
|
959
1096
|
agentId,
|
|
@@ -1083,7 +1220,15 @@ function useAutomationRun(options) {
|
|
|
1083
1220
|
};
|
|
1084
1221
|
}
|
|
1085
1222
|
export {
|
|
1223
|
+
AUDIT_LOG_MAX_COLLECTIONS as A,
|
|
1086
1224
|
useAgentChatSessions as a,
|
|
1087
|
-
|
|
1225
|
+
useAuditLog as b,
|
|
1226
|
+
useAutomationRun as c,
|
|
1227
|
+
auditLogDetailValue as d,
|
|
1228
|
+
auditLogActorLabel as e,
|
|
1229
|
+
fetchRecordAuditLogCsv as f,
|
|
1230
|
+
getRecordAuditLogSnapshot as g,
|
|
1231
|
+
AUDIT_LOG_EXPORT_LIMIT as h,
|
|
1232
|
+
normalizeRecordAuditCollections as n,
|
|
1088
1233
|
useAgentChat as u
|
|
1089
1234
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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-
|
|
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
4
|
function useAutomationAgent({
|
|
5
5
|
agentId,
|
|
6
6
|
limit = 5,
|
package/package.json
CHANGED