@webiny/app-audit-logs 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e

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 (207) hide show
  1. package/README.md +11 -1
  2. package/SecurityPermission.d.ts +2 -0
  3. package/SecurityPermission.js +15 -0
  4. package/SecurityPermission.js.map +1 -0
  5. package/components/Text.d.ts +10 -4
  6. package/components/Text.js +32 -22
  7. package/components/Text.js.map +1 -1
  8. package/config/list/AuditLogsListConfig.d.ts +31 -18
  9. package/config/list/AuditLogsListConfig.js +38 -15
  10. package/config/list/AuditLogsListConfig.js.map +1 -1
  11. package/config/list/Browser/Filter.js +30 -37
  12. package/config/list/Browser/Filter.js.map +1 -1
  13. package/config/list/Browser/FiltersToWhere.js +10 -13
  14. package/config/list/Browser/FiltersToWhere.js.map +1 -1
  15. package/config/list/Browser/index.d.ts +14 -16
  16. package/config/list/Browser/index.js +6 -5
  17. package/config/list/Browser/index.js.map +1 -1
  18. package/config/list/Details/PreviewTab.d.ts +15 -0
  19. package/config/list/Details/PreviewTab.js +32 -0
  20. package/config/list/Details/PreviewTab.js.map +1 -0
  21. package/config/list/Details/index.d.ts +8 -0
  22. package/config/list/Details/index.js +7 -0
  23. package/config/list/Details/index.js.map +1 -0
  24. package/config/list/index.d.ts +1 -1
  25. package/config/list/index.js +1 -3
  26. package/constants/index.js +2 -1
  27. package/constants/index.js.map +1 -1
  28. package/domain/permissionsSchema.d.ts +4 -0
  29. package/domain/permissionsSchema.js +8 -0
  30. package/domain/permissionsSchema.js.map +1 -0
  31. package/features/listAuditLogs/ListAuditLogsGateway.d.ts +11 -0
  32. package/features/listAuditLogs/ListAuditLogsGateway.js +71 -0
  33. package/features/listAuditLogs/ListAuditLogsGateway.js.map +1 -0
  34. package/features/listAuditLogs/ListAuditLogsRepository.d.ts +11 -0
  35. package/features/listAuditLogs/ListAuditLogsRepository.js +35 -0
  36. package/features/listAuditLogs/ListAuditLogsRepository.js.map +1 -0
  37. package/features/listAuditLogs/ListAuditLogsUseCase.d.ts +10 -0
  38. package/features/listAuditLogs/ListAuditLogsUseCase.js +19 -0
  39. package/features/listAuditLogs/ListAuditLogsUseCase.js.map +1 -0
  40. package/features/listAuditLogs/abstractions/ListAuditLogsGateway.d.ts +20 -0
  41. package/features/listAuditLogs/abstractions/ListAuditLogsGateway.js +5 -0
  42. package/features/listAuditLogs/abstractions/ListAuditLogsGateway.js.map +1 -0
  43. package/features/listAuditLogs/abstractions/ListAuditLogsRepository.d.ts +20 -0
  44. package/features/listAuditLogs/abstractions/ListAuditLogsRepository.js +5 -0
  45. package/features/listAuditLogs/abstractions/ListAuditLogsRepository.js.map +1 -0
  46. package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.d.ts +20 -0
  47. package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.js +5 -0
  48. package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.js.map +1 -0
  49. package/features/listAuditLogs/abstractions/index.d.ts +6 -0
  50. package/features/listAuditLogs/abstractions/index.js +3 -0
  51. package/features/listAuditLogs/feature.d.ts +3 -0
  52. package/features/listAuditLogs/feature.js +21 -0
  53. package/features/listAuditLogs/feature.js.map +1 -0
  54. package/features/listAuditLogs/index.d.ts +1 -0
  55. package/features/listAuditLogs/index.js +1 -0
  56. package/features/permissions/abstractions.d.ts +17 -0
  57. package/features/permissions/abstractions.js +6 -0
  58. package/features/permissions/abstractions.js.map +1 -0
  59. package/features/permissions/feature.d.ts +14 -0
  60. package/features/permissions/feature.js +7 -0
  61. package/features/permissions/feature.js.map +1 -0
  62. package/graphql.d.ts +1 -1
  63. package/graphql.js +4 -4
  64. package/graphql.js.map +1 -1
  65. package/hooks/graphql.d.ts +9 -0
  66. package/hooks/graphql.js +0 -0
  67. package/hooks/index.d.ts +1 -1
  68. package/hooks/index.js +1 -3
  69. package/hooks/schema.d.ts +35 -0
  70. package/hooks/schema.js +27 -0
  71. package/hooks/schema.js.map +1 -0
  72. package/hooks/useAuditLogsList.d.ts +11 -16
  73. package/hooks/useAuditLogsList.js +97 -101
  74. package/hooks/useAuditLogsList.js.map +1 -1
  75. package/index.js +48 -49
  76. package/index.js.map +1 -1
  77. package/package.json +29 -34
  78. package/routes.d.ts +4 -0
  79. package/routes.js +10 -0
  80. package/routes.js.map +1 -0
  81. package/types.d.ts +48 -22
  82. package/types.js +1 -14
  83. package/utils/transformRawAuditLog.d.ts +5 -0
  84. package/utils/transformRawAuditLog.js +26 -0
  85. package/utils/transformRawAuditLog.js.map +1 -0
  86. package/views/Logs/Filters/FilterByAction.d.ts +1 -1
  87. package/views/Logs/Filters/FilterByAction.js +41 -42
  88. package/views/Logs/Filters/FilterByAction.js.map +1 -1
  89. package/views/Logs/Filters/FilterByApp.js +33 -31
  90. package/views/Logs/Filters/FilterByApp.js.map +1 -1
  91. package/views/Logs/Filters/FilterByCreatedBy.d.ts +2 -0
  92. package/views/Logs/Filters/FilterByCreatedBy.js +50 -0
  93. package/views/Logs/Filters/FilterByCreatedBy.js.map +1 -0
  94. package/views/Logs/Filters/FilterByCreatedOn.d.ts +2 -0
  95. package/views/Logs/Filters/FilterByCreatedOn.js +38 -0
  96. package/views/Logs/Filters/FilterByCreatedOn.js.map +1 -0
  97. package/views/Logs/Filters/FilterByEntity.d.ts +1 -1
  98. package/views/Logs/Filters/FilterByEntity.js +41 -42
  99. package/views/Logs/Filters/FilterByEntity.js.map +1 -1
  100. package/views/Logs/Filters/FilterByEntityId.d.ts +2 -0
  101. package/views/Logs/Filters/FilterByEntityId.js +26 -0
  102. package/views/Logs/Filters/FilterByEntityId.js.map +1 -0
  103. package/views/Logs/Filters/FilterByInitiator.js +44 -34
  104. package/views/Logs/Filters/FilterByInitiator.js.map +1 -1
  105. package/views/Logs/Filters/Filters.d.ts +5 -6
  106. package/views/Logs/Filters/Filters.js +66 -29
  107. package/views/Logs/Filters/Filters.js.map +1 -1
  108. package/views/Logs/Filters/index.d.ts +7 -6
  109. package/views/Logs/Filters/index.js +7 -8
  110. package/views/Logs/Filters/types.d.ts +9 -0
  111. package/views/Logs/Filters/types.js +0 -0
  112. package/views/Logs/Header/ButtonFilters/ButtonFilters.js +24 -45
  113. package/views/Logs/Header/ButtonFilters/ButtonFilters.js.map +1 -1
  114. package/views/Logs/Header/ButtonFilters/index.d.ts +1 -1
  115. package/views/Logs/Header/ButtonFilters/index.js +1 -3
  116. package/views/Logs/Header/Header.d.ts +2 -6
  117. package/views/Logs/Header/Header.js +12 -77
  118. package/views/Logs/Header/Header.js.map +1 -1
  119. package/views/Logs/Header/index.d.ts +1 -1
  120. package/views/Logs/Header/index.js +1 -3
  121. package/views/Logs/LoadMoreButton/LoadMoreButton.js +11 -18
  122. package/views/Logs/LoadMoreButton/LoadMoreButton.js.map +1 -1
  123. package/views/Logs/LoadMoreButton/index.d.ts +1 -1
  124. package/views/Logs/LoadMoreButton/index.js +1 -3
  125. package/views/Logs/LoadMoreButton/styled.d.ts +4 -5
  126. package/views/Logs/LoadMoreButton/styled.js +5 -16
  127. package/views/Logs/LoadMoreButton/styled.js.map +1 -1
  128. package/views/Logs/LoadingMore/index.js +13 -13
  129. package/views/Logs/LoadingMore/index.js.map +1 -1
  130. package/views/Logs/LogsModule.js +24 -24
  131. package/views/Logs/LogsModule.js.map +1 -1
  132. package/views/Logs/LogsView.d.ts +2 -0
  133. package/views/Logs/LogsView.js +73 -0
  134. package/views/Logs/LogsView.js.map +1 -0
  135. package/views/Logs/Preview/AuditLogDetailsPresenter.d.ts +13 -0
  136. package/views/Logs/Preview/AuditLogDetailsPresenter.js +36 -0
  137. package/views/Logs/Preview/AuditLogDetailsPresenter.js.map +1 -0
  138. package/views/Logs/Preview/Preview.d.ts +6 -4
  139. package/views/Logs/Preview/Preview.js +125 -88
  140. package/views/Logs/Preview/Preview.js.map +1 -1
  141. package/views/Logs/Preview/abstractions.d.ts +14 -0
  142. package/views/Logs/Preview/abstractions.js +5 -0
  143. package/views/Logs/Preview/abstractions.js.map +1 -0
  144. package/views/Logs/Preview/feature.d.ts +5 -0
  145. package/views/Logs/Preview/feature.js +22 -0
  146. package/views/Logs/Preview/feature.js.map +1 -0
  147. package/views/Logs/Preview/index.d.ts +3 -1
  148. package/views/Logs/Preview/index.js +2 -3
  149. package/views/Logs/Preview/tabs/AiPromptTabs.d.ts +2 -0
  150. package/views/Logs/Preview/tabs/AiPromptTabs.js +25 -0
  151. package/views/Logs/Preview/tabs/AiPromptTabs.js.map +1 -0
  152. package/views/Logs/Preview/tabs/LlmResponseTab.d.ts +4 -0
  153. package/views/Logs/Preview/tabs/LlmResponseTab.js +41 -0
  154. package/views/Logs/Preview/tabs/LlmResponseTab.js.map +1 -0
  155. package/views/Logs/Preview/tabs/SystemPromptTab.d.ts +4 -0
  156. package/views/Logs/Preview/tabs/SystemPromptTab.js +24 -0
  157. package/views/Logs/Preview/tabs/SystemPromptTab.js.map +1 -0
  158. package/views/Logs/Preview/tabs/UserPromptTab.d.ts +4 -0
  159. package/views/Logs/Preview/tabs/UserPromptTab.js +18 -0
  160. package/views/Logs/Preview/tabs/UserPromptTab.js.map +1 -0
  161. package/views/Logs/Preview/tabs/shared.d.ts +28 -0
  162. package/views/Logs/Preview/tabs/shared.js +16 -0
  163. package/views/Logs/Preview/tabs/shared.js.map +1 -0
  164. package/views/Logs/Table/Table.d.ts +10 -14
  165. package/views/Logs/Table/Table.js +112 -125
  166. package/views/Logs/Table/Table.js.map +1 -1
  167. package/views/Logs/Table/index.d.ts +1 -1
  168. package/views/Logs/Table/index.js +1 -3
  169. package/views/Logs/Table/styled.d.ts +1 -17
  170. package/views/Logs/Table/styled.js +15 -79
  171. package/views/Logs/Table/styled.js.map +1 -1
  172. package/config/list/index.js.map +0 -1
  173. package/hooks/index.js.map +0 -1
  174. package/plugins/permissionRenderer/AuditLogsPermissions.d.ts +0 -8
  175. package/plugins/permissionRenderer/AuditLogsPermissions.js +0 -100
  176. package/plugins/permissionRenderer/AuditLogsPermissions.js.map +0 -1
  177. package/plugins/permissionRenderer/index.d.ts +0 -1
  178. package/plugins/permissionRenderer/index.js +0 -32
  179. package/plugins/permissionRenderer/index.js.map +0 -1
  180. package/types.js.map +0 -1
  181. package/utils/transformCmsContentEntriesToRecordEntries.d.ts +0 -25
  182. package/utils/transformCmsContentEntriesToRecordEntries.js +0 -36
  183. package/utils/transformCmsContentEntriesToRecordEntries.js.map +0 -1
  184. package/views/Logs/Filters/FilterByTimestamp.d.ts +0 -2
  185. package/views/Logs/Filters/FilterByTimestamp.js +0 -40
  186. package/views/Logs/Filters/FilterByTimestamp.js.map +0 -1
  187. package/views/Logs/Filters/index.js.map +0 -1
  188. package/views/Logs/Filters/styled.d.ts +0 -5
  189. package/views/Logs/Filters/styled.js +0 -18
  190. package/views/Logs/Filters/styled.js.map +0 -1
  191. package/views/Logs/Header/ButtonFilters/index.js.map +0 -1
  192. package/views/Logs/Header/index.js.map +0 -1
  193. package/views/Logs/LoadMoreButton/index.js.map +0 -1
  194. package/views/Logs/LoadingMore/styled.d.ts +0 -9
  195. package/views/Logs/LoadingMore/styled.js +0 -32
  196. package/views/Logs/LoadingMore/styled.js.map +0 -1
  197. package/views/Logs/Logs.d.ts +0 -3
  198. package/views/Logs/Logs.js +0 -84
  199. package/views/Logs/Logs.js.map +0 -1
  200. package/views/Logs/Preview/index.js.map +0 -1
  201. package/views/Logs/Preview/styled.d.ts +0 -6
  202. package/views/Logs/Preview/styled.js +0 -25
  203. package/views/Logs/Preview/styled.js.map +0 -1
  204. package/views/Logs/Table/index.js.map +0 -1
  205. package/views/Logs/styled.d.ts +0 -9
  206. package/views/Logs/styled.js +0 -32
  207. package/views/Logs/styled.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const AiPromptPreviewTabs: () => React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ import react from "react";
2
+ import { AuditLogsListConfig } from "../../../../config/list/index.js";
3
+ import { SystemPromptTab } from "./SystemPromptTab.js";
4
+ import { UserPromptTab } from "./UserPromptTab.js";
5
+ import { LlmResponseTab } from "./LlmResponseTab.js";
6
+ import { hasAfter, isAiGenerateText } from "./shared.js";
7
+ const AiPromptPreviewTabs = ()=>/*#__PURE__*/ react.createElement(AuditLogsListConfig, null, /*#__PURE__*/ react.createElement(AuditLogsListConfig.Details.Tab, {
8
+ name: "systemPrompt",
9
+ label: "System Prompt",
10
+ element: /*#__PURE__*/ react.createElement(SystemPromptTab, null),
11
+ canRender: isAiGenerateText
12
+ }), /*#__PURE__*/ react.createElement(AuditLogsListConfig.Details.Tab, {
13
+ name: "userPrompt",
14
+ label: "User Prompt",
15
+ element: /*#__PURE__*/ react.createElement(UserPromptTab, null),
16
+ canRender: isAiGenerateText
17
+ }), /*#__PURE__*/ react.createElement(AuditLogsListConfig.Details.Tab, {
18
+ name: "llmResponse",
19
+ label: "LLM Response",
20
+ element: /*#__PURE__*/ react.createElement(LlmResponseTab, null),
21
+ canRender: hasAfter
22
+ }));
23
+ export { AiPromptPreviewTabs };
24
+
25
+ //# sourceMappingURL=AiPromptTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views/Logs/Preview/tabs/AiPromptTabs.js","sources":["../../../../../src/views/Logs/Preview/tabs/AiPromptTabs.tsx"],"sourcesContent":["import React from \"react\";\nimport { AuditLogsListConfig } from \"~/config/list/index.js\";\nimport { SystemPromptTab } from \"./SystemPromptTab.js\";\nimport { UserPromptTab } from \"./UserPromptTab.js\";\nimport { LlmResponseTab } from \"./LlmResponseTab.js\";\nimport { isAiGenerateText, hasAfter } from \"./shared.js\";\n\nexport const AiPromptPreviewTabs = () => {\n return (\n <AuditLogsListConfig>\n <AuditLogsListConfig.Details.Tab\n name=\"systemPrompt\"\n label=\"System Prompt\"\n element={<SystemPromptTab />}\n canRender={isAiGenerateText}\n />\n <AuditLogsListConfig.Details.Tab\n name=\"userPrompt\"\n label=\"User Prompt\"\n element={<UserPromptTab />}\n canRender={isAiGenerateText}\n />\n <AuditLogsListConfig.Details.Tab\n name=\"llmResponse\"\n label=\"LLM Response\"\n element={<LlmResponseTab />}\n canRender={hasAfter}\n />\n </AuditLogsListConfig>\n );\n};\n"],"names":["AiPromptPreviewTabs","AuditLogsListConfig","SystemPromptTab","isAiGenerateText","UserPromptTab","LlmResponseTab","hasAfter"],"mappings":";;;;;;AAOO,MAAMA,sBAAsB,IACxB,WAAP,GACI,oBAACC,qBAAmBA,MAAAA,WAAAA,GAChB,oBAACA,oBAAoB,OAAO,CAAC,GAAG;QAC5B,MAAK;QACL,OAAM;QACN,uBAAS,oBAACC,iBAAeA;QACzB,WAAWC;sBAEf,oBAACF,oBAAoB,OAAO,CAAC,GAAG;QAC5B,MAAK;QACL,OAAM;QACN,uBAAS,oBAACG,eAAaA;QACvB,WAAWD;sBAEf,oBAACF,oBAAoB,OAAO,CAAC,GAAG;QAC5B,MAAK;QACL,OAAM;QACN,uBAAS,oBAACI,gBAAcA;QACxB,WAAWC"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export declare const LlmResponseTab: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element;
4
+ };
@@ -0,0 +1,41 @@
1
+ import react from "react";
2
+ import { CodeEditor } from "@webiny/admin-ui";
3
+ import { createReactiveComponent } from "@webiny/app-admin";
4
+ import { useAuditLogDetailsPresenter } from "../feature.js";
5
+ import { EDITOR_HEIGHT } from "./shared.js";
6
+ const LlmResponseTab = createReactiveComponent(()=>{
7
+ const presenter = useAuditLogDetailsPresenter();
8
+ const after = presenter.vm.content.after;
9
+ if (!after) return /*#__PURE__*/ react.createElement(CodeEditor, {
10
+ language: "markdown",
11
+ value: "(pending — no response yet)",
12
+ height: EDITOR_HEIGHT
13
+ });
14
+ if ("error" === after.status) {
15
+ const errorText = [
16
+ `# Error: ${after.error?.name ?? "Unknown"}`,
17
+ "",
18
+ after.error?.message ?? "No error message available.",
19
+ "",
20
+ null != after.duration ? `Duration: ${after.duration}ms` : ""
21
+ ].join("\n");
22
+ return /*#__PURE__*/ react.createElement(CodeEditor, {
23
+ language: "markdown",
24
+ value: errorText,
25
+ height: EDITOR_HEIGHT
26
+ });
27
+ }
28
+ const text = after.text ?? "";
29
+ let formatted = text;
30
+ try {
31
+ formatted = JSON.stringify(JSON.parse(text), null, 2);
32
+ } catch {}
33
+ return /*#__PURE__*/ react.createElement(CodeEditor, {
34
+ language: "json",
35
+ value: formatted,
36
+ height: EDITOR_HEIGHT
37
+ });
38
+ });
39
+ export { LlmResponseTab };
40
+
41
+ //# sourceMappingURL=LlmResponseTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views/Logs/Preview/tabs/LlmResponseTab.js","sources":["../../../../../src/views/Logs/Preview/tabs/LlmResponseTab.tsx"],"sourcesContent":["import React from \"react\";\nimport { CodeEditor } from \"@webiny/admin-ui\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { useAuditLogDetailsPresenter } from \"~/views/Logs/Preview/feature.js\";\nimport { EDITOR_HEIGHT, type AiAuditPayload } from \"./shared.js\";\n\nexport const LlmResponseTab = createReactiveComponent(() => {\n const presenter = useAuditLogDetailsPresenter();\n const after = presenter.vm.content.after as AiAuditPayload[\"after\"];\n\n if (!after) {\n return (\n <CodeEditor\n language=\"markdown\"\n value=\"(pending — no response yet)\"\n height={EDITOR_HEIGHT}\n />\n );\n }\n\n if (after.status === \"error\") {\n const errorText = [\n `# Error: ${after.error?.name ?? \"Unknown\"}`,\n \"\",\n after.error?.message ?? \"No error message available.\",\n \"\",\n after.duration != null ? `Duration: ${after.duration}ms` : \"\"\n ].join(\"\\n\");\n\n return <CodeEditor language=\"markdown\" value={errorText} height={EDITOR_HEIGHT} />;\n }\n\n const text = after.text ?? \"\";\n let formatted = text;\n try {\n formatted = JSON.stringify(JSON.parse(text), null, 2);\n } catch {\n // not JSON, show as-is\n }\n\n return <CodeEditor language=\"json\" value={formatted} height={EDITOR_HEIGHT} />;\n});\n"],"names":["LlmResponseTab","createReactiveComponent","presenter","useAuditLogDetailsPresenter","after","CodeEditor","EDITOR_HEIGHT","errorText","text","formatted","JSON"],"mappings":";;;;;AAMO,MAAMA,iBAAiBC,wBAAwB;IAClD,MAAMC,YAAYC;IAClB,MAAMC,QAAQF,UAAU,EAAE,CAAC,OAAO,CAAC,KAAK;IAExC,IAAI,CAACE,OACD,OAAO,WAAP,GACI,oBAACC,YAAUA;QACP,UAAS;QACT,OAAM;QACN,QAAQC;;IAKpB,IAAIF,AAAiB,YAAjBA,MAAM,MAAM,EAAc;QAC1B,MAAMG,YAAY;YACd,CAAC,SAAS,EAAEH,MAAM,KAAK,EAAE,QAAQ,WAAW;YAC5C;YACAA,MAAM,KAAK,EAAE,WAAW;YACxB;YACkB,QAAlBA,MAAM,QAAQ,GAAW,CAAC,UAAU,EAAEA,MAAM,QAAQ,CAAC,EAAE,CAAC,GAAG;SAC9D,CAAC,IAAI,CAAC;QAEP,OAAO,WAAP,GAAO,oBAACC,YAAUA;YAAC,UAAS;YAAW,OAAOE;YAAW,QAAQD;;IACrE;IAEA,MAAME,OAAOJ,MAAM,IAAI,IAAI;IAC3B,IAAIK,YAAYD;IAChB,IAAI;QACAC,YAAYC,KAAK,SAAS,CAACA,KAAK,KAAK,CAACF,OAAO,MAAM;IACvD,EAAE,OAAM,CAER;IAEA,OAAO,WAAP,GAAO,oBAACH,YAAUA;QAAC,UAAS;QAAO,OAAOI;QAAW,QAAQH;;AACjE"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export declare const SystemPromptTab: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element;
4
+ };
@@ -0,0 +1,24 @@
1
+ import react from "react";
2
+ import { CodeEditor } from "@webiny/admin-ui";
3
+ import { createReactiveComponent } from "@webiny/app-admin";
4
+ import { useAuditLogDetailsPresenter } from "../feature.js";
5
+ import { EDITOR_HEIGHT } from "./shared.js";
6
+ function extractSystemPrompt(content) {
7
+ const before = content.before;
8
+ const system = before?.system;
9
+ if ("string" == typeof system) return system;
10
+ if (system && "string" == typeof system.content) return system.content;
11
+ return "";
12
+ }
13
+ const SystemPromptTab = createReactiveComponent(()=>{
14
+ const presenter = useAuditLogDetailsPresenter();
15
+ const text = extractSystemPrompt(presenter.vm.content);
16
+ return /*#__PURE__*/ react.createElement(CodeEditor, {
17
+ language: "markdown",
18
+ value: text || "(empty)",
19
+ height: EDITOR_HEIGHT
20
+ });
21
+ });
22
+ export { SystemPromptTab };
23
+
24
+ //# sourceMappingURL=SystemPromptTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views/Logs/Preview/tabs/SystemPromptTab.js","sources":["../../../../../src/views/Logs/Preview/tabs/SystemPromptTab.tsx"],"sourcesContent":["import React from \"react\";\nimport { CodeEditor } from \"@webiny/admin-ui\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { useAuditLogDetailsPresenter } from \"~/views/Logs/Preview/feature.js\";\nimport { EDITOR_HEIGHT, type AiAuditPayload } from \"./shared.js\";\n\nfunction extractSystemPrompt(content: Record<string, unknown>): string {\n const before = content.before as AiAuditPayload[\"before\"];\n const system = before?.system;\n if (typeof system === \"string\") {\n return system;\n }\n if (system && typeof system.content === \"string\") {\n return system.content;\n }\n return \"\";\n}\n\nexport const SystemPromptTab = createReactiveComponent(() => {\n const presenter = useAuditLogDetailsPresenter();\n const text = extractSystemPrompt(presenter.vm.content);\n return <CodeEditor language=\"markdown\" value={text || \"(empty)\"} height={EDITOR_HEIGHT} />;\n});\n"],"names":["extractSystemPrompt","content","before","system","SystemPromptTab","createReactiveComponent","presenter","useAuditLogDetailsPresenter","text","CodeEditor","EDITOR_HEIGHT"],"mappings":";;;;;AAMA,SAASA,oBAAoBC,OAAgC;IACzD,MAAMC,SAASD,QAAQ,MAAM;IAC7B,MAAME,SAASD,QAAQ;IACvB,IAAI,AAAkB,YAAlB,OAAOC,QACP,OAAOA;IAEX,IAAIA,UAAU,AAA0B,YAA1B,OAAOA,OAAO,OAAO,EAC/B,OAAOA,OAAO,OAAO;IAEzB,OAAO;AACX;AAEO,MAAMC,kBAAkBC,wBAAwB;IACnD,MAAMC,YAAYC;IAClB,MAAMC,OAAOR,oBAAoBM,UAAU,EAAE,CAAC,OAAO;IACrD,OAAO,WAAP,GAAO,oBAACG,YAAUA;QAAC,UAAS;QAAW,OAAOD,QAAQ;QAAW,QAAQE;;AAC7E"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export declare const UserPromptTab: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
3
+ readonly type: () => React.JSX.Element;
4
+ };
@@ -0,0 +1,18 @@
1
+ import react from "react";
2
+ import { CodeEditor } from "@webiny/admin-ui";
3
+ import { createReactiveComponent } from "@webiny/app-admin";
4
+ import { useAuditLogDetailsPresenter } from "../feature.js";
5
+ import { EDITOR_HEIGHT } from "./shared.js";
6
+ const UserPromptTab = createReactiveComponent(()=>{
7
+ const presenter = useAuditLogDetailsPresenter();
8
+ const before = presenter.vm.content.before;
9
+ const text = before?.prompt ?? "";
10
+ return /*#__PURE__*/ react.createElement(CodeEditor, {
11
+ language: "markdown",
12
+ value: text || "(empty)",
13
+ height: EDITOR_HEIGHT
14
+ });
15
+ });
16
+ export { UserPromptTab };
17
+
18
+ //# sourceMappingURL=UserPromptTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views/Logs/Preview/tabs/UserPromptTab.js","sources":["../../../../../src/views/Logs/Preview/tabs/UserPromptTab.tsx"],"sourcesContent":["import React from \"react\";\nimport { CodeEditor } from \"@webiny/admin-ui\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { useAuditLogDetailsPresenter } from \"~/views/Logs/Preview/feature.js\";\nimport { EDITOR_HEIGHT, type AiAuditPayload } from \"./shared.js\";\n\nexport const UserPromptTab = createReactiveComponent(() => {\n const presenter = useAuditLogDetailsPresenter();\n const before = presenter.vm.content.before as AiAuditPayload[\"before\"];\n const text = before?.prompt ?? \"\";\n return <CodeEditor language=\"markdown\" value={text || \"(empty)\"} height={EDITOR_HEIGHT} />;\n});\n"],"names":["UserPromptTab","createReactiveComponent","presenter","useAuditLogDetailsPresenter","before","text","CodeEditor","EDITOR_HEIGHT"],"mappings":";;;;;AAMO,MAAMA,gBAAgBC,wBAAwB;IACjD,MAAMC,YAAYC;IAClB,MAAMC,SAASF,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM;IAC1C,MAAMG,OAAOD,QAAQ,UAAU;IAC/B,OAAO,WAAP,GAAO,oBAACE,YAAUA;QAAC,UAAS;QAAW,OAAOD,QAAQ;QAAW,QAAQE;;AAC7E"}
@@ -0,0 +1,28 @@
1
+ import type { IAuditLog } from "../../../../types.js";
2
+ export declare const EDITOR_HEIGHT = "calc(100vh - 350px)";
3
+ export interface AiAuditPayload {
4
+ before?: {
5
+ model?: string;
6
+ system?: string | {
7
+ content?: string;
8
+ role?: string;
9
+ };
10
+ prompt?: string;
11
+ tools?: string[];
12
+ };
13
+ after?: {
14
+ status?: "success" | "error";
15
+ duration?: number;
16
+ text?: string;
17
+ usage?: unknown;
18
+ finishReason?: string;
19
+ steps?: number;
20
+ toolCalls?: number;
21
+ error?: {
22
+ message?: string;
23
+ name?: string;
24
+ };
25
+ };
26
+ }
27
+ export declare function isAiGenerateText(auditLog: IAuditLog): boolean;
28
+ export declare function hasAfter(auditLog: IAuditLog): boolean;
@@ -0,0 +1,16 @@
1
+ const EDITOR_HEIGHT = "calc(100vh - 350px)";
2
+ function isAiGenerateText(auditLog) {
3
+ return "AI" === auditLog.app && "TEXT" === auditLog.entity.value;
4
+ }
5
+ function hasAfter(auditLog) {
6
+ if (!isAiGenerateText(auditLog)) return false;
7
+ try {
8
+ const content = JSON.parse(auditLog.content);
9
+ return !!content.after;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ export { EDITOR_HEIGHT, hasAfter, isAiGenerateText };
15
+
16
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views/Logs/Preview/tabs/shared.js","sources":["../../../../../src/views/Logs/Preview/tabs/shared.ts"],"sourcesContent":["import type { IAuditLog } from \"~/types.js\";\n\nexport const EDITOR_HEIGHT = \"calc(100vh - 350px)\";\n\nexport interface AiAuditPayload {\n before?: {\n model?: string;\n system?: string | { content?: string; role?: string };\n prompt?: string;\n tools?: string[];\n };\n after?: {\n status?: \"success\" | \"error\";\n duration?: number;\n text?: string;\n usage?: unknown;\n finishReason?: string;\n steps?: number;\n toolCalls?: number;\n error?: { message?: string; name?: string };\n };\n}\n\nexport function isAiGenerateText(auditLog: IAuditLog): boolean {\n return auditLog.app === \"AI\" && auditLog.entity.value === \"TEXT\";\n}\n\nexport function hasAfter(auditLog: IAuditLog): boolean {\n if (!isAiGenerateText(auditLog)) {\n return false;\n }\n try {\n const content = JSON.parse(auditLog.content);\n return !!content.after;\n } catch {\n return false;\n }\n}\n"],"names":["EDITOR_HEIGHT","isAiGenerateText","auditLog","hasAfter","content","JSON"],"mappings":"AAEO,MAAMA,gBAAgB;AAqBtB,SAASC,iBAAiBC,QAAmB;IAChD,OAAOA,AAAiB,SAAjBA,SAAS,GAAG,IAAaA,AAA0B,WAA1BA,SAAS,MAAM,CAAC,KAAK;AACzD;AAEO,SAASC,SAASD,QAAmB;IACxC,IAAI,CAACD,iBAAiBC,WAClB,OAAO;IAEX,IAAI;QACA,MAAME,UAAUC,KAAK,KAAK,CAACH,SAAS,OAAO;QAC3C,OAAO,CAAC,CAACE,QAAQ,KAAK;IAC1B,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
@@ -1,24 +1,20 @@
1
1
  import React from "react";
2
- import type { OnSortingChange, Sorting } from "@webiny/ui/DataTable";
3
- import type { Entry } from "../../../utils/transformCmsContentEntriesToRecordEntries";
4
- import type { ActionType } from "../../../types";
5
- type ActionProps = {
2
+ import { type DataTableSorting, type OnDataTableSortingChange } from "@webiny/admin-ui";
3
+ import type { IAuditLog } from "../../../types.js";
4
+ interface ActionProps {
6
5
  label: string;
7
- value: ActionType;
8
- };
6
+ value: string;
7
+ }
9
8
  export declare const Action: ({ label, value }: ActionProps) => React.JSX.Element;
10
9
  export interface TableProps {
11
- records: Entry[];
10
+ records: IAuditLog[];
12
11
  loading?: boolean;
13
- handleRecordSelect: (auditLog: Entry) => void;
14
- sorting: Sorting;
15
- onSortingChange: OnSortingChange;
12
+ handleRecordSelect: (auditLog: IAuditLog) => void;
13
+ sorting: DataTableSorting;
14
+ onSortingChange: OnDataTableSortingChange;
16
15
  hasAccessToUsers: boolean;
17
16
  }
18
- export interface EntryWithPreview extends Entry {
19
- /**
20
- * We need the preview property because data table is expecting it in columns.
21
- */
17
+ export interface EntryWithPreview extends IAuditLog {
22
18
  preview?: string;
23
19
  }
24
20
  export declare const Table: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,130 +1,117 @@
1
- import React, { forwardRef, useMemo } from "react";
2
- import { format, addMinutes } from "date-fns";
3
- import { ReactComponent as PreviewIcon } from "@webiny/icons/info.svg";
4
- import { DataTable } from "@webiny/ui/DataTable";
5
- import { IconButton } from "@webiny/ui/Button";
6
- import { Tooltip } from "@webiny/ui/Tooltip";
7
- import { Text } from "../../../components/Text";
8
- import { ActionWrapper, TextGray, TimezoneText, wideColumn, appColumn, previewColumn } from "./styled";
9
- export const Action = ({
10
- label,
11
- value
12
- }) => {
13
- return /*#__PURE__*/React.createElement(ActionWrapper, {
14
- value: value
15
- }, /*#__PURE__*/React.createElement(Text, {
16
- use: "subtitle1"
17
- }, label));
18
- };
19
- export const Table = /*#__PURE__*/forwardRef((props, ref) => {
20
- const {
21
- records,
22
- loading,
23
- handleRecordSelect,
24
- sorting,
25
- onSortingChange,
26
- hasAccessToUsers
27
- } = props;
28
- const columns = {
29
- savedOn: {
30
- header: "Timestamp",
31
- cell: ({
32
- savedOn
33
- }) => {
34
- const date = new Date(savedOn);
35
- return /*#__PURE__*/React.createElement(Tooltip, {
36
- placement: "right",
37
- content: `UTC: ${format(addMinutes(date, date.getTimezoneOffset()), "yyyy-MM-dd HH:mm:ss")}`
38
- }, /*#__PURE__*/React.createElement(Text, {
39
- use: "subtitle1"
40
- }, format(date, "yyyy-MM-dd HH:mm:ss")), /*#__PURE__*/React.createElement(TimezoneText, {
41
- use: "body2"
42
- }, format(date, "(O)")));
43
- },
44
- enableSorting: true
45
- },
46
- app: {
47
- header: "App/Entity",
48
- cell: ({
49
- app,
50
- entity,
51
- entityId
52
- }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
1
+ import react, { forwardRef, useMemo } from "react";
2
+ import { addMinutes, format } from "date-fns";
3
+ import { ReactComponent } from "@webiny/icons/search.svg";
4
+ import { Button, DataTable, Tooltip } from "@webiny/admin-ui";
5
+ import { Text } from "../../../components/Text.js";
6
+ import { getActionColorClasses } from "./styled.js";
7
+ const Action = ({ label, value })=>/*#__PURE__*/ react.createElement("div", {
8
+ className: `px-sm w-fit border border-solid rounded-[5px] ${getActionColorClasses(value)}`
9
+ }, /*#__PURE__*/ react.createElement(Text, {
53
10
  use: "subtitle1"
54
- }, app), entity && /*#__PURE__*/React.createElement(TextGray, {
55
- use: "body2"
56
- }, ` [Entity: ${entity.label}]`), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(TextGray, {
57
- use: "body2"
58
- }, `ID: `), entity.link ? /*#__PURE__*/React.createElement("a", {
59
- href: entity.link,
60
- target: "blank"
61
- }, /*#__PURE__*/React.createElement(Text, {
62
- use: "body2"
63
- }, entityId)) : /*#__PURE__*/React.createElement(Text, {
64
- use: "body2"
65
- }, entityId)),
66
- className: appColumn
67
- },
68
- action: {
69
- header: "Action",
70
- cell: ({
71
- action
72
- }) => /*#__PURE__*/React.createElement(Action, {
73
- label: action.label,
74
- value: action.value
75
- })
76
- },
77
- message: {
78
- header: "Message",
79
- cell: ({
80
- message
81
- }) => /*#__PURE__*/React.createElement(Text, {
82
- use: "subtitle1"
83
- }, message),
84
- className: wideColumn
85
- },
86
- ...(hasAccessToUsers && {
87
- initiator: {
88
- header: "Initiator",
89
- cell: ({
90
- initiator
91
- }) => /*#__PURE__*/React.createElement("a", {
92
- href: `/admin-users?id=${initiator.id}`,
93
- target: "blank"
94
- }, /*#__PURE__*/React.createElement(Text, {
95
- use: "subtitle1"
96
- }, initiator.name))
97
- }
98
- }),
99
- preview: {
100
- header: "",
101
- cell: auditLog => /*#__PURE__*/React.createElement(IconButton, {
102
- onClick: () => handleRecordSelect(auditLog),
103
- icon: /*#__PURE__*/React.createElement(PreviewIcon, null)
104
- }),
105
- className: previewColumn
106
- }
107
- };
108
- const tableSorting = useMemo(() => {
109
- if (!Array.isArray(sorting) || sorting.length === 0) {
110
- return [{
111
- id: "savedOn",
112
- desc: true
113
- }];
114
- }
115
- return sorting;
116
- }, [sorting]);
117
- return /*#__PURE__*/React.createElement("div", {
118
- ref: ref
119
- }, /*#__PURE__*/React.createElement(DataTable, {
120
- columns: columns,
121
- data: records,
122
- loadingInitial: loading,
123
- stickyRows: 1,
124
- sorting: tableSorting,
125
- onSortingChange: onSortingChange
126
- }));
11
+ }, label));
12
+ const Table = /*#__PURE__*/ forwardRef((props, ref)=>{
13
+ const { records, loading, handleRecordSelect, sorting, onSortingChange, hasAccessToUsers } = props;
14
+ const columns = {
15
+ createdOn: {
16
+ header: "Timestamp",
17
+ cell: (row)=>{
18
+ const date = new Date(row.createdOn);
19
+ return /*#__PURE__*/ react.createElement(Tooltip, {
20
+ side: "right",
21
+ content: `UTC: ${format(addMinutes(date, date.getTimezoneOffset()), "yyyy-MM-dd HH:mm:ss")}`,
22
+ trigger: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Text, {
23
+ use: "subtitle1"
24
+ }, format(date, "yyyy-MM-dd HH:mm:ss")), /*#__PURE__*/ react.createElement("span", {
25
+ className: "px-xs text-neutral-dimmed"
26
+ }, /*#__PURE__*/ react.createElement(Text, {
27
+ use: "body2"
28
+ }, format(date, "(O)"))))
29
+ });
30
+ },
31
+ enableSorting: true
32
+ },
33
+ app: {
34
+ header: "App/Entity",
35
+ cell: (row)=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Text, {
36
+ use: "subtitle1",
37
+ className: "text-neutral-strong"
38
+ }, row.app), row.entity && /*#__PURE__*/ react.createElement(react.Fragment, null, "\xa0/\xa0", /*#__PURE__*/ react.createElement("span", {
39
+ className: "text-neutral-strong"
40
+ }, /*#__PURE__*/ react.createElement(Text, {
41
+ use: "body2"
42
+ }, row.entity.label))), /*#__PURE__*/ react.createElement("br", null), /*#__PURE__*/ react.createElement("span", {
43
+ className: "text-neutral-dimmed"
44
+ }, /*#__PURE__*/ react.createElement(Text, {
45
+ use: "body2"
46
+ }, "ID: "), row.entity.link ? /*#__PURE__*/ react.createElement("a", {
47
+ href: row.entity.link,
48
+ target: "blank"
49
+ }, /*#__PURE__*/ react.createElement(Text, {
50
+ use: "body2"
51
+ }, row.entityId)) : /*#__PURE__*/ react.createElement(Text, {
52
+ use: "body2"
53
+ }, row.entityId))),
54
+ className: "!w-[280px]"
55
+ },
56
+ action: {
57
+ header: "Action",
58
+ cell: (row)=>/*#__PURE__*/ react.createElement(Action, {
59
+ label: row.action.label,
60
+ value: row.action.value
61
+ })
62
+ },
63
+ message: {
64
+ header: "Message",
65
+ cell: (row)=>/*#__PURE__*/ react.createElement(Text, {
66
+ use: "subtitle1"
67
+ }, row.message),
68
+ className: "!w-auto"
69
+ },
70
+ ...hasAccessToUsers && {
71
+ createdBy: {
72
+ header: "Initiator",
73
+ cell: (row)=>/*#__PURE__*/ react.createElement("a", {
74
+ href: `/admin-users?id=${row.createdBy.id}`,
75
+ target: "blank"
76
+ }, /*#__PURE__*/ react.createElement(Text, {
77
+ use: "subtitle1"
78
+ }, row.createdBy.displayName || "-"))
79
+ }
80
+ },
81
+ preview: {
82
+ header: "",
83
+ cell: (auditLog)=>/*#__PURE__*/ react.createElement(Button, {
84
+ variant: "secondary",
85
+ onClick: ()=>handleRecordSelect(auditLog),
86
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
87
+ text: "Details"
88
+ }),
89
+ className: "!w-[100px]"
90
+ }
91
+ };
92
+ const tableSorting = useMemo(()=>{
93
+ if (!Array.isArray(sorting) || 0 === sorting.length) return [
94
+ {
95
+ id: "savedOn",
96
+ desc: true
97
+ }
98
+ ];
99
+ return sorting;
100
+ }, [
101
+ sorting
102
+ ]);
103
+ return /*#__PURE__*/ react.createElement("div", {
104
+ ref: ref
105
+ }, /*#__PURE__*/ react.createElement(DataTable, {
106
+ columns: columns,
107
+ data: records,
108
+ loading: loading,
109
+ stickyHeader: true,
110
+ sorting: tableSorting,
111
+ onSortingChange: onSortingChange
112
+ }));
127
113
  });
128
114
  Table.displayName = "Table";
115
+ export { Action, Table };
129
116
 
130
117
  //# sourceMappingURL=Table.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useMemo","format","addMinutes","ReactComponent","PreviewIcon","DataTable","IconButton","Tooltip","Text","ActionWrapper","TextGray","TimezoneText","wideColumn","appColumn","previewColumn","Action","label","value","createElement","use","Table","props","ref","records","loading","handleRecordSelect","sorting","onSortingChange","hasAccessToUsers","columns","savedOn","header","cell","date","Date","placement","content","getTimezoneOffset","enableSorting","app","entity","entityId","Fragment","link","href","target","className","action","message","initiator","id","name","preview","auditLog","onClick","icon","tableSorting","Array","isArray","length","desc","data","loadingInitial","stickyRows","displayName"],"sources":["Table.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from \"react\";\nimport { format, addMinutes } from \"date-fns\";\n\nimport { ReactComponent as PreviewIcon } from \"@webiny/icons/info.svg\";\nimport type { Columns, OnSortingChange, Sorting } from \"@webiny/ui/DataTable\";\nimport { DataTable } from \"@webiny/ui/DataTable\";\nimport { IconButton } from \"@webiny/ui/Button\";\nimport { Tooltip } from \"@webiny/ui/Tooltip\";\n\nimport type { Entry } from \"~/utils/transformCmsContentEntriesToRecordEntries\";\nimport { Text } from \"~/components/Text\";\nimport {\n ActionWrapper,\n TextGray,\n TimezoneText,\n wideColumn,\n appColumn,\n previewColumn\n} from \"./styled\";\nimport type { ActionType } from \"~/types\";\n\ntype ActionProps = {\n label: string;\n value: ActionType;\n};\n\nexport const Action = ({ label, value }: ActionProps) => {\n return (\n <ActionWrapper value={value}>\n <Text use={\"subtitle1\"}>{label}</Text>\n </ActionWrapper>\n );\n};\n\nexport interface TableProps {\n records: Entry[];\n loading?: boolean;\n handleRecordSelect: (auditLog: Entry) => void;\n sorting: Sorting;\n onSortingChange: OnSortingChange;\n hasAccessToUsers: boolean;\n}\n\nexport interface EntryWithPreview extends Entry {\n /**\n * We need the preview property because data table is expecting it in columns.\n */\n preview?: string;\n}\n\nexport const Table = forwardRef<HTMLDivElement, TableProps>((props, ref) => {\n const { records, loading, handleRecordSelect, sorting, onSortingChange, hasAccessToUsers } =\n props;\n\n const columns: Columns<EntryWithPreview> = {\n savedOn: {\n header: \"Timestamp\",\n cell: ({ savedOn }) => {\n const date = new Date(savedOn);\n\n return (\n <Tooltip\n placement=\"right\"\n content={`UTC: ${format(\n addMinutes(date, date.getTimezoneOffset()),\n \"yyyy-MM-dd HH:mm:ss\"\n )}`}\n >\n <Text use={\"subtitle1\"}>{format(date, \"yyyy-MM-dd HH:mm:ss\")}</Text>\n <TimezoneText use={\"body2\"}>{format(date, \"(O)\")}</TimezoneText>\n </Tooltip>\n );\n },\n enableSorting: true\n },\n app: {\n header: \"App/Entity\",\n cell: ({ app, entity, entityId }) => (\n <>\n <Text use={\"subtitle1\"}>{app}</Text>\n {entity && <TextGray use={\"body2\"}>{` [Entity: ${entity.label}]`}</TextGray>}\n <br />\n <TextGray use={\"body2\"}>{`ID: `}</TextGray>\n {entity.link ? (\n <a href={entity.link} target={\"blank\"}>\n <Text use={\"body2\"}>{entityId}</Text>\n </a>\n ) : (\n <Text use={\"body2\"}>{entityId}</Text>\n )}\n </>\n ),\n className: appColumn\n },\n action: {\n header: \"Action\",\n cell: ({ action }) => <Action label={action.label} value={action.value} />\n },\n message: {\n header: \"Message\",\n cell: ({ message }) => <Text use={\"subtitle1\"}>{message}</Text>,\n className: wideColumn\n },\n ...(hasAccessToUsers && {\n initiator: {\n header: \"Initiator\",\n cell: ({ initiator }) => (\n <a href={`/admin-users?id=${initiator.id}`} target={\"blank\"}>\n <Text use={\"subtitle1\"}>{initiator.name}</Text>\n </a>\n )\n }\n }),\n preview: {\n header: \"\",\n cell: auditLog => (\n <IconButton onClick={() => handleRecordSelect(auditLog)} icon={<PreviewIcon />} />\n ),\n className: previewColumn\n }\n };\n\n const tableSorting = useMemo(() => {\n if (!Array.isArray(sorting) || sorting.length === 0) {\n return [\n {\n id: \"savedOn\",\n desc: true\n }\n ];\n }\n\n return sorting;\n }, [sorting]);\n\n return (\n <div ref={ref}>\n <DataTable\n columns={columns}\n data={records}\n loadingInitial={loading}\n stickyRows={1}\n sorting={tableSorting}\n onSortingChange={onSortingChange}\n />\n </div>\n );\n});\n\nTable.displayName = \"Table\";\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,MAAM,EAAEC,UAAU,QAAQ,UAAU;AAE7C,SAASC,cAAc,IAAIC,WAAW,QAAQ,wBAAwB;AAEtE,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,OAAO,QAAQ,oBAAoB;AAG5C,SAASC,IAAI;AACb,SACIC,aAAa,EACbC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,SAAS,EACTC,aAAa;AASjB,OAAO,MAAMC,MAAM,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAmB,CAAC,KAAK;EACrD,oBACInB,KAAA,CAAAoB,aAAA,CAACT,aAAa;IAACQ,KAAK,EAAEA;EAAM,gBACxBnB,KAAA,CAAAoB,aAAA,CAACV,IAAI;IAACW,GAAG,EAAE;EAAY,GAAEH,KAAY,CAC1B,CAAC;AAExB,CAAC;AAkBD,OAAO,MAAMI,KA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CAACE,IAAW,CAC/C;MAEX;IACJ,CAAC,CAAC;IACFC,OAAO,EAAE;MACLrB,MAAM,EAAE,EAAE;MACVC,IAAI,EAAEqB,QAAQ,iBACVvD,KAAA,CAAAoB,aAAA,CAACZ,UAAU;QAACgD,OAAO,EAAEA,CAAA,KAAM7B,kBAAkB,CAAC4B,QAAQ,CAAE;QAACE,IAAI,eAAEzD,KAAA,CAAAoB,aAAA,CAACd,WAAW,MAAE;MAAE,CAAE,CACpF;MACD0C,SAAS,EAAEhC;IACf;EACJ,CAAC;EAED,MAAM0C,YAAY,GAAGxD,OAAO,CAAC,MAAM;IAC/B,IAAI,CAACyD,KAAK,CAACC,OAAO,CAAChC,OAAO,CAAC,IAAIA,OAAO,CAACiC,MAAM,KAAK,CAAC,EAAE;MACjD,OAAO,CACH;QACIT,EAAE,EAAE,SAAS;QACbU,IAAI,EAAE;MACV,CAAC,CACJ;IACL;IAEA,OAAOlC,OAAO;EAClB,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,oBACI5B,KAAA,CAAAoB,aAAA;IAAKI,GAAG,EAAEA;EAAI,gBACVxB,KAAA,CAAAoB,aAAA,CAACb,SAAS;IACNwB,OAAO,EAAEA,OAAQ;IACjBgC,IAAI,EAAEtC,OAAQ;IACduC,cAAc,EAAEtC,OAAQ;IACxBuC,UAAU,EAAE,CAAE;IACdrC,OAAO,EAAE8B,YAAa;IACtB7B,eAAe,EAAEA;EAAgB,CACpC,CACA,CAAC;AAEd,CAAC,CAAC;AAEFP,KAAK,CAAC4C,WAAW,GAAG,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"views/Logs/Table/Table.js","sources":["../../../../src/views/Logs/Table/Table.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from \"react\";\nimport { addMinutes, format } from \"date-fns\";\nimport { ReactComponent as PreviewIcon } from \"@webiny/icons/search.svg\";\nimport {\n Button,\n type DataTableColumns,\n type DataTableSorting,\n type OnDataTableSortingChange\n} from \"@webiny/admin-ui\";\nimport { DataTable, Tooltip } from \"@webiny/admin-ui\";\n\nimport { Text } from \"~/components/Text.js\";\nimport { getActionColorClasses } from \"./styled.js\";\nimport type { IAuditLog } from \"~/types.js\";\n\ninterface ActionProps {\n label: string;\n value: string;\n}\n\nexport const Action = ({ label, value }: ActionProps) => {\n return (\n <div\n className={`px-sm w-fit border border-solid rounded-[5px] ${getActionColorClasses(value)}`}\n >\n <Text use={\"subtitle1\"}>{label}</Text>\n </div>\n );\n};\n\nexport interface TableProps {\n records: IAuditLog[];\n loading?: boolean;\n handleRecordSelect: (auditLog: IAuditLog) => void;\n sorting: DataTableSorting;\n onSortingChange: OnDataTableSortingChange;\n hasAccessToUsers: boolean;\n}\n\nexport interface EntryWithPreview extends IAuditLog {\n preview?: string;\n}\n\nexport const Table = forwardRef<HTMLDivElement, TableProps>((props, ref) => {\n const { records, loading, handleRecordSelect, sorting, onSortingChange, hasAccessToUsers } =\n props;\n\n const columns: DataTableColumns<EntryWithPreview> = {\n createdOn: {\n header: \"Timestamp\",\n cell: (row: EntryWithPreview) => {\n const date = new Date(row.createdOn);\n\n return (\n <Tooltip\n side=\"right\"\n content={`UTC: ${format(\n addMinutes(date, date.getTimezoneOffset()),\n \"yyyy-MM-dd HH:mm:ss\"\n )}`}\n trigger={\n <>\n <Text use={\"subtitle1\"}>{format(date, \"yyyy-MM-dd HH:mm:ss\")}</Text>\n <span className={\"px-xs text-neutral-dimmed\"}>\n <Text use={\"body2\"}>{format(date, \"(O)\")}</Text>\n </span>\n </>\n }\n />\n );\n },\n enableSorting: true\n },\n app: {\n header: \"App/Entity\",\n cell: (row: EntryWithPreview) => (\n <>\n <Text use={\"subtitle1\"} className={\"text-neutral-strong\"}>\n {row.app}\n </Text>\n {row.entity && (\n <>\n &nbsp;/&nbsp;\n <span className={\"text-neutral-strong\"}>\n <Text use={\"body2\"}>{row.entity.label}</Text>\n </span>\n </>\n )}\n <br />\n <span className={\"text-neutral-dimmed\"}>\n <Text use={\"body2\"}>{`ID: `}</Text>\n {row.entity.link ? (\n <a href={row.entity.link} target={\"blank\"}>\n <Text use={\"body2\"}>{row.entityId}</Text>\n </a>\n ) : (\n <Text use={\"body2\"}>{row.entityId}</Text>\n )}\n </span>\n </>\n ),\n className: \"!w-[280px]\"\n },\n action: {\n header: \"Action\",\n cell: (row: EntryWithPreview) => (\n <Action label={row.action.label} value={row.action.value} />\n )\n },\n message: {\n header: \"Message\",\n cell: (row: EntryWithPreview) => <Text use={\"subtitle1\"}>{row.message}</Text>,\n className: \"!w-auto\"\n },\n ...(hasAccessToUsers && {\n createdBy: {\n header: \"Initiator\",\n cell: (row: EntryWithPreview) => (\n <a href={`/admin-users?id=${row.createdBy.id}`} target={\"blank\"}>\n <Text use={\"subtitle1\"}>{row.createdBy.displayName || \"-\"}</Text>\n </a>\n )\n }\n }),\n preview: {\n header: \"\",\n cell: (auditLog: EntryWithPreview) => (\n <Button\n variant={\"secondary\"}\n onClick={() => handleRecordSelect(auditLog)}\n icon={<PreviewIcon />}\n text={\"Details\"}\n />\n ),\n className: \"!w-[100px]\"\n }\n };\n\n const tableSorting = useMemo(() => {\n if (!Array.isArray(sorting) || sorting.length === 0) {\n return [\n {\n id: \"savedOn\",\n desc: true\n }\n ];\n }\n\n return sorting;\n }, [sorting]);\n\n return (\n <div ref={ref}>\n <DataTable\n columns={columns}\n data={records}\n loading={loading}\n stickyHeader={true}\n sorting={tableSorting}\n onSortingChange={onSortingChange}\n />\n </div>\n );\n});\n\nTable.displayName = \"Table\";\n"],"names":["Action","label","value","getActionColorClasses","Text","Table","forwardRef","props","ref","records","loading","handleRecordSelect","sorting","onSortingChange","hasAccessToUsers","columns","row","date","Date","Tooltip","format","addMinutes","auditLog","Button","PreviewIcon","tableSorting","useMemo","Array","DataTable"],"mappings":";;;;;;AAoBO,MAAMA,SAAS,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAe,GACzC,WAAP,GACI,oBAAC;QACG,WAAW,CAAC,8CAA8C,EAAEC,sBAAsBD,Q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;QACA,QAAQ;YACJ,QAAQ;YACR,MAAM,CAACA,MAAAA,WAAAA,GACH,oBAAChB,QAAMA;oBAAC,OAAOgB,IAAI,MAAM,CAAC,KAAK;oBAAE,OAAOA,IAAI,MAAM,CAAC,KAAK;;QAEhE;QACA,SAAS;YACL,QAAQ;YACR,MAAM,CAACA,MAAAA,WAAAA,GAA0B,oBAACZ,MAAIA;oBAAC,KAAK;mBAAcY,IAAI,OAAO;YACrE,WAAW;QACf;QACA,GAAIF,oBAAoB;YACpB,WAAW;gBACP,QAAQ;gBACR,MAAM,CAACE,MAAAA,WAAAA,GACH,oBAAC;wBAAE,MAAM,CAAC,gBAAgB,EAAEA,IAAI,SAAS,CAAC,EAAE,EAAE;wBAAE,QAAQ;qCACpD,oBAACZ,MAAIA;wBAAC,KAAK;uBAAcY,IAAI,SAAS,CAAC,WAAW,IAAI;YAGlE;QACJ,CAAC;QACD,SAAS;YACL,QAAQ;YACR,MAAM,CAACM,WAAAA,WAAAA,GACH,oBAACC,QAAMA;oBACH,SAAS;oBACT,SAAS,IAAMZ,mBAAmBW;oBAClC,oBAAM,oBAACE,gBAAWA;oBAClB,MAAM;;YAGd,WAAW;QACf;IACJ;IAEA,MAAMC,eAAeC,QAAQ;QACzB,IAAI,CAACC,MAAM,OAAO,CAACf,YAAYA,AAAmB,MAAnBA,QAAQ,MAAM,EACzC,OAAO;YACH;gBACI,IAAI;gBACJ,MAAM;YACV;SACH;QAGL,OAAOA;IACX,GAAG;QAACA;KAAQ;IAEZ,OAAO,WAAP,GACI,oBAAC;QAAI,KAAKJ;qBACN,oBAACoB,WAASA;QACN,SAASb;QACT,MAAMN;QACN,SAASC;QACT,cAAc;QACd,SAASe;QACT,iBAAiBZ;;AAIjC;AAEAR,MAAM,WAAW,GAAG"}
@@ -1 +1 @@
1
- export * from "./Table";
1
+ export * from "./Table.js";
@@ -1,3 +1 @@
1
- export * from "./Table";
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export * from "./Table.js";
@@ -1,17 +1 @@
1
- /// <reference types="react" />
2
- import { ActionType } from "../../../types";
3
- export declare const ActionWrapper: import("@emotion/styled").StyledComponent<{
4
- theme?: import("@emotion/react").Theme | undefined;
5
- as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
6
- } & {
7
- value: ActionType;
8
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
- export declare const wideColumn: string;
10
- export declare const appColumn: string;
11
- export declare const previewColumn: string;
12
- export declare const TextGray: import("@emotion/styled").StyledComponent<import("@webiny/ui/Typography/Typography").TypographyProps & {
13
- theme?: import("@emotion/react").Theme | undefined;
14
- }, {}, {}>;
15
- export declare const TimezoneText: import("@emotion/styled").StyledComponent<import("@webiny/ui/Typography/Typography").TypographyProps & {
16
- theme?: import("@emotion/react").Theme | undefined;
17
- }, {}, {}>;
1
+ export declare function getActionColorClasses(value: string): string;