@webiny/api-audit-logs 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (349) hide show
  1. package/AuditLogsFeature.d.ts +8 -0
  2. package/AuditLogsFeature.js +32 -0
  3. package/AuditLogsFeature.js.map +1 -0
  4. package/abstractions.d.ts +14 -4
  5. package/abstractions.js +3 -2
  6. package/abstractions.js.map +1 -1
  7. package/domain/errors.d.ts +5 -0
  8. package/domain/errors.js +11 -0
  9. package/domain/errors.js.map +1 -0
  10. package/events/abstractions.d.ts +0 -5
  11. package/events/abstractions.js.map +1 -1
  12. package/features/AuditLogPermissions/AuditLogPermissions.d.ts +15 -0
  13. package/features/AuditLogPermissions/AuditLogPermissions.js +24 -0
  14. package/features/AuditLogPermissions/AuditLogPermissions.js.map +1 -0
  15. package/features/AuditLogPermissions/abstractions.d.ts +11 -0
  16. package/features/AuditLogPermissions/abstractions.js +5 -0
  17. package/features/AuditLogPermissions/abstractions.js.map +1 -0
  18. package/features/AuditLogPermissions/feature.d.ts +4 -0
  19. package/features/AuditLogPermissions/feature.js +11 -0
  20. package/features/AuditLogPermissions/feature.js.map +1 -0
  21. package/features/CreateAuditLog/CreateAuditLogGateway.d.ts +12 -0
  22. package/features/CreateAuditLog/CreateAuditLogGateway.js +23 -0
  23. package/features/CreateAuditLog/CreateAuditLogGateway.js.map +1 -0
  24. package/features/CreateAuditLog/CreateAuditLogRepository.d.ts +14 -0
  25. package/features/CreateAuditLog/CreateAuditLogRepository.js +25 -0
  26. package/features/CreateAuditLog/CreateAuditLogRepository.js.map +1 -0
  27. package/features/CreateAuditLog/CreateAuditLogUseCase.d.ts +24 -0
  28. package/features/CreateAuditLog/CreateAuditLogUseCase.js +70 -0
  29. package/features/CreateAuditLog/CreateAuditLogUseCase.js.map +1 -0
  30. package/features/CreateAuditLog/abstractions.d.ts +42 -0
  31. package/features/CreateAuditLog/abstractions.js +7 -0
  32. package/features/CreateAuditLog/abstractions.js.map +1 -0
  33. package/features/CreateAuditLog/feature.d.ts +4 -0
  34. package/features/CreateAuditLog/feature.js +15 -0
  35. package/features/CreateAuditLog/feature.js.map +1 -0
  36. package/features/GetAuditLog/GetAuditLogGateway.d.ts +13 -0
  37. package/features/GetAuditLog/GetAuditLogGateway.js +21 -0
  38. package/features/GetAuditLog/GetAuditLogGateway.js.map +1 -0
  39. package/features/GetAuditLog/GetAuditLogRepository.d.ts +16 -0
  40. package/features/GetAuditLog/GetAuditLogRepository.js +32 -0
  41. package/features/GetAuditLog/GetAuditLogRepository.js.map +1 -0
  42. package/features/GetAuditLog/GetAuditLogUseCase.d.ts +15 -0
  43. package/features/GetAuditLog/GetAuditLogUseCase.js +29 -0
  44. package/features/GetAuditLog/GetAuditLogUseCase.js.map +1 -0
  45. package/features/GetAuditLog/abstractions.d.ts +42 -0
  46. package/features/GetAuditLog/abstractions.js +7 -0
  47. package/features/GetAuditLog/abstractions.js.map +1 -0
  48. package/features/GetAuditLog/feature.d.ts +4 -0
  49. package/features/GetAuditLog/feature.js +15 -0
  50. package/features/GetAuditLog/feature.js.map +1 -0
  51. package/features/ListAuditLogs/ListAuditLogsGateway.d.ts +12 -0
  52. package/features/ListAuditLogs/ListAuditLogsGateway.js +24 -0
  53. package/features/ListAuditLogs/ListAuditLogsGateway.js.map +1 -0
  54. package/features/ListAuditLogs/ListAuditLogsRepository.d.ts +17 -0
  55. package/features/ListAuditLogs/ListAuditLogsRepository.js +38 -0
  56. package/features/ListAuditLogs/ListAuditLogsRepository.js.map +1 -0
  57. package/features/ListAuditLogs/ListAuditLogsUseCase.d.ts +15 -0
  58. package/features/ListAuditLogs/ListAuditLogsUseCase.js +27 -0
  59. package/features/ListAuditLogs/ListAuditLogsUseCase.js.map +1 -0
  60. package/features/ListAuditLogs/abstractions.d.ts +55 -0
  61. package/features/ListAuditLogs/abstractions.js +7 -0
  62. package/features/ListAuditLogs/abstractions.js.map +1 -0
  63. package/features/ListAuditLogs/feature.d.ts +4 -0
  64. package/features/ListAuditLogs/feature.js +15 -0
  65. package/features/ListAuditLogs/feature.js.map +1 -0
  66. package/features/RecordAuditLog/RecordAuditLogUseCase.d.ts +30 -0
  67. package/features/RecordAuditLog/RecordAuditLogUseCase.js +108 -0
  68. package/features/RecordAuditLog/RecordAuditLogUseCase.js.map +1 -0
  69. package/features/RecordAuditLog/abstractions.d.ts +26 -0
  70. package/features/RecordAuditLog/abstractions.js +5 -0
  71. package/features/RecordAuditLog/abstractions.js.map +1 -0
  72. package/features/RecordAuditLog/feature.d.ts +4 -0
  73. package/features/RecordAuditLog/feature.js +11 -0
  74. package/features/RecordAuditLog/feature.js.map +1 -0
  75. package/features/UpdateAuditLog/UpdateAuditLogGateway.d.ts +12 -0
  76. package/features/UpdateAuditLog/UpdateAuditLogGateway.js +23 -0
  77. package/features/UpdateAuditLog/UpdateAuditLogGateway.js.map +1 -0
  78. package/features/UpdateAuditLog/UpdateAuditLogRepository.d.ts +14 -0
  79. package/features/UpdateAuditLog/UpdateAuditLogRepository.js +25 -0
  80. package/features/UpdateAuditLog/UpdateAuditLogRepository.js.map +1 -0
  81. package/features/UpdateAuditLog/UpdateAuditLogUseCase.d.ts +18 -0
  82. package/features/UpdateAuditLog/UpdateAuditLogUseCase.js +53 -0
  83. package/features/UpdateAuditLog/UpdateAuditLogUseCase.js.map +1 -0
  84. package/features/UpdateAuditLog/abstractions.d.ts +42 -0
  85. package/features/UpdateAuditLog/abstractions.js +7 -0
  86. package/features/UpdateAuditLog/abstractions.js.map +1 -0
  87. package/features/UpdateAuditLog/feature.d.ts +4 -0
  88. package/features/UpdateAuditLog/feature.js +15 -0
  89. package/features/UpdateAuditLog/feature.js.map +1 -0
  90. package/graphql/AuditLogsGraphQLSchema.d.ts +10 -0
  91. package/graphql/AuditLogsGraphQLSchema.js +139 -0
  92. package/graphql/AuditLogsGraphQLSchema.js.map +1 -0
  93. package/index.d.ts +2 -8
  94. package/index.js +1 -25
  95. package/package.json +26 -25
  96. package/storage/types.d.ts +0 -35
  97. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.d.ts +3 -3
  98. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +18 -9
  99. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -1
  100. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +3 -3
  101. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +35 -13
  102. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
  103. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +3 -3
  104. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +24 -15
  105. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js.map +1 -1
  106. package/subscriptions/aco/index.d.ts +2 -2
  107. package/subscriptions/aco/index.js +4 -4
  108. package/subscriptions/aco/index.js.map +1 -1
  109. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +11 -0
  110. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +45 -0
  111. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -0
  112. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +11 -0
  113. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +42 -0
  114. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -0
  115. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +11 -0
  116. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +44 -0
  117. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -0
  118. package/subscriptions/ai/index.d.ts +2 -0
  119. package/subscriptions/ai/index.js +11 -0
  120. package/subscriptions/ai/index.js.map +1 -0
  121. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.d.ts +3 -3
  122. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +11 -7
  123. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -1
  124. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +3 -3
  125. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +11 -7
  126. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -1
  127. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +3 -3
  128. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +14 -10
  129. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -1
  130. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +3 -3
  131. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +14 -10
  132. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js.map +1 -1
  133. package/subscriptions/fileManager/index.d.ts +2 -2
  134. package/subscriptions/fileManager/index.js +5 -5
  135. package/subscriptions/fileManager/index.js.map +1 -1
  136. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.d.ts +3 -3
  137. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +11 -7
  138. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -1
  139. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +3 -3
  140. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +18 -9
  141. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -1
  142. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +3 -3
  143. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +11 -7
  144. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -1
  145. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +3 -3
  146. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +11 -7
  147. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -1
  148. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +3 -3
  149. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +11 -7
  150. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -1
  151. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +3 -3
  152. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +14 -10
  153. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -1
  154. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +3 -3
  155. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +11 -7
  156. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -1
  157. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +3 -3
  158. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +11 -7
  159. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -1
  160. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +3 -3
  161. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +11 -7
  162. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -1
  163. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +3 -3
  164. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +11 -7
  165. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -1
  166. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +3 -3
  167. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +14 -10
  168. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -1
  169. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +3 -3
  170. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +11 -7
  171. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -1
  172. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +3 -3
  173. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +11 -7
  174. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -1
  175. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +3 -3
  176. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js +14 -10
  177. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js.map +1 -1
  178. package/subscriptions/headlessCms/index.d.ts +2 -2
  179. package/subscriptions/headlessCms/index.js +15 -15
  180. package/subscriptions/headlessCms/index.js.map +1 -1
  181. package/subscriptions/index.d.ts +2 -2
  182. package/subscriptions/index.js +9 -7
  183. package/subscriptions/index.js.map +1 -1
  184. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +3 -3
  185. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +13 -9
  186. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -1
  187. package/subscriptions/mailer/index.d.ts +2 -2
  188. package/subscriptions/mailer/index.js +2 -2
  189. package/subscriptions/mailer/index.js.map +1 -1
  190. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.d.ts +3 -3
  191. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +11 -7
  192. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -1
  193. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +3 -3
  194. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +11 -7
  195. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -1
  196. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +3 -3
  197. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +14 -10
  198. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -1
  199. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +3 -3
  200. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +11 -7
  201. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -1
  202. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +3 -3
  203. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +11 -7
  204. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -1
  205. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +3 -3
  206. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +14 -10
  207. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -1
  208. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +3 -3
  209. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +11 -7
  210. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -1
  211. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +3 -3
  212. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +11 -7
  213. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -1
  214. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +3 -3
  215. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +14 -10
  216. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -1
  217. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +3 -3
  218. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +11 -7
  219. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -1
  220. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +3 -3
  221. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +11 -7
  222. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -1
  223. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +3 -3
  224. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +14 -10
  225. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js.map +1 -1
  226. package/subscriptions/security/index.d.ts +2 -2
  227. package/subscriptions/security/index.js +13 -13
  228. package/subscriptions/security/index.js.map +1 -1
  229. package/subscriptions/websiteBuilder/index.d.ts +2 -2
  230. package/subscriptions/websiteBuilder/index.js +13 -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 -23
  269. package/context/AuditLogsContextValue.d.ts +0 -10
  270. package/context/AuditLogsContextValue.js +0 -129
  271. package/context/AuditLogsContextValue.js.map +0 -1
  272. package/context/index.d.ts +0 -9
  273. package/context/index.js +0 -31
  274. package/context/index.js.map +0 -1
  275. package/graphql/schema.d.ts +0 -3
  276. package/graphql/schema.js +0 -115
  277. package/graphql/schema.js.map +0 -1
  278. package/index.js.map +0 -1
  279. package/storage/AccessPatternHandler.d.ts +0 -14
  280. package/storage/AccessPatternHandler.js +0 -39
  281. package/storage/AccessPatternHandler.js.map +0 -1
  282. package/storage/Converter.d.ts +0 -16
  283. package/storage/Converter.js +0 -49
  284. package/storage/Converter.js.map +0 -1
  285. package/storage/Storage.d.ts +0 -18
  286. package/storage/Storage.js +0 -81
  287. package/storage/Storage.js.map +0 -1
  288. package/storage/abstractions/AccessPattern.d.ts +0 -24
  289. package/storage/abstractions/AccessPattern.js +0 -0
  290. package/storage/abstractions/AccessPatternHandler.d.ts +0 -13
  291. package/storage/abstractions/AccessPatternHandler.js +0 -0
  292. package/storage/abstractions/Converter.d.ts +0 -6
  293. package/storage/abstractions/Converter.js +0 -0
  294. package/storage/accessPatterns/AppAccessPattern.d.ts +0 -9
  295. package/storage/accessPatterns/AppAccessPattern.js +0 -35
  296. package/storage/accessPatterns/AppAccessPattern.js.map +0 -1
  297. package/storage/accessPatterns/AppCreatedByAccessPattern.d.ts +0 -9
  298. package/storage/accessPatterns/AppCreatedByAccessPattern.js +0 -38
  299. package/storage/accessPatterns/AppCreatedByAccessPattern.js.map +0 -1
  300. package/storage/accessPatterns/AppEntityAccessPattern.d.ts +0 -9
  301. package/storage/accessPatterns/AppEntityAccessPattern.js +0 -35
  302. package/storage/accessPatterns/AppEntityAccessPattern.js.map +0 -1
  303. package/storage/accessPatterns/AppEntityActionAccessPattern.d.ts +0 -9
  304. package/storage/accessPatterns/AppEntityActionAccessPattern.js +0 -35
  305. package/storage/accessPatterns/AppEntityActionAccessPattern.js.map +0 -1
  306. package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.d.ts +0 -9
  307. package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js +0 -38
  308. package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js.map +0 -1
  309. package/storage/accessPatterns/AppEntityCreatedByAccessPattern.d.ts +0 -9
  310. package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js +0 -38
  311. package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js.map +0 -1
  312. package/storage/accessPatterns/BaseAccessPattern.d.ts +0 -32
  313. package/storage/accessPatterns/BaseAccessPattern.js +0 -60
  314. package/storage/accessPatterns/BaseAccessPattern.js.map +0 -1
  315. package/storage/accessPatterns/CreatedByAccessPattern.d.ts +0 -9
  316. package/storage/accessPatterns/CreatedByAccessPattern.js +0 -38
  317. package/storage/accessPatterns/CreatedByAccessPattern.js.map +0 -1
  318. package/storage/accessPatterns/CreatedOnAccessPattern.d.ts +0 -9
  319. package/storage/accessPatterns/CreatedOnAccessPattern.js +0 -38
  320. package/storage/accessPatterns/CreatedOnAccessPattern.js.map +0 -1
  321. package/storage/accessPatterns/DefaultAccessPattern.d.ts +0 -15
  322. package/storage/accessPatterns/DefaultAccessPattern.js +0 -35
  323. package/storage/accessPatterns/DefaultAccessPattern.js.map +0 -1
  324. package/storage/accessPatterns/EntityIdAccessPattern.d.ts +0 -9
  325. package/storage/accessPatterns/EntityIdAccessPattern.js +0 -38
  326. package/storage/accessPatterns/EntityIdAccessPattern.js.map +0 -1
  327. package/storage/accessPatterns/index.d.ts +0 -6
  328. package/storage/accessPatterns/index.js +0 -57
  329. package/storage/accessPatterns/index.js.map +0 -1
  330. package/storage/cursorSchema.d.ts +0 -4
  331. package/storage/cursorSchema.js +0 -22
  332. package/storage/cursorSchema.js.map +0 -1
  333. package/storage/entity.d.ts +0 -36
  334. package/storage/entity.js +0 -120
  335. package/storage/entity.js.map +0 -1
  336. package/storage/results/ListErrorResult.d.ts +0 -10
  337. package/storage/results/ListErrorResult.js +0 -12
  338. package/storage/results/ListErrorResult.js.map +0 -1
  339. package/storage/results/ListSuccessResult.d.ts +0 -14
  340. package/storage/results/ListSuccessResult.js +0 -17
  341. package/storage/results/ListSuccessResult.js.map +0 -1
  342. package/storage/results/index.d.ts +0 -2
  343. package/storage/results/index.js +0 -2
  344. package/storage/startKey.d.ts +0 -6
  345. package/storage/startKey.js +0 -8
  346. package/storage/startKey.js.map +0 -1
  347. package/utils/getAuditConfig.d.ts +0 -4
  348. package/utils/getAuditConfig.js +0 -86
  349. package/utils/getAuditConfig.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
4
+ import type { IAuditLog } from "../../storage/types.js";
5
+ import { GetAuditLogRepository as Abstraction } from "./abstractions.js";
6
+ import { GetAuditLogGateway } from "./abstractions.js";
7
+ declare class GetAuditLogRepositoryImpl implements Abstraction.Interface {
8
+ private readonly gateway;
9
+ private readonly tenantContext;
10
+ constructor(gateway: GetAuditLogGateway.Interface, tenantContext: TenantContext.Interface);
11
+ get(id: string): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
12
+ }
13
+ export declare const GetAuditLogRepository: typeof GetAuditLogRepositoryImpl & {
14
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetAuditLogRepository>;
15
+ };
16
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
4
+ import { GetAuditLogGateway, GetAuditLogRepository } from "./abstractions.js";
5
+ class GetAuditLogRepositoryImpl {
6
+ constructor(gateway, tenantContext){
7
+ this.gateway = gateway;
8
+ this.tenantContext = tenantContext;
9
+ }
10
+ async get(id) {
11
+ try {
12
+ const tenant = this.tenantContext.getTenant().id;
13
+ const auditLog = await this.gateway.get({
14
+ id,
15
+ tenant
16
+ });
17
+ return Result.ok(auditLog);
18
+ } catch (error) {
19
+ return Result.fail(new AuditLogPersistenceError(error));
20
+ }
21
+ }
22
+ }
23
+ const GetAuditLogRepository_GetAuditLogRepository = GetAuditLogRepository.createImplementation({
24
+ implementation: GetAuditLogRepositoryImpl,
25
+ dependencies: [
26
+ GetAuditLogGateway,
27
+ TenantContext
28
+ ]
29
+ });
30
+ export { GetAuditLogRepository_GetAuditLogRepository as GetAuditLogRepository };
31
+
32
+ //# sourceMappingURL=GetAuditLogRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetAuditLog/GetAuditLogRepository.js","sources":["../../../src/features/GetAuditLog/GetAuditLogRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { AuditLogPersistenceError } from \"~/domain/errors.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { GetAuditLogRepository as Abstraction } from \"./abstractions.js\";\nimport { GetAuditLogGateway } from \"./abstractions.js\";\n\nclass GetAuditLogRepositoryImpl implements Abstraction.Interface {\n public constructor(\n private readonly gateway: GetAuditLogGateway.Interface,\n private readonly tenantContext: TenantContext.Interface\n ) {}\n\n public async get(id: string): Promise<Result<IAuditLog, AuditLogPersistenceError>> {\n try {\n const tenant = this.tenantContext.getTenant().id;\n const auditLog = await this.gateway.get({ id, tenant });\n return Result.ok(auditLog);\n } catch (error) {\n return Result.fail(new AuditLogPersistenceError(error as Error));\n }\n }\n}\n\nexport const GetAuditLogRepository = Abstraction.createImplementation({\n implementation: GetAuditLogRepositoryImpl,\n dependencies: [GetAuditLogGateway, TenantContext]\n});\n"],"names":["GetAuditLogRepositoryImpl","gateway","tenantContext","id","tenant","auditLog","Result","error","AuditLogPersistenceError","GetAuditLogRepository","Abstraction","GetAuditLogGateway","TenantContext"],"mappings":";;;;AAOA,MAAMA;IACF,YACqBC,OAAqC,EACrCC,aAAsC,CACzD;aAFmBD,OAAO,GAAPA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,IAAIC,EAAU,EAAwD;QAC/E,IAAI;YACA,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,EAAE;YAChD,MAAMC,WAAW,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;gBAAEF;gBAAIC;YAAO;YACrD,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,yBAAyBD;QACpD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBV;IAChB,cAAc;QAACW;QAAoBC;KAAc;AACrD"}
@@ -0,0 +1,15 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { AuditLogPermissions } from "../../features/AuditLogPermissions/abstractions.js";
3
+ import type { IAuditLog } from "../../storage/types.js";
4
+ import { GetAuditLogUseCase as UseCaseAbstraction } from "./abstractions.js";
5
+ import { GetAuditLogRepository } from "./abstractions.js";
6
+ declare class GetAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {
7
+ private readonly repository;
8
+ private readonly permissions;
9
+ constructor(repository: GetAuditLogRepository.Interface, permissions: AuditLogPermissions.Interface);
10
+ execute(id: string): Promise<Result<IAuditLog, UseCaseAbstraction.Error>>;
11
+ }
12
+ export declare const GetAuditLogUseCase: typeof GetAuditLogUseCaseImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetAuditLogUseCase>;
14
+ };
15
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
3
+ import { AuditLogPermissions } from "../AuditLogPermissions/abstractions.js";
4
+ import { GetAuditLogRepository, GetAuditLogUseCase } from "./abstractions.js";
5
+ class GetAuditLogUseCaseImpl {
6
+ constructor(repository, permissions){
7
+ this.repository = repository;
8
+ this.permissions = permissions;
9
+ }
10
+ async execute(id) {
11
+ const result = await this.repository.get(id);
12
+ if (result.isFail()) return Result.fail(result.error);
13
+ const canAccess = await this.permissions.canAccess(result.value.action);
14
+ if (!canAccess) return Result.fail(new NotAuthorizedError({
15
+ message: "You cannot access audit logs."
16
+ }));
17
+ return Result.ok(result.value);
18
+ }
19
+ }
20
+ const GetAuditLogUseCase_GetAuditLogUseCase = GetAuditLogUseCase.createImplementation({
21
+ implementation: GetAuditLogUseCaseImpl,
22
+ dependencies: [
23
+ GetAuditLogRepository,
24
+ AuditLogPermissions
25
+ ]
26
+ });
27
+ export { GetAuditLogUseCase_GetAuditLogUseCase as GetAuditLogUseCase };
28
+
29
+ //# sourceMappingURL=GetAuditLogUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetAuditLog/GetAuditLogUseCase.js","sources":["../../../src/features/GetAuditLog/GetAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { GetAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetAuditLogRepository } from \"./abstractions.js\";\n\nclass GetAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: GetAuditLogRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface\n ) {}\n\n public async execute(id: string): Promise<Result<IAuditLog, UseCaseAbstraction.Error>> {\n const result = await this.repository.get(id);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const canAccess = await this.permissions.canAccess(result.value.action);\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const GetAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetAuditLogUseCaseImpl,\n dependencies: [GetAuditLogRepository, AuditLogPermissions]\n});\n"],"names":["GetAuditLogUseCaseImpl","repository","permissions","id","result","Result","canAccess","NotAuthorizedError","GetAuditLogUseCase","UseCaseAbstraction","GetAuditLogRepository","AuditLogPermissions"],"mappings":";;;;AAOA,MAAMA;IACF,YACqBC,UAA2C,EAC3CC,WAA0C,CAC7D;aAFmBD,UAAU,GAAVA;aACAC,WAAW,GAAXA;IAClB;IAEH,MAAa,QAAQC,EAAU,EAAwD;QACnF,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAACD;QACzC,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAACD,OAAO,KAAK;QAGnC,MAAME,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAACF,OAAO,KAAK,CAAC,MAAM;QACtE,IAAI,CAACE,WACD,OAAOD,OAAO,IAAI,CACd,IAAIE,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,OAAOF,OAAO,EAAE,CAACD,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMI,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBT;IAChB,cAAc;QAACU;QAAuBC;KAAoB;AAC9D"}
@@ -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 { IAuditLog } from "../../storage/types.js";
4
+ import type { IStorageFetchParams } from "../../storage/abstractions/Storage.js";
5
+ import type { AuditLogPersistenceError } from "../../domain/errors.js";
6
+ /**
7
+ * GetAuditLog Use Case - Gets an audit log of the current tenant by its id.
8
+ */
9
+ export interface IGetAuditLogUseCase {
10
+ execute(id: string): Promise<Result<IAuditLog, UseCaseError>>;
11
+ }
12
+ export interface IGetAuditLogUseCaseErrors {
13
+ notAuthorized: NotAuthorizedError;
14
+ persistence: AuditLogPersistenceError;
15
+ }
16
+ type UseCaseError = IGetAuditLogUseCaseErrors[keyof IGetAuditLogUseCaseErrors];
17
+ export declare const GetAuditLogUseCase: import("@webiny/di").Abstraction<IGetAuditLogUseCase>;
18
+ export declare namespace GetAuditLogUseCase {
19
+ type Interface = IGetAuditLogUseCase;
20
+ type Error = UseCaseError;
21
+ }
22
+ /**
23
+ * GetAuditLogRepository - Fetches an audit log of the current tenant.
24
+ */
25
+ export interface IGetAuditLogRepository {
26
+ get(id: string): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
27
+ }
28
+ export declare const GetAuditLogRepository: import("@webiny/di").Abstraction<IGetAuditLogRepository>;
29
+ export declare namespace GetAuditLogRepository {
30
+ type Interface = IGetAuditLogRepository;
31
+ }
32
+ /**
33
+ * GetAuditLogGateway - Reads an audit log from the audit logs storage.
34
+ */
35
+ export interface IGetAuditLogGateway {
36
+ get(params: IStorageFetchParams): Promise<IAuditLog>;
37
+ }
38
+ export declare const GetAuditLogGateway: import("@webiny/di").Abstraction<IGetAuditLogGateway>;
39
+ export declare namespace GetAuditLogGateway {
40
+ type Interface = IGetAuditLogGateway;
41
+ }
42
+ export {};
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const GetAuditLogUseCase = createAbstraction("GetAuditLogUseCase");
3
+ const GetAuditLogRepository = createAbstraction("GetAuditLogRepository");
4
+ const GetAuditLogGateway = createAbstraction("GetAuditLogGateway");
5
+ export { GetAuditLogGateway, GetAuditLogRepository, GetAuditLogUseCase };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetAuditLog/abstractions.js","sources":["../../../src/features/GetAuditLog/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 { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageFetchParams } from \"~/storage/abstractions/Storage.js\";\nimport type { AuditLogPersistenceError } from \"~/domain/errors.js\";\n\n/**\n * GetAuditLog Use Case - Gets an audit log of the current tenant by its id.\n */\nexport interface IGetAuditLogUseCase {\n execute(id: string): Promise<Result<IAuditLog, UseCaseError>>;\n}\n\nexport interface IGetAuditLogUseCaseErrors {\n notAuthorized: NotAuthorizedError;\n persistence: AuditLogPersistenceError;\n}\n\ntype UseCaseError = IGetAuditLogUseCaseErrors[keyof IGetAuditLogUseCaseErrors];\n\nexport const GetAuditLogUseCase = createAbstraction<IGetAuditLogUseCase>(\"GetAuditLogUseCase\");\n\nexport namespace GetAuditLogUseCase {\n export type Interface = IGetAuditLogUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * GetAuditLogRepository - Fetches an audit log of the current tenant.\n */\nexport interface IGetAuditLogRepository {\n get(id: string): Promise<Result<IAuditLog, AuditLogPersistenceError>>;\n}\n\nexport const GetAuditLogRepository =\n createAbstraction<IGetAuditLogRepository>(\"GetAuditLogRepository\");\n\nexport namespace GetAuditLogRepository {\n export type Interface = IGetAuditLogRepository;\n}\n\n/**\n * GetAuditLogGateway - Reads an audit log from the audit logs storage.\n */\nexport interface IGetAuditLogGateway {\n get(params: IStorageFetchParams): Promise<IAuditLog>;\n}\n\nexport const GetAuditLogGateway = createAbstraction<IGetAuditLogGateway>(\"GetAuditLogGateway\");\n\nexport namespace GetAuditLogGateway {\n export type Interface = IGetAuditLogGateway;\n}\n"],"names":["GetAuditLogUseCase","createAbstraction","GetAuditLogRepository","GetAuditLogGateway"],"mappings":";AAqBO,MAAMA,qBAAqBC,kBAAuC;AAclE,MAAMC,wBACTD,kBAA0C;AAavC,MAAME,qBAAqBF,kBAAuC"}
@@ -0,0 +1,4 @@
1
+ export declare const GetAuditLogFeature: {
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 { GetAuditLogUseCase } from "./GetAuditLogUseCase.js";
3
+ import { GetAuditLogRepository } from "./GetAuditLogRepository.js";
4
+ import { GetAuditLogGateway } from "./GetAuditLogGateway.js";
5
+ const GetAuditLogFeature = createFeature({
6
+ name: "AuditLogs/GetAuditLog",
7
+ register (container) {
8
+ container.register(GetAuditLogUseCase);
9
+ container.register(GetAuditLogRepository).inSingletonScope();
10
+ container.register(GetAuditLogGateway).inSingletonScope();
11
+ }
12
+ });
13
+ export { GetAuditLogFeature };
14
+
15
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetAuditLog/feature.js","sources":["../../../src/features/GetAuditLog/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetAuditLogUseCase } from \"./GetAuditLogUseCase.js\";\nimport { GetAuditLogRepository } from \"./GetAuditLogRepository.js\";\nimport { GetAuditLogGateway } from \"./GetAuditLogGateway.js\";\n\nexport const GetAuditLogFeature = createFeature({\n name: \"AuditLogs/GetAuditLog\",\n register(container) {\n container.register(GetAuditLogUseCase);\n container.register(GetAuditLogRepository).inSingletonScope();\n container.register(GetAuditLogGateway).inSingletonScope();\n }\n});\n"],"names":["GetAuditLogFeature","createFeature","container","GetAuditLogUseCase","GetAuditLogRepository","GetAuditLogGateway"],"mappings":";;;;AAKO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,uBAAuB,gBAAgB;QAC1DF,UAAU,QAAQ,CAACG,oBAAoB,gBAAgB;IAC3D;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { AuditLogsStorage } from "../../abstractions.js";
2
+ import type { IStorageListParams } from "../../storage/abstractions/Storage.js";
3
+ import { ListAuditLogsGateway as Abstraction } from "./abstractions.js";
4
+ declare class ListAuditLogsGatewayImpl implements Abstraction.Interface {
5
+ private readonly storage;
6
+ constructor(storage: AuditLogsStorage.Interface);
7
+ list(params: IStorageListParams): Promise<Abstraction.Output>;
8
+ }
9
+ export declare const ListAuditLogsGateway: typeof ListAuditLogsGatewayImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListAuditLogsGateway>;
11
+ };
12
+ export {};
@@ -0,0 +1,24 @@
1
+ import { AuditLogsStorage } from "../../abstractions.js";
2
+ import { ListAuditLogsGateway } from "./abstractions.js";
3
+ class ListAuditLogsGatewayImpl {
4
+ constructor(storage){
5
+ this.storage = storage;
6
+ }
7
+ async list(params) {
8
+ const result = await this.storage.list(params);
9
+ if (!result.success) throw result.error;
10
+ return {
11
+ items: result.data,
12
+ meta: result.meta
13
+ };
14
+ }
15
+ }
16
+ const ListAuditLogsGateway_ListAuditLogsGateway = ListAuditLogsGateway.createImplementation({
17
+ implementation: ListAuditLogsGatewayImpl,
18
+ dependencies: [
19
+ AuditLogsStorage
20
+ ]
21
+ });
22
+ export { ListAuditLogsGateway_ListAuditLogsGateway as ListAuditLogsGateway };
23
+
24
+ //# sourceMappingURL=ListAuditLogsGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ListAuditLogs/ListAuditLogsGateway.js","sources":["../../../src/features/ListAuditLogs/ListAuditLogsGateway.ts"],"sourcesContent":["import { AuditLogsStorage } from \"~/abstractions.js\";\nimport type { IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport { ListAuditLogsGateway as Abstraction } from \"./abstractions.js\";\n\nclass ListAuditLogsGatewayImpl implements Abstraction.Interface {\n public constructor(private readonly storage: AuditLogsStorage.Interface) {}\n\n public async list(params: IStorageListParams): Promise<Abstraction.Output> {\n const result = await this.storage.list(params);\n if (!result.success) {\n throw result.error;\n }\n return {\n items: result.data,\n meta: result.meta\n };\n }\n}\n\nexport const ListAuditLogsGateway = Abstraction.createImplementation({\n implementation: ListAuditLogsGatewayImpl,\n dependencies: [AuditLogsStorage]\n});\n"],"names":["ListAuditLogsGatewayImpl","storage","params","result","ListAuditLogsGateway","Abstraction","AuditLogsStorage"],"mappings":";;AAIA,MAAMA;IACF,YAAoCC,OAAmC,CAAE;aAArCA,OAAO,GAAPA;IAAsC;IAE1E,MAAa,KAAKC,MAA0B,EAA+B;QACvE,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAACD;QACvC,IAAI,CAACC,OAAO,OAAO,EACf,MAAMA,OAAO,KAAK;QAEtB,OAAO;YACH,OAAOA,OAAO,IAAI;YAClB,MAAMA,OAAO,IAAI;QACrB;IACJ;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBL;IAChB,cAAc;QAACM;KAAiB;AACpC"}
@@ -0,0 +1,17 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
4
+ import type { IListAuditLogsParams } from "../../types.js";
5
+ import { ListAuditLogsRepository as Abstraction } from "./abstractions.js";
6
+ import { ListAuditLogsGateway } from "./abstractions.js";
7
+ import type { ListAuditLogsOutput } from "./abstractions.js";
8
+ declare class ListAuditLogsRepositoryImpl implements Abstraction.Interface {
9
+ private readonly gateway;
10
+ private readonly tenantContext;
11
+ constructor(gateway: ListAuditLogsGateway.Interface, tenantContext: TenantContext.Interface);
12
+ list(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>>;
13
+ }
14
+ export declare const ListAuditLogsRepository: typeof ListAuditLogsRepositoryImpl & {
15
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListAuditLogsRepository>;
16
+ };
17
+ export {};
@@ -0,0 +1,38 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
+ import { AuditLogPersistenceError } from "../../domain/errors.js";
4
+ import { ListAuditLogsGateway, ListAuditLogsRepository } from "./abstractions.js";
5
+ class ListAuditLogsRepositoryImpl {
6
+ constructor(gateway, tenantContext){
7
+ this.gateway = gateway;
8
+ this.tenantContext = tenantContext;
9
+ }
10
+ async list(params) {
11
+ try {
12
+ const storageParams = {
13
+ ...params,
14
+ tenant: this.tenantContext.getTenant().id
15
+ };
16
+ const { items, meta } = await this.gateway.list(storageParams);
17
+ return Result.ok({
18
+ items,
19
+ meta: {
20
+ cursor: meta.after || null,
21
+ hasMoreItems: meta.hasMoreItems
22
+ }
23
+ });
24
+ } catch (error) {
25
+ return Result.fail(new AuditLogPersistenceError(error));
26
+ }
27
+ }
28
+ }
29
+ const ListAuditLogsRepository_ListAuditLogsRepository = ListAuditLogsRepository.createImplementation({
30
+ implementation: ListAuditLogsRepositoryImpl,
31
+ dependencies: [
32
+ ListAuditLogsGateway,
33
+ TenantContext
34
+ ]
35
+ });
36
+ export { ListAuditLogsRepository_ListAuditLogsRepository as ListAuditLogsRepository };
37
+
38
+ //# sourceMappingURL=ListAuditLogsRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ListAuditLogs/ListAuditLogsRepository.js","sources":["../../../src/features/ListAuditLogs/ListAuditLogsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { AuditLogPersistenceError } from \"~/domain/errors.js\";\nimport type { IListAuditLogsParams } from \"~/types.js\";\nimport type { IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport { ListAuditLogsRepository as Abstraction } from \"./abstractions.js\";\nimport { ListAuditLogsGateway } from \"./abstractions.js\";\nimport type { ListAuditLogsOutput } from \"./abstractions.js\";\n\nclass ListAuditLogsRepositoryImpl implements Abstraction.Interface {\n public constructor(\n private readonly gateway: ListAuditLogsGateway.Interface,\n private readonly tenantContext: TenantContext.Interface\n ) {}\n\n public async list(\n params: IListAuditLogsParams\n ): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>> {\n try {\n const storageParams = {\n ...params,\n tenant: this.tenantContext.getTenant().id\n } as unknown as IStorageListParams;\n\n const { items, meta } = await this.gateway.list(storageParams);\n\n return Result.ok({\n items,\n meta: {\n cursor: meta.after || null,\n hasMoreItems: meta.hasMoreItems\n }\n });\n } catch (error) {\n return Result.fail(new AuditLogPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListAuditLogsRepository = Abstraction.createImplementation({\n implementation: ListAuditLogsRepositoryImpl,\n dependencies: [ListAuditLogsGateway, TenantContext]\n});\n"],"names":["ListAuditLogsRepositoryImpl","gateway","tenantContext","params","storageParams","items","meta","Result","error","AuditLogPersistenceError","ListAuditLogsRepository","Abstraction","ListAuditLogsGateway","TenantContext"],"mappings":";;;;AASA,MAAMA;IACF,YACqBC,OAAuC,EACvCC,aAAsC,CACzD;aAFmBD,OAAO,GAAPA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,KACTC,MAA4B,EACkC;QAC9D,IAAI;YACA,MAAMC,gBAAgB;gBAClB,GAAGD,MAAM;gBACT,QAAQ,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,EAAE;YAC7C;YAEA,MAAM,EAAEE,KAAK,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAACF;YAEhD,OAAOG,OAAO,EAAE,CAAC;gBACbF;gBACA,MAAM;oBACF,QAAQC,KAAK,KAAK,IAAI;oBACtB,cAAcA,KAAK,YAAY;gBACnC;YACJ;QACJ,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,yBAAyBD;QACpD;IACJ;AACJ;AAEO,MAAME,kDAA0BC,wBAAAA,oBAAgC,CAAC;IACpE,gBAAgBX;IAChB,cAAc;QAACY;QAAsBC;KAAc;AACvD"}
@@ -0,0 +1,15 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { AuditLogPermissions } from "../../features/AuditLogPermissions/abstractions.js";
3
+ import type { IListAuditLogsParams } from "../../types.js";
4
+ import { ListAuditLogsUseCase as UseCaseAbstraction } from "./abstractions.js";
5
+ import { ListAuditLogsRepository } from "./abstractions.js";
6
+ declare class ListAuditLogsUseCaseImpl implements UseCaseAbstraction.Interface {
7
+ private readonly repository;
8
+ private readonly permissions;
9
+ constructor(repository: ListAuditLogsRepository.Interface, permissions: AuditLogPermissions.Interface);
10
+ execute(params: IListAuditLogsParams): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>>;
11
+ }
12
+ export declare const ListAuditLogsUseCase: typeof ListAuditLogsUseCaseImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListAuditLogsUseCase>;
14
+ };
15
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
3
+ import { AuditLogPermissions } from "../AuditLogPermissions/abstractions.js";
4
+ import { ListAuditLogsRepository, ListAuditLogsUseCase } from "./abstractions.js";
5
+ class ListAuditLogsUseCaseImpl {
6
+ constructor(repository, permissions){
7
+ this.repository = repository;
8
+ this.permissions = permissions;
9
+ }
10
+ async execute(params) {
11
+ const canAccess = await this.permissions.canAccessAll();
12
+ if (!canAccess) return Result.fail(new NotAuthorizedError({
13
+ message: "You cannot access audit logs."
14
+ }));
15
+ return await this.repository.list(params);
16
+ }
17
+ }
18
+ const ListAuditLogsUseCase_ListAuditLogsUseCase = ListAuditLogsUseCase.createImplementation({
19
+ implementation: ListAuditLogsUseCaseImpl,
20
+ dependencies: [
21
+ ListAuditLogsRepository,
22
+ AuditLogPermissions
23
+ ]
24
+ });
25
+ export { ListAuditLogsUseCase_ListAuditLogsUseCase as ListAuditLogsUseCase };
26
+
27
+ //# sourceMappingURL=ListAuditLogsUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ListAuditLogs/ListAuditLogsUseCase.js","sources":["../../../src/features/ListAuditLogs/ListAuditLogsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport type { IListAuditLogsParams } from \"~/types.js\";\nimport { ListAuditLogsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ListAuditLogsRepository } from \"./abstractions.js\";\n\nclass ListAuditLogsUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: ListAuditLogsRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface\n ) {}\n\n public async execute(\n params: IListAuditLogsParams\n ): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>> {\n const canAccess = await this.permissions.canAccessAll();\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n return await this.repository.list(params);\n }\n}\n\nexport const ListAuditLogsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListAuditLogsUseCaseImpl,\n dependencies: [ListAuditLogsRepository, AuditLogPermissions]\n});\n"],"names":["ListAuditLogsUseCaseImpl","repository","permissions","params","canAccess","Result","NotAuthorizedError","ListAuditLogsUseCase","UseCaseAbstraction","ListAuditLogsRepository","AuditLogPermissions"],"mappings":";;;;AAOA,MAAMA;IACF,YACqBC,UAA6C,EAC7CC,WAA0C,CAC7D;aAFmBD,UAAU,GAAVA;aACAC,WAAW,GAAXA;IAClB;IAEH,MAAa,QACTC,MAA4B,EACwC;QACpE,MAAMC,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY;QACrD,IAAI,CAACA,WACD,OAAOC,OAAO,IAAI,CACd,IAAIC,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAACH;IACtC;AACJ;AAEO,MAAMI,4CAAuBC,qBAAAA,oBAAuC,CAAC;IACxE,gBAAgBR;IAChB,cAAc;QAACS;QAAyBC;KAAoB;AAChE"}
@@ -0,0 +1,55 @@
1
+ import type { Result } from "@webiny/feature/api";
2
+ import type { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
3
+ import type { IListAuditLogsParams } from "../../types.js";
4
+ import type { IListAuditLogsResultMeta } from "../../types.js";
5
+ import type { IAuditLog } from "../../storage/types.js";
6
+ import type { IStorageListParams } from "../../storage/abstractions/Storage.js";
7
+ import type { IStorageListSuccessResultMeta } from "../../storage/abstractions/Storage.js";
8
+ import type { AuditLogPersistenceError } from "../../domain/errors.js";
9
+ export interface ListAuditLogsOutput {
10
+ items: IAuditLog[];
11
+ meta: IListAuditLogsResultMeta;
12
+ }
13
+ /**
14
+ * ListAuditLogs Use Case - Lists audit logs of the current tenant. Needs access to all audit logs.
15
+ */
16
+ export interface IListAuditLogsUseCase {
17
+ execute(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, UseCaseError>>;
18
+ }
19
+ export interface IListAuditLogsUseCaseErrors {
20
+ notAuthorized: NotAuthorizedError;
21
+ persistence: AuditLogPersistenceError;
22
+ }
23
+ type UseCaseError = IListAuditLogsUseCaseErrors[keyof IListAuditLogsUseCaseErrors];
24
+ export declare const ListAuditLogsUseCase: import("@webiny/di").Abstraction<IListAuditLogsUseCase>;
25
+ export declare namespace ListAuditLogsUseCase {
26
+ type Interface = IListAuditLogsUseCase;
27
+ type Output = ListAuditLogsOutput;
28
+ type Error = UseCaseError;
29
+ }
30
+ /**
31
+ * ListAuditLogsRepository - Lists audit logs of the current tenant.
32
+ */
33
+ export interface IListAuditLogsRepository {
34
+ list(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>>;
35
+ }
36
+ export declare const ListAuditLogsRepository: import("@webiny/di").Abstraction<IListAuditLogsRepository>;
37
+ export declare namespace ListAuditLogsRepository {
38
+ type Interface = IListAuditLogsRepository;
39
+ }
40
+ export interface ListAuditLogsGatewayOutput {
41
+ items: IAuditLog[];
42
+ meta: IStorageListSuccessResultMeta;
43
+ }
44
+ /**
45
+ * ListAuditLogsGateway - Lists audit logs from the audit logs storage.
46
+ */
47
+ export interface IListAuditLogsGateway {
48
+ list(params: IStorageListParams): Promise<ListAuditLogsGatewayOutput>;
49
+ }
50
+ export declare const ListAuditLogsGateway: import("@webiny/di").Abstraction<IListAuditLogsGateway>;
51
+ export declare namespace ListAuditLogsGateway {
52
+ type Interface = IListAuditLogsGateway;
53
+ type Output = ListAuditLogsGatewayOutput;
54
+ }
55
+ export {};
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const ListAuditLogsUseCase = createAbstraction("ListAuditLogsUseCase");
3
+ const ListAuditLogsRepository = createAbstraction("ListAuditLogsRepository");
4
+ const ListAuditLogsGateway = createAbstraction("ListAuditLogsGateway");
5
+ export { ListAuditLogsGateway, ListAuditLogsRepository, ListAuditLogsUseCase };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ListAuditLogs/abstractions.js","sources":["../../../src/features/ListAuditLogs/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 { IListAuditLogsParams } from \"~/types.js\";\nimport type { IListAuditLogsResultMeta } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport type { IStorageListSuccessResultMeta } from \"~/storage/abstractions/Storage.js\";\nimport type { AuditLogPersistenceError } from \"~/domain/errors.js\";\n\nexport interface ListAuditLogsOutput {\n items: IAuditLog[];\n meta: IListAuditLogsResultMeta;\n}\n\n/**\n * ListAuditLogs Use Case - Lists audit logs of the current tenant. Needs access to all audit logs.\n */\nexport interface IListAuditLogsUseCase {\n execute(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, UseCaseError>>;\n}\n\nexport interface IListAuditLogsUseCaseErrors {\n notAuthorized: NotAuthorizedError;\n persistence: AuditLogPersistenceError;\n}\n\ntype UseCaseError = IListAuditLogsUseCaseErrors[keyof IListAuditLogsUseCaseErrors];\n\nexport const ListAuditLogsUseCase =\n createAbstraction<IListAuditLogsUseCase>(\"ListAuditLogsUseCase\");\n\nexport namespace ListAuditLogsUseCase {\n export type Interface = IListAuditLogsUseCase;\n export type Output = ListAuditLogsOutput;\n export type Error = UseCaseError;\n}\n\n/**\n * ListAuditLogsRepository - Lists audit logs of the current tenant.\n */\nexport interface IListAuditLogsRepository {\n list(\n params: IListAuditLogsParams\n ): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>>;\n}\n\nexport const ListAuditLogsRepository =\n createAbstraction<IListAuditLogsRepository>(\"ListAuditLogsRepository\");\n\nexport namespace ListAuditLogsRepository {\n export type Interface = IListAuditLogsRepository;\n}\n\nexport interface ListAuditLogsGatewayOutput {\n items: IAuditLog[];\n meta: IStorageListSuccessResultMeta;\n}\n\n/**\n * ListAuditLogsGateway - Lists audit logs from the audit logs storage.\n */\nexport interface IListAuditLogsGateway {\n list(params: IStorageListParams): Promise<ListAuditLogsGatewayOutput>;\n}\n\nexport const ListAuditLogsGateway =\n createAbstraction<IListAuditLogsGateway>(\"ListAuditLogsGateway\");\n\nexport namespace ListAuditLogsGateway {\n export type Interface = IListAuditLogsGateway;\n export type Output = ListAuditLogsGatewayOutput;\n}\n"],"names":["ListAuditLogsUseCase","createAbstraction","ListAuditLogsRepository","ListAuditLogsGateway"],"mappings":";AA6BO,MAAMA,uBACTC,kBAAyC;AAiBtC,MAAMC,0BACTD,kBAA4C;AAkBzC,MAAME,uBACTF,kBAAyC"}
@@ -0,0 +1,4 @@
1
+ export declare const ListAuditLogsFeature: {
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 { ListAuditLogsUseCase } from "./ListAuditLogsUseCase.js";
3
+ import { ListAuditLogsRepository } from "./ListAuditLogsRepository.js";
4
+ import { ListAuditLogsGateway } from "./ListAuditLogsGateway.js";
5
+ const ListAuditLogsFeature = createFeature({
6
+ name: "AuditLogs/ListAuditLogs",
7
+ register (container) {
8
+ container.register(ListAuditLogsUseCase);
9
+ container.register(ListAuditLogsRepository).inSingletonScope();
10
+ container.register(ListAuditLogsGateway).inSingletonScope();
11
+ }
12
+ });
13
+ export { ListAuditLogsFeature };
14
+
15
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ListAuditLogs/feature.js","sources":["../../../src/features/ListAuditLogs/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListAuditLogsUseCase } from \"./ListAuditLogsUseCase.js\";\nimport { ListAuditLogsRepository } from \"./ListAuditLogsRepository.js\";\nimport { ListAuditLogsGateway } from \"./ListAuditLogsGateway.js\";\n\nexport const ListAuditLogsFeature = createFeature({\n name: \"AuditLogs/ListAuditLogs\",\n register(container) {\n container.register(ListAuditLogsUseCase);\n container.register(ListAuditLogsRepository).inSingletonScope();\n container.register(ListAuditLogsGateway).inSingletonScope();\n }\n});\n"],"names":["ListAuditLogsFeature","createFeature","container","ListAuditLogsUseCase","ListAuditLogsRepository","ListAuditLogsGateway"],"mappings":";;;;AAKO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,yBAAyB,gBAAgB;QAC5DF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;IAC7D;AACJ"}
@@ -0,0 +1,30 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
3
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
4
+ import { CreateAuditLogUseCase } from "../../features/CreateAuditLog/abstractions.js";
5
+ import { ListAuditLogsUseCase } from "../../features/ListAuditLogs/abstractions.js";
6
+ import { UpdateAuditLogUseCase } from "../../features/UpdateAuditLog/abstractions.js";
7
+ import type { IAuditLog } from "../../storage/types.js";
8
+ import { RecordAuditLogUseCase as UseCaseAbstraction } from "./abstractions.js";
9
+ /**
10
+ * Records audit logs for things the current identity did. Writes happen without authorization,
11
+ * because the identity doing the audited action doesn't need audit log permissions.
12
+ *
13
+ * An action with a `newEntryDelay` merges into the entity's latest audit log when that log is
14
+ * newer than the delay, instead of creating a new one. A failure on that path is logged and
15
+ * nothing is recorded.
16
+ */
17
+ declare class RecordAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {
18
+ private readonly createAuditLog;
19
+ private readonly listAuditLogs;
20
+ private readonly updateAuditLog;
21
+ private readonly identityContext;
22
+ private readonly logger;
23
+ constructor(createAuditLog: CreateAuditLogUseCase.Interface, listAuditLogs: ListAuditLogsUseCase.Interface, updateAuditLog: UpdateAuditLogUseCase.Interface, identityContext: IdentityContext.Interface, logger: Logger.Interface);
24
+ execute(input: UseCaseAbstraction.Input): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>>;
25
+ private createOrMergeAuditLog;
26
+ }
27
+ export declare const RecordAuditLogUseCase: typeof RecordAuditLogUseCaseImpl & {
28
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRecordAuditLogUseCase>;
29
+ };
30
+ export {};
@@ -0,0 +1,108 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
3
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
4
+ import { CreateAuditLogUseCase } from "../CreateAuditLog/abstractions.js";
5
+ import { ListAuditLogsUseCase } from "../ListAuditLogs/abstractions.js";
6
+ import { UpdateAuditLogUseCase } from "../UpdateAuditLog/abstractions.js";
7
+ import { RecordAuditLogUseCase } from "./abstractions.js";
8
+ const createAuditLogDelayDate = (delay)=>{
9
+ const date = new Date();
10
+ date.setTime(date.getTime() - 1000 * delay);
11
+ return date;
12
+ };
13
+ class RecordAuditLogUseCaseImpl {
14
+ constructor(createAuditLog, listAuditLogs, updateAuditLog, identityContext, logger){
15
+ this.createAuditLog = createAuditLog;
16
+ this.listAuditLogs = listAuditLogs;
17
+ this.updateAuditLog = updateAuditLog;
18
+ this.identityContext = identityContext;
19
+ this.logger = logger;
20
+ }
21
+ async execute(input) {
22
+ const { audit, message, content, entityId } = input;
23
+ if (!this.identityContext.getIdentity()?.id) {
24
+ this.logger.debug("No identity, skipping audit log creation.");
25
+ return Result.ok(null);
26
+ }
27
+ const payload = {
28
+ message,
29
+ app: audit.app.app,
30
+ entityId,
31
+ entity: audit.entity.type,
32
+ action: audit.action.type,
33
+ content,
34
+ tags: []
35
+ };
36
+ const delay = audit.action.newEntryDelay || 0;
37
+ return await this.identityContext.withoutAuthorization(async ()=>{
38
+ if (delay > 0) try {
39
+ return await this.createOrMergeAuditLog(payload, delay);
40
+ } catch (error) {
41
+ this.logger.warn({
42
+ error
43
+ }, "Could not create or merge an audit log.");
44
+ return Result.ok(null);
45
+ }
46
+ return await this.createAuditLog.execute(payload);
47
+ });
48
+ }
49
+ async createOrMergeAuditLog(payload, delay) {
50
+ const createdOnGte = createAuditLogDelayDate(delay);
51
+ const listResult = await this.listAuditLogs.execute({
52
+ app: payload.app,
53
+ entityId: payload.entityId,
54
+ limit: 1,
55
+ createdOn_gte: createdOnGte,
56
+ sort: "DESC"
57
+ });
58
+ if (listResult.isFail()) {
59
+ this.logger.warn({
60
+ error: listResult.error
61
+ }, "Could not list audit logs to merge into.");
62
+ return Result.ok(null);
63
+ }
64
+ const original = listResult.value.items[0];
65
+ if (!original) {
66
+ const createResult = await this.createAuditLog.execute(payload);
67
+ if (createResult.isFail()) {
68
+ this.logger.warn({
69
+ error: createResult.error
70
+ }, "Could not create an audit log.");
71
+ return Result.ok(null);
72
+ }
73
+ return Result.ok(createResult.value);
74
+ }
75
+ let content = payload.content;
76
+ if (original.content) {
77
+ const beforePayloadData = JSON.parse(original.content)?.before;
78
+ if (beforePayloadData) content = {
79
+ before: beforePayloadData,
80
+ after: payload.content?.after
81
+ };
82
+ }
83
+ const updateResult = await this.updateAuditLog.execute(original, {
84
+ message: payload.message,
85
+ content
86
+ });
87
+ if (updateResult.isFail()) {
88
+ this.logger.warn({
89
+ error: updateResult.error
90
+ }, "Could not merge an audit log.");
91
+ return Result.ok(null);
92
+ }
93
+ return Result.ok(updateResult.value);
94
+ }
95
+ }
96
+ const RecordAuditLogUseCase_RecordAuditLogUseCase = RecordAuditLogUseCase.createImplementation({
97
+ implementation: RecordAuditLogUseCaseImpl,
98
+ dependencies: [
99
+ CreateAuditLogUseCase,
100
+ ListAuditLogsUseCase,
101
+ UpdateAuditLogUseCase,
102
+ IdentityContext,
103
+ Logger
104
+ ]
105
+ });
106
+ export { RecordAuditLogUseCase_RecordAuditLogUseCase as RecordAuditLogUseCase };
107
+
108
+ //# sourceMappingURL=RecordAuditLogUseCase.js.map
@@ -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"}