@webiny/api-audit-logs 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (274) hide show
  1. package/AuditLogsFeature.js +19 -30
  2. package/AuditLogsFeature.js.map +1 -1
  3. package/abstractions.d.ts +9 -4
  4. package/abstractions.js +2 -2
  5. package/abstractions.js.map +1 -1
  6. package/domain/errors.d.ts +5 -0
  7. package/domain/errors.js +11 -0
  8. package/domain/errors.js.map +1 -0
  9. package/events/abstractions.d.ts +0 -5
  10. package/events/abstractions.js.map +1 -1
  11. package/features/AuditLogPermissions/AuditLogPermissions.d.ts +15 -0
  12. package/features/AuditLogPermissions/AuditLogPermissions.js +24 -0
  13. package/features/AuditLogPermissions/AuditLogPermissions.js.map +1 -0
  14. package/features/AuditLogPermissions/abstractions.d.ts +11 -0
  15. package/features/AuditLogPermissions/abstractions.js +5 -0
  16. package/features/AuditLogPermissions/abstractions.js.map +1 -0
  17. package/features/AuditLogPermissions/feature.d.ts +4 -0
  18. package/features/AuditLogPermissions/feature.js +11 -0
  19. package/features/AuditLogPermissions/feature.js.map +1 -0
  20. package/features/CreateAuditLog/CreateAuditLogGateway.d.ts +12 -0
  21. package/features/CreateAuditLog/CreateAuditLogGateway.js +23 -0
  22. package/features/CreateAuditLog/CreateAuditLogGateway.js.map +1 -0
  23. package/features/CreateAuditLog/CreateAuditLogRepository.d.ts +14 -0
  24. package/features/CreateAuditLog/CreateAuditLogRepository.js +25 -0
  25. package/features/CreateAuditLog/CreateAuditLogRepository.js.map +1 -0
  26. package/features/CreateAuditLog/CreateAuditLogUseCase.d.ts +24 -0
  27. package/features/CreateAuditLog/CreateAuditLogUseCase.js +70 -0
  28. package/features/CreateAuditLog/CreateAuditLogUseCase.js.map +1 -0
  29. package/features/CreateAuditLog/abstractions.d.ts +42 -0
  30. package/features/CreateAuditLog/abstractions.js +7 -0
  31. package/features/CreateAuditLog/abstractions.js.map +1 -0
  32. package/features/CreateAuditLog/feature.d.ts +4 -0
  33. package/features/CreateAuditLog/feature.js +15 -0
  34. package/features/CreateAuditLog/feature.js.map +1 -0
  35. package/features/GetAuditLog/GetAuditLogGateway.d.ts +13 -0
  36. package/features/GetAuditLog/GetAuditLogGateway.js +21 -0
  37. package/features/GetAuditLog/GetAuditLogGateway.js.map +1 -0
  38. package/features/GetAuditLog/GetAuditLogRepository.d.ts +16 -0
  39. package/features/GetAuditLog/GetAuditLogRepository.js +32 -0
  40. package/features/GetAuditLog/GetAuditLogRepository.js.map +1 -0
  41. package/features/GetAuditLog/GetAuditLogUseCase.d.ts +15 -0
  42. package/features/GetAuditLog/GetAuditLogUseCase.js +29 -0
  43. package/features/GetAuditLog/GetAuditLogUseCase.js.map +1 -0
  44. package/features/GetAuditLog/abstractions.d.ts +42 -0
  45. package/features/GetAuditLog/abstractions.js +7 -0
  46. package/features/GetAuditLog/abstractions.js.map +1 -0
  47. package/features/GetAuditLog/feature.d.ts +4 -0
  48. package/features/GetAuditLog/feature.js +15 -0
  49. package/features/GetAuditLog/feature.js.map +1 -0
  50. package/features/ListAuditLogs/ListAuditLogsGateway.d.ts +12 -0
  51. package/features/ListAuditLogs/ListAuditLogsGateway.js +24 -0
  52. package/features/ListAuditLogs/ListAuditLogsGateway.js.map +1 -0
  53. package/features/ListAuditLogs/ListAuditLogsRepository.d.ts +17 -0
  54. package/features/ListAuditLogs/ListAuditLogsRepository.js +38 -0
  55. package/features/ListAuditLogs/ListAuditLogsRepository.js.map +1 -0
  56. package/features/ListAuditLogs/ListAuditLogsUseCase.d.ts +15 -0
  57. package/features/ListAuditLogs/ListAuditLogsUseCase.js +27 -0
  58. package/features/ListAuditLogs/ListAuditLogsUseCase.js.map +1 -0
  59. package/features/ListAuditLogs/abstractions.d.ts +55 -0
  60. package/features/ListAuditLogs/abstractions.js +7 -0
  61. package/features/ListAuditLogs/abstractions.js.map +1 -0
  62. package/features/ListAuditLogs/feature.d.ts +4 -0
  63. package/features/ListAuditLogs/feature.js +15 -0
  64. package/features/ListAuditLogs/feature.js.map +1 -0
  65. package/features/RecordAuditLog/RecordAuditLogUseCase.d.ts +30 -0
  66. package/features/RecordAuditLog/RecordAuditLogUseCase.js +108 -0
  67. package/features/RecordAuditLog/RecordAuditLogUseCase.js.map +1 -0
  68. package/features/RecordAuditLog/abstractions.d.ts +26 -0
  69. package/features/RecordAuditLog/abstractions.js +5 -0
  70. package/features/RecordAuditLog/abstractions.js.map +1 -0
  71. package/features/RecordAuditLog/feature.d.ts +4 -0
  72. package/features/RecordAuditLog/feature.js +11 -0
  73. package/features/RecordAuditLog/feature.js.map +1 -0
  74. package/features/UpdateAuditLog/UpdateAuditLogGateway.d.ts +12 -0
  75. package/features/UpdateAuditLog/UpdateAuditLogGateway.js +23 -0
  76. package/features/UpdateAuditLog/UpdateAuditLogGateway.js.map +1 -0
  77. package/features/UpdateAuditLog/UpdateAuditLogRepository.d.ts +14 -0
  78. package/features/UpdateAuditLog/UpdateAuditLogRepository.js +25 -0
  79. package/features/UpdateAuditLog/UpdateAuditLogRepository.js.map +1 -0
  80. package/features/UpdateAuditLog/UpdateAuditLogUseCase.d.ts +18 -0
  81. package/features/UpdateAuditLog/UpdateAuditLogUseCase.js +53 -0
  82. package/features/UpdateAuditLog/UpdateAuditLogUseCase.js.map +1 -0
  83. package/features/UpdateAuditLog/abstractions.d.ts +42 -0
  84. package/features/UpdateAuditLog/abstractions.js +7 -0
  85. package/features/UpdateAuditLog/abstractions.js.map +1 -0
  86. package/features/UpdateAuditLog/feature.d.ts +4 -0
  87. package/features/UpdateAuditLog/feature.js +15 -0
  88. package/features/UpdateAuditLog/feature.js.map +1 -0
  89. package/graphql/AuditLogsGraphQLSchema.d.ts +1 -0
  90. package/graphql/AuditLogsGraphQLSchema.js +18 -13
  91. package/graphql/AuditLogsGraphQLSchema.js.map +1 -1
  92. package/graphql/validation.d.ts +3 -3
  93. package/package.json +25 -24
  94. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.d.ts +3 -3
  95. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +18 -9
  96. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -1
  97. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +3 -3
  98. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +35 -13
  99. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
  100. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +3 -3
  101. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +24 -15
  102. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js.map +1 -1
  103. package/subscriptions/aco/index.d.ts +2 -2
  104. package/subscriptions/aco/index.js +4 -4
  105. package/subscriptions/aco/index.js.map +1 -1
  106. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +11 -0
  107. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +45 -0
  108. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -0
  109. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +11 -0
  110. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +42 -0
  111. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -0
  112. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +11 -0
  113. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +44 -0
  114. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -0
  115. package/subscriptions/ai/index.d.ts +2 -0
  116. package/subscriptions/ai/index.js +11 -0
  117. package/subscriptions/ai/index.js.map +1 -0
  118. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.d.ts +3 -3
  119. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +11 -7
  120. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -1
  121. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +3 -3
  122. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +11 -7
  123. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -1
  124. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +3 -3
  125. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +14 -10
  126. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -1
  127. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +3 -3
  128. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +14 -10
  129. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js.map +1 -1
  130. package/subscriptions/fileManager/index.d.ts +2 -2
  131. package/subscriptions/fileManager/index.js +5 -5
  132. package/subscriptions/fileManager/index.js.map +1 -1
  133. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.d.ts +3 -3
  134. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +11 -7
  135. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -1
  136. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +3 -3
  137. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +18 -9
  138. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -1
  139. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +3 -3
  140. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +11 -7
  141. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -1
  142. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +3 -3
  143. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +11 -7
  144. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -1
  145. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +3 -3
  146. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +11 -7
  147. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -1
  148. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +3 -3
  149. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +14 -10
  150. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -1
  151. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +3 -3
  152. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +11 -7
  153. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -1
  154. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +3 -3
  155. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +11 -7
  156. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -1
  157. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +3 -3
  158. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +11 -7
  159. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -1
  160. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +3 -3
  161. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +11 -7
  162. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -1
  163. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +3 -3
  164. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +14 -10
  165. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -1
  166. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +3 -3
  167. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +11 -7
  168. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -1
  169. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +3 -3
  170. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +11 -7
  171. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -1
  172. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +3 -3
  173. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js +14 -10
  174. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js.map +1 -1
  175. package/subscriptions/headlessCms/index.d.ts +2 -2
  176. package/subscriptions/headlessCms/index.js +15 -15
  177. package/subscriptions/headlessCms/index.js.map +1 -1
  178. package/subscriptions/index.d.ts +2 -2
  179. package/subscriptions/index.js +9 -7
  180. package/subscriptions/index.js.map +1 -1
  181. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +3 -3
  182. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +13 -9
  183. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -1
  184. package/subscriptions/mailer/index.d.ts +2 -2
  185. package/subscriptions/mailer/index.js +2 -2
  186. package/subscriptions/mailer/index.js.map +1 -1
  187. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.d.ts +3 -3
  188. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +11 -7
  189. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -1
  190. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +3 -3
  191. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +11 -7
  192. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -1
  193. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +3 -3
  194. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +14 -10
  195. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -1
  196. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +3 -3
  197. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +11 -7
  198. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -1
  199. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +3 -3
  200. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +11 -7
  201. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -1
  202. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +3 -3
  203. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +14 -10
  204. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -1
  205. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +3 -3
  206. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +11 -7
  207. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -1
  208. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +3 -3
  209. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +11 -7
  210. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -1
  211. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +3 -3
  212. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +14 -10
  213. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -1
  214. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +3 -3
  215. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +11 -7
  216. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -1
  217. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +3 -3
  218. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +11 -7
  219. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -1
  220. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +3 -3
  221. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +14 -10
  222. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js.map +1 -1
  223. package/subscriptions/security/index.d.ts +2 -2
  224. package/subscriptions/security/index.js +13 -13
  225. package/subscriptions/security/index.js.map +1 -1
  226. package/subscriptions/websiteBuilder/globalComponents/SaveGlobalComponentWithAuditLog.d.ts +21 -0
  227. package/subscriptions/websiteBuilder/globalComponents/SaveGlobalComponentWithAuditLog.js +63 -0
  228. package/subscriptions/websiteBuilder/globalComponents/SaveGlobalComponentWithAuditLog.js.map +1 -0
  229. package/subscriptions/websiteBuilder/index.d.ts +2 -2
  230. package/subscriptions/websiteBuilder/index.js +15 -13
  231. package/subscriptions/websiteBuilder/index.js.map +1 -1
  232. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.d.ts +3 -3
  233. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js +11 -7
  234. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js.map +1 -1
  235. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.d.ts +3 -3
  236. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js +11 -7
  237. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js.map +1 -1
  238. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.d.ts +3 -3
  239. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js +11 -7
  240. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js.map +1 -1
  241. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.d.ts +3 -3
  242. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js +14 -10
  243. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js.map +1 -1
  244. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.d.ts +3 -3
  245. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js +11 -7
  246. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js.map +1 -1
  247. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.d.ts +3 -3
  248. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js +11 -7
  249. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js.map +1 -1
  250. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.d.ts +3 -3
  251. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js +11 -7
  252. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js.map +1 -1
  253. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.d.ts +3 -3
  254. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js +14 -10
  255. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js.map +1 -1
  256. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.d.ts +3 -3
  257. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js +11 -7
  258. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js.map +1 -1
  259. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.d.ts +3 -3
  260. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js +11 -7
  261. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js.map +1 -1
  262. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.d.ts +3 -3
  263. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js +11 -7
  264. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js.map +1 -1
  265. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.d.ts +3 -3
  266. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js +14 -10
  267. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js.map +1 -1
  268. package/types.d.ts +0 -22
  269. package/context/AuditLogsContextValue.d.ts +0 -10
  270. package/context/AuditLogsContextValue.js +0 -131
  271. package/context/AuditLogsContextValue.js.map +0 -1
  272. package/utils/getAuditConfig.d.ts +0 -4
  273. package/utils/getAuditConfig.js +0 -88
  274. package/utils/getAuditConfig.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/RecordAuditLog/RecordAuditLogUseCase.js","sources":["../../../src/features/RecordAuditLog/RecordAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { CreateAuditLogUseCase } from \"~/features/CreateAuditLog/abstractions.js\";\nimport { ListAuditLogsUseCase } from \"~/features/ListAuditLogs/abstractions.js\";\nimport { UpdateAuditLogUseCase } from \"~/features/UpdateAuditLog/abstractions.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { RecordAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\nconst createAuditLogDelayDate = (delay: number): Date => {\n const date = new Date();\n date.setTime(date.getTime() - delay * 1000);\n return date;\n};\n\n/**\n * Records audit logs for things the current identity did. Writes happen without authorization,\n * because the identity doing the audited action doesn't need audit log permissions.\n *\n * An action with a `newEntryDelay` merges into the entity's latest audit log when that log is\n * newer than the delay, instead of creating a new one. A failure on that path is logged and\n * nothing is recorded.\n */\nclass RecordAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly createAuditLog: CreateAuditLogUseCase.Interface,\n private readonly listAuditLogs: ListAuditLogsUseCase.Interface,\n private readonly updateAuditLog: UpdateAuditLogUseCase.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly logger: Logger.Interface\n ) {}\n\n public async execute(\n input: UseCaseAbstraction.Input\n ): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>> {\n const { audit, message, content, entityId } = input;\n\n if (!this.identityContext.getIdentity()?.id) {\n this.logger.debug(\"No identity, skipping audit log creation.\");\n return Result.ok(null);\n }\n\n const payload: AuditLogPayload = {\n message,\n app: audit.app.app,\n entityId,\n entity: audit.entity.type,\n action: audit.action.type,\n content,\n tags: []\n };\n\n const delay = audit.action.newEntryDelay || 0;\n\n return await this.identityContext.withoutAuthorization(async () => {\n if (delay > 0) {\n try {\n return await this.createOrMergeAuditLog(payload, delay);\n } catch (error) {\n this.logger.warn({ error }, \"Could not create or merge an audit log.\");\n return Result.ok(null);\n }\n }\n return await this.createAuditLog.execute(payload);\n });\n }\n\n private async createOrMergeAuditLog(\n payload: AuditLogPayload,\n delay: number\n ): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>> {\n const createdOnGte = createAuditLogDelayDate(delay);\n const listResult = await this.listAuditLogs.execute({\n app: payload.app,\n entityId: payload.entityId,\n limit: 1,\n createdOn_gte: createdOnGte,\n sort: \"DESC\"\n });\n if (listResult.isFail()) {\n this.logger.warn(\n { error: listResult.error },\n \"Could not list audit logs to merge into.\"\n );\n return Result.ok(null);\n }\n\n const original = listResult.value.items[0];\n if (!original) {\n const createResult = await this.createAuditLog.execute(payload);\n if (createResult.isFail()) {\n this.logger.warn({ error: createResult.error }, \"Could not create an audit log.\");\n return Result.ok(null);\n }\n return Result.ok(createResult.value);\n }\n\n // Update the latest audit log with the new \"after\" payload, keeping its original \"before\".\n // Only the message and the content change: the original log keeps everything else,\n // including any tags it was created with.\n let content = payload.content;\n if (original.content) {\n const beforePayloadData = JSON.parse(original.content)?.before;\n if (beforePayloadData) {\n content = {\n before: beforePayloadData,\n after: payload.content?.after\n };\n }\n }\n\n const updateResult = await this.updateAuditLog.execute(original, {\n message: payload.message,\n content\n });\n if (updateResult.isFail()) {\n this.logger.warn({ error: updateResult.error }, \"Could not merge an audit log.\");\n return Result.ok(null);\n }\n\n return Result.ok(updateResult.value);\n }\n}\n\nexport const RecordAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: RecordAuditLogUseCaseImpl,\n dependencies: [\n CreateAuditLogUseCase,\n ListAuditLogsUseCase,\n UpdateAuditLogUseCase,\n IdentityContext,\n Logger\n ]\n});\n"],"names":["createAuditLogDelayDate","delay","date","Date","RecordAuditLogUseCaseImpl","createAuditLog","listAuditLogs","updateAuditLog","identityContext","logger","input","audit","message","content","entityId","Result","payload","error","createdOnGte","listResult","original","createResult","beforePayloadData","JSON","updateResult","RecordAuditLogUseCase","UseCaseAbstraction","CreateAuditLogUseCase","ListAuditLogsUseCase","UpdateAuditLogUseCase","IdentityContext","Logger"],"mappings":";;;;;;;AAUA,MAAMA,0BAA0B,CAACC;IAC7B,MAAMC,OAAO,IAAIC;IACjBD,KAAK,OAAO,CAACA,KAAK,OAAO,KAAKD,AAAQ,OAARA;IAC9B,OAAOC;AACX;AAUA,MAAME;IACF,YACqBC,cAA+C,EAC/CC,aAA6C,EAC7CC,cAA+C,EAC/CC,eAA0C,EAC1CC,MAAwB,CAC3C;aALmBJ,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;aACAC,eAAe,GAAfA;aACAC,MAAM,GAANA;IAClB;IAEH,MAAa,QACTC,KAA+B,EAC4B;QAC3D,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGJ;QAE9C,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI,IAAI;YACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAClB,OAAOK,OAAO,EAAE,CAAC;QACrB;QAEA,MAAMC,UAA2B;YAC7BJ;YACA,KAAKD,MAAM,GAAG,CAAC,GAAG;YAClBG;YACA,QAAQH,MAAM,MAAM,CAAC,IAAI;YACzB,QAAQA,MAAM,MAAM,CAAC,IAAI;YACzBE;YACA,MAAM,EAAE;QACZ;QAEA,MAAMZ,QAAQU,MAAM,MAAM,CAAC,aAAa,IAAI;QAE5C,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC;YACnD,IAAIV,QAAQ,GACR,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAACe,SAASf;YACrD,EAAE,OAAOgB,OAAO;gBACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;oBAAEA;gBAAM,GAAG;gBAC5B,OAAOF,OAAO,EAAE,CAAC;YACrB;YAEJ,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACC;QAC7C;IACJ;IAEA,MAAc,sBACVA,OAAwB,EACxBf,KAAa,EAC8C;QAC3D,MAAMiB,eAAelB,wBAAwBC;QAC7C,MAAMkB,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAChD,KAAKH,QAAQ,GAAG;YAChB,UAAUA,QAAQ,QAAQ;YAC1B,OAAO;YACP,eAAeE;YACf,MAAM;QACV;QACA,IAAIC,WAAW,MAAM,IAAI;YACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ;gBAAE,OAAOA,WAAW,KAAK;YAAC,GAC1B;YAEJ,OAAOJ,OAAO,EAAE,CAAC;QACrB;QAEA,MAAMK,WAAWD,WAAW,KAAK,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI,CAACC,UAAU;YACX,MAAMC,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACL;YACvD,IAAIK,aAAa,MAAM,IAAI;gBACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;oBAAE,OAAOA,aAAa,KAAK;gBAAC,GAAG;gBAChD,OAAON,OAAO,EAAE,CAAC;YACrB;YACA,OAAOA,OAAO,EAAE,CAACM,aAAa,KAAK;QACvC;QAKA,IAAIR,UAAUG,QAAQ,OAAO;QAC7B,IAAII,SAAS,OAAO,EAAE;YAClB,MAAME,oBAAoBC,KAAK,KAAK,CAACH,SAAS,OAAO,GAAG;YACxD,IAAIE,mBACAT,UAAU;gBACN,QAAQS;gBACR,OAAON,QAAQ,OAAO,EAAE;YAC5B;QAER;QAEA,MAAMQ,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACJ,UAAU;YAC7D,SAASJ,QAAQ,OAAO;YACxBH;QACJ;QACA,IAAIW,aAAa,MAAM,IAAI;YACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAAE,OAAOA,aAAa,KAAK;YAAC,GAAG;YAChD,OAAOT,OAAO,EAAE,CAAC;QACrB;QAEA,OAAOA,OAAO,EAAE,CAACS,aAAa,KAAK;IACvC;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBtB;IAChB,cAAc;QACVuB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -0,0 +1,26 @@
1
+ import type { Result } from "@webiny/feature/api";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ import type { AuditAction } from "../../types.js";
4
+ import type { IAuditLog } from "../../storage/types.js";
5
+ import type { CreateAuditLogUseCase } from "../../features/CreateAuditLog/abstractions.js";
6
+ export interface RecordAuditLogInput {
7
+ audit: AuditAction;
8
+ message: string;
9
+ content: GenericRecord;
10
+ entityId: string;
11
+ }
12
+ /**
13
+ * RecordAuditLog Use Case - Records an audit log for something the current identity did. Returns
14
+ * null when nothing was recorded: there's no identity, or merging into an earlier log failed.
15
+ */
16
+ export interface IRecordAuditLogUseCase {
17
+ execute(input: RecordAuditLogInput): Promise<Result<IAuditLog | null, UseCaseError>>;
18
+ }
19
+ type UseCaseError = CreateAuditLogUseCase.Error;
20
+ export declare const RecordAuditLogUseCase: import("@webiny/di").Abstraction<IRecordAuditLogUseCase>;
21
+ export declare namespace RecordAuditLogUseCase {
22
+ type Interface = IRecordAuditLogUseCase;
23
+ type Input = RecordAuditLogInput;
24
+ type Error = UseCaseError;
25
+ }
26
+ export {};
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const RecordAuditLogUseCase = createAbstraction("RecordAuditLogUseCase");
3
+ export { RecordAuditLogUseCase };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/RecordAuditLog/abstractions.js","sources":["../../../src/features/RecordAuditLog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { AuditAction } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { CreateAuditLogUseCase } from \"~/features/CreateAuditLog/abstractions.js\";\n\nexport interface RecordAuditLogInput {\n audit: AuditAction;\n message: string;\n content: GenericRecord;\n entityId: string;\n}\n\n/**\n * RecordAuditLog Use Case - Records an audit log for something the current identity did. Returns\n * null when nothing was recorded: there's no identity, or merging into an earlier log failed.\n */\nexport interface IRecordAuditLogUseCase {\n execute(input: RecordAuditLogInput): Promise<Result<IAuditLog | null, UseCaseError>>;\n}\n\ntype UseCaseError = CreateAuditLogUseCase.Error;\n\nexport const RecordAuditLogUseCase =\n createAbstraction<IRecordAuditLogUseCase>(\"RecordAuditLogUseCase\");\n\nexport namespace RecordAuditLogUseCase {\n export type Interface = IRecordAuditLogUseCase;\n export type Input = RecordAuditLogInput;\n export type Error = UseCaseError;\n}\n"],"names":["RecordAuditLogUseCase","createAbstraction"],"mappings":";AAwBO,MAAMA,wBACTC,kBAA0C"}
@@ -0,0 +1,4 @@
1
+ export declare const RecordAuditLogFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { RecordAuditLogUseCase } from "./RecordAuditLogUseCase.js";
3
+ const RecordAuditLogFeature = createFeature({
4
+ name: "AuditLogs/RecordAuditLog",
5
+ register (container) {
6
+ container.register(RecordAuditLogUseCase);
7
+ }
8
+ });
9
+ export { RecordAuditLogFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/RecordAuditLog/feature.js","sources":["../../../src/features/RecordAuditLog/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RecordAuditLogUseCase } from \"./RecordAuditLogUseCase.js\";\n\nexport const RecordAuditLogFeature = createFeature({\n name: \"AuditLogs/RecordAuditLog\",\n register(container) {\n container.register(RecordAuditLogUseCase);\n }\n});\n"],"names":["RecordAuditLogFeature","createFeature","container","RecordAuditLogUseCase"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { AuditLogsStorage } from "../../abstractions.js";
2
+ import type { IAuditLog } from "../../storage/types.js";
3
+ import { UpdateAuditLogGateway as Abstraction } from "./abstractions.js";
4
+ declare class UpdateAuditLogGatewayImpl implements Abstraction.Interface {
5
+ private readonly storage;
6
+ constructor(storage: AuditLogsStorage.Interface);
7
+ update(auditLog: IAuditLog): Promise<IAuditLog>;
8
+ }
9
+ export declare const UpdateAuditLogGateway: typeof UpdateAuditLogGatewayImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogGateway>;
11
+ };
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { AuditLogsStorage } from "../../abstractions.js";
2
+ import { UpdateAuditLogGateway } from "./abstractions.js";
3
+ class UpdateAuditLogGatewayImpl {
4
+ constructor(storage){
5
+ this.storage = storage;
6
+ }
7
+ async update(auditLog) {
8
+ const result = await this.storage.store({
9
+ data: auditLog
10
+ });
11
+ if (!result.success) throw result.error;
12
+ return result.data;
13
+ }
14
+ }
15
+ const UpdateAuditLogGateway_UpdateAuditLogGateway = UpdateAuditLogGateway.createImplementation({
16
+ implementation: UpdateAuditLogGatewayImpl,
17
+ dependencies: [
18
+ AuditLogsStorage
19
+ ]
20
+ });
21
+ export { UpdateAuditLogGateway_UpdateAuditLogGateway as UpdateAuditLogGateway };
22
+
23
+ //# sourceMappingURL=UpdateAuditLogGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogGateway.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogGateway.ts"],"sourcesContent":["import { AuditLogsStorage } from \"~/abstractions.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogGateway as Abstraction } from \"./abstractions.js\";\n\nclass UpdateAuditLogGatewayImpl implements Abstraction.Interface {\n public constructor(private readonly storage: AuditLogsStorage.Interface) {}\n\n public async update(auditLog: IAuditLog): Promise<IAuditLog> {\n const result = await this.storage.store({ data: auditLog });\n if (!result.success) {\n throw result.error;\n }\n return result.data;\n }\n}\n\nexport const UpdateAuditLogGateway = Abstraction.createImplementation({\n implementation: UpdateAuditLogGatewayImpl,\n dependencies: [AuditLogsStorage]\n});\n"],"names":["UpdateAuditLogGatewayImpl","storage","auditLog","result","UpdateAuditLogGateway","Abstraction","AuditLogsStorage"],"mappings":";;AAIA,MAAMA;IACF,YAAoCC,OAAmC,CAAE;aAArCA,OAAO,GAAPA;IAAsC;IAE1E,MAAa,OAAOC,QAAmB,EAAsB;QACzD,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,MAAMD;QAAS;QACzD,IAAI,CAACC,OAAO,OAAO,EACf,MAAMA,OAAO,KAAK;QAEtB,OAAOA,OAAO,IAAI;IACtB;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBL;IAChB,cAAc;QAACM;KAAiB;AACpC"}
@@ -0,0 +1,14 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
3
+ import type { IAuditLog } from "../../storage/types.js";
4
+ import { UpdateAuditLogRepository as Abstraction } from "./abstractions.js";
5
+ import { UpdateAuditLogGateway } from "./abstractions.js";
6
+ declare class UpdateAuditLogRepositoryImpl implements Abstraction.Interface {
7
+ private readonly gateway;
8
+ constructor(gateway: UpdateAuditLogGateway.Interface);
9
+ update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
10
+ }
11
+ export declare const UpdateAuditLogRepository: typeof UpdateAuditLogRepositoryImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogRepository>;
13
+ };
14
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
3
+ import { UpdateAuditLogGateway, UpdateAuditLogRepository } from "./abstractions.js";
4
+ class UpdateAuditLogRepositoryImpl {
5
+ constructor(gateway){
6
+ this.gateway = gateway;
7
+ }
8
+ async update(auditLog) {
9
+ try {
10
+ const updated = await this.gateway.update(auditLog);
11
+ return Result.ok(updated);
12
+ } catch (error) {
13
+ return Result.fail(new AuditLogPersistenceError(error));
14
+ }
15
+ }
16
+ }
17
+ const UpdateAuditLogRepository_UpdateAuditLogRepository = UpdateAuditLogRepository.createImplementation({
18
+ implementation: UpdateAuditLogRepositoryImpl,
19
+ dependencies: [
20
+ UpdateAuditLogGateway
21
+ ]
22
+ });
23
+ export { UpdateAuditLogRepository_UpdateAuditLogRepository as UpdateAuditLogRepository };
24
+
25
+ //# sourceMappingURL=UpdateAuditLogRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogRepository.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { AuditLogPersistenceError } from \"~/domain/errors.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogRepository as Abstraction } from \"./abstractions.js\";\nimport { UpdateAuditLogGateway } from \"./abstractions.js\";\n\nclass UpdateAuditLogRepositoryImpl implements Abstraction.Interface {\n public constructor(private readonly gateway: UpdateAuditLogGateway.Interface) {}\n\n public async update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>> {\n try {\n const updated = await this.gateway.update(auditLog);\n return Result.ok(updated);\n } catch (error) {\n return Result.fail(new AuditLogPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateAuditLogRepository = Abstraction.createImplementation({\n implementation: UpdateAuditLogRepositoryImpl,\n dependencies: [UpdateAuditLogGateway]\n});\n"],"names":["UpdateAuditLogRepositoryImpl","gateway","auditLog","updated","Result","error","AuditLogPersistenceError","UpdateAuditLogRepository","Abstraction","UpdateAuditLogGateway"],"mappings":";;;AAMA,MAAMA;IACF,YAAoCC,OAAwC,CAAE;aAA1CA,OAAO,GAAPA;IAA2C;IAE/E,MAAa,OAAOC,QAAmB,EAAwD;QAC3F,IAAI;YACA,MAAMC,UAAU,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAACD;YAC1C,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,yBAAyBD;QACpD;IACJ;AACJ;AAEO,MAAME,oDAA2BC,yBAAAA,oBAAgC,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;KAAsB;AACzC"}
@@ -0,0 +1,18 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { AuditLogPermissions } from "../../features/AuditLogPermissions/abstractions.js";
4
+ import type { AuditLogPayload } from "../../types.js";
5
+ import type { IAuditLog } from "../../storage/types.js";
6
+ import { UpdateAuditLogUseCase as UseCaseAbstraction } from "./abstractions.js";
7
+ import { UpdateAuditLogRepository } from "./abstractions.js";
8
+ declare class UpdateAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {
9
+ private readonly repository;
10
+ private readonly permissions;
11
+ private readonly eventPublisher;
12
+ constructor(repository: UpdateAuditLogRepository.Interface, permissions: AuditLogPermissions.Interface, eventPublisher: EventPublisher.Interface);
13
+ execute(original: IAuditLog, payload: Partial<AuditLogPayload>): Promise<Result<IAuditLog, UseCaseAbstraction.Error>>;
14
+ }
15
+ export declare const UpdateAuditLogUseCase: typeof UpdateAuditLogUseCaseImpl & {
16
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogUseCase>;
17
+ };
18
+ export {};
@@ -0,0 +1,53 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
3
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
4
+ import { AuditLogPermissions } from "../AuditLogPermissions/abstractions.js";
5
+ import { AuditLogAfterUpdateEvent, AuditLogBeforeUpdateEvent } from "../../events/index.js";
6
+ import { UpdateAuditLogRepository, UpdateAuditLogUseCase } from "./abstractions.js";
7
+ class UpdateAuditLogUseCaseImpl {
8
+ constructor(repository, permissions, eventPublisher){
9
+ this.repository = repository;
10
+ this.permissions = permissions;
11
+ this.eventPublisher = eventPublisher;
12
+ }
13
+ async execute(original, payload) {
14
+ let content = original.content;
15
+ if (payload.content) content = JSON.stringify(payload.content);
16
+ const auditLog = {
17
+ ...original,
18
+ ...payload,
19
+ content
20
+ };
21
+ const canAccess = await this.permissions.canAccess(auditLog.action);
22
+ if (!canAccess) return Result.fail(new NotAuthorizedError({
23
+ message: "You cannot access audit logs."
24
+ }));
25
+ const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({
26
+ original,
27
+ auditLog,
28
+ setAuditLog (input) {
29
+ Object.assign(auditLog, input);
30
+ }
31
+ });
32
+ await this.eventPublisher.publish(beforeUpdateEvent);
33
+ const result = await this.repository.update(auditLog);
34
+ if (result.isFail()) return Result.fail(result.error);
35
+ const afterUpdateEvent = new AuditLogAfterUpdateEvent({
36
+ original,
37
+ auditLog
38
+ });
39
+ await this.eventPublisher.publish(afterUpdateEvent);
40
+ return Result.ok(result.value);
41
+ }
42
+ }
43
+ const UpdateAuditLogUseCase_UpdateAuditLogUseCase = UpdateAuditLogUseCase.createImplementation({
44
+ implementation: UpdateAuditLogUseCaseImpl,
45
+ dependencies: [
46
+ UpdateAuditLogRepository,
47
+ AuditLogPermissions,
48
+ EventPublisher
49
+ ]
50
+ });
51
+ export { UpdateAuditLogUseCase_UpdateAuditLogUseCase as UpdateAuditLogUseCase };
52
+
53
+ //# sourceMappingURL=UpdateAuditLogUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogUseCase.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport { AuditLogBeforeUpdateEvent } from \"~/events/index.js\";\nimport { AuditLogAfterUpdateEvent } from \"~/events/index.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UpdateAuditLogRepository } from \"./abstractions.js\";\n\nclass UpdateAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: UpdateAuditLogRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface,\n private readonly eventPublisher: EventPublisher.Interface\n ) {}\n\n public async execute(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<Result<IAuditLog, UseCaseAbstraction.Error>> {\n let content = original.content;\n if (payload.content) {\n content = JSON.stringify(payload.content);\n }\n\n const auditLog: IAuditLog = {\n ...original,\n ...payload,\n content\n };\n\n const canAccess = await this.permissions.canAccess(auditLog.action);\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({\n original,\n auditLog,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeUpdateEvent);\n\n const result = await this.repository.update(auditLog);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const afterUpdateEvent = new AuditLogAfterUpdateEvent({ original, auditLog });\n await this.eventPublisher.publish(afterUpdateEvent);\n\n return Result.ok(result.value);\n }\n}\n\nexport const UpdateAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateAuditLogUseCaseImpl,\n dependencies: [UpdateAuditLogRepository, AuditLogPermissions, EventPublisher]\n});\n"],"names":["UpdateAuditLogUseCaseImpl","repository","permissions","eventPublisher","original","payload","content","JSON","auditLog","canAccess","Result","NotAuthorizedError","beforeUpdateEvent","AuditLogBeforeUpdateEvent","input","Object","result","afterUpdateEvent","AuditLogAfterUpdateEvent","UpdateAuditLogUseCase","UseCaseAbstraction","UpdateAuditLogRepository","AuditLogPermissions","EventPublisher"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACqBC,UAA8C,EAC9CC,WAA0C,EAC1CC,cAAwC,CAC3D;aAHmBF,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IAClB;IAEH,MAAa,QACTC,QAAmB,EACnBC,OAAiC,EACmB;QACpD,IAAIC,UAAUF,SAAS,OAAO;QAC9B,IAAIC,QAAQ,OAAO,EACfC,UAAUC,KAAK,SAAS,CAACF,QAAQ,OAAO;QAG5C,MAAMG,WAAsB;YACxB,GAAGJ,QAAQ;YACX,GAAGC,OAAO;YACVC;QACJ;QAEA,MAAMG,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAACD,SAAS,MAAM;QAClE,IAAI,CAACC,WACD,OAAOC,OAAO,IAAI,CACd,IAAIC,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,MAAMC,oBAAoB,IAAIC,0BAA0B;YACpDT;YACAI;YACA,aAAYM,KAAK;gBACbC,OAAO,MAAM,CAACP,UAAUM;YAC5B;QACJ;QACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACF;QAElC,MAAMI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACR;QAC5C,IAAIQ,OAAO,MAAM,IACb,OAAON,OAAO,IAAI,CAACM,OAAO,KAAK;QAGnC,MAAMC,mBAAmB,IAAIC,yBAAyB;YAAEd;YAAUI;QAAS;QAC3E,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACS;QAElC,OAAOP,OAAO,EAAE,CAACM,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBpB;IAChB,cAAc;QAACqB;QAA0BC;QAAqBC;KAAe;AACjF"}
@@ -0,0 +1,42 @@
1
+ import type { Result } from "@webiny/feature/api";
2
+ import type { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
3
+ import type { AuditLogPayload } from "../../types.js";
4
+ import type { IAuditLog } from "../../storage/types.js";
5
+ import type { AuditLogPersistenceError } from "../../domain/errors.js";
6
+ /**
7
+ * UpdateAuditLog Use Case - Updates an existing audit log with new values.
8
+ */
9
+ export interface IUpdateAuditLogUseCase {
10
+ execute(original: IAuditLog, payload: Partial<AuditLogPayload>): Promise<Result<IAuditLog, UseCaseError>>;
11
+ }
12
+ export interface IUpdateAuditLogUseCaseErrors {
13
+ notAuthorized: NotAuthorizedError;
14
+ persistence: AuditLogPersistenceError;
15
+ }
16
+ type UseCaseError = IUpdateAuditLogUseCaseErrors[keyof IUpdateAuditLogUseCaseErrors];
17
+ export declare const UpdateAuditLogUseCase: import("@webiny/di").Abstraction<IUpdateAuditLogUseCase>;
18
+ export declare namespace UpdateAuditLogUseCase {
19
+ type Interface = IUpdateAuditLogUseCase;
20
+ type Error = UseCaseError;
21
+ }
22
+ /**
23
+ * UpdateAuditLogRepository - Stores an updated audit log.
24
+ */
25
+ export interface IUpdateAuditLogRepository {
26
+ update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
27
+ }
28
+ export declare const UpdateAuditLogRepository: import("@webiny/di").Abstraction<IUpdateAuditLogRepository>;
29
+ export declare namespace UpdateAuditLogRepository {
30
+ type Interface = IUpdateAuditLogRepository;
31
+ }
32
+ /**
33
+ * UpdateAuditLogGateway - Writes an updated audit log to the audit logs storage.
34
+ */
35
+ export interface IUpdateAuditLogGateway {
36
+ update(auditLog: IAuditLog): Promise<IAuditLog>;
37
+ }
38
+ export declare const UpdateAuditLogGateway: import("@webiny/di").Abstraction<IUpdateAuditLogGateway>;
39
+ export declare namespace UpdateAuditLogGateway {
40
+ type Interface = IUpdateAuditLogGateway;
41
+ }
42
+ export {};
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const UpdateAuditLogUseCase = createAbstraction("UpdateAuditLogUseCase");
3
+ const UpdateAuditLogRepository = createAbstraction("UpdateAuditLogRepository");
4
+ const UpdateAuditLogGateway = createAbstraction("UpdateAuditLogGateway");
5
+ export { UpdateAuditLogGateway, UpdateAuditLogRepository, UpdateAuditLogUseCase };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/UpdateAuditLog/abstractions.js","sources":["../../../src/features/UpdateAuditLog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { AuditLogPersistenceError } from \"~/domain/errors.js\";\n\n/**\n * UpdateAuditLog Use Case - Updates an existing audit log with new values.\n */\nexport interface IUpdateAuditLogUseCase {\n execute(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<Result<IAuditLog, UseCaseError>>;\n}\n\nexport interface IUpdateAuditLogUseCaseErrors {\n notAuthorized: NotAuthorizedError;\n persistence: AuditLogPersistenceError;\n}\n\ntype UseCaseError = IUpdateAuditLogUseCaseErrors[keyof IUpdateAuditLogUseCaseErrors];\n\nexport const UpdateAuditLogUseCase =\n createAbstraction<IUpdateAuditLogUseCase>(\"UpdateAuditLogUseCase\");\n\nexport namespace UpdateAuditLogUseCase {\n export type Interface = IUpdateAuditLogUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UpdateAuditLogRepository - Stores an updated audit log.\n */\nexport interface IUpdateAuditLogRepository {\n update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;\n}\n\nexport const UpdateAuditLogRepository = createAbstraction<IUpdateAuditLogRepository>(\n \"UpdateAuditLogRepository\"\n);\n\nexport namespace UpdateAuditLogRepository {\n export type Interface = IUpdateAuditLogRepository;\n}\n\n/**\n * UpdateAuditLogGateway - Writes an updated audit log to the audit logs storage.\n */\nexport interface IUpdateAuditLogGateway {\n update(auditLog: IAuditLog): Promise<IAuditLog>;\n}\n\nexport const UpdateAuditLogGateway =\n createAbstraction<IUpdateAuditLogGateway>(\"UpdateAuditLogGateway\");\n\nexport namespace UpdateAuditLogGateway {\n export type Interface = IUpdateAuditLogGateway;\n}\n"],"names":["UpdateAuditLogUseCase","createAbstraction","UpdateAuditLogRepository","UpdateAuditLogGateway"],"mappings":";AAwBO,MAAMA,wBACTC,kBAA0C;AAcvC,MAAMC,2BAA2BD,kBACpC;AAcG,MAAME,wBACTF,kBAA0C"}
@@ -0,0 +1,4 @@
1
+ export declare const UpdateAuditLogFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,15 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { UpdateAuditLogUseCase } from "./UpdateAuditLogUseCase.js";
3
+ import { UpdateAuditLogRepository } from "./UpdateAuditLogRepository.js";
4
+ import { UpdateAuditLogGateway } from "./UpdateAuditLogGateway.js";
5
+ const UpdateAuditLogFeature = createFeature({
6
+ name: "AuditLogs/UpdateAuditLog",
7
+ register (container) {
8
+ container.register(UpdateAuditLogUseCase);
9
+ container.register(UpdateAuditLogRepository).inSingletonScope();
10
+ container.register(UpdateAuditLogGateway).inSingletonScope();
11
+ }
12
+ });
13
+ export { UpdateAuditLogFeature };
14
+
15
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/UpdateAuditLog/feature.js","sources":["../../../src/features/UpdateAuditLog/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UpdateAuditLogUseCase } from \"./UpdateAuditLogUseCase.js\";\nimport { UpdateAuditLogRepository } from \"./UpdateAuditLogRepository.js\";\nimport { UpdateAuditLogGateway } from \"./UpdateAuditLogGateway.js\";\n\nexport const UpdateAuditLogFeature = createFeature({\n name: \"AuditLogs/UpdateAuditLog\",\n register(container) {\n container.register(UpdateAuditLogUseCase);\n container.register(UpdateAuditLogRepository).inSingletonScope();\n container.register(UpdateAuditLogGateway).inSingletonScope();\n }\n});\n"],"names":["UpdateAuditLogFeature","createFeature","container","UpdateAuditLogUseCase","UpdateAuditLogRepository","UpdateAuditLogGateway"],"mappings":";;;;AAKO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,0BAA0B,gBAAgB;QAC7DF,UAAU,QAAQ,CAACG,uBAAuB,gBAAgB;IAC9D;AACJ"}
@@ -1,6 +1,7 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
2
  import { GraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
3
  declare class AuditLogsGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
4
5
  execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return;
5
6
  }
6
7
  export declare const AuditLogsGraphQLSchema: typeof AuditLogsGraphQLSchemaImpl & {
@@ -1,7 +1,9 @@
1
- import { NotFoundError, resolve, resolveList } from "@webiny/api-graphql";
1
+ import { resolve, resolveList } from "@webiny/api-graphql";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
2
3
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
3
4
  import { createZodError } from "@webiny/utils";
4
- import { AuditLogsContext } from "../abstractions.js";
5
+ import { GetAuditLogUseCase } from "../features/GetAuditLog/abstractions.js";
6
+ import { ListAuditLogsUseCase } from "../features/ListAuditLogs/abstractions.js";
5
7
  import { getValidationSchema, listValidationSchema } from "./validation.js";
6
8
  const TYPE_DEFS = `
7
9
  type AuditLogCreatedBy {
@@ -86,36 +88,36 @@ class AuditLogsGraphQLSchemaImpl {
86
88
  builder.addResolver({
87
89
  path: "AuditLogsQuery.getAuditLog",
88
90
  dependencies: [
89
- AuditLogsContext
91
+ GetAuditLogUseCase
90
92
  ],
91
- resolver (auditLogs) {
93
+ resolver (getAuditLog) {
92
94
  return async ({ args })=>resolve(async ()=>{
93
95
  const validation = await getValidationSchema.safeParseAsync(args);
94
96
  if (!validation.success) throw createZodError(validation.error);
95
- const result = await auditLogs.getAuditLog(validation.data.id);
96
- if (!result) throw new NotFoundError(`Audit log with id "${validation.data.id}" not found.`);
97
- return result;
97
+ const result = await getAuditLog.execute(validation.data.id);
98
+ if (result.isFail()) throw result.error;
99
+ return result.value;
98
100
  });
99
101
  }
100
102
  });
101
103
  builder.addResolver({
102
104
  path: "AuditLogsQuery.listAuditLogs",
103
105
  dependencies: [
104
- AuditLogsContext
106
+ ListAuditLogsUseCase
105
107
  ],
106
- resolver (auditLogs) {
108
+ resolver (listAuditLogs) {
107
109
  return async ({ args })=>resolveList(async ()=>{
108
110
  const validation = await listValidationSchema.safeParseAsync(args);
109
111
  if (!validation.success) throw createZodError(validation.error);
110
- const result = await auditLogs.listAuditLogs({
112
+ const result = await listAuditLogs.execute({
111
113
  ...validation.data,
112
114
  ...validation.data.where
113
115
  });
114
- if (result.error) throw result.error;
116
+ if (result.isFail()) throw result.error;
115
117
  return {
116
- items: result.items,
118
+ items: result.value.items,
117
119
  meta: {
118
- ...result.meta,
120
+ ...result.value.meta,
119
121
  totalCount: 0
120
122
  }
121
123
  };
@@ -124,6 +126,9 @@ class AuditLogsGraphQLSchemaImpl {
124
126
  });
125
127
  return builder;
126
128
  }
129
+ constructor(){
130
+ this.getSchemaKey = staticSchemaKey("api-audit-logs/AuditLogsGraphQLSchemaImpl");
131
+ }
127
132
  }
128
133
  const AuditLogsGraphQLSchema = CoreGraphQLSchemaFactory.createImplementation({
129
134
  implementation: AuditLogsGraphQLSchemaImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/AuditLogsGraphQLSchema.js","sources":["../../src/graphql/AuditLogsGraphQLSchema.ts"],"sourcesContent":["import { NotFoundError, resolve, resolveList } from \"@webiny/api-graphql\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { AuditLogsContext } from \"~/abstractions.js\";\nimport type { AuditLogsContextValue } from \"~/types.js\";\nimport { getValidationSchema, listValidationSchema } from \"./validation.js\";\n\ninterface IListAuditLogsWhere {\n app?: string;\n action?: string;\n createdBy?: string;\n entity?: string;\n entityId?: string;\n createdOn_gte?: Date;\n createdOn_lte?: Date;\n}\n\ninterface IListAuditLogsArgs {\n where?: IListAuditLogsWhere;\n sort?: \"ASC\" | \"DESC\";\n limit?: number;\n after?: string;\n}\n\nconst TYPE_DEFS = /* GraphQL */ `\n type AuditLogCreatedBy {\n id: ID!\n displayName: String\n type: String\n }\n type AuditLog {\n id: ID!\n createdBy: AuditLogCreatedBy!\n createdOn: DateTime!\n app: String!\n action: String!\n message: String!\n entity: String!\n entityId: String!\n tags: [String!]!\n expiresAt: DateTime!\n content: String\n }\n\n type AuditLogListMeta {\n cursor: String\n hasMoreItems: Boolean!\n }\n\n type AuditLogError {\n code: String\n message: String!\n data: JSON\n stack: String\n }\n\n type AuditLogListResponse {\n data: [AuditLog!]\n meta: AuditLogListMeta\n error: AuditLogError\n }\n\n type AuditLogGetResponse {\n data: AuditLog\n error: AuditLogError\n }\n\n enum AuditLogsSort {\n ASC\n DESC\n }\n\n input ListAuditLogsWhere {\n app: String\n action: String\n createdBy: String\n entity: String\n entityId: String\n createdOn_gte: DateTime\n createdOn_lte: DateTime\n }\n\n type AuditLogsQuery {\n getAuditLog(id: ID!): AuditLogGetResponse\n listAuditLogs(\n where: ListAuditLogsWhere\n sort: AuditLogsSort\n limit: Number\n after: String\n ): AuditLogListResponse!\n }\n\n extend type Query {\n auditLogs: AuditLogsQuery\n }\n`;\n\nclass AuditLogsGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {\n public async execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return {\n builder.addTypeDefs(TYPE_DEFS);\n\n builder.addResolver({\n path: \"Query.auditLogs\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver<{ id: string }>({\n path: \"AuditLogsQuery.getAuditLog\",\n dependencies: [AuditLogsContext],\n resolver(auditLogs: AuditLogsContextValue) {\n return async ({ args }) => {\n return resolve(async () => {\n const validation = await getValidationSchema.safeParseAsync(args);\n\n if (!validation.success) {\n throw createZodError(validation.error);\n }\n\n const result = await auditLogs.getAuditLog(validation.data.id);\n if (!result) {\n throw new NotFoundError(\n `Audit log with id \"${validation.data.id}\" not found.`\n );\n }\n return result;\n });\n };\n }\n });\n\n builder.addResolver<IListAuditLogsArgs>({\n path: \"AuditLogsQuery.listAuditLogs\",\n dependencies: [AuditLogsContext],\n resolver(auditLogs: AuditLogsContextValue) {\n return async ({ args }) => {\n return resolveList(async () => {\n const validation = await listValidationSchema.safeParseAsync(args);\n if (!validation.success) {\n throw createZodError(validation.error);\n }\n const result = await auditLogs.listAuditLogs({\n ...validation.data,\n ...validation.data.where\n });\n if (result.error) {\n throw result.error;\n }\n return {\n items: result.items,\n meta: {\n ...result.meta,\n totalCount: 0\n }\n };\n });\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const AuditLogsGraphQLSchema = CoreGraphQLSchemaFactory.createImplementation({\n implementation: AuditLogsGraphQLSchemaImpl,\n dependencies: []\n});\n"],"names":["TYPE_DEFS","AuditLogsGraphQLSchemaImpl","builder","AuditLogsContext","auditLogs","args","resolve","validation","getValidationSchema","createZodError","result","NotFoundError","resolveList","listValidationSchema","AuditLogsGraphQLSchema","CoreGraphQLSchemaFactory"],"mappings":";;;;;AAyBA,MAAMA,YAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEjC,CAAC;AAED,MAAMC;IACF,MAAa,QAAQC,OAAuC,EAAmC;QAC3FA,QAAQ,WAAW,CAACF;QAEpBE,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAiB;YAChC,MAAM;YACN,cAAc;gBAACC;aAAiB;YAChC,UAASC,SAAgC;gBACrC,OAAO,OAAO,EAAEC,IAAI,EAAE,GACXC,QAAQ;wBACX,MAAMC,aAAa,MAAMC,oBAAoB,cAAc,CAACH;wBAE5D,IAAI,CAACE,WAAW,OAAO,EACnB,MAAME,eAAeF,WAAW,KAAK;wBAGzC,MAAMG,SAAS,MAAMN,UAAU,WAAW,CAACG,WAAW,IAAI,CAAC,EAAE;wBAC7D,IAAI,CAACG,QACD,MAAM,IAAIC,cACN,CAAC,mBAAmB,EAAEJ,WAAW,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC;wBAG9D,OAAOG;oBACX;YAER;QACJ;QAEAR,QAAQ,WAAW,CAAqB;YACpC,MAAM;YACN,cAAc;gBAACC;aAAiB;YAChC,UAASC,SAAgC;gBACrC,OAAO,OAAO,EAAEC,IAAI,EAAE,GACXO,YAAY;wBACf,MAAML,aAAa,MAAMM,qBAAqB,cAAc,CAACR;wBAC7D,IAAI,CAACE,WAAW,OAAO,EACnB,MAAME,eAAeF,WAAW,KAAK;wBAEzC,MAAMG,SAAS,MAAMN,UAAU,aAAa,CAAC;4BACzC,GAAGG,WAAW,IAAI;4BAClB,GAAGA,WAAW,IAAI,CAAC,KAAK;wBAC5B;wBACA,IAAIG,OAAO,KAAK,EACZ,MAAMA,OAAO,KAAK;wBAEtB,OAAO;4BACH,OAAOA,OAAO,KAAK;4BACnB,MAAM;gCACF,GAAGA,OAAO,IAAI;gCACd,YAAY;4BAChB;wBACJ;oBACJ;YAER;QACJ;QAEA,OAAOR;IACX;AACJ;AAEO,MAAMY,yBAAyBC,yBAAyB,oBAAoB,CAAC;IAChF,gBAAgBd;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"graphql/AuditLogsGraphQLSchema.js","sources":["../../src/graphql/AuditLogsGraphQLSchema.ts"],"sourcesContent":["import { resolve } from \"@webiny/api-graphql\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport { resolveList } from \"@webiny/api-graphql\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { GetAuditLogUseCase } from \"~/features/GetAuditLog/abstractions.js\";\nimport { ListAuditLogsUseCase } from \"~/features/ListAuditLogs/abstractions.js\";\nimport { getValidationSchema, listValidationSchema } from \"./validation.js\";\n\ninterface IListAuditLogsWhere {\n app?: string;\n action?: string;\n createdBy?: string;\n entity?: string;\n entityId?: string;\n createdOn_gte?: Date;\n createdOn_lte?: Date;\n}\n\ninterface IListAuditLogsArgs {\n where?: IListAuditLogsWhere;\n sort?: \"ASC\" | \"DESC\";\n limit?: number;\n after?: string;\n}\n\nconst TYPE_DEFS = /* GraphQL */ `\n type AuditLogCreatedBy {\n id: ID!\n displayName: String\n type: String\n }\n type AuditLog {\n id: ID!\n createdBy: AuditLogCreatedBy!\n createdOn: DateTime!\n app: String!\n action: String!\n message: String!\n entity: String!\n entityId: String!\n tags: [String!]!\n expiresAt: DateTime!\n content: String\n }\n\n type AuditLogListMeta {\n cursor: String\n hasMoreItems: Boolean!\n }\n\n type AuditLogError {\n code: String\n message: String!\n data: JSON\n stack: String\n }\n\n type AuditLogListResponse {\n data: [AuditLog!]\n meta: AuditLogListMeta\n error: AuditLogError\n }\n\n type AuditLogGetResponse {\n data: AuditLog\n error: AuditLogError\n }\n\n enum AuditLogsSort {\n ASC\n DESC\n }\n\n input ListAuditLogsWhere {\n app: String\n action: String\n createdBy: String\n entity: String\n entityId: String\n createdOn_gte: DateTime\n createdOn_lte: DateTime\n }\n\n type AuditLogsQuery {\n getAuditLog(id: ID!): AuditLogGetResponse\n listAuditLogs(\n where: ListAuditLogsWhere\n sort: AuditLogsSort\n limit: Number\n after: String\n ): AuditLogListResponse!\n }\n\n extend type Query {\n auditLogs: AuditLogsQuery\n }\n`;\n\nclass AuditLogsGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-audit-logs/AuditLogsGraphQLSchemaImpl\");\n\n public async execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return {\n builder.addTypeDefs(TYPE_DEFS);\n\n builder.addResolver({\n path: \"Query.auditLogs\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver<{ id: string }>({\n path: \"AuditLogsQuery.getAuditLog\",\n dependencies: [GetAuditLogUseCase],\n resolver(getAuditLog: GetAuditLogUseCase.Interface) {\n return async ({ args }) => {\n return resolve(async () => {\n const validation = await getValidationSchema.safeParseAsync(args);\n\n if (!validation.success) {\n throw createZodError(validation.error);\n }\n\n const result = await getAuditLog.execute(validation.data.id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver<IListAuditLogsArgs>({\n path: \"AuditLogsQuery.listAuditLogs\",\n dependencies: [ListAuditLogsUseCase],\n resolver(listAuditLogs: ListAuditLogsUseCase.Interface) {\n return async ({ args }) => {\n return resolveList(async () => {\n const validation = await listValidationSchema.safeParseAsync(args);\n if (!validation.success) {\n throw createZodError(validation.error);\n }\n const result = await listAuditLogs.execute({\n ...validation.data,\n ...validation.data.where\n });\n if (result.isFail()) {\n throw result.error;\n }\n return {\n items: result.value.items,\n meta: {\n ...result.value.meta,\n totalCount: 0\n }\n };\n });\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const AuditLogsGraphQLSchema = CoreGraphQLSchemaFactory.createImplementation({\n implementation: AuditLogsGraphQLSchemaImpl,\n dependencies: []\n});\n"],"names":["TYPE_DEFS","AuditLogsGraphQLSchemaImpl","builder","GetAuditLogUseCase","getAuditLog","args","resolve","validation","getValidationSchema","createZodError","result","ListAuditLogsUseCase","listAuditLogs","resolveList","listValidationSchema","staticSchemaKey","AuditLogsGraphQLSchema","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;AA2BA,MAAMA,YAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEjC,CAAC;AAED,MAAMC;IAGF,MAAa,QAAQC,OAAuC,EAAmC;QAC3FA,QAAQ,WAAW,CAACF;QAEpBE,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAiB;YAChC,MAAM;YACN,cAAc;gBAACC;aAAmB;YAClC,UAASC,WAAyC;gBAC9C,OAAO,OAAO,EAAEC,IAAI,EAAE,GACXC,QAAQ;wBACX,MAAMC,aAAa,MAAMC,oBAAoB,cAAc,CAACH;wBAE5D,IAAI,CAACE,WAAW,OAAO,EACnB,MAAME,eAAeF,WAAW,KAAK;wBAGzC,MAAMG,SAAS,MAAMN,YAAY,OAAO,CAACG,WAAW,IAAI,CAAC,EAAE;wBAC3D,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;YAER;QACJ;QAEAR,QAAQ,WAAW,CAAqB;YACpC,MAAM;YACN,cAAc;gBAACS;aAAqB;YACpC,UAASC,aAA6C;gBAClD,OAAO,OAAO,EAAEP,IAAI,EAAE,GACXQ,YAAY;wBACf,MAAMN,aAAa,MAAMO,qBAAqB,cAAc,CAACT;wBAC7D,IAAI,CAACE,WAAW,OAAO,EACnB,MAAME,eAAeF,WAAW,KAAK;wBAEzC,MAAMG,SAAS,MAAME,cAAc,OAAO,CAAC;4BACvC,GAAGL,WAAW,IAAI;4BAClB,GAAGA,WAAW,IAAI,CAAC,KAAK;wBAC5B;wBACA,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAO;4BACH,OAAOA,OAAO,KAAK,CAAC,KAAK;4BACzB,MAAM;gCACF,GAAGA,OAAO,KAAK,CAAC,IAAI;gCACpB,YAAY;4BAChB;wBACJ;oBACJ;YAER;QACJ;QAEA,OAAOR;IACX;;aA/DO,YAAY,GAAGa,gBAAgB;;AAgE1C;AAEO,MAAMC,yBAAyBC,yBAAyB,oBAAoB,CAAC;IAChF,gBAAgBhB;IAChB,cAAc,EAAE;AACpB"}
@@ -7,8 +7,8 @@ export declare const listValidationSchema: zod.ZodObject<{
7
7
  app: zod.ZodOptional<zod.ZodString>;
8
8
  entity: zod.ZodOptional<zod.ZodString>;
9
9
  entityId: zod.ZodOptional<zod.ZodString>;
10
- createdOn_gte: zod.ZodPreprocess<zod.ZodOptional<zod.ZodDate>>;
11
- createdOn_lte: zod.ZodPreprocess<zod.ZodOptional<zod.ZodDate>>;
10
+ createdOn_gte: zod.ZodPreprocess<zod.ZodOptional<zod.ZodDate>, unknown>;
11
+ createdOn_lte: zod.ZodPreprocess<zod.ZodOptional<zod.ZodDate>, unknown>;
12
12
  createdBy: zod.ZodOptional<zod.ZodString>;
13
13
  action: zod.ZodOptional<zod.ZodString>;
14
14
  }, zod.core.$strip>;
@@ -17,5 +17,5 @@ export declare const listValidationSchema: zod.ZodObject<{
17
17
  ASC: "ASC";
18
18
  DESC: "DESC";
19
19
  }>>;
20
- limit: zod.ZodDefault<zod.ZodPreprocess<zod.ZodOptional<zod.ZodNumber>>>;
20
+ limit: zod.ZodDefault<zod.ZodPreprocess<zod.ZodOptional<zod.ZodNumber>, unknown>>;
21
21
  }, zod.core.$strip>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-audit-logs",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.10",
4
4
  "exports": {
5
5
  ".": "./index.js",
6
6
  "./*": "./*"
@@ -22,33 +22,34 @@
22
22
  "access": "public"
23
23
  },
24
24
  "devDependencies": {
25
- "@webiny/api-headless-cms-testing": "6.6.0-alpha.0",
26
- "@webiny/di": "1.0.2",
27
- "@webiny/event-handler-core": "6.6.0-alpha.0",
28
- "@webiny/handler": "6.6.0-alpha.0",
29
- "@webiny/plugins": "6.6.0-alpha.0",
30
- "@webiny/project-utils": "6.6.0-alpha.0",
25
+ "@webiny/api-core-testing": "6.6.0-alpha.10",
26
+ "@webiny/api-headless-cms-testing": "6.6.0-alpha.10",
27
+ "@webiny/api-websockets": "6.6.0-alpha.10",
28
+ "@webiny/db-dynamodb": "6.6.0-alpha.10",
29
+ "@webiny/di": "2.0.0",
30
+ "@webiny/event-handler-core": "6.6.0-alpha.10",
31
+ "@webiny/handler": "6.6.0-alpha.10",
32
+ "@webiny/plugins": "6.6.0-alpha.10",
31
33
  "graphql": "16.14.2",
32
34
  "typescript": "7.0.2",
33
- "vitest": "4.1.10"
35
+ "vitest": "5.0.5"
34
36
  },
35
37
  "dependencies": {
36
- "@graphql-tools/schema": "10.0.38",
37
- "@webiny/api": "6.6.0-alpha.0",
38
- "@webiny/api-aco": "6.6.0-alpha.0",
39
- "@webiny/api-core": "6.6.0-alpha.0",
40
- "@webiny/api-file-manager": "6.6.0-alpha.0",
41
- "@webiny/api-graphql": "6.6.0-alpha.0",
42
- "@webiny/api-headless-cms": "6.6.0-alpha.0",
43
- "@webiny/api-mailer": "6.6.0-alpha.0",
44
- "@webiny/api-website-builder": "6.6.0-alpha.0",
45
- "@webiny/build-tools": "6.6.0-alpha.0",
46
- "@webiny/common-audit-logs": "6.6.0-alpha.0",
47
- "@webiny/error": "6.6.0-alpha.0",
48
- "@webiny/feature": "6.6.0-alpha.0",
49
- "@webiny/utils": "6.6.0-alpha.0",
50
- "@webiny/wcp": "6.6.0-alpha.0",
51
- "zod": "4.4.3"
38
+ "@webiny/api": "6.6.0-alpha.10",
39
+ "@webiny/api-aco": "6.6.0-alpha.10",
40
+ "@webiny/api-core": "6.6.0-alpha.10",
41
+ "@webiny/api-file-manager": "6.6.0-alpha.10",
42
+ "@webiny/api-graphql": "6.6.0-alpha.10",
43
+ "@webiny/api-headless-cms": "6.6.0-alpha.10",
44
+ "@webiny/api-mailer": "6.6.0-alpha.10",
45
+ "@webiny/api-website-builder": "6.6.0-alpha.10",
46
+ "@webiny/build-tools": "6.6.0-alpha.10",
47
+ "@webiny/common-audit-logs": "6.6.0-alpha.10",
48
+ "@webiny/error": "6.6.0-alpha.10",
49
+ "@webiny/feature": "6.6.0-alpha.10",
50
+ "@webiny/utils": "6.6.0-alpha.10",
51
+ "@webiny/wcp": "6.6.0-alpha.10",
52
+ "zod": "4.6.7"
52
53
  },
53
54
  "webiny": {
54
55
  "publishFrom": "dist"
@@ -1,8 +1,8 @@
1
1
  import { FolderAfterCreateEventHandler } from "@webiny/api-aco/features/folder/CreateFolder/index.js";
2
- import { AuditLogsContext } from "../../../abstractions.js";
2
+ import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
3
3
  declare class AuditLogFolderAfterCreateHandlerImpl implements FolderAfterCreateEventHandler.Interface {
4
- private context;
5
- constructor(context: AuditLogsContext.Interface);
4
+ private recordAuditLog;
5
+ constructor(recordAuditLog: RecordAuditLogUseCase.Interface);
6
6
  handle(event: FolderAfterCreateEventHandler.Event): Promise<void>;
7
7
  }
8
8
  export declare const AuditLogFolderAfterCreateHandler: typeof AuditLogFolderAfterCreateHandlerImpl & {
@@ -1,21 +1,30 @@
1
1
  import _webiny_error from "@webiny/error";
2
2
  import { FolderAfterCreateEventHandler } from "@webiny/api-aco/features/folder/CreateFolder/index.js";
3
- import { AuditLogsContext } from "../../../abstractions.js";
3
+ import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
4
4
  import { AUDIT } from "../../../config.js";
5
- import { getAuditConfig } from "../../../utils/getAuditConfig.js";
6
5
  class AuditLogFolderAfterCreateHandlerImpl {
7
- constructor(context){
8
- this.context = context;
6
+ constructor(recordAuditLog){
7
+ this.recordAuditLog = recordAuditLog;
9
8
  }
10
9
  async handle(event) {
11
10
  try {
12
11
  const { folder } = event.payload;
13
12
  if ("FmFile" === folder.type) {
14
- const createAuditLog = getAuditConfig(AUDIT.FILE_MANAGER.FILE_FOLDER.CREATE);
15
- await createAuditLog("Folder created", folder, folder.id, this.context);
13
+ const recordResult = await this.recordAuditLog.execute({
14
+ audit: AUDIT.FILE_MANAGER.FILE_FOLDER.CREATE,
15
+ message: "Folder created",
16
+ content: folder,
17
+ entityId: folder.id
18
+ });
19
+ if (recordResult.isFail()) throw recordResult.error;
16
20
  } else if (folder.type.startsWith("cms:")) {
17
- const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.MODEL_FOLDER.CREATE);
18
- await createAuditLog("Folder created", folder, folder.id, this.context);
21
+ const recordResult = await this.recordAuditLog.execute({
22
+ audit: AUDIT.HEADLESS_CMS.MODEL_FOLDER.CREATE,
23
+ message: "Folder created",
24
+ content: folder,
25
+ entityId: folder.id
26
+ });
27
+ if (recordResult.isFail()) throw recordResult.error;
19
28
  }
20
29
  } catch (error) {
21
30
  throw _webiny_error.from(error, {
@@ -28,7 +37,7 @@ class AuditLogFolderAfterCreateHandlerImpl {
28
37
  const AuditLogFolderAfterCreateHandler = FolderAfterCreateEventHandler.createImplementation({
29
38
  implementation: AuditLogFolderAfterCreateHandlerImpl,
30
39
  dependencies: [
31
- AuditLogsContext
40
+ RecordAuditLogUseCase
32
41
  ]
33
42
  });
34
43
  export { AuditLogFolderAfterCreateHandler };