@webiny/api-audit-logs 0.0.0-unstable.8b6c57b569 → 0.0.0-unstable.9f53ea597d

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 (302) hide show
  1. package/README.md +11 -1
  2. package/abstractions.d.ts +10 -0
  3. package/abstractions.js +6 -0
  4. package/abstractions.js.map +1 -0
  5. package/config.d.ts +0 -13
  6. package/config.js +4 -291
  7. package/config.js.map +1 -1
  8. package/context/AuditLogsContextValue.d.ts +10 -0
  9. package/context/AuditLogsContextValue.js +129 -0
  10. package/context/AuditLogsContextValue.js.map +1 -0
  11. package/context/index.d.ts +6 -0
  12. package/context/index.js +25 -0
  13. package/context/index.js.map +1 -0
  14. package/events/AuditLogAfterCreateEvent.d.ts +6 -0
  15. package/events/AuditLogAfterCreateEvent.js +13 -0
  16. package/events/AuditLogAfterCreateEvent.js.map +1 -0
  17. package/events/AuditLogAfterUpdateEvent.d.ts +6 -0
  18. package/events/AuditLogAfterUpdateEvent.js +13 -0
  19. package/events/AuditLogAfterUpdateEvent.js.map +1 -0
  20. package/events/AuditLogBeforeCreateEvent.d.ts +6 -0
  21. package/events/AuditLogBeforeCreateEvent.js +13 -0
  22. package/events/AuditLogBeforeCreateEvent.js.map +1 -0
  23. package/events/AuditLogBeforeUpdateEvent.d.ts +6 -0
  24. package/events/AuditLogBeforeUpdateEvent.js +13 -0
  25. package/events/AuditLogBeforeUpdateEvent.js.map +1 -0
  26. package/events/abstractions.d.ts +43 -0
  27. package/events/abstractions.js +8 -0
  28. package/events/abstractions.js.map +1 -0
  29. package/events/index.d.ts +5 -0
  30. package/events/index.js +5 -0
  31. package/graphql/schema.d.ts +3 -0
  32. package/graphql/schema.js +115 -0
  33. package/graphql/schema.js.map +1 -0
  34. package/graphql/validation.d.ts +21 -0
  35. package/graphql/validation.js +31 -0
  36. package/graphql/validation.js.map +1 -0
  37. package/index.d.ts +5 -4
  38. package/index.js +21 -46
  39. package/index.js.map +1 -1
  40. package/package.json +33 -26
  41. package/storage/abstractions/Storage.d.ts +108 -0
  42. package/storage/abstractions/Storage.js +0 -0
  43. package/storage/types.d.ts +19 -0
  44. package/storage/types.js +0 -0
  45. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.d.ts +11 -0
  46. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +36 -0
  47. package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -0
  48. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +11 -0
  49. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +39 -0
  50. package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -0
  51. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +11 -0
  52. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +42 -0
  53. package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js.map +1 -0
  54. package/subscriptions/aco/index.d.ts +1 -1
  55. package/subscriptions/aco/index.js +8 -15
  56. package/subscriptions/aco/index.js.map +1 -1
  57. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +11 -0
  58. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +41 -0
  59. package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -0
  60. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +11 -0
  61. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +38 -0
  62. package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -0
  63. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +11 -0
  64. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +40 -0
  65. package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -0
  66. package/subscriptions/ai/index.d.ts +2 -0
  67. package/subscriptions/ai/index.js +11 -0
  68. package/subscriptions/ai/index.js.map +1 -0
  69. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.d.ts +11 -0
  70. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +31 -0
  71. package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -0
  72. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +11 -0
  73. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +31 -0
  74. package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -0
  75. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +11 -0
  76. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +34 -0
  77. package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -0
  78. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +11 -0
  79. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +34 -0
  80. package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js.map +1 -0
  81. package/subscriptions/fileManager/index.d.ts +2 -2
  82. package/subscriptions/fileManager/index.js +10 -14
  83. package/subscriptions/fileManager/index.js.map +1 -1
  84. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.d.ts +11 -0
  85. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +32 -0
  86. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -0
  87. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +11 -0
  88. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +37 -0
  89. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -0
  90. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +11 -0
  91. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +32 -0
  92. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -0
  93. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +11 -0
  94. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +32 -0
  95. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -0
  96. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +11 -0
  97. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +32 -0
  98. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -0
  99. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +11 -0
  100. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +35 -0
  101. package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -0
  102. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +11 -0
  103. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +32 -0
  104. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -0
  105. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +11 -0
  106. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +32 -0
  107. package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -0
  108. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +11 -0
  109. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +31 -0
  110. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -0
  111. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +11 -0
  112. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +31 -0
  113. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -0
  114. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +11 -0
  115. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +34 -0
  116. package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -0
  117. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +11 -0
  118. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +31 -0
  119. package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -0
  120. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +11 -0
  121. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +31 -0
  122. package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -0
  123. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +11 -0
  124. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js +34 -0
  125. package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js.map +1 -0
  126. package/subscriptions/headlessCms/index.d.ts +1 -1
  127. package/subscriptions/headlessCms/index.js +30 -28
  128. package/subscriptions/headlessCms/index.js.map +1 -1
  129. package/subscriptions/index.d.ts +1 -1
  130. package/subscriptions/index.js +16 -22
  131. package/subscriptions/index.js.map +1 -1
  132. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +11 -0
  133. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +33 -0
  134. package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -0
  135. package/subscriptions/mailer/index.d.ts +2 -2
  136. package/subscriptions/mailer/index.js +4 -10
  137. package/subscriptions/mailer/index.js.map +1 -1
  138. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.d.ts +11 -0
  139. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +41 -0
  140. package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -0
  141. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +11 -0
  142. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +41 -0
  143. package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -0
  144. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +11 -0
  145. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +45 -0
  146. package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -0
  147. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +11 -0
  148. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +31 -0
  149. package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -0
  150. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +11 -0
  151. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +31 -0
  152. package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -0
  153. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +11 -0
  154. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +34 -0
  155. package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -0
  156. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +11 -0
  157. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +31 -0
  158. package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -0
  159. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +11 -0
  160. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +31 -0
  161. package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -0
  162. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +11 -0
  163. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +34 -0
  164. package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -0
  165. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +11 -0
  166. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +31 -0
  167. package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -0
  168. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +11 -0
  169. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +31 -0
  170. package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -0
  171. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +11 -0
  172. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +34 -0
  173. package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js.map +1 -0
  174. package/subscriptions/security/handlers/cleanupApiKey.d.ts +7 -0
  175. package/subscriptions/security/handlers/cleanupApiKey.js +12 -0
  176. package/subscriptions/security/handlers/cleanupApiKey.js.map +1 -0
  177. package/subscriptions/security/index.d.ts +2 -2
  178. package/subscriptions/security/index.js +26 -24
  179. package/subscriptions/security/index.js.map +1 -1
  180. package/subscriptions/websiteBuilder/index.d.ts +2 -0
  181. package/subscriptions/websiteBuilder/index.js +29 -0
  182. package/subscriptions/websiteBuilder/index.js.map +1 -0
  183. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.d.ts +11 -0
  184. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js +31 -0
  185. package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js.map +1 -0
  186. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.d.ts +11 -0
  187. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js +31 -0
  188. package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js.map +1 -0
  189. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.d.ts +11 -0
  190. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js +31 -0
  191. package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js.map +1 -0
  192. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.d.ts +11 -0
  193. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js +34 -0
  194. package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js.map +1 -0
  195. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.d.ts +11 -0
  196. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js +31 -0
  197. package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js.map +1 -0
  198. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.d.ts +11 -0
  199. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js +31 -0
  200. package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js.map +1 -0
  201. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.d.ts +11 -0
  202. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js +31 -0
  203. package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js.map +1 -0
  204. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.d.ts +11 -0
  205. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js +34 -0
  206. package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js.map +1 -0
  207. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.d.ts +11 -0
  208. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js +31 -0
  209. package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js.map +1 -0
  210. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.d.ts +11 -0
  211. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js +31 -0
  212. package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js.map +1 -0
  213. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.d.ts +11 -0
  214. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js +31 -0
  215. package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js.map +1 -0
  216. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.d.ts +11 -0
  217. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js +34 -0
  218. package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js.map +1 -0
  219. package/types.d.ts +37 -38
  220. package/types.js +0 -18
  221. package/utils/expiresAt.d.ts +4 -0
  222. package/utils/expiresAt.js +20 -0
  223. package/utils/expiresAt.js.map +1 -0
  224. package/utils/getAuditConfig.d.ts +4 -36
  225. package/utils/getAuditConfig.js +75 -138
  226. package/utils/getAuditConfig.js.map +1 -1
  227. package/utils/getAuditObject.d.ts +2 -1
  228. package/utils/getAuditObject.js +14 -22
  229. package/utils/getAuditObject.js.map +1 -1
  230. package/app/app.d.ts +0 -2
  231. package/app/app.js +0 -119
  232. package/app/app.js.map +0 -1
  233. package/app/contants.d.ts +0 -2
  234. package/app/contants.js +0 -10
  235. package/app/contants.js.map +0 -1
  236. package/app/createAppModifier.d.ts +0 -4
  237. package/app/createAppModifier.js +0 -14
  238. package/app/createAppModifier.js.map +0 -1
  239. package/app/index.d.ts +0 -4
  240. package/app/index.js +0 -43
  241. package/app/index.js.map +0 -1
  242. package/app/types.d.ts +0 -7
  243. package/app/types.js +0 -7
  244. package/app/types.js.map +0 -1
  245. package/subscriptions/aco/folders.d.ts +0 -4
  246. package/subscriptions/aco/folders.js +0 -94
  247. package/subscriptions/aco/folders.js.map +0 -1
  248. package/subscriptions/apw/changeRequests.d.ts +0 -4
  249. package/subscriptions/apw/changeRequests.js +0 -80
  250. package/subscriptions/apw/changeRequests.js.map +0 -1
  251. package/subscriptions/apw/comments.d.ts +0 -2
  252. package/subscriptions/apw/comments.js +0 -28
  253. package/subscriptions/apw/comments.js.map +0 -1
  254. package/subscriptions/apw/contentReviews.d.ts +0 -2
  255. package/subscriptions/apw/contentReviews.js +0 -28
  256. package/subscriptions/apw/contentReviews.js.map +0 -1
  257. package/subscriptions/apw/index.d.ts +0 -2
  258. package/subscriptions/apw/index.js +0 -26
  259. package/subscriptions/apw/index.js.map +0 -1
  260. package/subscriptions/apw/workflows.d.ts +0 -4
  261. package/subscriptions/apw/workflows.js +0 -64
  262. package/subscriptions/apw/workflows.js.map +0 -1
  263. package/subscriptions/fileManager/files.d.ts +0 -4
  264. package/subscriptions/fileManager/files.js +0 -64
  265. package/subscriptions/fileManager/files.js.map +0 -1
  266. package/subscriptions/fileManager/settings.d.ts +0 -2
  267. package/subscriptions/fileManager/settings.js +0 -32
  268. package/subscriptions/fileManager/settings.js.map +0 -1
  269. package/subscriptions/headlessCms/entries.d.ts +0 -9
  270. package/subscriptions/headlessCms/entries.js +0 -183
  271. package/subscriptions/headlessCms/entries.js.map +0 -1
  272. package/subscriptions/headlessCms/groups.d.ts +0 -4
  273. package/subscriptions/headlessCms/groups.js +0 -64
  274. package/subscriptions/headlessCms/groups.js.map +0 -1
  275. package/subscriptions/headlessCms/models.d.ts +0 -4
  276. package/subscriptions/headlessCms/models.js +0 -64
  277. package/subscriptions/headlessCms/models.js.map +0 -1
  278. package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +0 -1
  279. package/subscriptions/headlessCms/utils/isSearchModelEntry.js +0 -13
  280. package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +0 -1
  281. package/subscriptions/i18n/index.d.ts +0 -2
  282. package/subscriptions/i18n/index.js +0 -15
  283. package/subscriptions/i18n/index.js.map +0 -1
  284. package/subscriptions/i18n/locales.d.ts +0 -4
  285. package/subscriptions/i18n/locales.js +0 -64
  286. package/subscriptions/i18n/locales.js.map +0 -1
  287. package/subscriptions/mailer/settings.d.ts +0 -2
  288. package/subscriptions/mailer/settings.js +0 -32
  289. package/subscriptions/mailer/settings.js.map +0 -1
  290. package/subscriptions/security/apiKeys.d.ts +0 -4
  291. package/subscriptions/security/apiKeys.js +0 -85
  292. package/subscriptions/security/apiKeys.js.map +0 -1
  293. package/subscriptions/security/roles.d.ts +0 -4
  294. package/subscriptions/security/roles.js +0 -64
  295. package/subscriptions/security/roles.js.map +0 -1
  296. package/subscriptions/security/teams.d.ts +0 -4
  297. package/subscriptions/security/teams.js +0 -64
  298. package/subscriptions/security/teams.js.map +0 -1
  299. package/subscriptions/security/users.d.ts +0 -4
  300. package/subscriptions/security/users.js +0 -64
  301. package/subscriptions/security/users.js.map +0 -1
  302. package/types.js.map +0 -1
package/README.md CHANGED
@@ -1 +1,11 @@
1
- # @webiny/api-audit-logs
1
+ # @webiny/api-audit-logs
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,10 @@
1
+ import type { AuditLogsContext as Context } from "./types.js";
2
+ import type { IStorage } from "./storage/abstractions/Storage.js";
3
+ export declare const AuditLogsContext: import("@webiny/di").Abstraction<Context>;
4
+ export declare namespace AuditLogsContext {
5
+ type Interface = Context;
6
+ }
7
+ export declare const AuditLogsStorage: import("@webiny/di").Abstraction<IStorage>;
8
+ export declare namespace AuditLogsStorage {
9
+ type Interface = IStorage;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const AuditLogsContext = createAbstraction("AuditLogsContext");
3
+ const AuditLogsStorage = createAbstraction("AuditLogsStorage");
4
+ export { AuditLogsContext, AuditLogsStorage };
5
+
6
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractions.js","sources":["../src/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { AuditLogsContext as Context } from \"~/types.js\";\nimport type { IStorage } from \"~/storage/abstractions/Storage.js\";\n\n// TODO: this is a bridge for legacy context; needs review and refactor of code that uses it.\n\nexport const AuditLogsContext = createAbstraction<Context>(\"AuditLogsContext\");\n\nexport namespace AuditLogsContext {\n export type Interface = Context;\n}\n\nexport const AuditLogsStorage = createAbstraction<IStorage>(\"AuditLogsStorage\");\n\nexport namespace AuditLogsStorage {\n export type Interface = IStorage;\n}\n"],"names":["AuditLogsContext","createAbstraction","AuditLogsStorage"],"mappings":";AAMO,MAAMA,mBAAmBC,kBAA2B;AAMpD,MAAMC,mBAAmBD,kBAA4B"}
package/config.d.ts CHANGED
@@ -1,14 +1 @@
1
- import type { App } from "./types";
2
- export declare enum ActionType {
3
- CREATE = "CREATE",
4
- UPDATE = "UPDATE",
5
- DELETE = "DELETE",
6
- MOVE_TO_TRASH = "MOVE_TO_TRASH",
7
- RESTORE_FROM_TRASH = "RESTORE_FROM_TRASH",
8
- PUBLISH = "PUBLISH",
9
- UNPUBLISH = "UNPUBLISH",
10
- IMPORT = "IMPORT",
11
- EXPORT = "EXPORT"
12
- }
13
- export declare const auditLogsApps: App[];
14
1
  export declare const AUDIT: import("./types").AuditObject;
package/config.js CHANGED
@@ -1,293 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.auditLogsApps = exports.ActionType = exports.AUDIT = void 0;
7
- var _getAuditObject = require("./utils/getAuditObject");
8
- let ActionType = exports.ActionType = /*#__PURE__*/function (ActionType) {
9
- ActionType["CREATE"] = "CREATE";
10
- ActionType["UPDATE"] = "UPDATE";
11
- ActionType["DELETE"] = "DELETE";
12
- ActionType["MOVE_TO_TRASH"] = "MOVE_TO_TRASH";
13
- ActionType["RESTORE_FROM_TRASH"] = "RESTORE_FROM_TRASH";
14
- ActionType["PUBLISH"] = "PUBLISH";
15
- ActionType["UNPUBLISH"] = "UNPUBLISH";
16
- ActionType["IMPORT"] = "IMPORT";
17
- ActionType["EXPORT"] = "EXPORT";
18
- return ActionType;
19
- }({});
20
- const commonActions = {
21
- CREATE: {
22
- type: ActionType.CREATE,
23
- displayName: "Create"
24
- },
25
- UPDATE: {
26
- type: ActionType.UPDATE,
27
- displayName: "Update"
28
- },
29
- DELETE: {
30
- type: ActionType.DELETE,
31
- displayName: "Delete"
32
- }
33
- };
34
- const publishActions = {
35
- PUBLISH: {
36
- type: ActionType.PUBLISH,
37
- displayName: "Publish"
38
- },
39
- UNPUBLISH: {
40
- type: ActionType.UNPUBLISH,
41
- displayName: "Unpublish"
42
- }
43
- };
44
- const importExportActions = {
45
- IMPORT: {
46
- type: ActionType.IMPORT,
47
- displayName: "Import"
48
- },
49
- EXPORT: {
50
- type: ActionType.EXPORT,
51
- displayName: "Export"
52
- }
53
- };
54
- const trashBinActions = {
55
- MOVE_TO_TRASH: {
56
- type: ActionType.MOVE_TO_TRASH,
57
- displayName: "Move to trash"
58
- },
59
- RESTORE_FROM_TRASH: {
60
- type: ActionType.RESTORE_FROM_TRASH,
61
- displayName: "Restore from trash"
62
- }
63
- };
64
- const auditLogsApps = exports.auditLogsApps = [{
65
- app: "APW",
66
- displayName: "APW",
67
- entities: [{
68
- type: "CHANGE_REQUEST",
69
- displayName: "Change Request",
70
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE, {
71
- type: "MARK_RESOLVED",
72
- displayName: "Mark resolved"
73
- }, {
74
- type: "MARK_UNRESOLVED",
75
- displayName: "Mark unresolved"
76
- }]
77
- }, {
78
- type: "COMMENT",
79
- displayName: "Comment",
80
- actions: [commonActions.CREATE]
81
- }, {
82
- type: "CONTENT_REVIEW",
83
- displayName: "Content Review",
84
- linkToEntity(id) {
85
- return `/apw/content-reviews/${id}`;
86
- },
87
- actions: [commonActions.CREATE]
88
- }, {
89
- type: "WORKFLOW",
90
- displayName: "Workflow",
91
- linkToEntity(id) {
92
- return `/apw/publishing-workflows?id=${id}`;
93
- },
94
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
95
- }]
96
- }, {
97
- app: "FILE_MANAGER",
98
- displayName: "File Manager",
99
- entities: [{
100
- type: "FILE",
101
- displayName: "File",
102
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
103
- }, {
104
- type: "FILE_FOLDER",
105
- displayName: "File folder",
106
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
107
- }, {
108
- type: "SETTINGS",
109
- displayName: "Settings",
110
- actions: [commonActions.UPDATE]
111
- }]
112
- }, {
113
- app: "FORM_BUILDER",
114
- displayName: "Form Builder",
115
- entities: [{
116
- type: "FORM",
117
- displayName: "Form",
118
- linkToEntity(id) {
119
- return `/form-builder/forms?id=${id}`;
120
- },
121
- actions: [commonActions.CREATE, commonActions.DELETE, importExportActions.EXPORT, importExportActions.IMPORT]
122
- }, {
123
- type: "FORM_REVISION",
124
- displayName: "Form revision",
125
- linkToEntity(id) {
126
- return `/form-builder/forms?id=${id}`;
127
- },
128
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE, publishActions.PUBLISH, publishActions.UNPUBLISH]
129
- }, {
130
- type: "FORM_SUBMISSION",
131
- displayName: "Form submission",
132
- actions: [importExportActions.EXPORT]
133
- }, {
134
- type: "SETTINGS",
135
- displayName: "Settings",
136
- actions: [commonActions.UPDATE]
137
- }]
138
- }, {
139
- app: "HEADLESS_CMS",
140
- displayName: "Headless CMS",
141
- entities: [{
142
- type: "ENTRY",
143
- displayName: "Entry",
144
- actions: [commonActions.CREATE, commonActions.DELETE, trashBinActions.MOVE_TO_TRASH, trashBinActions.RESTORE_FROM_TRASH]
145
- }, {
146
- type: "ENTRY_REVISION",
147
- displayName: "Entry revision",
148
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE, publishActions.PUBLISH, publishActions.UNPUBLISH]
149
- }, {
150
- type: "GROUP",
151
- displayName: "Group",
152
- linkToEntity(id) {
153
- return `/cms/content-model-groups?id=${id}`;
154
- },
155
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
156
- }, {
157
- type: "MODEL",
158
- displayName: "Model",
159
- linkToEntity(modelId) {
160
- return `/cms/content-models/${modelId}`;
161
- },
162
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
163
- }, {
164
- type: "MODEL_FOLDER",
165
- displayName: "Model folder",
166
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
167
- }]
168
- }, {
169
- app: "I18N",
170
- displayName: "i18n",
171
- entities: [{
172
- type: "LOCALE",
173
- displayName: "Locale",
174
- linkToEntity(id) {
175
- return `/i18n/locales?code=${id}`;
176
- },
177
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
178
- }]
179
- }, {
180
- app: "MAILER",
181
- displayName: "Mailer",
182
- entities: [{
183
- type: "SETTINGS",
184
- displayName: "Settings",
185
- actions: [commonActions.UPDATE]
186
- }]
187
- }, {
188
- app: "PAGE_BUILDER",
189
- displayName: "Page Builder",
190
- entities: [{
191
- type: "BLOCK",
192
- displayName: "Block",
193
- linkToEntity(id) {
194
- return `/page-builder/block-editor/${id}`;
195
- },
196
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE, importExportActions.EXPORT, importExportActions.IMPORT]
197
- }, {
198
- type: "BLOCK_CATEGORY",
199
- displayName: "Block category",
200
- linkToEntity(slug) {
201
- return `/page-builder/block-categories?slug=${slug}`;
202
- },
203
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
204
- }, {
205
- type: "CATEGORY",
206
- displayName: "Category",
207
- linkToEntity(slug) {
208
- return `/page-builder/categories?slug=${slug}`;
209
- },
210
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
211
- }, {
212
- type: "MENU",
213
- displayName: "Menu",
214
- linkToEntity(slug) {
215
- return `/page-builder/menus?slug=${slug}`;
216
- },
217
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
218
- }, {
219
- type: "PAGE",
220
- displayName: "Page",
221
- linkToEntity(id) {
222
- return `/page-builder/editor/${id}`;
223
- },
224
- actions: [commonActions.CREATE, commonActions.DELETE, importExportActions.EXPORT, importExportActions.IMPORT]
225
- }, {
226
- type: "PAGE_ELEMENT",
227
- displayName: "Page element",
228
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
229
- }, {
230
- type: "PAGE_FOLDER",
231
- displayName: "Page folder",
232
- linkToEntity(id) {
233
- return `/page-builder/pages?folderId=${id}`;
234
- },
235
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
236
- }, {
237
- type: "PAGE_REVISION",
238
- displayName: "Page revision",
239
- linkToEntity(id) {
240
- return `/page-builder/editor/${id}`;
241
- },
242
- actions: [commonActions.CREATE, {
243
- ...commonActions.UPDATE,
244
- newEntryDelay: 60
245
- }, commonActions.DELETE, publishActions.PUBLISH, publishActions.UNPUBLISH]
246
- }, {
247
- type: "SETTINGS",
248
- displayName: "Settings",
249
- actions: [commonActions.UPDATE]
250
- }, {
251
- type: "TEMPLATE",
252
- displayName: "Template",
253
- linkToEntity(id) {
254
- return `/page-builder/page-templates?id=${id}`;
255
- },
256
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE, importExportActions.EXPORT, importExportActions.IMPORT]
257
- }]
258
- }, {
259
- app: "SECURITY",
260
- displayName: "Security",
261
- entities: [{
262
- type: "API_KEY",
263
- displayName: "API Key",
264
- linkToEntity(id) {
265
- return `/access-management/api-keys?id=${id}`;
266
- },
267
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
268
- }, {
269
- type: "ROLE",
270
- displayName: "Role",
271
- linkToEntity(id) {
272
- return `/access-management/roles?id=${id}`;
273
- },
274
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
275
- }, {
276
- type: "TEAM",
277
- displayName: "Team",
278
- linkToEntity(id) {
279
- return `/access-management/teams?id=${id}`;
280
- },
281
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
282
- }, {
283
- type: "USER",
284
- displayName: "User",
285
- linkToEntity(id) {
286
- return `/admin-users?id=${id}`;
287
- },
288
- actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]
289
- }]
290
- }];
291
- const AUDIT = exports.AUDIT = (0, _getAuditObject.getAuditObject)(auditLogsApps);
1
+ import { getAuditObject } from "./utils/getAuditObject.js";
2
+ import { apps } from "@webiny/common-audit-logs";
3
+ const AUDIT = getAuditObject(apps);
4
+ export { AUDIT };
292
5
 
293
6
  //# sourceMappingURL=config.js.map
package/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_getAuditObject","require","ActionType","exports","commonActions","CREATE","type","displayName","UPDATE","DELETE","publishActions","PUBLISH","UNPUBLISH","importExportActions","IMPORT","EXPORT","trashBinActions","MOVE_TO_TRASH","RESTORE_FROM_TRASH","auditLogsApps","app","entities","actions","linkToEntity","id","modelId","slug","newEntryDelay","AUDIT","getAuditObject"],"sources":["config.ts"],"sourcesContent":["import { getAuditObject } from \"~/utils/getAuditObject\";\nimport type { App } from \"~/types\";\n\nexport enum ActionType {\n CREATE = \"CREATE\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n MOVE_TO_TRASH = \"MOVE_TO_TRASH\",\n RESTORE_FROM_TRASH = \"RESTORE_FROM_TRASH\",\n PUBLISH = \"PUBLISH\",\n UNPUBLISH = \"UNPUBLISH\",\n IMPORT = \"IMPORT\",\n EXPORT = \"EXPORT\"\n}\n\nconst commonActions = {\n CREATE: { type: ActionType.CREATE, displayName: \"Create\" },\n UPDATE: { type: ActionType.UPDATE, displayName: \"Update\" },\n DELETE: { type: ActionType.DELETE, displayName: \"Delete\" }\n};\n\nconst publishActions = {\n PUBLISH: { type: ActionType.PUBLISH, displayName: \"Publish\" },\n UNPUBLISH: { type: ActionType.UNPUBLISH, displayName: \"Unpublish\" }\n};\n\nconst importExportActions = {\n IMPORT: { type: ActionType.IMPORT, displayName: \"Import\" },\n EXPORT: { type: ActionType.EXPORT, displayName: \"Export\" }\n};\n\nconst trashBinActions = {\n MOVE_TO_TRASH: { type: ActionType.MOVE_TO_TRASH, displayName: \"Move to trash\" },\n RESTORE_FROM_TRASH: { type: ActionType.RESTORE_FROM_TRASH, displayName: \"Restore from trash\" }\n};\n\nexport const auditLogsApps: App[] = [\n {\n app: \"APW\",\n displayName: \"APW\",\n entities: [\n {\n type: \"CHANGE_REQUEST\",\n displayName: \"Change Request\",\n actions: [\n commonActions.CREATE,\n commonActions.UPDATE,\n commonActions.DELETE,\n { type: \"MARK_RESOLVED\", displayName: \"Mark resolved\" },\n { type: \"MARK_UNRESOLVED\", displayName: \"Mark unresolved\" }\n ]\n },\n {\n type: \"COMMENT\",\n displayName: \"Comment\",\n actions: [commonActions.CREATE]\n },\n {\n type: \"CONTENT_REVIEW\",\n displayName: \"Content Review\",\n linkToEntity(id) {\n return `/apw/content-reviews/${id}`;\n },\n actions: [commonActions.CREATE]\n },\n {\n type: \"WORKFLOW\",\n displayName: \"Workflow\",\n linkToEntity(id) {\n return `/apw/publishing-workflows?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n }\n ]\n },\n {\n app: \"FILE_MANAGER\",\n displayName: \"File Manager\",\n entities: [\n {\n type: \"FILE\",\n displayName: \"File\",\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"FILE_FOLDER\",\n displayName: \"File folder\",\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"SETTINGS\",\n displayName: \"Settings\",\n actions: [commonActions.UPDATE]\n }\n ]\n },\n {\n app: \"FORM_BUILDER\",\n displayName: \"Form Builder\",\n entities: [\n {\n type: \"FORM\",\n displayName: \"Form\",\n linkToEntity(id) {\n return `/form-builder/forms?id=${id}`;\n },\n actions: [\n commonActions.CREATE,\n commonActions.DELETE,\n importExportActions.EXPORT,\n importExportActions.IMPORT\n ]\n },\n {\n type: \"FORM_REVISION\",\n displayName: \"Form revision\",\n linkToEntity(id) {\n return `/form-builder/forms?id=${id}`;\n },\n actions: [\n commonActions.CREATE,\n commonActions.UPDATE,\n commonActions.DELETE,\n publishActions.PUBLISH,\n publishActions.UNPUBLISH\n ]\n },\n {\n type: \"FORM_SUBMISSION\",\n displayName: \"Form submission\",\n actions: [importExportActions.EXPORT]\n },\n {\n type: \"SETTINGS\",\n displayName: \"Settings\",\n actions: [commonActions.UPDATE]\n }\n ]\n },\n {\n app: \"HEADLESS_CMS\",\n displayName: \"Headless CMS\",\n entities: [\n {\n type: \"ENTRY\",\n displayName: \"Entry\",\n actions: [\n commonActions.CREATE,\n commonActions.DELETE,\n trashBinActions.MOVE_TO_TRASH,\n trashBinActions.RESTORE_FROM_TRASH\n ]\n },\n {\n type: \"ENTRY_REVISION\",\n displayName: \"Entry revision\",\n actions: [\n commonActions.CREATE,\n commonActions.UPDATE,\n commonActions.DELETE,\n publishActions.PUBLISH,\n publishActions.UNPUBLISH\n ]\n },\n {\n type: \"GROUP\",\n displayName: \"Group\",\n linkToEntity(id) {\n return `/cms/content-model-groups?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"MODEL\",\n displayName: \"Model\",\n linkToEntity(modelId) {\n return `/cms/content-models/${modelId}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"MODEL_FOLDER\",\n displayName: \"Model folder\",\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n }\n ]\n },\n {\n app: \"I18N\",\n displayName: \"i18n\",\n entities: [\n {\n type: \"LOCALE\",\n displayName: \"Locale\",\n linkToEntity(id) {\n return `/i18n/locales?code=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n }\n ]\n },\n {\n app: \"MAILER\",\n displayName: \"Mailer\",\n entities: [\n {\n type: \"SETTINGS\",\n displayName: \"Settings\",\n actions: [commonActions.UPDATE]\n }\n ]\n },\n {\n app: \"PAGE_BUILDER\",\n displayName: \"Page Builder\",\n entities: [\n {\n type: \"BLOCK\",\n displayName: \"Block\",\n linkToEntity(id) {\n return `/page-builder/block-editor/${id}`;\n },\n actions: [\n commonActions.CREATE,\n commonActions.UPDATE,\n commonActions.DELETE,\n importExportActions.EXPORT,\n importExportActions.IMPORT\n ]\n },\n {\n type: \"BLOCK_CATEGORY\",\n displayName: \"Block category\",\n linkToEntity(slug) {\n return `/page-builder/block-categories?slug=${slug}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"CATEGORY\",\n displayName: \"Category\",\n linkToEntity(slug) {\n return `/page-builder/categories?slug=${slug}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"MENU\",\n displayName: \"Menu\",\n linkToEntity(slug) {\n return `/page-builder/menus?slug=${slug}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"PAGE\",\n displayName: \"Page\",\n linkToEntity(id) {\n return `/page-builder/editor/${id}`;\n },\n actions: [\n commonActions.CREATE,\n commonActions.DELETE,\n importExportActions.EXPORT,\n importExportActions.IMPORT\n ]\n },\n {\n type: \"PAGE_ELEMENT\",\n displayName: \"Page element\",\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"PAGE_FOLDER\",\n displayName: \"Page folder\",\n linkToEntity(id) {\n return `/page-builder/pages?folderId=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"PAGE_REVISION\",\n displayName: \"Page revision\",\n linkToEntity(id) {\n return `/page-builder/editor/${id}`;\n },\n actions: [\n commonActions.CREATE,\n { ...commonActions.UPDATE, newEntryDelay: 60 },\n commonActions.DELETE,\n publishActions.PUBLISH,\n publishActions.UNPUBLISH\n ]\n },\n {\n type: \"SETTINGS\",\n displayName: \"Settings\",\n actions: [commonActions.UPDATE]\n },\n {\n type: \"TEMPLATE\",\n displayName: \"Template\",\n linkToEntity(id) {\n return `/page-builder/page-templates?id=${id}`;\n },\n actions: [\n commonActions.CREATE,\n commonActions.UPDATE,\n commonActions.DELETE,\n importExportActions.EXPORT,\n importExportActions.IMPORT\n ]\n }\n ]\n },\n {\n app: \"SECURITY\",\n displayName: \"Security\",\n entities: [\n {\n type: \"API_KEY\",\n displayName: \"API Key\",\n linkToEntity(id) {\n return `/access-management/api-keys?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"ROLE\",\n displayName: \"Role\",\n linkToEntity(id) {\n return `/access-management/roles?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"TEAM\",\n displayName: \"Team\",\n linkToEntity(id) {\n return `/access-management/teams?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n },\n {\n type: \"USER\",\n displayName: \"User\",\n linkToEntity(id) {\n return `/admin-users?id=${id}`;\n },\n actions: [commonActions.CREATE, commonActions.UPDATE, commonActions.DELETE]\n }\n ]\n }\n];\n\nexport const AUDIT = getAuditObject(auditLogsApps);\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAwD,IAG5CC,UAAU,GA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ClC,CAAC;IACDF,OAAO,EAAE,CAAClB,aAAa,CAACC,MAAM,EAAED,aAAa,CAACI,MAAM,EAAEJ,aAAa,CAACK,MAAM;EAC9E,CAAC;AAET,CAAC,CACJ;AAEM,MAAMmB,KAAK,GAAAzB,OAAA,CAAAyB,KAAA,GAAG,IAAAC,8BAAc,EAACV,aAAa,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"config.js","sources":["../src/config.ts"],"sourcesContent":["import { getAuditObject } from \"~/utils/getAuditObject.js\";\nimport { apps } from \"@webiny/common-audit-logs\";\n\nexport const AUDIT = getAuditObject(apps);\n"],"names":["AUDIT","getAuditObject","apps"],"mappings":";;AAGO,MAAMA,QAAQC,eAAeC"}
@@ -0,0 +1,10 @@
1
+ import type { AuditLogsContext, AuditLogsContextValue } from "../types.js";
2
+ import type { IStorage } from "../storage/abstractions/Storage.js";
3
+ import type { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
4
+ export interface IAuditLogsContextValueParams {
5
+ getContext: () => AuditLogsContext;
6
+ deleteLogsAfterDays: number;
7
+ storage: IStorage;
8
+ eventPublisher: EventPublisher.Interface;
9
+ }
10
+ export declare const createAuditLogsContextValue: (params: IAuditLogsContextValueParams) => AuditLogsContextValue;
@@ -0,0 +1,129 @@
1
+ import { convertExpiresAtDaysToDate } from "../utils/expiresAt.js";
2
+ import { mdbid } from "@webiny/utils/mdbid.js";
3
+ import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
4
+ import { AuditLogAfterCreateEvent, AuditLogAfterUpdateEvent, AuditLogBeforeCreateEvent, AuditLogBeforeUpdateEvent } from "../events/index.js";
5
+ class AuditLogsContextValueImpl {
6
+ constructor(params){
7
+ this.getContext = params.getContext;
8
+ this.deleteLogsAfterDays = params.deleteLogsAfterDays;
9
+ this.storage = params.storage;
10
+ this.eventPublisher = params.eventPublisher;
11
+ }
12
+ async createAuditLog(payload) {
13
+ const context = this.getContext();
14
+ const expiresAt = convertExpiresAtDaysToDate(this.deleteLogsAfterDays);
15
+ const auditLog = {
16
+ id: mdbid(),
17
+ tenant: this.getTenantId(),
18
+ createdBy: this.getIdentity(),
19
+ createdOn: new Date(),
20
+ ...payload,
21
+ content: JSON.stringify(payload.content),
22
+ expiresAt
23
+ };
24
+ await this.checkPermissions(auditLog);
25
+ const beforeCreateEvent = new AuditLogBeforeCreateEvent({
26
+ auditLog: auditLog,
27
+ context,
28
+ setAuditLog (input) {
29
+ Object.assign(auditLog, input);
30
+ }
31
+ });
32
+ await this.eventPublisher.publish(beforeCreateEvent);
33
+ const result = await this.storage.store({
34
+ data: auditLog
35
+ });
36
+ if (result.success) {
37
+ const afterCreateEvent = new AuditLogAfterCreateEvent({
38
+ auditLog: auditLog,
39
+ context
40
+ });
41
+ await this.eventPublisher.publish(afterCreateEvent);
42
+ return result.data;
43
+ }
44
+ throw result.error;
45
+ }
46
+ async updateAuditLog(original, payload) {
47
+ const context = this.getContext();
48
+ const auditLog = {
49
+ ...original,
50
+ ...payload,
51
+ content: payload.content ? JSON.stringify(payload.content) : original.content
52
+ };
53
+ await this.checkPermissions(auditLog);
54
+ const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({
55
+ original,
56
+ auditLog,
57
+ context,
58
+ setAuditLog (input) {
59
+ Object.assign(auditLog, input);
60
+ }
61
+ });
62
+ await this.eventPublisher.publish(beforeUpdateEvent);
63
+ const result = await this.storage.store({
64
+ data: auditLog
65
+ });
66
+ if (result.success) {
67
+ const afterUpdateEvent = new AuditLogAfterUpdateEvent({
68
+ original: original,
69
+ auditLog: auditLog,
70
+ context
71
+ });
72
+ await this.eventPublisher.publish(afterUpdateEvent);
73
+ return result.data;
74
+ }
75
+ throw result.error;
76
+ }
77
+ async getAuditLog(id) {
78
+ const result = await this.storage.fetch({
79
+ id,
80
+ tenant: this.getTenantId()
81
+ });
82
+ if (result.success) {
83
+ await this.checkPermissions(result.data);
84
+ return result.data;
85
+ }
86
+ throw result.error;
87
+ }
88
+ async listAuditLogs(params) {
89
+ const result = await this.storage.list({
90
+ ...params,
91
+ tenant: this.getTenantId()
92
+ });
93
+ if (result.success) return {
94
+ items: result.data,
95
+ meta: {
96
+ cursor: result.meta.after || null,
97
+ hasMoreItems: result.meta.hasMoreItems
98
+ }
99
+ };
100
+ throw result.error;
101
+ }
102
+ async checkPermissions(auditLog) {
103
+ if (!auditLog.action) throw new Error("Audit log action is not defined. Cannot check permissions.");
104
+ const permissions = await this.getContext().security.getPermissions("al.*");
105
+ for (const permission of permissions){
106
+ if ("*" === permission.name) return;
107
+ if ("al.*" === permission.name) return;
108
+ if (permission.name === `al.${auditLog.action}`) return;
109
+ }
110
+ throw new NotAuthorizedError({
111
+ message: "You cannot access audit logs."
112
+ });
113
+ }
114
+ getTenantId() {
115
+ return this.getContext().tenancy.getCurrentTenant().id;
116
+ }
117
+ getIdentity() {
118
+ const identity = this.getContext().security.getIdentity();
119
+ return {
120
+ id: identity.id,
121
+ type: identity.type,
122
+ displayName: identity.displayName || "unknown"
123
+ };
124
+ }
125
+ }
126
+ const createAuditLogsContextValue = (params)=>new AuditLogsContextValueImpl(params);
127
+ export { createAuditLogsContextValue };
128
+
129
+ //# sourceMappingURL=AuditLogsContextValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context/AuditLogsContextValue.js","sources":["../../src/context/AuditLogsContextValue.ts"],"sourcesContent":["import type {\n AuditLogPayload,\n AuditLogsContext,\n AuditLogsContextValue,\n IListAuditLogsParams,\n IListAuditLogsResult\n} from \"~/types.js\";\nimport { convertExpiresAtDaysToDate } from \"~/utils/expiresAt.js\";\nimport type { IAuditLog, IAuditLogCreatedBy } from \"~/storage/types.js\";\nimport { mdbid } from \"@webiny/utils/mdbid.js\";\nimport type { IStorage, IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport type { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n AuditLogBeforeCreateEvent,\n AuditLogAfterCreateEvent,\n AuditLogBeforeUpdateEvent,\n AuditLogAfterUpdateEvent\n} from \"~/events/index.js\";\n\nexport interface IAuditLogsContextValueParams {\n getContext: () => AuditLogsContext;\n deleteLogsAfterDays: number;\n storage: IStorage;\n eventPublisher: EventPublisher.Interface;\n}\n\nclass AuditLogsContextValueImpl implements AuditLogsContextValue {\n private readonly getContext;\n public readonly deleteLogsAfterDays;\n private readonly storage: IStorage;\n private readonly eventPublisher: EventPublisher.Interface;\n\n public constructor(params: IAuditLogsContextValueParams) {\n this.getContext = params.getContext;\n this.deleteLogsAfterDays = params.deleteLogsAfterDays;\n this.storage = params.storage;\n this.eventPublisher = params.eventPublisher;\n }\n\n public async createAuditLog(payload: AuditLogPayload): Promise<IAuditLog> {\n const context = this.getContext();\n const expiresAt = convertExpiresAtDaysToDate(this.deleteLogsAfterDays);\n\n const auditLog: IAuditLog = {\n id: mdbid(),\n tenant: this.getTenantId(),\n createdBy: this.getIdentity(),\n createdOn: new Date(),\n ...payload,\n content: JSON.stringify(payload.content),\n expiresAt\n };\n await this.checkPermissions(auditLog);\n\n const beforeCreateEvent = new AuditLogBeforeCreateEvent({\n auditLog: auditLog,\n context,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeCreateEvent);\n\n const result = await this.storage.store({\n data: auditLog\n });\n if (result.success) {\n const afterCreateEvent = new AuditLogAfterCreateEvent({\n auditLog: auditLog,\n context\n });\n await this.eventPublisher.publish(afterCreateEvent);\n return result.data;\n }\n throw result.error;\n }\n\n public async updateAuditLog(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<IAuditLog> {\n const context = this.getContext();\n const auditLog: IAuditLog = {\n ...original,\n ...payload,\n content: payload.content ? JSON.stringify(payload.content) : original.content\n };\n await this.checkPermissions(auditLog);\n\n const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({\n original,\n auditLog,\n context,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeUpdateEvent);\n\n const result = await this.storage.store({\n data: auditLog\n });\n if (result.success) {\n const afterUpdateEvent = new AuditLogAfterUpdateEvent({\n original: original,\n auditLog: auditLog,\n context\n });\n await this.eventPublisher.publish(afterUpdateEvent);\n return result.data;\n }\n throw result.error;\n }\n\n public async getAuditLog(id: string): Promise<IAuditLog | null> {\n const result = await this.storage.fetch({\n id,\n tenant: this.getTenantId()\n });\n if (result.success) {\n await this.checkPermissions(result.data);\n return result.data;\n }\n throw result.error;\n }\n\n public async listAuditLogs(params: IListAuditLogsParams): Promise<IListAuditLogsResult> {\n const result = await this.storage.list({\n ...params,\n tenant: this.getTenantId()\n } as unknown as IStorageListParams);\n if (result.success) {\n return {\n items: result.data,\n meta: {\n cursor: result.meta.after || null,\n hasMoreItems: result.meta.hasMoreItems\n }\n };\n }\n throw result.error;\n }\n\n private async checkPermissions(auditLog: Pick<IAuditLog, \"action\">): Promise<void> {\n if (!auditLog.action) {\n throw new Error(\"Audit log action is not defined. Cannot check permissions.\");\n }\n const permissions = await this.getContext().security.getPermissions(\"al.*\");\n for (const permission of permissions) {\n if (permission.name === \"*\") {\n return;\n }\n if (permission.name === \"al.*\") {\n return;\n } else if (permission.name === `al.${auditLog.action}`) {\n return;\n }\n }\n\n throw new NotAuthorizedError({\n message: \"You cannot access audit logs.\"\n });\n }\n\n private getTenantId(): string {\n return this.getContext().tenancy.getCurrentTenant().id;\n }\n\n private getIdentity(): IAuditLogCreatedBy {\n const identity = this.getContext().security.getIdentity();\n return {\n id: identity.id,\n type: identity.type,\n displayName: identity.displayName || \"unknown\"\n };\n }\n}\n\nexport const createAuditLogsContextValue = (\n params: IAuditLogsContextValueParams\n): AuditLogsContextValue => {\n return new AuditLogsContextValueImpl(params);\n};\n"],"names":["AuditLogsContextValueImpl","params","payload","context","expiresAt","convertExpiresAtDaysToDate","auditLog","mdbid","Date","JSON","beforeCreateEvent","AuditLogBeforeCreateEvent","input","Object","result","afterCreateEvent","AuditLogAfterCreateEvent","original","beforeUpdateEvent","AuditLogBeforeUpdateEvent","afterUpdateEvent","AuditLogAfterUpdateEvent","id","Error","permissions","permission","NotAuthorizedError","identity","createAuditLogsContextValue"],"mappings":";;;;AA2BA,MAAMA;IAMF,YAAmBC,MAAoC,CAAE;QACrD,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,mBAAmB,GAAGA,OAAO,mBAAmB;QACrD,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,cAAc,GAAGA,OAAO,cAAc;IAC/C;IAEA,MAAa,eAAeC,OAAwB,EAAsB;QACtE,MAAMC,UAAU,IAAI,CAAC,UAAU;QAC/B,MAAMC,YAAYC,2BAA2B,IAAI,CAAC,mBAAmB;QAErE,MAAMC,WAAsB;YACxB,IAAIC;YACJ,QAAQ,IAAI,CAAC,WAAW;YACxB,WAAW,IAAI,CAAC,WAAW;YAC3B,WAAW,IAAIC;YACf,GAAGN,OAAO;YACV,SAASO,KAAK,SAAS,CAACP,QAAQ,OAAO;YACvCE;QACJ;QACA,MAAM,IAAI,CAAC,gBAAgB,CAACE;QAE5B,MAAMI,oBAAoB,IAAIC,0BAA0B;YACpD,UAAUL;YACVH;YACA,aAAYS,KAAK;gBACbC,OAAO,MAAM,CAACP,UAAUM;YAC5B;QACJ;QACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACF;QAElC,MAAMI,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YACpC,MAAMR;QACV;QACA,IAAIQ,OAAO,OAAO,EAAE;YAChB,MAAMC,mBAAmB,IAAIC,yBAAyB;gBAClD,UAAUV;gBACVH;YACJ;YACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACY;YAClC,OAAOD,OAAO,IAAI;QACtB;QACA,MAAMA,OAAO,KAAK;IACtB;IAEA,MAAa,eACTG,QAAmB,EACnBf,OAAiC,EACf;QAClB,MAAMC,UAAU,IAAI,CA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O,IAAI,CAAC,YAAY;YAC1C;QACJ;QAEJ,MAAMA,OAAO,KAAK;IACtB;IAEA,MAAc,iBAAiBR,QAAmC,EAAiB;QAC/E,IAAI,CAACA,SAAS,MAAM,EAChB,MAAM,IAAIiB,MAAM;QAEpB,MAAMC,cAAc,MAAM,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC;QACpE,KAAK,MAAMC,cAAcD,YAAa;YAClC,IAAIC,AAAoB,QAApBA,WAAW,IAAI,EACf;YAEJ,IAAIA,AAAoB,WAApBA,WAAW,IAAI,EACf;YACG,IAAIA,WAAW,IAAI,KAAK,CAAC,GAAG,EAAEnB,SAAS,MAAM,EAAE,EAClD;QAER;QAEA,MAAM,IAAIoB,mBAAmB;YACzB,SAAS;QACb;IACJ;IAEQ,cAAsB;QAC1B,OAAO,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,gBAAgB,GAAG,EAAE;IAC1D;IAEQ,cAAkC;QACtC,MAAMC,WAAW,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,WAAW;QACvD,OAAO;YACH,IAAIA,SAAS,EAAE;YACf,MAAMA,SAAS,IAAI;YACnB,aAAaA,SAAS,WAAW,IAAI;QACzC;IACJ;AACJ;AAEO,MAAMC,8BAA8B,CACvC3B,SAEO,IAAID,0BAA0BC"}
@@ -0,0 +1,6 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import type { AuditLogsContext } from "../types.js";
3
+ export interface ISetupContextOptions {
4
+ deleteLogsAfterDays: number | undefined;
5
+ }
6
+ export declare const createAuditLogsContext: (params?: ISetupContextOptions) => ContextPlugin<AuditLogsContext>;
@@ -0,0 +1,25 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { createAuditLogsContextValue } from "./AuditLogsContextValue.js";
4
+ import { AuditLogsStorage } from "../abstractions.js";
5
+ const getDeleteLogsAfterDays = (days)=>{
6
+ if (days && days > 0) return days;
7
+ return 60;
8
+ };
9
+ const createAuditLogsContext = (params)=>{
10
+ const plugin = new ContextPlugin(async (context)=>{
11
+ const storage = context.container.resolve(AuditLogsStorage);
12
+ const eventPublisher = context.container.resolve(EventPublisher);
13
+ context.auditLogs = createAuditLogsContextValue({
14
+ getContext: ()=>context,
15
+ deleteLogsAfterDays: getDeleteLogsAfterDays(params?.deleteLogsAfterDays),
16
+ storage,
17
+ eventPublisher
18
+ });
19
+ });
20
+ plugin.name = "audit-logs.createContext";
21
+ return plugin;
22
+ };
23
+ export { createAuditLogsContext };
24
+
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context/index.js","sources":["../../src/context/index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { AuditLogsContext } from \"~/types.js\";\nimport { createAuditLogsContextValue } from \"./AuditLogsContextValue.js\";\nimport { AuditLogsStorage } from \"~/abstractions.js\";\n\nexport interface ISetupContextOptions {\n deleteLogsAfterDays: number | undefined;\n}\n\nconst getDeleteLogsAfterDays = (days?: number): number => {\n if (days && days > 0) {\n return days;\n }\n /**\n * Default days to delete logs after.\n */\n return 60;\n};\n\nexport const createAuditLogsContext = (params?: ISetupContextOptions) => {\n const plugin = new ContextPlugin<AuditLogsContext>(async context => {\n const storage = context.container.resolve(AuditLogsStorage);\n\n const eventPublisher = context.container.resolve(EventPublisher);\n\n context.auditLogs = createAuditLogsContextValue({\n getContext: () => {\n return context;\n },\n deleteLogsAfterDays: getDeleteLogsAfterDays(params?.deleteLogsAfterDays),\n storage,\n eventPublisher\n });\n });\n\n plugin.name = \"audit-logs.createContext\";\n\n return plugin;\n};\n"],"names":["getDeleteLogsAfterDays","days","createAuditLogsContext","params","plugin","ContextPlugin","context","storage","AuditLogsStorage","eventPublisher","EventPublisher","createAuditLogsContextValue"],"mappings":";;;;AAUA,MAAMA,yBAAyB,CAACC;IAC5B,IAAIA,QAAQA,OAAO,GACf,OAAOA;IAKX,OAAO;AACX;AAEO,MAAMC,yBAAyB,CAACC;IACnC,MAAMC,SAAS,IAAIC,cAAgC,OAAMC;QACrD,MAAMC,UAAUD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAE1C,MAAMC,iBAAiBH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAEjDJ,QAAQ,SAAS,GAAGK,4BAA4B;YAC5C,YAAY,IACDL;YAEX,qBAAqBN,uBAAuBG,QAAQ;YACpDI;YACAE;QACJ;IACJ;IAEAL,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -0,0 +1,6 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { AuditLogAfterCreatePayload } from "./abstractions.js";
3
+ export declare class AuditLogAfterCreateEvent extends DomainEvent<AuditLogAfterCreatePayload> {
4
+ eventType: "auditLog.afterCreate";
5
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<AuditLogAfterCreatePayload>>>;
6
+ }
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { AuditLogAfterCreateHandler } from "./abstractions.js";
3
+ class AuditLogAfterCreateEvent extends DomainEvent {
4
+ getHandlerAbstraction() {
5
+ return AuditLogAfterCreateHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "auditLog.afterCreate";
9
+ }
10
+ }
11
+ export { AuditLogAfterCreateEvent };
12
+
13
+ //# sourceMappingURL=AuditLogAfterCreateEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events/AuditLogAfterCreateEvent.js","sources":["../../src/events/AuditLogAfterCreateEvent.ts"],"sourcesContent":["import { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { AuditLogAfterCreateHandler, AuditLogAfterCreatePayload } from \"./abstractions.js\";\n\nexport class AuditLogAfterCreateEvent extends DomainEvent<AuditLogAfterCreatePayload> {\n eventType = \"auditLog.afterCreate\" as const;\n\n getHandlerAbstraction() {\n return AuditLogAfterCreateHandler;\n }\n}\n"],"names":["AuditLogAfterCreateEvent","DomainEvent","AuditLogAfterCreateHandler"],"mappings":";;AAGO,MAAMA,iCAAiCC;IAG1C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB"}
@@ -0,0 +1,6 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { AuditLogAfterUpdatePayload } from "./abstractions.js";
3
+ export declare class AuditLogAfterUpdateEvent extends DomainEvent<AuditLogAfterUpdatePayload> {
4
+ eventType: "auditLog.afterUpdate";
5
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<AuditLogAfterUpdatePayload>>>;
6
+ }
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { AuditLogAfterUpdateHandler } from "./abstractions.js";
3
+ class AuditLogAfterUpdateEvent extends DomainEvent {
4
+ getHandlerAbstraction() {
5
+ return AuditLogAfterUpdateHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "auditLog.afterUpdate";
9
+ }
10
+ }
11
+ export { AuditLogAfterUpdateEvent };
12
+
13
+ //# sourceMappingURL=AuditLogAfterUpdateEvent.js.map