@krak-stack/registry 0.1.54 → 0.1.55
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/CHANGELOG.md +18 -0
- package/dist/components/ui/error-component.js +9 -5
- package/dist/components/ui/form.d.ts +5 -5
- package/dist/services/events/browser.js +9 -3
- package/dist/services/events/client/audit-log-table.d.ts +17 -12
- package/dist/services/events/client/audit-log-table.js +71 -17
- package/dist/services/events/index.d.ts +7 -3
- package/dist/services/events/index.js +19 -22
- package/dist/services/events/schema.d.ts +51 -1
- package/dist/services/events/schema.js +12 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.1.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9ec74fb: Default the activity history dateTime column to America/New_York, expose a timeZone override, and use Activity history titles in English and French.
|
|
8
|
+
|
|
9
|
+
Display event-time OpenTelemetry user.full_name, user.name, user.email and user.id attributes in activity history without resolving or linking Auth profiles. Preserve those trusted server annotations for audit events, while omitting them from analytics. Remove the separate actors prop.
|
|
10
|
+
|
|
11
|
+
Replace Events.listAudit / ListAudit with Events.list / ListEvents and require an explicit audit or analytics category. Preserve server pagination and service/tenant isolation; audit results remain restricted to server events.
|
|
12
|
+
|
|
13
|
+
Support an optional exact eventName filter, combined with category and search before counting and pagination.
|
|
14
|
+
|
|
15
|
+
Add an Action dropdown with a filter icon as the first toolbar menu in controlled AuditLogTable instances. Accept an application-owned events catalog of { value, label } options, use the labels in both the dropdown and Action column, and include All actions to clear the selection. Reset pagination when the event changes and preserve it across table query updates. Export EventQuery and EventQueryStandard for shared table and route state.
|
|
16
|
+
|
|
17
|
+
Display recorded target names with type and ID as secondary text. For older events whose target name is missing or duplicates the ID, show the target type above the ID instead. Target names remain event-time snapshots, not current entity lookups.
|
|
18
|
+
|
|
19
|
+
Migration required: replace Events.listAudit with Events.list({ ...query, organizationId, category: "audit" }), replace ListAudit with ListEvents, remove AuditActor/actors wiring, and use EventQuery / EventQueryStandard through API, client, and route query state to preserve eventName. Populate events with the full application event catalog and localized labels. Existing events are not backfilled.
|
|
20
|
+
|
|
3
21
|
## 0.1.54
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -289,10 +289,13 @@ var ErrorComponent = ({
|
|
|
289
289
|
...messages?.[locale.split("-")[0] ?? locale],
|
|
290
290
|
...messages?.[locale]
|
|
291
291
|
}), [locale, messages]);
|
|
292
|
-
const
|
|
292
|
+
const standardError = error instanceof Error ? error : undefined;
|
|
293
|
+
const errorName = standardError?.name ?? labels.errorLabel;
|
|
294
|
+
const errorMessage = standardError?.message.trim() || labels.description;
|
|
295
|
+
const reference = diagnostics?.reference ?? (standardError ? getErrorTraceId(standardError) : undefined);
|
|
293
296
|
const report = useMemo(() => [
|
|
294
|
-
`${labels.errorLabel}: ${
|
|
295
|
-
`${labels.messageLabel}: ${
|
|
297
|
+
`${labels.errorLabel}: ${errorName}`,
|
|
298
|
+
`${labels.messageLabel}: ${errorMessage}`,
|
|
296
299
|
"",
|
|
297
300
|
`${labels.pageLabel}: ${pathname}`,
|
|
298
301
|
`${labels.timeLabel}: ${new Date().toISOString()}`,
|
|
@@ -302,7 +305,8 @@ var ErrorComponent = ({
|
|
|
302
305
|
...reference ? [`${labels.referenceLabel}: ${reference}`] : []
|
|
303
306
|
].join(`
|
|
304
307
|
`), [
|
|
305
|
-
|
|
308
|
+
errorName,
|
|
309
|
+
errorMessage,
|
|
306
310
|
pathname,
|
|
307
311
|
locale,
|
|
308
312
|
labels,
|
|
@@ -328,7 +332,7 @@ var ErrorComponent = ({
|
|
|
328
332
|
})
|
|
329
333
|
}),
|
|
330
334
|
/* @__PURE__ */ jsx5(EmptyDescription, {
|
|
331
|
-
children:
|
|
335
|
+
children: errorMessage
|
|
332
336
|
})
|
|
333
337
|
]
|
|
334
338
|
}),
|
|
@@ -103,7 +103,7 @@ export declare const FieldWrapper: ({ children, legend, localized, description,
|
|
|
103
103
|
value: string;
|
|
104
104
|
}[];
|
|
105
105
|
}) => JSX.Element;
|
|
106
|
-
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/
|
|
106
|
+
declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/form-core").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
107
107
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
108
108
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
109
109
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -160,7 +160,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
160
160
|
locale?: string;
|
|
161
161
|
messages?: FormMessageTranslations;
|
|
162
162
|
}) => JSX.Element;
|
|
163
|
-
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/
|
|
163
|
+
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
164
164
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
165
165
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
166
166
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -218,7 +218,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
218
218
|
messages?: FormMessageTranslations;
|
|
219
219
|
}) => JSX.Element;
|
|
220
220
|
}, TRenderProps>) => import("react").FunctionComponent<import("react").PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
221
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/
|
|
221
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
222
222
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
223
223
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
224
224
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -333,8 +333,8 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
|
|
|
333
333
|
locale?: string;
|
|
334
334
|
messages?: FormMessageTranslations;
|
|
335
335
|
}) => JSX.Element;
|
|
336
|
-
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/
|
|
337
|
-
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/
|
|
336
|
+
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/form-core").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/form-core").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
|
|
337
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/form-core").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
338
338
|
readonly TextField: ({ children, ...props }: React.ComponentProps<"input"> & DefaultOptions) => JSX.Element;
|
|
339
339
|
readonly TextAreaField: ({ children, ...props }: React.ComponentProps<"textarea"> & DefaultOptions) => JSX.Element;
|
|
340
340
|
readonly SelectField: ({ description, label, multiple, options, placeholder, }: SelectFieldProps) => JSX.Element;
|
|
@@ -407,10 +407,16 @@ var TrackEvent = Schema5.Union([
|
|
|
407
407
|
target: AuditTarget
|
|
408
408
|
})
|
|
409
409
|
]).annotate({ identifier: "TrackEvent" });
|
|
410
|
-
var
|
|
410
|
+
var EventQuery = Schema5.Struct({
|
|
411
|
+
...Query.fields,
|
|
412
|
+
eventName: Schema5.optional(trackEventFields.name)
|
|
413
|
+
}).annotate({ identifier: "EventQuery" });
|
|
414
|
+
var EventQueryStandard = Schema5.toStandardSchemaV1(EventQuery);
|
|
415
|
+
var ListEvents = Schema5.Struct({
|
|
411
416
|
organizationId: Schema5.NonEmptyString,
|
|
412
|
-
|
|
413
|
-
|
|
417
|
+
category: Schema5.Literals(["audit", "analytics"]),
|
|
418
|
+
...EventQuery.fields
|
|
419
|
+
}).annotate({ identifier: "ListEvents" });
|
|
414
420
|
var AuditSortId = Schema5.Literals([
|
|
415
421
|
"time",
|
|
416
422
|
"eventName",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { type
|
|
3
|
-
import type { EventLogRecord } from "../schema.js";
|
|
2
|
+
import { type DataTableStatus } from "../../../components/ui/data-table.js";
|
|
3
|
+
import type { EventLogRecord, EventQuery } from "../schema.js";
|
|
4
4
|
declare const translations: {
|
|
5
5
|
en: {
|
|
6
6
|
title: string;
|
|
7
|
+
event: string;
|
|
8
|
+
allEvents: string;
|
|
7
9
|
time: string;
|
|
8
10
|
action: string;
|
|
9
11
|
target: string;
|
|
@@ -18,6 +20,8 @@ declare const translations: {
|
|
|
18
20
|
};
|
|
19
21
|
fr: {
|
|
20
22
|
title: string;
|
|
23
|
+
event: string;
|
|
24
|
+
allEvents: string;
|
|
21
25
|
time: string;
|
|
22
26
|
action: string;
|
|
23
27
|
target: string;
|
|
@@ -32,22 +36,23 @@ declare const translations: {
|
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
export type AuditLogMessages = typeof translations.en;
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
export type AuditLogTableProps = DataTableStatus & {
|
|
40
|
+
/** Full application-owned event catalog, with localized display labels. */
|
|
41
|
+
events?: readonly {
|
|
42
|
+
value: string;
|
|
43
|
+
label: string;
|
|
44
|
+
}[];
|
|
45
|
+
state?: EventQuery;
|
|
46
|
+
onStateChange?: (state: EventQuery) => void;
|
|
40
47
|
entries: readonly EventLogRecord[];
|
|
41
48
|
/** Total matching records from the query response; paging lives in state. */
|
|
42
49
|
rowCount: number;
|
|
50
|
+
/** Display time zone for the dateTime column. Defaults to America/New_York. */
|
|
51
|
+
timeZone?: string;
|
|
43
52
|
/** Overrides the shared KrakstackProvider locale when supplied. */
|
|
44
53
|
locale?: string;
|
|
45
54
|
messages?: Readonly<Record<string, Partial<AuditLogMessages>>>;
|
|
46
|
-
/** Current profiles the viewer may access. Matched by type and ID, including user impersonators.
|
|
47
|
-
* Missing profiles use neutral labels: the list may be loading, incomplete, or unavailable.
|
|
48
|
-
*/
|
|
49
|
-
actors?: readonly AuditActor[];
|
|
50
55
|
renderAction?: (entry: EventLogRecord) => ReactNode;
|
|
51
56
|
};
|
|
52
|
-
export declare const AuditLogTable: ({ entries, rowCount, locale: localeOverride, messages,
|
|
57
|
+
export declare const AuditLogTable: ({ entries, events, rowCount, timeZone, locale: localeOverride, messages, renderAction, state, onStateChange, ...status }: AuditLogTableProps) => import("react").JSX.Element;
|
|
53
58
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// ../../src/services/events/client/audit-log-table.tsx
|
|
2
|
+
import { ListFilterIcon } from "lucide-react";
|
|
3
|
+
|
|
1
4
|
// ../../src/components/ui/data-table.tsx
|
|
2
5
|
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
3
6
|
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
@@ -3501,7 +3504,9 @@ var eventTextAttribute = (record, key) => Schema2.decodeUnknownOption(TextValue)
|
|
|
3501
3504
|
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3502
3505
|
var translations = {
|
|
3503
3506
|
en: {
|
|
3504
|
-
title: "
|
|
3507
|
+
title: "Activity history",
|
|
3508
|
+
event: "Action",
|
|
3509
|
+
allEvents: "All actions",
|
|
3505
3510
|
time: "Time",
|
|
3506
3511
|
action: "Action",
|
|
3507
3512
|
target: "Target",
|
|
@@ -3515,7 +3520,9 @@ var translations = {
|
|
|
3515
3520
|
methodUnknown: "Unknown"
|
|
3516
3521
|
},
|
|
3517
3522
|
fr: {
|
|
3518
|
-
title: "
|
|
3523
|
+
title: "Historique d’activité",
|
|
3524
|
+
event: "Action",
|
|
3525
|
+
allEvents: "Toutes les actions",
|
|
3519
3526
|
time: "Date",
|
|
3520
3527
|
action: "Action",
|
|
3521
3528
|
target: "Cible",
|
|
@@ -3531,10 +3538,11 @@ var translations = {
|
|
|
3531
3538
|
};
|
|
3532
3539
|
var AuditLogTable = ({
|
|
3533
3540
|
entries,
|
|
3541
|
+
events = [],
|
|
3534
3542
|
rowCount,
|
|
3543
|
+
timeZone = "America/New_York",
|
|
3535
3544
|
locale: localeOverride,
|
|
3536
3545
|
messages,
|
|
3537
|
-
actors = [],
|
|
3538
3546
|
renderAction,
|
|
3539
3547
|
state,
|
|
3540
3548
|
onStateChange,
|
|
@@ -3552,18 +3560,20 @@ var AuditLogTable = ({
|
|
|
3552
3560
|
["session", labels.methodSession],
|
|
3553
3561
|
["api_key", labels.methodApiKey]
|
|
3554
3562
|
]);
|
|
3555
|
-
const actorsByKey = new Map(actors.map((actor) => [`${actor.type}:${actor.id}`, actor]));
|
|
3556
3563
|
const getActor = (entry) => {
|
|
3557
3564
|
const type = eventTextAttribute(entry, "app.actor.type");
|
|
3558
|
-
const id = eventTextAttribute(entry, "app.actor.id");
|
|
3559
|
-
const actor = actorsByKey.get(`${type}:${id}`);
|
|
3560
|
-
if (actor)
|
|
3561
|
-
return actor;
|
|
3565
|
+
const id = eventTextAttribute(entry, "app.actor.id") ?? eventTextAttribute(entry, "user.id");
|
|
3562
3566
|
if (type === "organization") {
|
|
3563
3567
|
return { label: labels.actorOrganization, description: id };
|
|
3564
3568
|
}
|
|
3565
|
-
if (type === "user") {
|
|
3566
|
-
|
|
3569
|
+
if (type === "user" || eventTextAttribute(entry, "user.id") !== null) {
|
|
3570
|
+
const fullName = eventTextAttribute(entry, "user.full_name");
|
|
3571
|
+
const name = eventTextAttribute(entry, "user.name");
|
|
3572
|
+
const email = eventTextAttribute(entry, "user.email");
|
|
3573
|
+
return {
|
|
3574
|
+
label: fullName || name || email || labels.actorMember,
|
|
3575
|
+
description: fullName || name ? email || id : id
|
|
3576
|
+
};
|
|
3567
3577
|
}
|
|
3568
3578
|
return { label: type ?? labels.actor, description: id };
|
|
3569
3579
|
};
|
|
@@ -3572,12 +3582,13 @@ var AuditLogTable = ({
|
|
|
3572
3582
|
colId: "time",
|
|
3573
3583
|
headerName: labels.time,
|
|
3574
3584
|
type: "dateTime",
|
|
3585
|
+
typeOptions: { timeZone },
|
|
3575
3586
|
valueGetter: ({ data }) => new Date(Number(BigInt(data.timeUnixNano) / 1000000n))
|
|
3576
3587
|
},
|
|
3577
3588
|
{
|
|
3578
3589
|
field: "eventName",
|
|
3579
3590
|
headerName: labels.action,
|
|
3580
|
-
cellRenderer: ({ data }) => renderAction?.(data) ?? data.eventName
|
|
3591
|
+
cellRenderer: ({ data }) => renderAction?.(data) ?? events.find((event) => event.value === data.eventName)?.label ?? data.eventName
|
|
3581
3592
|
},
|
|
3582
3593
|
{
|
|
3583
3594
|
colId: "record",
|
|
@@ -3588,9 +3599,10 @@ var AuditLogTable = ({
|
|
|
3588
3599
|
getItem: (entry) => {
|
|
3589
3600
|
const id = eventTextAttribute(entry, "app.audit.target.id");
|
|
3590
3601
|
const name = eventTextAttribute(entry, "app.audit.target.name");
|
|
3602
|
+
const type = eventTextAttribute(entry, "app.audit.target.type");
|
|
3591
3603
|
return id === null ? null : {
|
|
3592
|
-
label: name ||
|
|
3593
|
-
description: name && name !== id ? id :
|
|
3604
|
+
label: name && name !== id ? name : type || labels.target,
|
|
3605
|
+
description: name && name !== id && type ? `${type} · ${id}` : id
|
|
3594
3606
|
};
|
|
3595
3607
|
}
|
|
3596
3608
|
}
|
|
@@ -3615,9 +3627,8 @@ var AuditLogTable = ({
|
|
|
3615
3627
|
className: "text-muted-foreground text-xs",
|
|
3616
3628
|
children: [
|
|
3617
3629
|
labels.impersonatedBy,
|
|
3618
|
-
":",
|
|
3619
|
-
|
|
3620
|
-
actorsByKey.get(`user:${impersonatorId}`)?.label ?? impersonatorId
|
|
3630
|
+
": ",
|
|
3631
|
+
impersonatorId
|
|
3621
3632
|
]
|
|
3622
3633
|
}) : null
|
|
3623
3634
|
]
|
|
@@ -3636,12 +3647,55 @@ var AuditLogTable = ({
|
|
|
3636
3647
|
];
|
|
3637
3648
|
return /* @__PURE__ */ jsx15("section", {
|
|
3638
3649
|
"aria-label": labels.title,
|
|
3650
|
+
className: "flex flex-col gap-4",
|
|
3639
3651
|
children: /* @__PURE__ */ jsx15(DataTable, {
|
|
3640
3652
|
locale,
|
|
3641
3653
|
status,
|
|
3642
3654
|
state,
|
|
3643
|
-
onStateChange
|
|
3655
|
+
onStateChange: onStateChange ? (next) => onStateChange({
|
|
3656
|
+
...next,
|
|
3657
|
+
eventName: state?.eventName
|
|
3658
|
+
}) : undefined,
|
|
3644
3659
|
features: {
|
|
3660
|
+
toolbar: state && onStateChange ? {
|
|
3661
|
+
items: /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
3662
|
+
children: [
|
|
3663
|
+
/* @__PURE__ */ jsxs9(MenubarTrigger, {
|
|
3664
|
+
children: [
|
|
3665
|
+
/* @__PURE__ */ jsx15(ListFilterIcon, {
|
|
3666
|
+
"aria-hidden": "true",
|
|
3667
|
+
"data-icon": "inline-start"
|
|
3668
|
+
}),
|
|
3669
|
+
labels.event,
|
|
3670
|
+
state.eventName ? `: ${events.find((event) => event.value === state.eventName)?.label ?? state.eventName}` : ""
|
|
3671
|
+
]
|
|
3672
|
+
}),
|
|
3673
|
+
/* @__PURE__ */ jsx15(MenubarContent, {
|
|
3674
|
+
className: "w-80",
|
|
3675
|
+
children: /* @__PURE__ */ jsxs9(MenubarGroup, {
|
|
3676
|
+
children: [
|
|
3677
|
+
/* @__PURE__ */ jsx15(MenubarItem, {
|
|
3678
|
+
onClick: () => onStateChange({
|
|
3679
|
+
...state,
|
|
3680
|
+
eventName: undefined,
|
|
3681
|
+
page: 0
|
|
3682
|
+
}),
|
|
3683
|
+
children: labels.allEvents
|
|
3684
|
+
}),
|
|
3685
|
+
events.map((event) => /* @__PURE__ */ jsx15(MenubarItem, {
|
|
3686
|
+
onClick: () => onStateChange({
|
|
3687
|
+
...state,
|
|
3688
|
+
eventName: event.value,
|
|
3689
|
+
page: 0
|
|
3690
|
+
}),
|
|
3691
|
+
children: event.label
|
|
3692
|
+
}, event.value))
|
|
3693
|
+
]
|
|
3694
|
+
})
|
|
3695
|
+
})
|
|
3696
|
+
]
|
|
3697
|
+
})
|
|
3698
|
+
} : false,
|
|
3645
3699
|
pagination: { mode: "server", rowCount }
|
|
3646
3700
|
},
|
|
3647
3701
|
columnDefs: columns,
|
|
@@ -6,7 +6,7 @@ import { OtlpEvents } from "../opentelemetry/events.js";
|
|
|
6
6
|
import { EventIdentity, EventGeolocation, EventConflictError, EventsPersistenceError } from "./schema.js";
|
|
7
7
|
export declare const SESSION_TIMEOUT_MS: number;
|
|
8
8
|
export type { EventGeolocation } from "./schema.js";
|
|
9
|
-
export { AuditTarget, TrackEvent, EventLogRecord,
|
|
9
|
+
export { AuditTarget, TrackEvent, EventLogRecord, ListEvents } from "./schema.js";
|
|
10
10
|
export type EventGeolocationResolver = (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<EventGeolocation | null, unknown>;
|
|
11
11
|
export interface EventsOptions {
|
|
12
12
|
/** Enforce the shared browser preference for ingestion and request-scoped analytics. */
|
|
@@ -71,7 +71,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
71
71
|
eventId: string;
|
|
72
72
|
inserted: boolean;
|
|
73
73
|
}, EventConflictError | EventsPersistenceError | import("effect/PlatformError").PlatformError | Schema.SchemaError, never>;
|
|
74
|
-
|
|
74
|
+
list: (input: {
|
|
75
75
|
readonly page?: string | number | undefined;
|
|
76
76
|
readonly pageSize?: string | number | undefined;
|
|
77
77
|
readonly globalFilter?: string | undefined;
|
|
@@ -79,7 +79,9 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
79
79
|
readonly id: string;
|
|
80
80
|
readonly direction: "asc" | "desc";
|
|
81
81
|
}[] | undefined;
|
|
82
|
+
readonly eventName?: string | undefined;
|
|
82
83
|
readonly organizationId: string;
|
|
84
|
+
readonly category: "analytics" | "audit";
|
|
83
85
|
}) => Effect.Effect<{
|
|
84
86
|
data: {
|
|
85
87
|
readonly eventName: string;
|
|
@@ -159,7 +161,7 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
159
161
|
eventId: string;
|
|
160
162
|
inserted: boolean;
|
|
161
163
|
}, EventConflictError | EventsPersistenceError | import("effect/PlatformError").PlatformError | Schema.SchemaError, never>;
|
|
162
|
-
|
|
164
|
+
list: (input: {
|
|
163
165
|
readonly page?: string | number | undefined;
|
|
164
166
|
readonly pageSize?: string | number | undefined;
|
|
165
167
|
readonly globalFilter?: string | undefined;
|
|
@@ -167,7 +169,9 @@ declare const Events_base: Context.ServiceClass<Events, "krakstack/events/Events
|
|
|
167
169
|
readonly id: string;
|
|
168
170
|
readonly direction: "asc" | "desc";
|
|
169
171
|
}[] | undefined;
|
|
172
|
+
readonly eventName?: string | undefined;
|
|
170
173
|
readonly organizationId: string;
|
|
174
|
+
readonly category: "analytics" | "audit";
|
|
171
175
|
}) => Effect.Effect<{
|
|
172
176
|
data: {
|
|
173
177
|
readonly eventName: string;
|
|
@@ -395,10 +395,16 @@ var TrackEvent = Schema6.Union([
|
|
|
395
395
|
target: AuditTarget
|
|
396
396
|
})
|
|
397
397
|
]).annotate({ identifier: "TrackEvent" });
|
|
398
|
-
var
|
|
398
|
+
var EventQuery = Schema6.Struct({
|
|
399
|
+
...Query.fields,
|
|
400
|
+
eventName: Schema6.optional(trackEventFields.name)
|
|
401
|
+
}).annotate({ identifier: "EventQuery" });
|
|
402
|
+
var EventQueryStandard = Schema6.toStandardSchemaV1(EventQuery);
|
|
403
|
+
var ListEvents = Schema6.Struct({
|
|
399
404
|
organizationId: Schema6.NonEmptyString,
|
|
400
|
-
|
|
401
|
-
|
|
405
|
+
category: Schema6.Literals(["audit", "analytics"]),
|
|
406
|
+
...EventQuery.fields
|
|
407
|
+
}).annotate({ identifier: "ListEvents" });
|
|
402
408
|
var AuditSortId = Schema6.Literals([
|
|
403
409
|
"time",
|
|
404
410
|
"eventName",
|
|
@@ -819,7 +825,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
819
825
|
attributes[name] = value;
|
|
820
826
|
}
|
|
821
827
|
Object.assign(attributes, identityAttributes(identity));
|
|
822
|
-
Object.assign(attributes, Object.fromEntries(Object.entries(annotations).filter(([key]) =>
|
|
828
|
+
Object.assign(attributes, Object.fromEntries(Object.entries(annotations).filter(([key]) => (category === "audit" || !["user.full_name", "user.name", "user.email"].includes(key)) && key !== "user.image" && key !== "app.user.image")));
|
|
823
829
|
attributes["log.record.uid"] = eventId;
|
|
824
830
|
if (event.category === "audit") {
|
|
825
831
|
attributes["app.audit.target.id"] = event.target.id;
|
|
@@ -880,8 +886,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
880
886
|
operation: "track"
|
|
881
887
|
})));
|
|
882
888
|
});
|
|
883
|
-
const
|
|
884
|
-
const request = yield* Schema9.decodeUnknownEffect(
|
|
889
|
+
const list = Effect8.fn("Events.list")(function* (input) {
|
|
890
|
+
const request = yield* Schema9.decodeUnknownEffect(ListEvents)(input);
|
|
885
891
|
if (!storage)
|
|
886
892
|
return yield* new EventsPersistenceError({
|
|
887
893
|
operation: "persistence-disabled"
|
|
@@ -908,17 +914,8 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
908
914
|
const id = yield* Schema9.decodeUnknownEffect(AuditSortId)(part.id);
|
|
909
915
|
return sql`${sortColumns[id]} ${sql.literal(part.direction === "desc" ? "DESC" : "ASC")}`;
|
|
910
916
|
}));
|
|
911
|
-
const category = sql
|
|
912
|
-
|
|
913
|
-
orElse: () => sql`EXISTS (
|
|
914
|
-
SELECT 1 FROM json_each(payload_json, '$.resourceLogs') AS resource,
|
|
915
|
-
json_each(resource.value, '$.scopeLogs') AS scope,
|
|
916
|
-
json_each(scope.value, '$.logRecords') AS record,
|
|
917
|
-
json_each(record.value, '$.attributes') AS attribute
|
|
918
|
-
WHERE json_extract(attribute.value, '$.key') = 'app.event.category'
|
|
919
|
-
AND json_extract(attribute.value, '$.value.stringValue') = 'audit'
|
|
920
|
-
)`
|
|
921
|
-
});
|
|
917
|
+
const source = request.category === "audit" ? sql`AND source = 'server'` : sql``;
|
|
918
|
+
const event = request.eventName ? sql`AND event_name = ${request.eventName}` : sql``;
|
|
922
919
|
const search = request.globalFilter?.trim();
|
|
923
920
|
const filter = search ? sql`AND ${sql.or([
|
|
924
921
|
sql`LOWER(event_name) LIKE ${`%${search.toLowerCase()}%`}`,
|
|
@@ -932,14 +929,14 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
932
929
|
].map((key) => sql`LOWER(${text(key)}) LIKE ${`%${search.toLowerCase()}%`}`)
|
|
933
930
|
])}` : sql``;
|
|
934
931
|
const predicate = sql`service_name = ${configuration.serviceName} AND organization_id = ${request.organizationId}
|
|
935
|
-
AND
|
|
932
|
+
AND ${text("app.event.category")} = ${request.category} ${source} ${event} ${filter}`;
|
|
936
933
|
const total = yield* SqlSchema.findOne({
|
|
937
|
-
Request:
|
|
934
|
+
Request: ListEvents,
|
|
938
935
|
Result: AuditCount,
|
|
939
936
|
execute: () => sql`SELECT CAST(COUNT(*) AS INTEGER) AS total FROM events WHERE ${predicate}`
|
|
940
937
|
})(request);
|
|
941
938
|
const find = SqlSchema.findAll({
|
|
942
|
-
Request:
|
|
939
|
+
Request: ListEvents,
|
|
943
940
|
Result: StoredEventPayload,
|
|
944
941
|
execute: () => sql`
|
|
945
942
|
SELECT payload_json FROM events
|
|
@@ -1092,7 +1089,7 @@ class Events extends Context4.Service()("krakstack/events/Events", {
|
|
|
1092
1089
|
status: error._tag === "EventConflictError" ? 409 : 503
|
|
1093
1090
|
})));
|
|
1094
1091
|
});
|
|
1095
|
-
return { process, track,
|
|
1092
|
+
return { process, track, list };
|
|
1096
1093
|
})
|
|
1097
1094
|
}) {
|
|
1098
1095
|
static baseLayerWith = (options = {}) => Layer3.effect(this, Effect8.gen(function* () {
|
|
@@ -1124,7 +1121,7 @@ export {
|
|
|
1124
1121
|
EventLogRecord,
|
|
1125
1122
|
Events,
|
|
1126
1123
|
EventsConfigurationError,
|
|
1127
|
-
|
|
1124
|
+
ListEvents,
|
|
1128
1125
|
SESSION_TIMEOUT_MS,
|
|
1129
1126
|
TrackEvent,
|
|
1130
1127
|
dailyVisitorId
|
|
@@ -72,7 +72,7 @@ export declare const TrackEvent: Schema.Union<readonly [Schema.Struct<{
|
|
|
72
72
|
}>;
|
|
73
73
|
}>]>;
|
|
74
74
|
export type TrackEvent = typeof TrackEvent.Type;
|
|
75
|
-
export declare const
|
|
75
|
+
export declare const EventQuery: Schema.Struct<{
|
|
76
76
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
77
77
|
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
78
78
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
@@ -83,7 +83,57 @@ export declare const ListAudit: Schema.Struct<{
|
|
|
83
83
|
readonly id: string;
|
|
84
84
|
readonly direction: "asc" | "desc";
|
|
85
85
|
}[]>>;
|
|
86
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
87
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
88
|
+
}>;
|
|
89
|
+
export type EventQuery = typeof EventQuery.Type;
|
|
90
|
+
export declare const EventQueryStandard: import("effect/StandardSchema").StandardSchemaV1<{
|
|
91
|
+
readonly page?: string | number | undefined;
|
|
92
|
+
readonly pageSize?: string | number | undefined;
|
|
93
|
+
readonly globalFilter?: string | undefined;
|
|
94
|
+
readonly sort?: readonly {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly direction: "asc" | "desc";
|
|
97
|
+
}[] | undefined;
|
|
98
|
+
readonly eventName?: string | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
readonly page: number;
|
|
101
|
+
readonly pageSize: number;
|
|
102
|
+
readonly globalFilter?: string | undefined;
|
|
103
|
+
readonly sort?: readonly {
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly direction: "asc" | "desc";
|
|
106
|
+
}[] | undefined;
|
|
107
|
+
readonly eventName?: string | undefined;
|
|
108
|
+
}> & Schema.Struct<{
|
|
109
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
110
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
111
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
112
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
113
|
+
readonly id: string;
|
|
114
|
+
readonly direction: "asc" | "desc";
|
|
115
|
+
}[], readonly {
|
|
116
|
+
readonly id: string;
|
|
117
|
+
readonly direction: "asc" | "desc";
|
|
118
|
+
}[]>>;
|
|
119
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
120
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
121
|
+
}>;
|
|
122
|
+
export declare const ListEvents: Schema.Struct<{
|
|
123
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
124
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
125
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
126
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly direction: "asc" | "desc";
|
|
129
|
+
}[], readonly {
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly direction: "asc" | "desc";
|
|
132
|
+
}[]>>;
|
|
133
|
+
/** Exact, case-sensitive event name; combined with category and query filters. */
|
|
134
|
+
readonly eventName: Schema.optional<Schema.NonEmptyString>;
|
|
86
135
|
readonly organizationId: Schema.NonEmptyString;
|
|
136
|
+
readonly category: Schema.Literals<readonly ["audit", "analytics"]>;
|
|
87
137
|
}>;
|
|
88
138
|
export declare const AuditSortId: Schema.Literals<readonly ["time", "eventName", "recordType", "record", "actorType", "actorId"]>;
|
|
89
139
|
export declare const AuditCount: Schema.Struct<{
|
|
@@ -229,10 +229,16 @@ var TrackEvent = Schema3.Union([
|
|
|
229
229
|
target: AuditTarget
|
|
230
230
|
})
|
|
231
231
|
]).annotate({ identifier: "TrackEvent" });
|
|
232
|
-
var
|
|
232
|
+
var EventQuery = Schema3.Struct({
|
|
233
|
+
...Query.fields,
|
|
234
|
+
eventName: Schema3.optional(trackEventFields.name)
|
|
235
|
+
}).annotate({ identifier: "EventQuery" });
|
|
236
|
+
var EventQueryStandard = Schema3.toStandardSchemaV1(EventQuery);
|
|
237
|
+
var ListEvents = Schema3.Struct({
|
|
233
238
|
organizationId: Schema3.NonEmptyString,
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
category: Schema3.Literals(["audit", "analytics"]),
|
|
240
|
+
...EventQuery.fields
|
|
241
|
+
}).annotate({ identifier: "ListEvents" });
|
|
236
242
|
var AuditSortId = Schema3.Literals([
|
|
237
243
|
"time",
|
|
238
244
|
"eventName",
|
|
@@ -354,12 +360,14 @@ export {
|
|
|
354
360
|
EventIdentity,
|
|
355
361
|
EventIpAddress,
|
|
356
362
|
EventLogRecord,
|
|
363
|
+
EventQuery,
|
|
364
|
+
EventQueryStandard,
|
|
357
365
|
EventRegion,
|
|
358
366
|
EventSource,
|
|
359
367
|
EventUuid,
|
|
360
368
|
EventsPersistenceError,
|
|
361
369
|
ExistingEventRequest,
|
|
362
|
-
|
|
370
|
+
ListEvents,
|
|
363
371
|
OtlpLogs,
|
|
364
372
|
RequestActorAttribution,
|
|
365
373
|
StoredEventId,
|