@lumerahq/ui 0.13.0 → 0.14.1

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 (41) hide show
  1. package/README.md +27 -29
  2. package/dist/{RecordSheet-BGs3rudM.js → RecordSheet-Bzy5YmGG.js} +7398 -10729
  3. package/dist/audit-log-DvTR_z7A.js +128 -0
  4. package/dist/{automations-DGUEnAYR.js → automations-BuMtkzex.js} +1 -1
  5. package/dist/components/index.d.ts +0 -1
  6. package/dist/components/index.d.ts.map +1 -1
  7. package/dist/components/index.js +5 -6
  8. package/dist/{highlighted-body-OFNGDK62-V6FEuBTg.js → highlighted-body-OFNGDK62-CBG3mC_9.js} +1 -1
  9. package/dist/hooks/index.d.ts +2 -1
  10. package/dist/hooks/index.d.ts.map +1 -1
  11. package/dist/hooks/index.js +7 -6
  12. package/dist/hooks/use-automation-run.d.ts +2 -2
  13. package/dist/hooks/use-automation-run.d.ts.map +1 -1
  14. package/dist/hooks/use-record-audit-log-snapshot.d.ts +15 -0
  15. package/dist/hooks/use-record-audit-log-snapshot.d.ts.map +1 -0
  16. package/dist/hooks/use-record-audit-log.d.ts +23 -0
  17. package/dist/hooks/use-record-audit-log.d.ts.map +1 -0
  18. package/dist/index.js +33 -21
  19. package/dist/lib/audit-log-core.d.ts +40 -46
  20. package/dist/lib/audit-log-core.d.ts.map +1 -1
  21. package/dist/lib/audit-log.d.ts +5 -5
  22. package/dist/lib/audit-log.d.ts.map +1 -1
  23. package/dist/lib/automations.d.ts +1 -1
  24. package/dist/lib/automations.d.ts.map +1 -1
  25. package/dist/lib/index.d.ts +1 -0
  26. package/dist/lib/index.d.ts.map +1 -1
  27. package/dist/lib/index.js +13 -1
  28. package/dist/mermaid-GHXKKRXX-CLA1Bowf.js +4 -0
  29. package/dist/ui.css +1 -185
  30. package/dist/{use-automation-run-D6DIaHy3.js → use-automation-run-CAp0e1av.js} +3 -189
  31. package/dist/{use-sql-table-BfA0A-w3.js → use-sql-table-C5bU2-ES.js} +72 -3
  32. package/package.json +1 -1
  33. package/dist/components/audit-log/AuditLog.d.ts +0 -51
  34. package/dist/components/audit-log/AuditLog.d.ts.map +0 -1
  35. package/dist/components/audit-log/AuditLogEntry.d.ts +0 -19
  36. package/dist/components/audit-log/AuditLogEntry.d.ts.map +0 -1
  37. package/dist/components/audit-log/index.d.ts +0 -2
  38. package/dist/components/audit-log/index.d.ts.map +0 -1
  39. package/dist/hooks/use-audit-log.d.ts +0 -18
  40. package/dist/hooks/use-audit-log.d.ts.map +0 -1
  41. package/dist/mermaid-GHXKKRXX-AvjGDhsO.js +0 -4
@@ -1,6 +1,7 @@
1
- import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
1
+ import { useQueryClient, useQuery, useMutation, useInfiniteQuery } from "@tanstack/react-query";
2
2
  import { useState, useCallback, useEffect, useMemo } from "react";
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";
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-BuMtkzex.js";
4
+ import { n as normalizeRecordAuditCollections, d as normalizeRecordAuditPageSize, l as listRecordAuditLog, g as getRecordAuditLogSnapshot } from "./audit-log-DvTR_z7A.js";
4
5
  function useAutomationAgent({
5
6
  agentId,
6
7
  limit = 5,
@@ -151,6 +152,72 @@ function useLumeraUser() {
151
152
  }, []);
152
153
  return hostData;
153
154
  }
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
+ }
154
221
  function buildFilterClause(filters) {
155
222
  if (filters.length === 0) {
156
223
  return { clause: "", args: [] };
@@ -337,6 +404,8 @@ export {
337
404
  useLumeraUser as b,
338
405
  usePbSql as c,
339
406
  usePbUpdate as d,
340
- useSqlTable as e,
407
+ useRecordAuditLog as e,
408
+ useRecordAuditLogSnapshot as f,
409
+ useSqlTable as g,
341
410
  useAutomationAgent as u
342
411
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumerahq/ui",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -1,51 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AuditLogEntry as AuditLogEntryData, AuditLogFilterState as AuditLogFilterStateData } from '../../lib/audit-log';
3
- export type AuditLogDensity = 'compact' | 'comfortable';
4
- export type AuditLogFilterState = AuditLogFilterStateData;
5
- export type AuditLogRecord = AuditLogEntryData;
6
- export type AuditLogProps = {
7
- /** Collections whose combined record history should be shown (maximum 20). */
8
- collections: readonly string[];
9
- /** Friendly display names keyed by collection API name. */
10
- collectionLabels?: Readonly<Record<string, string>>;
11
- /** Singular activity nouns keyed by collection API name, e.g. "invoice" or "payment". */
12
- activityNouns?: Readonly<Record<string, string>>;
13
- /** Controlled filter state. */
14
- filters?: AuditLogFilterState;
15
- /** Initial filters when the component manages its own state. */
16
- defaultFilters?: Partial<AuditLogFilterState>;
17
- /** Called after any user filter change, in controlled and uncontrolled modes. */
18
- onFiltersChange?: (filters: AuditLogFilterState) => void;
19
- /** Rows fetched per page. Defaults to 50; the API maximum is 200. */
20
- pageSize?: number;
21
- /** Maximum rows in one CSV export. Defaults to 10,000 and cannot exceed it. */
22
- exportMaxRows?: number;
23
- /** Download name for CSV exports. Defaults to a date-stamped name. */
24
- exportFilename?: string;
25
- /** Header text. Defaults to "Activity". */
26
- title?: string;
27
- /** Row spacing. Defaults to "compact". */
28
- density?: AuditLogDensity;
29
- /** Show the collection column. Defaults to true. */
30
- showCollectionColumn?: boolean;
31
- /** Show the actor column. Defaults to true. */
32
- showActorColumn?: boolean;
33
- /** Include record system fields in before/after values. Defaults to true. */
34
- showSystemFields?: boolean;
35
- /** Friendly labels keyed by a field's API key or current label. */
36
- fieldLabels?: Readonly<Record<string, string>>;
37
- /** Return an app-specific destination for an audit entry's record. */
38
- getRecordHref?: (entry: AuditLogEntryData) => string | undefined;
39
- /** Called when the app-specific record action is selected. */
40
- onRecordClick?: (entry: AuditLogEntryData) => void;
41
- /** Optional replacement for the built-in loading state. */
42
- loadingState?: ReactNode;
43
- /** Optional replacement for the built-in empty state. */
44
- emptyState?: ReactNode;
45
- /** Optional replacement for an API error state. */
46
- errorState?: (error: Error) => ReactNode;
47
- /** Optional classes for the outer container. */
48
- className?: string;
49
- };
50
- export declare function AuditLog({ collections, collectionLabels, activityNouns, filters: controlledFilters, defaultFilters, onFiltersChange, pageSize, exportMaxRows, exportFilename, title, density, showCollectionColumn, showActorColumn, showSystemFields, fieldLabels, getRecordHref, onRecordClick, loadingState, emptyState, errorState, className, }: AuditLogProps): import("react/jsx-runtime").JSX.Element;
51
- //# sourceMappingURL=AuditLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuditLog.d.ts","sourceRoot":"","sources":["../../../src/components/audit-log/AuditLog.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAA4B,MAAM,OAAO,CAAC;AAmBjE,OAAO,EAGL,KAAK,aAAa,IAAI,iBAAiB,EAEvC,KAAK,mBAAmB,IAAI,uBAAuB,EAOpD,MAAM,iBAAiB,CAAC;AAGzB,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,CAAC;AACxD,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG;IAC1B,8EAA8E;IAC9E,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MA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ChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA4FF,wBAAgB,QAAQ,CAAC,EACvB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EACd,eAAe,EACf,QAAa,EACb,aAAa,EACb,cAAc,EACd,KAAkB,EAClB,OAAmB,EACnB,oBAA2B,EAC3B,eAAsB,EACtB,gBAAuB,EACvB,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE,aAAa,2CAyiBf"}
@@ -1,19 +0,0 @@
1
- import { AuditLogDensity } from './AuditLog';
2
- import { AuditLogEntry as AuditLogEntryData } from '../../lib/audit-log';
3
- type AuditLogEntryProps = {
4
- entry: AuditLogEntryData;
5
- collectionApiName: string;
6
- collectionLabel: string;
7
- activityCollectionLabel?: string;
8
- density: AuditLogDensity;
9
- showCollectionColumn: boolean;
10
- showActorColumn: boolean;
11
- showSystemFields: boolean;
12
- fieldLabels?: Readonly<Record<string, string>>;
13
- columnCount: number;
14
- getRecordHref?: (entry: AuditLogEntryData) => string | undefined;
15
- onRecordClick?: (entry: AuditLogEntryData) => void;
16
- };
17
- export declare function AuditLogEntry({ entry, collectionApiName, collectionLabel, activityCollectionLabel, density, showCollectionColumn, showActorColumn, showSystemFields, fieldLabels, columnCount, getRecordHref, onRecordClick, }: AuditLogEntryProps): import("react/jsx-runtime").JSX.Element;
18
- export {};
19
- //# sourceMappingURL=AuditLogEntry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuditLogEntry.d.ts","sourceRoot":"","sources":["../../../src/components/audit-log/AuditLogEntry.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EACL,KAAK,aAAa,IAAI,iBAAiB,EAMxC,MAAM,iBAAiB,CAAC;AA6KzB,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,iBAAiB,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,OAAO,EAAE,eAAe,CAAC;IACzB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,MAAM,GAAG,SAAS,CAAC;IACjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,GACd,EAAE,kBAAkB,2CA6HpB"}
@@ -1,2 +0,0 @@
1
- export { AuditLog, type AuditLogDensity, type AuditLogFilterState, type AuditLogProps, type AuditLogRecord, } from './AuditLog';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/audit-log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC"}
@@ -1,18 +0,0 @@
1
- import { AuditLogCollectionStatus, AuditLogEntry, AuditLogFilters } from '../lib/audit-log';
2
- export type UseAuditLogOptions = {
3
- pageSize?: number;
4
- enabled?: boolean;
5
- };
6
- export type UseAuditLogResult = {
7
- entries: AuditLogEntry[];
8
- collectionStatus: AuditLogCollectionStatus[];
9
- error: Error | null;
10
- isLoading: boolean;
11
- isFetching: boolean;
12
- isLoadingMore: boolean;
13
- hasMore: boolean;
14
- loadMore: () => Promise<void>;
15
- refresh: () => Promise<void>;
16
- };
17
- export declare function useAuditLog(collections: readonly string[], filters?: AuditLogFilters, options?: UseAuditLogOptions): UseAuditLogResult;
18
- //# sourceMappingURL=use-audit-log.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-audit-log.d.ts","sourceRoot":"","sources":["../../src/hooks/use-audit-log.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,eAAe,EAKrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;IAC7C,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,WAAW,CACzB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,GAAE,eAAoB,EAC7B,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CA+CnB"}
@@ -1,4 +0,0 @@
1
- import { s } from "./RecordSheet-BGs3rudM.js";
2
- export {
3
- s as Mermaid
4
- };