@krak-stack/registry 0.11.6 → 0.11.9

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 (123) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +39 -0
  3. package/dist/components/app-switcher/html.d.ts +2 -2
  4. package/dist/components/asset-input/html.d.ts +70 -0
  5. package/dist/components/asset-input/html.js +1549 -0
  6. package/dist/components/asset-input/index.d.ts +280 -0
  7. package/dist/components/asset-input/react.d.ts +32 -0
  8. package/dist/components/asset-input/react.js +2269 -0
  9. package/dist/components/asset-input/schema.d.ts +93 -0
  10. package/dist/components/asset-input/upload.d.ts +15 -0
  11. package/dist/components/asset-table/html.d.ts +110 -0
  12. package/dist/components/asset-table/html.js +4934 -0
  13. package/dist/components/asset-table/index.d.ts +225 -0
  14. package/dist/components/asset-table/react.d.ts +21 -0
  15. package/dist/components/asset-table/react.js +8241 -0
  16. package/dist/components/asset-table/schema.d.ts +73 -0
  17. package/dist/components/audit-log-table/classes.d.ts +1 -0
  18. package/dist/components/audit-log-table/html.d.ts +158 -0
  19. package/dist/components/audit-log-table/html.js +3294 -0
  20. package/dist/components/audit-log-table/index.d.ts +37 -0
  21. package/dist/components/audit-log-table/react.d.ts +3 -51
  22. package/dist/components/audit-log-table/react.js +130 -89
  23. package/dist/components/audit-log-table/schema.d.ts +122 -0
  24. package/dist/components/danger-confirmation/html.d.ts +2 -2
  25. package/dist/components/danger-confirmation/index.d.ts +2 -2
  26. package/dist/components/data-table/classes.d.ts +3 -0
  27. package/dist/components/data-table/html.d.ts +70 -12
  28. package/dist/components/data-table/html.js +56 -19
  29. package/dist/components/data-table/index.d.ts +51 -1
  30. package/dist/components/data-table/react.d.ts +1 -0
  31. package/dist/components/data-table/react.js +46 -16
  32. package/dist/components/data-table/schema.d.ts +93 -3
  33. package/dist/components/docs/html.js +22 -4
  34. package/dist/components/docs/react.js +33 -2
  35. package/dist/components/editable-text/html.d.ts +2 -2
  36. package/dist/components/editable-text/index.d.ts +4 -4
  37. package/dist/components/effect-form/react.js +343 -138
  38. package/dist/components/email-editor/legacy-editor.html.d.ts +6 -6
  39. package/dist/components/file-input/classes.d.ts +1 -1
  40. package/dist/components/file-input/file-type.d.ts +1 -0
  41. package/dist/components/file-input/html.d.ts +8 -1
  42. package/dist/components/file-input/html.js +170 -12
  43. package/dist/components/file-input/index.d.ts +1 -0
  44. package/dist/components/file-input/react.d.ts +9 -1
  45. package/dist/components/file-input/react.js +277 -127
  46. package/dist/components/file-input/schema.d.ts +1 -0
  47. package/dist/components/form/react.js +343 -138
  48. package/dist/components/icon-input/html.js +19 -5
  49. package/dist/components/icon-input/react.js +70 -13
  50. package/dist/components/map-menu/html.d.ts +6 -0
  51. package/dist/components/map-menu/html.js +13 -8
  52. package/dist/components/map-menu/index.d.ts +5 -4
  53. package/dist/components/map-menu/react.d.ts +28 -17
  54. package/dist/components/map-menu/react.js +84 -178
  55. package/dist/components/map-menu/schema.d.ts +6 -0
  56. package/dist/components/map-menu/shared.d.ts +4 -0
  57. package/dist/components/permissions-input/classes.d.ts +8 -0
  58. package/dist/components/permissions-input/html.d.ts +41 -0
  59. package/dist/components/permissions-input/html.js +130 -0
  60. package/dist/components/permissions-input/index.d.ts +80 -0
  61. package/dist/components/permissions-input/react.d.ts +7 -0
  62. package/dist/components/permissions-input/react.js +201 -0
  63. package/dist/components/permissions-input/schema.d.ts +33 -0
  64. package/dist/components/phone-number-input/html.js +48 -14
  65. package/dist/components/phone-number-input/react.js +67 -10
  66. package/dist/components/search-menu/html.d.ts +2 -2
  67. package/dist/components/select-with-custom-input/html.d.ts +2 -2
  68. package/dist/components/sidebar-layout/html.d.ts +3 -2
  69. package/dist/components/sidebar-layout/html.js +20 -2
  70. package/dist/components/sidebar-layout/index.d.ts +1 -0
  71. package/dist/components/sidebar-layout/react.js +33 -2
  72. package/dist/components/switch/react.d.ts +14 -0
  73. package/dist/components/switch/react.js +55 -0
  74. package/dist/components/theme-switcher/html.d.ts +2 -2
  75. package/dist/components/time-input/html.d.ts +2 -2
  76. package/dist/components/timezone-input/html.js +48 -14
  77. package/dist/components/timezone-input/react.js +67 -10
  78. package/dist/components/tracking-notice/classes.d.ts +6 -0
  79. package/dist/components/tracking-notice/html.d.ts +85 -0
  80. package/dist/components/tracking-notice/html.js +354 -0
  81. package/dist/components/tracking-notice/index.d.ts +95 -0
  82. package/dist/components/tracking-notice/react.d.ts +5 -27
  83. package/dist/components/tracking-notice/react.js +189 -59
  84. package/dist/components/tracking-notice/schema.d.ts +45 -0
  85. package/dist/components/upload-attachment/classes.d.ts +3 -2
  86. package/dist/components/upload-attachment/html.d.ts +5 -5
  87. package/dist/components/upload-attachment/html.js +7 -5
  88. package/dist/components/upload-attachment/react.d.ts +3 -1
  89. package/dist/components/upload-attachment/react.js +25 -17
  90. package/dist/components/virtualized-combobox/classes.d.ts +12 -0
  91. package/dist/components/virtualized-combobox/html.d.ts +42 -0
  92. package/dist/components/virtualized-combobox/html.js +48 -14
  93. package/dist/components/virtualized-combobox/index.d.ts +55 -4
  94. package/dist/components/virtualized-combobox/react.d.ts +6 -2
  95. package/dist/components/virtualized-combobox/react.js +67 -10
  96. package/dist/components/virtualized-combobox/schema.d.ts +60 -4
  97. package/dist/components/webhook-delivery-table/html.js +56 -19
  98. package/dist/components/webhook-delivery-table/react.js +46 -16
  99. package/dist/lib/access/index.d.ts +61 -0
  100. package/dist/lib/access/index.js +92 -0
  101. package/dist/lib/access/table/classes.d.ts +13 -0
  102. package/dist/lib/access/table/html.d.ts +39 -0
  103. package/dist/lib/access/table/html.js +157 -0
  104. package/dist/lib/access/table/index.d.ts +32 -0
  105. package/dist/lib/access/table/react.d.ts +3 -0
  106. package/dist/lib/access/table/react.js +195 -0
  107. package/dist/lib/access/table/schema.d.ts +43 -0
  108. package/dist/lib/docs.integrations.server.js +23 -1
  109. package/dist/lib/docs.js +33 -2
  110. package/dist/lib/docs.server.js +29 -2
  111. package/dist/lib/documentation-toolkit.js +23 -1
  112. package/dist/lib/effect-ui-adapter/use-model.d.ts +1 -1
  113. package/dist/lib/effect-ui-adapter/use-model.js +19 -11
  114. package/dist/lib/lucide-effect.d.ts +19 -19
  115. package/dist/lib/lucide-effect.js +38 -38
  116. package/dist/services/assets/library.d.ts +221 -0
  117. package/dist/services/assets/schema.d.ts +3 -0
  118. package/dist/services/assets/url.d.ts +12 -0
  119. package/dist/services/assets/use-library.d.ts +20 -0
  120. package/dist/services/events/browser.js +39 -26
  121. package/dist/services/events/index.js +23 -19
  122. package/dist/services/opentelemetry/web-vitals.js +27 -23
  123. package/package.json +21 -1
@@ -0,0 +1,37 @@
1
+ import type { EventLogRecord, EventQuery } from "../../services/events/schema.js";
2
+ import type { AuditLogMessages, AuditLogTableProps } from "./schema.js";
3
+ export declare const auditLogMessages: (locale: string, messages?: AuditLogTableProps["messages"]) => {
4
+ title: string;
5
+ event: string;
6
+ allEvents: string;
7
+ time: string;
8
+ action: string;
9
+ target: string;
10
+ actor: string;
11
+ method: string;
12
+ actorMember: string;
13
+ impersonatedBy: string;
14
+ actorOrganization: string;
15
+ methodApiKey: string;
16
+ methodSession: string;
17
+ methodUnknown: string;
18
+ };
19
+ export declare const auditTableState: (state?: EventQuery) => EventQuery | undefined;
20
+ export declare const auditRowId: (entry: EventLogRecord) => string;
21
+ export declare const auditRowTime: (entry: EventLogRecord) => number;
22
+ export declare const auditActionLabel: (entry: EventLogRecord, events: NonNullable<AuditLogTableProps["events"]>) => string;
23
+ export declare const auditActor: (entry: EventLogRecord, labels: AuditLogMessages) => {
24
+ label: string;
25
+ description: string | undefined;
26
+ };
27
+ export declare const auditTarget: (entry: EventLogRecord, labels: AuditLogMessages) => {
28
+ label: string;
29
+ description: string;
30
+ } | null;
31
+ export declare const auditImpersonation: (entry: EventLogRecord, labels: AuditLogMessages) => string | undefined;
32
+ export declare const auditMethod: (entry: EventLogRecord) => "api_key" | "session" | "unknown";
33
+ export declare const auditMethods: (labels: AuditLogMessages) => {
34
+ session: string;
35
+ api_key: string;
36
+ unknown: string;
37
+ };
@@ -1,58 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
2
  import { type DataTableStatus } from "../ui/data-table.js";
3
3
  import type { EventLogRecord, EventQuery } from "../../services/events/schema.js";
4
- declare const translations: {
5
- en: {
6
- title: string;
7
- event: string;
8
- allEvents: string;
9
- time: string;
10
- action: string;
11
- target: string;
12
- actor: string;
13
- method: string;
14
- actorMember: string;
15
- impersonatedBy: string;
16
- actorOrganization: string;
17
- methodApiKey: string;
18
- methodSession: string;
19
- methodUnknown: string;
20
- };
21
- fr: {
22
- title: string;
23
- event: string;
24
- allEvents: string;
25
- time: string;
26
- action: string;
27
- target: string;
28
- actor: string;
29
- method: string;
30
- actorMember: string;
31
- impersonatedBy: string;
32
- actorOrganization: string;
33
- methodApiKey: string;
34
- methodSession: string;
35
- methodUnknown: string;
36
- };
37
- };
38
- export type AuditLogMessages = typeof translations.en;
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;
4
+ import type { AuditLogTableProps as CommonProps } from "./schema.js";
5
+ export type { AuditLogMessages } from "./schema.js";
6
+ export type AuditLogTableProps = Omit<CommonProps, keyof DataTableStatus> & DataTableStatus & {
46
7
  onStateChange?: (state: EventQuery) => void;
47
- entries: readonly EventLogRecord[];
48
- /** Total matching records from the query response; paging lives in state. */
49
- rowCount: number;
50
- /** Display time zone for the dateTime column. Defaults to America/New_York. */
51
- timeZone?: string;
52
- /** Overrides the shared KrakstackProvider locale when supplied. */
53
- locale?: string;
54
- messages?: Readonly<Record<string, Partial<AuditLogMessages>>>;
55
8
  renderAction?: (entry: EventLogRecord) => ReactNode;
56
9
  };
57
10
  export declare const AuditLogTable: ({ entries, events, rowCount, timeZone, locale: localeOverride, messages, renderAction, state, onStateChange, ...status }: AuditLogTableProps) => import("react").JSX.Element;
58
- export {};
@@ -635,6 +635,7 @@ var tableClasses = {
635
635
  actionTrigger: `size-8 ${cellTriggerFocus}`,
636
636
  actionsCell: "sticky right-0 z-20 w-10 min-w-10 cursor-default bg-background p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
637
637
  actionsAlign: "flex min-h-12 items-center justify-end pe-1",
638
+ row: "h-16 [&:where(:not(:last-child))>td]:border-b",
638
639
  header: "relative h-12 p-0",
639
640
  stickyHeader: "sticky top-0 z-30 bg-background",
640
641
  stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
@@ -652,6 +653,7 @@ var tableClasses = {
652
653
  referenceName: "truncate font-medium",
653
654
  referenceDescription: "text-muted-foreground truncate text-xs"
654
655
  };
656
+ var tableResultsFooterClass = "bg-background text-muted-foreground sticky bottom-0 z-30 shrink-0 border-t px-2 py-2 text-sm";
655
657
  var resolveTableClasses = (overrides) => ({
656
658
  ...tableClasses,
657
659
  ...overrides
@@ -706,6 +708,7 @@ var DataTableItemSchema = Schema4.Struct({
706
708
  value: Schema4.NonEmptyString,
707
709
  label: Schema4.String
708
710
  }).annotate({ identifier: "DataTableItem" });
711
+ var TableIconSchema = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableIcon" });
709
712
  var DataTableReferenceSchema = Schema4.Struct({
710
713
  label: Schema4.String,
711
714
  description: Schema4.optionalKey(Schema4.String),
@@ -745,11 +748,15 @@ var DataTableActionSchema = Schema4.Struct({
745
748
  variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
746
749
  disabled: Schema4.optionalKey(Schema4.Boolean)
747
750
  }).annotate({ identifier: "DataTableAction" });
751
+ var DataTableRowActionSchema = Schema4.Struct({
752
+ ...DataTableActionSchema.fields,
753
+ icon: Schema4.optionalKey(TableIconSchema)
754
+ }).annotate({ identifier: "DataTableRowAction" });
748
755
  var DataTableRowSchema = Schema4.Struct({
749
756
  id: Schema4.NonEmptyString,
750
757
  label: Schema4.String,
751
758
  cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
752
- actions: Schema4.optionalKey(Schema4.Array(DataTableActionSchema)),
759
+ actions: Schema4.optionalKey(Schema4.Array(DataTableRowActionSchema)),
753
760
  primaryActionId: Schema4.optionalKey(Schema4.String),
754
761
  groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
755
762
  selectable: Schema4.optionalKey(Schema4.Boolean),
@@ -784,11 +791,10 @@ var DataTableBadgeOptionSchema = Schema4.Struct({
784
791
  "muted"
785
792
  ]))
786
793
  }).annotate({ identifier: "DataTableBadgeOption" });
787
- var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
788
794
  var DataTableBadgeOptionsSchema = Schema4.Struct({
789
795
  options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
790
796
  ...fields,
791
- icon: Schema4.optionalKey(BadgeIcon)
797
+ icon: Schema4.optionalKey(TableIconSchema)
792
798
  }))))
793
799
  }).annotate({ identifier: "DataTableBadgeOptions" });
794
800
  var DataTableFieldSchema = Schema4.Union([
@@ -803,6 +809,7 @@ var DataTableFieldSchema = Schema4.Union([
803
809
  type: Schema4.Literal("number"),
804
810
  typeOptions: Schema4.optionalKey(Schema4.Struct({
805
811
  locale: Schema4.optionalKey(Schema4.String),
812
+ format: Schema4.optionalKey(Schema4.Literal("bytes")),
806
813
  style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
807
814
  currency: Schema4.optionalKey(Schema4.String),
808
815
  unit: Schema4.optionalKey(Schema4.String),
@@ -812,7 +819,14 @@ var DataTableFieldSchema = Schema4.Union([
812
819
  exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
813
820
  }).annotate({ identifier: "DataTableNumberFormat" }))
814
821
  }),
815
- Schema4.Struct({ ...column, type: Schema4.Literal("reference") }),
822
+ Schema4.Struct({
823
+ ...column,
824
+ type: Schema4.Literal("reference"),
825
+ typeOptions: Schema4.optionalKey(Schema4.Struct({
826
+ imageVariant: Schema4.optionalKey(Schema4.Literals(["circle", "square"])),
827
+ fallbackIcons: Schema4.optionalKey(Schema4.Record(Schema4.String, TableIconSchema))
828
+ }).annotate({ identifier: "DataTableReferenceOptions" }))
829
+ }),
816
830
  Schema4.Struct({
817
831
  ...column,
818
832
  type: Schema4.Literal("date"),
@@ -1091,9 +1105,17 @@ var isTableBoolean = Schema5.is(Schema5.Boolean);
1091
1105
  var isTableReference = Schema5.is(DataTableReferenceSchema);
1092
1106
  var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
1093
1107
  var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
1108
+ var formatBytes = (bytes, locale) => {
1109
+ const [unit, scale] = bytes >= 1024 ** 2 ? ["megabyte", 1024 ** 2] : bytes >= 1024 ? ["kilobyte", 1024] : ["byte", 1];
1110
+ return new Intl.NumberFormat(locale, {
1111
+ style: "unit",
1112
+ unit,
1113
+ maximumFractionDigits: 1
1114
+ }).format(bytes / scale);
1115
+ };
1094
1116
  var formatNumberValue = (value, options, defaultLocale = "en") => {
1095
- const { locale, ...format } = options ?? {};
1096
- return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
1117
+ const { locale, format, ...intlOptions } = options ?? {};
1118
+ return format === "bytes" ? formatBytes(value, locale ?? defaultLocale) : new Intl.NumberFormat(locale ?? defaultLocale, intlOptions).format(value);
1097
1119
  };
1098
1120
  var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
1099
1121
  var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
@@ -2026,6 +2048,7 @@ var DataTableReferenceCell = ({
2026
2048
  if (!item)
2027
2049
  return emptyLabel;
2028
2050
  const initials = tableInitials(item.label);
2051
+ const image = item.imageSrc && item.imageSrc !== failedImage ? item.imageSrc : undefined;
2029
2052
  return /* @__PURE__ */ jsxs3("div", {
2030
2053
  className: tableClasses.reference,
2031
2054
  children: [
@@ -2035,14 +2058,16 @@ var DataTableReferenceCell = ({
2035
2058
  "aria-hidden": "true",
2036
2059
  className: "[&_svg]:size-4",
2037
2060
  children: item.icon
2038
- }) : item.imageSrc && item.imageSrc !== failedImage ? /* @__PURE__ */ jsx3("img", {
2039
- src: item.imageSrc,
2040
- alt: item.label,
2061
+ }) : image ? /* @__PURE__ */ jsx3("img", {
2062
+ src: image,
2063
+ alt: item.fallbackIcon ? "" : item.label,
2064
+ loading: "lazy",
2041
2065
  className: "size-full object-cover",
2042
- onError: () => setFailedImage(item.imageSrc ?? undefined)
2066
+ onError: () => setFailedImage(image)
2043
2067
  }) : /* @__PURE__ */ jsx3("span", {
2044
2068
  "aria-hidden": "true",
2045
- children: initials
2069
+ className: "[&_svg]:size-4",
2070
+ children: item.fallbackIcon ?? initials
2046
2071
  })
2047
2072
  }),
2048
2073
  /* @__PURE__ */ jsxs3("div", {
@@ -3579,7 +3604,7 @@ var TableDataRow = ({
3579
3604
  ref: measureRef,
3580
3605
  "data-index": virtualIndex,
3581
3606
  "aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
3582
- className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary h-16 data-[drag-source=true]:opacity-40 data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=before]:[&>td]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
3607
+ className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary data-[drag-source=true]:opacity-40 data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=before]:[&>td]:border-t-2", tableClasses.row, store.config.onRowClicked && "cursor-pointer"),
3583
3608
  "data-state": store.state.rowSelection[row.id] && "selected",
3584
3609
  "data-table-row": row.id,
3585
3610
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -4384,7 +4409,7 @@ var DataTableGallery = ({
4384
4409
  children: renderSections(sections)
4385
4410
  });
4386
4411
  };
4387
- var DataTablePagination = ({
4412
+ var DataTableFooter = ({
4388
4413
  table
4389
4414
  }) => {
4390
4415
  const styles = useContext(DataTableStylesContext);
@@ -4398,8 +4423,13 @@ var DataTablePagination = ({
4398
4423
  send(DataTableMessage.PageRequested({ page }));
4399
4424
  }
4400
4425
  }, [page, pageIndex, pagination, paginationVisible, send]);
4401
- if (!paginationVisible || !pagination)
4402
- return null;
4426
+ if (!paginationVisible || !pagination) {
4427
+ return /* @__PURE__ */ jsx3("div", {
4428
+ className: tableResultsFooterClass,
4429
+ role: "status",
4430
+ children: store.config.labels.results(model.totalRows)
4431
+ });
4432
+ }
4403
4433
  const selected = model.rows.filter((row) => store.state.rowSelection[row.id]).length;
4404
4434
  return /* @__PURE__ */ jsx3("div", {
4405
4435
  "data-table-slot": "pagination",
@@ -4596,7 +4626,7 @@ var HydratedDataTable = (props) => {
4596
4626
  /* @__PURE__ */ jsx3(DataTableContent, {
4597
4627
  table
4598
4628
  }),
4599
- /* @__PURE__ */ jsx3(DataTablePagination, {
4629
+ /* @__PURE__ */ jsx3(DataTableFooter, {
4600
4630
  table
4601
4631
  })
4602
4632
  ]
@@ -5241,9 +5271,11 @@ var TextArrayValue = Schema7.Struct({
5241
5271
  }).annotate({ identifier: "EventTextArrayValue" });
5242
5272
  var eventTextAttribute = (record, key) => Schema7.decodeUnknownOption(TextValue)(record.attributes.find((attribute) => attribute.key === key)?.value).pipe(Option5.map((value) => value.stringValue), Option5.getOrNull);
5243
5273
 
5244
- // ../../src/components/audit-log-table/react.tsx
5245
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
5246
- var translations = {
5274
+ // ../../src/components/audit-log-table/classes.ts
5275
+ var auditTableLayout = "flex min-h-0 flex-1 flex-col";
5276
+
5277
+ // ../../src/components/audit-log-table/index.ts
5278
+ var defaultMessages2 = {
5247
5279
  en: {
5248
5280
  title: "Activity history",
5249
5281
  event: "Action",
@@ -5277,6 +5309,65 @@ var translations = {
5277
5309
  methodUnknown: "Inconnue"
5278
5310
  }
5279
5311
  };
5312
+ var auditLogMessages = (locale, messages) => {
5313
+ const base = locale.split("-")[0];
5314
+ return {
5315
+ ...base === "fr" ? defaultMessages2.fr : defaultMessages2.en,
5316
+ ...messages?.[base],
5317
+ ...messages?.[locale]
5318
+ };
5319
+ };
5320
+ var auditTableState = (state) => state?.eventName && !state.filters?.some(({ id }) => id === "eventName") ? {
5321
+ ...state,
5322
+ filters: [
5323
+ ...state.filters ?? [],
5324
+ { id: "eventName", kind: "values", values: [state.eventName] }
5325
+ ]
5326
+ } : state;
5327
+ var auditRowId = (entry) => eventTextAttribute(entry, "log.record.uid") ?? `${entry.timeUnixNano}:${entry.eventName}`;
5328
+ var auditRowTime = (entry) => Number(BigInt(entry.timeUnixNano) / 1000000n);
5329
+ var auditActionLabel = (entry, events) => events.find(({ value }) => value === entry.eventName)?.label ?? entry.eventName;
5330
+ var auditActor = (entry, labels) => {
5331
+ const type = eventTextAttribute(entry, "app.actor.type");
5332
+ const userId = eventTextAttribute(entry, "user.id");
5333
+ const id = eventTextAttribute(entry, "app.actor.id") ?? userId;
5334
+ if (type === "organization")
5335
+ return { label: labels.actorOrganization, description: id ?? undefined };
5336
+ if (type === "user" || userId !== null) {
5337
+ const name = eventTextAttribute(entry, "user.full_name") || eventTextAttribute(entry, "user.name");
5338
+ const email = eventTextAttribute(entry, "user.email");
5339
+ return {
5340
+ label: name || email || labels.actorMember,
5341
+ description: (name ? email || id : id) ?? undefined
5342
+ };
5343
+ }
5344
+ return { label: type ?? labels.actor, description: id ?? undefined };
5345
+ };
5346
+ var auditTarget = (entry, labels) => {
5347
+ const id = eventTextAttribute(entry, "app.audit.target.id");
5348
+ const name = eventTextAttribute(entry, "app.audit.target.name");
5349
+ const type = eventTextAttribute(entry, "app.audit.target.type");
5350
+ return id === null ? null : {
5351
+ label: name && name !== id ? name : type || labels.target,
5352
+ description: name && name !== id && type ? `${type} · ${id}` : id
5353
+ };
5354
+ };
5355
+ var auditImpersonation = (entry, labels) => {
5356
+ const id = eventTextAttribute(entry, "app.auth.impersonator.id");
5357
+ return id === null ? undefined : `${labels.impersonatedBy}: ${id}`;
5358
+ };
5359
+ var auditMethod = (entry) => {
5360
+ const method = eventTextAttribute(entry, "app.auth.method");
5361
+ return method === "session" || method === "api_key" ? method : "unknown";
5362
+ };
5363
+ var auditMethods = (labels) => ({
5364
+ session: labels.methodSession,
5365
+ api_key: labels.methodApiKey,
5366
+ unknown: labels.methodUnknown
5367
+ });
5368
+
5369
+ // ../../src/components/audit-log-table/react.tsx
5370
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
5280
5371
  var AuditLogTable = ({
5281
5372
  entries,
5282
5373
  events = [],
@@ -5290,54 +5381,22 @@ var AuditLogTable = ({
5290
5381
  ...status
5291
5382
  }) => {
5292
5383
  const locale = useKrakstackLocale4(localeOverride);
5293
- const base = locale.split("-")[0];
5294
- const labels = {
5295
- ...translations.en,
5296
- ...base === "fr" ? translations.fr : translations.en,
5297
- ...messages?.[base],
5298
- ...messages?.[locale]
5299
- };
5300
- const methods = new Map([
5301
- ["session", labels.methodSession],
5302
- ["api_key", labels.methodApiKey]
5303
- ]);
5304
- const tableState = state?.eventName && !state.filters?.some((filter) => filter.id === "eventName") ? {
5305
- ...state,
5306
- filters: [
5307
- ...state.filters ?? [],
5308
- { id: "eventName", kind: "values", values: [state.eventName] }
5309
- ]
5310
- } : state;
5311
- const getActor = (entry) => {
5312
- const type = eventTextAttribute(entry, "app.actor.type");
5313
- const id = eventTextAttribute(entry, "app.actor.id") ?? eventTextAttribute(entry, "user.id");
5314
- if (type === "organization") {
5315
- return { label: labels.actorOrganization, description: id };
5316
- }
5317
- if (type === "user" || eventTextAttribute(entry, "user.id") !== null) {
5318
- const fullName = eventTextAttribute(entry, "user.full_name");
5319
- const name = eventTextAttribute(entry, "user.name");
5320
- const email = eventTextAttribute(entry, "user.email");
5321
- return {
5322
- label: fullName || name || email || labels.actorMember,
5323
- description: fullName || name ? email || id : id
5324
- };
5325
- }
5326
- return { label: type ?? labels.actor, description: id };
5327
- };
5384
+ const labels = auditLogMessages(locale, messages);
5385
+ const methods = auditMethods(labels);
5386
+ const getActor = (entry) => auditActor(entry, labels);
5328
5387
  const columns = [
5329
5388
  {
5330
5389
  colId: "time",
5331
5390
  headerName: labels.time,
5332
5391
  type: "dateTime",
5333
5392
  typeOptions: { timeZone },
5334
- valueGetter: ({ data }) => new Date(Number(BigInt(data.timeUnixNano) / 1000000n))
5393
+ valueGetter: ({ data }) => new Date(auditRowTime(data))
5335
5394
  },
5336
5395
  {
5337
5396
  field: "eventName",
5338
5397
  headerName: labels.action,
5339
5398
  filterOptions: events,
5340
- cellRenderer: ({ data }) => renderAction?.(data) ?? events.find((event) => event.value === data.eventName)?.label ?? data.eventName
5399
+ cellRenderer: ({ data }) => renderAction?.(data) ?? auditActionLabel(data, events)
5341
5400
  },
5342
5401
  {
5343
5402
  colId: "record",
@@ -5350,15 +5409,7 @@ var AuditLogTable = ({
5350
5409
  type: "reference",
5351
5410
  typeOptions: {
5352
5411
  imageVariant: "square",
5353
- getItem: (entry) => {
5354
- const id = eventTextAttribute(entry, "app.audit.target.id");
5355
- const name = eventTextAttribute(entry, "app.audit.target.name");
5356
- const type = eventTextAttribute(entry, "app.audit.target.type");
5357
- return id === null ? null : {
5358
- label: name && name !== id ? name : type || labels.target,
5359
- description: name && name !== id && type ? `${type} · ${id}` : id
5360
- };
5361
- }
5412
+ getItem: (entry) => auditTarget(entry, labels)
5362
5413
  }
5363
5414
  },
5364
5415
  {
@@ -5375,20 +5426,16 @@ var AuditLogTable = ({
5375
5426
  getItem: getActor
5376
5427
  },
5377
5428
  cellRenderer: ({ data }) => {
5378
- const impersonatorId = eventTextAttribute(data, "app.auth.impersonator.id");
5429
+ const impersonation = auditImpersonation(data, labels);
5379
5430
  return /* @__PURE__ */ jsxs4("div", {
5380
5431
  className: "flex min-w-0 flex-col gap-1",
5381
5432
  children: [
5382
5433
  /* @__PURE__ */ jsx4(DataTableReferenceCell, {
5383
5434
  item: getActor(data)
5384
5435
  }),
5385
- impersonatorId !== null ? /* @__PURE__ */ jsxs4("span", {
5436
+ impersonation !== undefined ? /* @__PURE__ */ jsx4("span", {
5386
5437
  className: "text-muted-foreground text-xs",
5387
- children: [
5388
- labels.impersonatedBy,
5389
- ": ",
5390
- impersonatorId
5391
- ]
5438
+ children: impersonation
5392
5439
  }) : null
5393
5440
  ]
5394
5441
  });
@@ -5397,40 +5444,34 @@ var AuditLogTable = ({
5397
5444
  {
5398
5445
  colId: "method",
5399
5446
  headerName: labels.method,
5400
- filterOptions: [
5401
- { value: "session", label: labels.methodSession },
5402
- { value: "api_key", label: labels.methodApiKey },
5403
- { value: "unknown", label: labels.methodUnknown }
5404
- ],
5405
- filterValueGetter: ({ data }) => {
5406
- const method = eventTextAttribute(data, "app.auth.method");
5407
- return method === "session" || method === "api_key" ? method : "unknown";
5408
- },
5447
+ filterOptions: Object.entries(methods).map(([value, label]) => ({
5448
+ value,
5449
+ label
5450
+ })),
5451
+ filterValueGetter: ({ data }) => auditMethod(data),
5409
5452
  sortable: false,
5410
- valueGetter: ({ data }) => {
5411
- const method = eventTextAttribute(data, "app.auth.method");
5412
- return method === null ? labels.methodUnknown : methods.get(method) ?? labels.methodUnknown;
5413
- }
5453
+ valueGetter: ({ data }) => methods[auditMethod(data)]
5414
5454
  }
5415
5455
  ];
5416
5456
  return /* @__PURE__ */ jsx4("section", {
5417
5457
  "aria-label": labels.title,
5418
- className: "flex flex-col gap-4",
5458
+ className: auditTableLayout,
5419
5459
  children: /* @__PURE__ */ jsx4(DataTable, {
5420
5460
  locale,
5421
5461
  status,
5422
- state: tableState,
5462
+ state: auditTableState(state),
5423
5463
  onStateChange: onStateChange ? (next) => onStateChange({
5424
5464
  ...next,
5425
5465
  eventName: undefined
5426
5466
  }) : undefined,
5427
5467
  features: {
5428
5468
  filtering: !!onStateChange,
5429
- pagination: { mode: "server", rowCount }
5469
+ pagination: { mode: "server", rowCount },
5470
+ virtualization: { scroll: "internal" }
5430
5471
  },
5431
5472
  columnDefs: columns,
5432
5473
  rowData: entries,
5433
- getRowId: (entry) => eventTextAttribute(entry, "log.record.uid") ?? `${entry.timeUnixNano}:${entry.eventName}`
5474
+ getRowId: auditRowId
5434
5475
  })
5435
5476
  });
5436
5477
  };
@@ -0,0 +1,122 @@
1
+ import { Schema } from "effect";
2
+ declare const AuditLogMessagesSchema: Schema.Struct<{
3
+ readonly title: Schema.String;
4
+ readonly event: Schema.String;
5
+ readonly allEvents: Schema.String;
6
+ readonly time: Schema.String;
7
+ readonly action: Schema.String;
8
+ readonly target: Schema.String;
9
+ readonly actor: Schema.String;
10
+ readonly method: Schema.String;
11
+ readonly actorMember: Schema.String;
12
+ readonly impersonatedBy: Schema.String;
13
+ readonly actorOrganization: Schema.String;
14
+ readonly methodApiKey: Schema.String;
15
+ readonly methodSession: Schema.String;
16
+ readonly methodUnknown: Schema.String;
17
+ }>;
18
+ export type AuditLogMessages = typeof AuditLogMessagesSchema.Type;
19
+ export declare const AuditLogTablePropsSchema: Schema.Struct<{
20
+ readonly entries: Schema.$Array<Schema.Struct<{
21
+ readonly eventName: Schema.NonEmptyString;
22
+ readonly timeUnixNano: Schema.String;
23
+ readonly observedTimeUnixNano: Schema.optional<Schema.String>;
24
+ readonly severityNumber: Schema.optional<Schema.Int>;
25
+ readonly traceId: Schema.optional<Schema.String>;
26
+ readonly spanId: Schema.optional<Schema.String>;
27
+ readonly attributes: Schema.$Array<Schema.Struct<{
28
+ readonly key: Schema.NonEmptyString;
29
+ readonly value: Schema.StructWithRest<Schema.Struct<{
30
+ readonly stringValue: Schema.optional<Schema.String>;
31
+ }>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
32
+ }>>;
33
+ }>>;
34
+ readonly rowCount: Schema.Int;
35
+ readonly events: Schema.optionalKey<Schema.$Array<Schema.Struct<{
36
+ readonly value: Schema.String;
37
+ readonly label: Schema.String;
38
+ }>>>;
39
+ readonly state: Schema.optionalKey<Schema.Struct<{
40
+ readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
41
+ readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Finite, Schema.FiniteFromString]>>, never, never>;
42
+ readonly globalFilter: Schema.optional<Schema.String>;
43
+ readonly sort: Schema.optional<Schema.declare<readonly {
44
+ readonly id: string;
45
+ readonly direction: "asc" | "desc";
46
+ }[], readonly {
47
+ readonly id: string;
48
+ readonly direction: "asc" | "desc";
49
+ }[]>>;
50
+ readonly filters: Schema.optional<Schema.declare<readonly ({
51
+ readonly id: string;
52
+ readonly kind: "number";
53
+ readonly min?: number | undefined;
54
+ readonly max?: number | undefined;
55
+ } | {
56
+ readonly id: string;
57
+ readonly kind: "date";
58
+ readonly from?: string | undefined;
59
+ readonly to?: string | undefined;
60
+ } | {
61
+ readonly id: string;
62
+ readonly kind: "text";
63
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
64
+ readonly value: string;
65
+ } | {
66
+ readonly id: string;
67
+ readonly kind: "boolean";
68
+ readonly value: boolean;
69
+ } | {
70
+ readonly id: string;
71
+ readonly kind: "values";
72
+ readonly values: readonly [string, ...string[]];
73
+ })[], readonly ({
74
+ readonly id: string;
75
+ readonly kind: "number";
76
+ readonly min?: number | undefined;
77
+ readonly max?: number | undefined;
78
+ } | {
79
+ readonly id: string;
80
+ readonly kind: "date";
81
+ readonly from?: string | undefined;
82
+ readonly to?: string | undefined;
83
+ } | {
84
+ readonly id: string;
85
+ readonly kind: "text";
86
+ readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
87
+ readonly value: string;
88
+ } | {
89
+ readonly id: string;
90
+ readonly kind: "boolean";
91
+ readonly value: boolean;
92
+ } | {
93
+ readonly id: string;
94
+ readonly kind: "values";
95
+ readonly values: readonly [string, ...string[]];
96
+ })[]>>;
97
+ readonly eventName: Schema.optional<Schema.NonEmptyString>;
98
+ }>>;
99
+ readonly timeZone: Schema.optionalKey<Schema.String>;
100
+ readonly locale: Schema.optionalKey<Schema.String>;
101
+ readonly messages: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
102
+ readonly title: Schema.optional<Schema.String>;
103
+ readonly event: Schema.optional<Schema.String>;
104
+ readonly allEvents: Schema.optional<Schema.String>;
105
+ readonly time: Schema.optional<Schema.String>;
106
+ readonly action: Schema.optional<Schema.String>;
107
+ readonly target: Schema.optional<Schema.String>;
108
+ readonly actor: Schema.optional<Schema.String>;
109
+ readonly method: Schema.optional<Schema.String>;
110
+ readonly actorMember: Schema.optional<Schema.String>;
111
+ readonly impersonatedBy: Schema.optional<Schema.String>;
112
+ readonly actorOrganization: Schema.optional<Schema.String>;
113
+ readonly methodApiKey: Schema.optional<Schema.String>;
114
+ readonly methodSession: Schema.optional<Schema.String>;
115
+ readonly methodUnknown: Schema.optional<Schema.String>;
116
+ }>>>;
117
+ readonly loading: Schema.optionalKey<Schema.Boolean>;
118
+ readonly error: Schema.optionalKey<Schema.String>;
119
+ readonly empty: Schema.optionalKey<Schema.String>;
120
+ }>;
121
+ export type AuditLogTableProps = typeof AuditLogTablePropsSchema.Type;
122
+ export {};
@@ -26,10 +26,10 @@ export declare const DangerConfirmation: import("effect/ui/Component").Component
26
26
  readonly status: "failed" | "idle" | "pending" | "succeeded";
27
27
  }, {
28
28
  readonly _tag: "Opened";
29
- } | {
30
- readonly _tag: "Confirmed";
31
29
  } | {
32
30
  readonly _tag: "Dismissed";
31
+ } | {
32
+ readonly _tag: "Confirmed";
33
33
  } | {
34
34
  readonly _tag: "Edited";
35
35
  readonly text: string;
@@ -98,8 +98,6 @@ export declare const DangerConfirmationModel: Component.Component<"DangerConfirm
98
98
  readonly text: string;
99
99
  readonly status: "failed" | "idle" | "pending" | "succeeded";
100
100
  }, {
101
- readonly _tag: "Opened";
102
- } | {
103
101
  readonly _tag: "Confirmed";
104
102
  } | {
105
103
  readonly _tag: "Dismissed";
@@ -109,5 +107,7 @@ export declare const DangerConfirmationModel: Component.Component<"DangerConfirm
109
107
  } | {
110
108
  readonly _tag: "Finished";
111
109
  readonly success: boolean;
110
+ } | {
111
+ readonly _tag: "Opened";
112
112
  }, never, RunConfirmation, never, {}, never>;
113
113
  export {};