@webiny/api-audit-logs 5.38.0-beta.0

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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/app/app.d.ts +2 -0
  4. package/app/app.js +121 -0
  5. package/app/app.js.map +1 -0
  6. package/app/contants.d.ts +2 -0
  7. package/app/contants.js +12 -0
  8. package/app/contants.js.map +1 -0
  9. package/app/createAppModifier.d.ts +4 -0
  10. package/app/createAppModifier.js +14 -0
  11. package/app/createAppModifier.js.map +1 -0
  12. package/app/index.d.ts +4 -0
  13. package/app/index.js +43 -0
  14. package/app/index.js.map +1 -0
  15. package/app/types.d.ts +7 -0
  16. package/app/types.js +7 -0
  17. package/app/types.js.map +1 -0
  18. package/config.d.ts +12 -0
  19. package/config.js +285 -0
  20. package/config.js.map +1 -0
  21. package/index.d.ts +5 -0
  22. package/index.js +49 -0
  23. package/index.js.map +1 -0
  24. package/package.json +56 -0
  25. package/subscriptions/aco/folders.d.ts +4 -0
  26. package/subscriptions/aco/folders.js +94 -0
  27. package/subscriptions/aco/folders.js.map +1 -0
  28. package/subscriptions/aco/index.d.ts +2 -0
  29. package/subscriptions/aco/index.js +18 -0
  30. package/subscriptions/aco/index.js.map +1 -0
  31. package/subscriptions/apw/changeRequests.d.ts +4 -0
  32. package/subscriptions/apw/changeRequests.js +81 -0
  33. package/subscriptions/apw/changeRequests.js.map +1 -0
  34. package/subscriptions/apw/comments.d.ts +2 -0
  35. package/subscriptions/apw/comments.js +28 -0
  36. package/subscriptions/apw/comments.js.map +1 -0
  37. package/subscriptions/apw/contentReviews.d.ts +2 -0
  38. package/subscriptions/apw/contentReviews.js +28 -0
  39. package/subscriptions/apw/contentReviews.js.map +1 -0
  40. package/subscriptions/apw/index.d.ts +2 -0
  41. package/subscriptions/apw/index.js +26 -0
  42. package/subscriptions/apw/index.js.map +1 -0
  43. package/subscriptions/apw/workflows.d.ts +4 -0
  44. package/subscriptions/apw/workflows.js +64 -0
  45. package/subscriptions/apw/workflows.js.map +1 -0
  46. package/subscriptions/fileManager/files.d.ts +4 -0
  47. package/subscriptions/fileManager/files.js +64 -0
  48. package/subscriptions/fileManager/files.js.map +1 -0
  49. package/subscriptions/fileManager/index.d.ts +2 -0
  50. package/subscriptions/fileManager/index.js +17 -0
  51. package/subscriptions/fileManager/index.js.map +1 -0
  52. package/subscriptions/fileManager/settings.d.ts +2 -0
  53. package/subscriptions/fileManager/settings.js +32 -0
  54. package/subscriptions/fileManager/settings.js.map +1 -0
  55. package/subscriptions/formBuilder/formRevisions.d.ts +6 -0
  56. package/subscriptions/formBuilder/formRevisions.js +96 -0
  57. package/subscriptions/formBuilder/formRevisions.js.map +1 -0
  58. package/subscriptions/formBuilder/formSubmissions.d.ts +2 -0
  59. package/subscriptions/formBuilder/formSubmissions.js +28 -0
  60. package/subscriptions/formBuilder/formSubmissions.js.map +1 -0
  61. package/subscriptions/formBuilder/forms.d.ts +5 -0
  62. package/subscriptions/formBuilder/forms.js +76 -0
  63. package/subscriptions/formBuilder/forms.js.map +1 -0
  64. package/subscriptions/formBuilder/index.d.ts +2 -0
  65. package/subscriptions/formBuilder/index.js +26 -0
  66. package/subscriptions/formBuilder/index.js.map +1 -0
  67. package/subscriptions/formBuilder/settings.d.ts +2 -0
  68. package/subscriptions/formBuilder/settings.js +32 -0
  69. package/subscriptions/formBuilder/settings.js.map +1 -0
  70. package/subscriptions/headlessCms/entries.d.ts +8 -0
  71. package/subscriptions/headlessCms/entries.js +157 -0
  72. package/subscriptions/headlessCms/entries.js.map +1 -0
  73. package/subscriptions/headlessCms/groups.d.ts +4 -0
  74. package/subscriptions/headlessCms/groups.js +64 -0
  75. package/subscriptions/headlessCms/groups.js.map +1 -0
  76. package/subscriptions/headlessCms/index.d.ts +2 -0
  77. package/subscriptions/headlessCms/index.js +30 -0
  78. package/subscriptions/headlessCms/index.js.map +1 -0
  79. package/subscriptions/headlessCms/models.d.ts +4 -0
  80. package/subscriptions/headlessCms/models.js +64 -0
  81. package/subscriptions/headlessCms/models.js.map +1 -0
  82. package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +1 -0
  83. package/subscriptions/headlessCms/utils/isSearchModelEntry.js +13 -0
  84. package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +1 -0
  85. package/subscriptions/i18n/index.d.ts +2 -0
  86. package/subscriptions/i18n/index.js +15 -0
  87. package/subscriptions/i18n/index.js.map +1 -0
  88. package/subscriptions/i18n/locales.d.ts +4 -0
  89. package/subscriptions/i18n/locales.js +64 -0
  90. package/subscriptions/i18n/locales.js.map +1 -0
  91. package/subscriptions/index.d.ts +2 -0
  92. package/subscriptions/index.js +29 -0
  93. package/subscriptions/index.js.map +1 -0
  94. package/subscriptions/mailer/index.d.ts +2 -0
  95. package/subscriptions/mailer/index.js +13 -0
  96. package/subscriptions/mailer/index.js.map +1 -0
  97. package/subscriptions/mailer/settings.d.ts +2 -0
  98. package/subscriptions/mailer/settings.js +32 -0
  99. package/subscriptions/mailer/settings.js.map +1 -0
  100. package/subscriptions/pageBuilder/blockCategories.d.ts +4 -0
  101. package/subscriptions/pageBuilder/blockCategories.js +64 -0
  102. package/subscriptions/pageBuilder/blockCategories.js.map +1 -0
  103. package/subscriptions/pageBuilder/blocks.d.ts +6 -0
  104. package/subscriptions/pageBuilder/blocks.js +96 -0
  105. package/subscriptions/pageBuilder/blocks.js.map +1 -0
  106. package/subscriptions/pageBuilder/categories.d.ts +4 -0
  107. package/subscriptions/pageBuilder/categories.js +64 -0
  108. package/subscriptions/pageBuilder/categories.js.map +1 -0
  109. package/subscriptions/pageBuilder/index.d.ts +2 -0
  110. package/subscriptions/pageBuilder/index.js +51 -0
  111. package/subscriptions/pageBuilder/index.js.map +1 -0
  112. package/subscriptions/pageBuilder/menus.d.ts +4 -0
  113. package/subscriptions/pageBuilder/menus.js +64 -0
  114. package/subscriptions/pageBuilder/menus.js.map +1 -0
  115. package/subscriptions/pageBuilder/pageElements.d.ts +4 -0
  116. package/subscriptions/pageBuilder/pageElements.js +64 -0
  117. package/subscriptions/pageBuilder/pageElements.js.map +1 -0
  118. package/subscriptions/pageBuilder/pageRevisions.d.ts +6 -0
  119. package/subscriptions/pageBuilder/pageRevisions.js +101 -0
  120. package/subscriptions/pageBuilder/pageRevisions.js.map +1 -0
  121. package/subscriptions/pageBuilder/pages.d.ts +4 -0
  122. package/subscriptions/pageBuilder/pages.js +60 -0
  123. package/subscriptions/pageBuilder/pages.js.map +1 -0
  124. package/subscriptions/pageBuilder/settings.d.ts +2 -0
  125. package/subscriptions/pageBuilder/settings.js +32 -0
  126. package/subscriptions/pageBuilder/settings.js.map +1 -0
  127. package/subscriptions/pageBuilder/templates.d.ts +6 -0
  128. package/subscriptions/pageBuilder/templates.js +96 -0
  129. package/subscriptions/pageBuilder/templates.js.map +1 -0
  130. package/subscriptions/security/apiKeys.d.ts +4 -0
  131. package/subscriptions/security/apiKeys.js +85 -0
  132. package/subscriptions/security/apiKeys.js.map +1 -0
  133. package/subscriptions/security/index.d.ts +2 -0
  134. package/subscriptions/security/index.js +27 -0
  135. package/subscriptions/security/index.js.map +1 -0
  136. package/subscriptions/security/roles.d.ts +4 -0
  137. package/subscriptions/security/roles.js +64 -0
  138. package/subscriptions/security/roles.js.map +1 -0
  139. package/subscriptions/security/teams.d.ts +4 -0
  140. package/subscriptions/security/teams.js +64 -0
  141. package/subscriptions/security/teams.js.map +1 -0
  142. package/subscriptions/security/users.d.ts +4 -0
  143. package/subscriptions/security/users.js +64 -0
  144. package/subscriptions/security/users.js.map +1 -0
  145. package/types.d.ts +58 -0
  146. package/types.js +18 -0
  147. package/types.js.map +1 -0
  148. package/utils/compressor.d.ts +11 -0
  149. package/utils/compressor.js +110 -0
  150. package/utils/compressor.js.map +1 -0
  151. package/utils/getAuditConfig.d.ts +33 -0
  152. package/utils/getAuditConfig.js +138 -0
  153. package/utils/getAuditConfig.js.map +1 -0
  154. package/utils/getAuditObject.d.ts +2 -0
  155. package/utils/getAuditObject.js +25 -0
  156. package/utils/getAuditObject.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onFileAfterCreateHook","context","fileManager","onFileAfterCreate","subscribe","file","createAuditLog","getAuditConfig","AUDIT","FILE_MANAGER","FILE","CREATE","id","error","WebinyError","from","message","code","exports","onFileAfterUpdateHook","onFileAfterUpdate","original","UPDATE","before","after","onFileAfterDeleteHook","onFileAfterDelete","DELETE"],"sources":["files.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onFileAfterCreateHook = (context: AuditLogsContext) => {\n context.fileManager.onFileAfterCreate.subscribe(async ({ file }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FILE_MANAGER.FILE.CREATE);\n\n await createAuditLog(\"File created\", file, file.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_FILE_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onFileAfterUpdateHook = (context: AuditLogsContext) => {\n context.fileManager.onFileAfterUpdate.subscribe(async ({ file, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FILE_MANAGER.FILE.UPDATE);\n\n await createAuditLog(\n \"File updated\",\n { before: original, after: file },\n file.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_FILE_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onFileAfterDeleteHook = (context: AuditLogsContext) => {\n context.fileManager.onFileAfterDelete.subscribe(async ({ file }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FILE_MANAGER.FILE.DELETE);\n\n await createAuditLog(\"File deleted\", file, file.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_FILE_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,WAAW,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,IAAI,CAACC,MAAM,CAAC;MAErE,MAAML,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA;AAEK,MAAMmB,qBAAqB,GAAIlB,OAAyB,IAAK;EAChEA,OAAO,CAACC,WAAW,CAACkB,iBAAiB,CAAChB,SAAS,CAAC,OAAO;IAAEC,IAAI;IAAEgB;EAAS,CAAC,KAAK;IAC1E,IAAI;MACA,MAAMf,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,IAAI,CAACY,MAAM,CAAC;MAErE,MAAMhB,cAAc,CAChB,cAAc,EACd;QAAEiB,MAAM,EAAEF,QAAQ;QAAEG,KAAK,EAAEnB;MAAK,CAAC,EACjCA,IAAI,CAACO,EAAE,EACPX,OACJ,CAAC;IACL,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMM,qBAAqB,GAAIxB,OAAyB,IAAK;EAChEA,OAAO,CAACC,WAAW,CAACwB,iBAAiB,CAACtB,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,IAAI,CAACiB,MAAM,CAAC;MAErE,MAAMrB,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAO,qBAAA,GAAAA,qBAAA"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const createFileManagerHooks: (context: AuditLogsContext) => void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFileManagerHooks = void 0;
7
+ var _files = require("./files");
8
+ var _settings = require("./settings");
9
+ const createFileManagerHooks = context => {
10
+ (0, _files.onFileAfterCreateHook)(context);
11
+ (0, _files.onFileAfterUpdateHook)(context);
12
+ (0, _files.onFileAfterDeleteHook)(context);
13
+ (0, _settings.onSettingsAfterUpdateHook)(context);
14
+ };
15
+ exports.createFileManagerHooks = createFileManagerHooks;
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_files","require","_settings","createFileManagerHooks","context","onFileAfterCreateHook","onFileAfterUpdateHook","onFileAfterDeleteHook","onSettingsAfterUpdateHook","exports"],"sources":["index.ts"],"sourcesContent":["import { onFileAfterCreateHook, onFileAfterUpdateHook, onFileAfterDeleteHook } from \"./files\";\nimport { onSettingsAfterUpdateHook } from \"./settings\";\n\nimport { AuditLogsContext } from \"~/types\";\n\nexport const createFileManagerHooks = (context: AuditLogsContext) => {\n onFileAfterCreateHook(context);\n onFileAfterUpdateHook(context);\n onFileAfterDeleteHook(context);\n onSettingsAfterUpdateHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAIO,MAAME,sBAAsB,GAAIC,OAAyB,IAAK;EACjE,IAAAC,4BAAqB,EAACD,OAAO,CAAC;EAC9B,IAAAE,4BAAqB,EAACF,OAAO,CAAC;EAC9B,IAAAG,4BAAqB,EAACH,OAAO,CAAC;EAC9B,IAAAI,mCAAyB,EAACJ,OAAO,CAAC;AACtC,CAAC;AAACK,OAAA,CAAAN,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onSettingsAfterUpdateHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onSettingsAfterUpdateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onSettingsAfterUpdateHook = context => {
12
+ context.fileManager.onSettingsAfterUpdate.subscribe(async ({
13
+ settings,
14
+ original
15
+ }) => {
16
+ try {
17
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FILE_MANAGER.SETTINGS.UPDATE);
18
+ await createAuditLog("Settings updated", {
19
+ before: original,
20
+ after: settings
21
+ }, "-", context);
22
+ } catch (error) {
23
+ throw _error.default.from(error, {
24
+ message: "Error while executing onSettingsAfterUpdateHook hook",
25
+ code: "AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK"
26
+ });
27
+ }
28
+ });
29
+ };
30
+ exports.onSettingsAfterUpdateHook = onSettingsAfterUpdateHook;
31
+
32
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onSettingsAfterUpdateHook","context","fileManager","onSettingsAfterUpdate","subscribe","settings","original","createAuditLog","getAuditConfig","AUDIT","FILE_MANAGER","SETTINGS","UPDATE","before","after","error","WebinyError","from","message","code","exports"],"sources":["settings.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onSettingsAfterUpdateHook = (context: AuditLogsContext) => {\n context.fileManager.onSettingsAfterUpdate.subscribe(async ({ settings, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FILE_MANAGER.SETTINGS.UPDATE);\n\n await createAuditLog(\n \"Settings updated\",\n { before: original, after: settings },\n \"-\",\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onSettingsAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAIC,OAAyB,IAAK;EACpEA,OAAO,CAACC,WAAW,CAACC,qBAAqB,CAACC,SAAS,CAAC,OAAO;IAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IAClF,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,QAAQ,CAACC,MAAM,CAAC;MAEzE,MAAML,cAAc,CAChB,kBAAkB,EAClB;QAAEM,MAAM,EAAEP,QAAQ;QAAEQ,KAAK,EAAET;MAAS,CAAC,EACrC,GAAG,EACHJ,OACJ,CAAC;IACL,CAAC,CAAC,OAAOc,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,sDAAsD;QAC/DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAApB,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1,6 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onFormRevisionAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onFormRevisionAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onFormRevisionAfterDeleteHook: (context: AuditLogsContext) => void;
5
+ export declare const onFormRevisionAfterPublishHook: (context: AuditLogsContext) => void;
6
+ export declare const onFormRevisionAfterUnpublishHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onFormRevisionAfterUpdateHook = exports.onFormRevisionAfterUnpublishHook = exports.onFormRevisionAfterPublishHook = exports.onFormRevisionAfterDeleteHook = exports.onFormRevisionAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onFormRevisionAfterCreateHook = context => {
12
+ context.formBuilder.onFormRevisionAfterCreate.subscribe(async ({
13
+ form
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_REVISION.CREATE);
17
+ await createAuditLog("Form revision created", form, form.id, context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onFormRevisionAfterCreateHook hook",
21
+ code: "AUDIT_LOGS_AFTER_FORM_REVISION_CREATE_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onFormRevisionAfterCreateHook = onFormRevisionAfterCreateHook;
27
+ const onFormRevisionAfterUpdateHook = context => {
28
+ context.formBuilder.onFormAfterUpdate.subscribe(async ({
29
+ form,
30
+ original
31
+ }) => {
32
+ try {
33
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_REVISION.UPDATE);
34
+ await createAuditLog("Form revision updated", {
35
+ before: original,
36
+ after: form
37
+ }, form.id, context);
38
+ } catch (error) {
39
+ throw _error.default.from(error, {
40
+ message: "Error while executing onFormRevisionAfterUpdateHook hook",
41
+ code: "AUDIT_LOGS_AFTER_FORM_REVISION_UPDATE_HOOK"
42
+ });
43
+ }
44
+ });
45
+ };
46
+ exports.onFormRevisionAfterUpdateHook = onFormRevisionAfterUpdateHook;
47
+ const onFormRevisionAfterDeleteHook = context => {
48
+ context.formBuilder.onFormRevisionAfterDelete.subscribe(async ({
49
+ form
50
+ }) => {
51
+ try {
52
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_REVISION.DELETE);
53
+ await createAuditLog("Form revision deleted", form, form.id, context);
54
+ } catch (error) {
55
+ throw _error.default.from(error, {
56
+ message: "Error while executing onFormRevisionAfterDeleteHook hook",
57
+ code: "AUDIT_LOGS_AFTER_FORM_REVISION_DELETE_HOOK"
58
+ });
59
+ }
60
+ });
61
+ };
62
+ exports.onFormRevisionAfterDeleteHook = onFormRevisionAfterDeleteHook;
63
+ const onFormRevisionAfterPublishHook = context => {
64
+ context.formBuilder.onFormAfterPublish.subscribe(async ({
65
+ form
66
+ }) => {
67
+ try {
68
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_REVISION.PUBLISH);
69
+ await createAuditLog("Form revision published", form, form.id, context);
70
+ } catch (error) {
71
+ throw _error.default.from(error, {
72
+ message: "Error while executing onFormRevisionAfterPublishHook hook",
73
+ code: "AUDIT_LOGS_AFTER_FORM_REVISION_PUBLISH_HOOK"
74
+ });
75
+ }
76
+ });
77
+ };
78
+ exports.onFormRevisionAfterPublishHook = onFormRevisionAfterPublishHook;
79
+ const onFormRevisionAfterUnpublishHook = context => {
80
+ context.formBuilder.onFormAfterUnpublish.subscribe(async ({
81
+ form
82
+ }) => {
83
+ try {
84
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_REVISION.UNPUBLISH);
85
+ await createAuditLog("Form revision unpublished", form, form.id, context);
86
+ } catch (error) {
87
+ throw _error.default.from(error, {
88
+ message: "Error while executing onFormRevisionAfterUnpublishHook hook",
89
+ code: "AUDIT_LOGS_AFTER_FORM_REVISION_UNPUBLISH_HOOK"
90
+ });
91
+ }
92
+ });
93
+ };
94
+ exports.onFormRevisionAfterUnpublishHook = onFormRevisionAfterUnpublishHook;
95
+
96
+ //# sourceMappingURL=formRevisions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onFormRevisionAfterCreateHook","context","formBuilder","onFormRevisionAfterCreate","subscribe","form","createAuditLog","getAuditConfig","AUDIT","FORM_BUILDER","FORM_REVISION","CREATE","id","error","WebinyError","from","message","code","exports","onFormRevisionAfterUpdateHook","onFormAfterUpdate","original","UPDATE","before","after","onFormRevisionAfterDeleteHook","onFormRevisionAfterDelete","DELETE","onFormRevisionAfterPublishHook","onFormAfterPublish","PUBLISH","onFormRevisionAfterUnpublishHook","onFormAfterUnpublish","UNPUBLISH"],"sources":["formRevisions.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onFormRevisionAfterCreateHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormRevisionAfterCreate.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_REVISION.CREATE);\n\n await createAuditLog(\"Form revision created\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormRevisionAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_REVISION_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onFormRevisionAfterUpdateHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormAfterUpdate.subscribe(async ({ form, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_REVISION.UPDATE);\n\n await createAuditLog(\n \"Form revision updated\",\n { before: original, after: form },\n form.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormRevisionAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_REVISION_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onFormRevisionAfterDeleteHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormRevisionAfterDelete.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_REVISION.DELETE);\n\n await createAuditLog(\"Form revision deleted\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormRevisionAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_REVISION_DELETE_HOOK\"\n });\n }\n });\n};\n\nexport const onFormRevisionAfterPublishHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormAfterPublish.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_REVISION.PUBLISH);\n\n await createAuditLog(\"Form revision published\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormRevisionAfterPublishHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_REVISION_PUBLISH_HOOK\"\n });\n }\n });\n};\n\nexport const onFormRevisionAfterUnpublishHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormAfterUnpublish.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_REVISION.UNPUBLISH);\n\n await createAuditLog(\"Form revision unpublished\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormRevisionAfterUnpublishHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_REVISION_UNPUBLISH_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,6BAA6B,GAAIC,OAAyB,IAAK;EACxEA,OAAO,CAACC,WAAW,CAACC,yBAAyB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IACxE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,aAAa,CAACC,MAAM,CAAC;MAE9E,MAAML,cAAc,CAAC,uBAAuB,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IACzE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,0DAA0D;QACnEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAlB,6BAAA,GAAAA,6BAAA;AAEK,MAAMmB,6BAA6B,GAAIlB,OAAyB,IAAK;EAC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B,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IACjE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,aAAa,CAACoB,OAAO,CAAC;MAE/E,MAAMxB,cAAc,CAAC,yBAAyB,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAC3E,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,2DAA2D;QACpEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAU,8BAAA,GAAAA,8BAAA;AAEK,MAAMG,gCAAgC,GAAI9B,OAAyB,IAAK;EAC3EA,OAAO,CAACC,WAAW,CAAC8B,oBAAoB,CAAC5B,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IACnE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,aAAa,CAACuB,SAAS,CAAC;MAEjF,MAAM3B,cAAc,CAAC,2BAA2B,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAC7E,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,6DAA6D;QACtEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAa,gCAAA,GAAAA,gCAAA"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onFormSubmissionsAfterExportHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onFormSubmissionsAfterExportHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onFormSubmissionsAfterExportHook = context => {
12
+ context.formBuilder.onFormSubmissionsAfterExport.subscribe(async ({
13
+ result
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM_SUBMISSION.EXPORT);
17
+ await createAuditLog("Form submissions exported", result, "-", context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onFormSubmissionsAfterExportHook hook",
21
+ code: "AUDIT_LOGS_AFTER_FORM_SUBMISSION_EXPORT_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onFormSubmissionsAfterExportHook = onFormSubmissionsAfterExportHook;
27
+
28
+ //# sourceMappingURL=formSubmissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onFormSubmissionsAfterExportHook","context","formBuilder","onFormSubmissionsAfterExport","subscribe","result","createAuditLog","getAuditConfig","AUDIT","FORM_BUILDER","FORM_SUBMISSION","EXPORT","error","WebinyError","from","message","code","exports"],"sources":["formSubmissions.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onFormSubmissionsAfterExportHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormSubmissionsAfterExport.subscribe(async ({ result }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM_SUBMISSION.EXPORT);\n\n await createAuditLog(\"Form submissions exported\", result, \"-\", context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormSubmissionsAfterExportHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_SUBMISSION_EXPORT_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,gCAAgC,GAAIC,OAAyB,IAAK;EAC3EA,OAAO,CAACC,WAAW,CAACC,4BAA4B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAO,CAAC,KAAK;IAC7E,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,eAAe,CAACC,MAAM,CAAC;MAEhF,MAAML,cAAc,CAAC,2BAA2B,EAAED,MAAM,EAAE,GAAG,EAAEJ,OAAO,CAAC;IAC3E,CAAC,CAAC,OAAOW,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,6DAA6D;QACtEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAjB,gCAAA,GAAAA,gCAAA"}
@@ -0,0 +1,5 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onFormAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onFormAfterDeleteHook: (context: AuditLogsContext) => void;
4
+ export declare const onFormsAfterExportHook: (context: AuditLogsContext) => void;
5
+ export declare const onFormsAfterImportHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onFormsAfterImportHook = exports.onFormsAfterExportHook = exports.onFormAfterDeleteHook = exports.onFormAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onFormAfterCreateHook = context => {
12
+ context.formBuilder.onFormAfterCreate.subscribe(async ({
13
+ form
14
+ }) => {
15
+ try {
16
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM.CREATE);
17
+ await createAuditLog("Form created", form, form.id, context);
18
+ } catch (error) {
19
+ throw _error.default.from(error, {
20
+ message: "Error while executing onFormAfterCreateHook hook",
21
+ code: "AUDIT_LOGS_AFTER_FORM_CREATE_HOOK"
22
+ });
23
+ }
24
+ });
25
+ };
26
+ exports.onFormAfterCreateHook = onFormAfterCreateHook;
27
+ const onFormAfterDeleteHook = context => {
28
+ context.formBuilder.onFormAfterDelete.subscribe(async ({
29
+ form
30
+ }) => {
31
+ try {
32
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM.DELETE);
33
+ await createAuditLog("Form deleted", form, form.id, context);
34
+ } catch (error) {
35
+ throw _error.default.from(error, {
36
+ message: "Error while executing onFormAfterDeleteHook hook",
37
+ code: "AUDIT_LOGS_AFTER_FORM_DELETE_HOOK"
38
+ });
39
+ }
40
+ });
41
+ };
42
+ exports.onFormAfterDeleteHook = onFormAfterDeleteHook;
43
+ const onFormsAfterExportHook = context => {
44
+ context.formBuilder.forms.onFormsAfterExport.subscribe(async ({
45
+ params
46
+ }) => {
47
+ try {
48
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM.EXPORT);
49
+ await createAuditLog("Forms exported", params, "-", context);
50
+ } catch (error) {
51
+ throw _error.default.from(error, {
52
+ message: "Error while executing onFormsAfterExportHook hook",
53
+ code: "AUDIT_LOGS_FORMS_EXPORT_HOOK"
54
+ });
55
+ }
56
+ });
57
+ };
58
+ exports.onFormsAfterExportHook = onFormsAfterExportHook;
59
+ const onFormsAfterImportHook = context => {
60
+ context.formBuilder.forms.onFormsAfterImport.subscribe(async ({
61
+ params
62
+ }) => {
63
+ try {
64
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.FORM.IMPORT);
65
+ await createAuditLog("Forms imported", params, "-", context);
66
+ } catch (error) {
67
+ throw _error.default.from(error, {
68
+ message: "Error while executing onFormsAfterImportHook hook",
69
+ code: "AUDIT_LOGS_FORMS_IMPORT_HOOK"
70
+ });
71
+ }
72
+ });
73
+ };
74
+ exports.onFormsAfterImportHook = onFormsAfterImportHook;
75
+
76
+ //# sourceMappingURL=forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onFormAfterCreateHook","context","formBuilder","onFormAfterCreate","subscribe","form","createAuditLog","getAuditConfig","AUDIT","FORM_BUILDER","FORM","CREATE","id","error","WebinyError","from","message","code","exports","onFormAfterDeleteHook","onFormAfterDelete","DELETE","onFormsAfterExportHook","forms","onFormsAfterExport","params","EXPORT","onFormsAfterImportHook","onFormsAfterImport","IMPORT"],"sources":["forms.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onFormAfterCreateHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormAfterCreate.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM.CREATE);\n\n await createAuditLog(\"Form created\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onFormAfterDeleteHook = (context: AuditLogsContext) => {\n context.formBuilder.onFormAfterDelete.subscribe(async ({ form }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM.DELETE);\n\n await createAuditLog(\"Form deleted\", form, form.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_FORM_DELETE_HOOK\"\n });\n }\n });\n};\n\nexport const onFormsAfterExportHook = (context: AuditLogsContext) => {\n context.formBuilder.forms.onFormsAfterExport.subscribe(async ({ params }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM.EXPORT);\n\n await createAuditLog(\"Forms exported\", params, \"-\", context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormsAfterExportHook hook\",\n code: \"AUDIT_LOGS_FORMS_EXPORT_HOOK\"\n });\n }\n });\n};\n\nexport const onFormsAfterImportHook = (context: AuditLogsContext) => {\n context.formBuilder.forms.onFormsAfterImport.subscribe(async ({ params }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.FORM.IMPORT);\n\n await createAuditLog(\"Forms imported\", params, \"-\", context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFormsAfterImportHook hook\",\n code: \"AUDIT_LOGS_FORMS_IMPORT_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,OAAyB,IAAK;EAChEA,OAAO,CAACC,WAAW,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChE,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,IAAI,CAACC,MAAM,CAAC;MAErE,MAAML,cAAc,CAAC,cAAc,EAAED,IAAI,EAAEA,IAAI,CAACO,EAAE,EAAEX,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,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AAACC,OAAA,CAAAI,sBAAA,GAAAA,sBAAA;AAEK,MAAMK,sBAAsB,GAAI1B,OAAyB,IAAK;EACjEA,OAAO,CAACC,WAAW,CAACqB,KAAK,CAACK,kBAAkB,CAACxB,SAAS,CAAC,OAAO;IAAEqB;EAAO,CAAC,KAAK;IACzE,IAAI;MACA,MAAMnB,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,IAAI,CAACmB,MAAM,CAAC;MAErE,MAAMvB,cAAc,CAAC,gBAAgB,EAAEmB,MAAM,EAAE,GAAG,EAAExB,OAAO,CAAC;IAChE,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,mDAAmD;QAC5DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAS,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const createFormBuilderHooks: (context: AuditLogsContext) => void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFormBuilderHooks = void 0;
7
+ var _forms = require("./forms");
8
+ var _formRevisions = require("./formRevisions");
9
+ var _formSubmissions = require("./formSubmissions");
10
+ var _settings = require("./settings");
11
+ const createFormBuilderHooks = context => {
12
+ (0, _forms.onFormAfterCreateHook)(context);
13
+ (0, _forms.onFormAfterDeleteHook)(context);
14
+ (0, _forms.onFormsAfterExportHook)(context);
15
+ (0, _forms.onFormsAfterImportHook)(context);
16
+ (0, _formRevisions.onFormRevisionAfterCreateHook)(context);
17
+ (0, _formRevisions.onFormRevisionAfterUpdateHook)(context);
18
+ (0, _formRevisions.onFormRevisionAfterDeleteHook)(context);
19
+ (0, _formRevisions.onFormRevisionAfterPublishHook)(context);
20
+ (0, _formRevisions.onFormRevisionAfterUnpublishHook)(context);
21
+ (0, _formSubmissions.onFormSubmissionsAfterExportHook)(context);
22
+ (0, _settings.onSettingsAfterUpdateHook)(context);
23
+ };
24
+ exports.createFormBuilderHooks = createFormBuilderHooks;
25
+
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_forms","require","_formRevisions","_formSubmissions","_settings","createFormBuilderHooks","context","onFormAfterCreateHook","onFormAfterDeleteHook","onFormsAfterExportHook","onFormsAfterImportHook","onFormRevisionAfterCreateHook","onFormRevisionAfterUpdateHook","onFormRevisionAfterDeleteHook","onFormRevisionAfterPublishHook","onFormRevisionAfterUnpublishHook","onFormSubmissionsAfterExportHook","onSettingsAfterUpdateHook","exports"],"sources":["index.ts"],"sourcesContent":["import {\n onFormAfterCreateHook,\n onFormAfterDeleteHook,\n onFormsAfterExportHook,\n onFormsAfterImportHook\n} from \"./forms\";\nimport {\n onFormRevisionAfterCreateHook,\n onFormRevisionAfterUpdateHook,\n onFormRevisionAfterDeleteHook,\n onFormRevisionAfterPublishHook,\n onFormRevisionAfterUnpublishHook\n} from \"./formRevisions\";\nimport { onFormSubmissionsAfterExportHook } from \"./formSubmissions\";\nimport { onSettingsAfterUpdateHook } from \"./settings\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const createFormBuilderHooks = (context: AuditLogsContext) => {\n onFormAfterCreateHook(context);\n onFormAfterDeleteHook(context);\n onFormsAfterExportHook(context);\n onFormsAfterImportHook(context);\n onFormRevisionAfterCreateHook(context);\n onFormRevisionAfterUpdateHook(context);\n onFormRevisionAfterDeleteHook(context);\n onFormRevisionAfterPublishHook(context);\n onFormRevisionAfterUnpublishHook(context);\n onFormSubmissionsAfterExportHook(context);\n onSettingsAfterUpdateHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,cAAA,GAAAD,OAAA;AAOA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAGO,MAAMI,sBAAsB,GAAIC,OAAyB,IAAK;EACjE,IAAAC,4BAAqB,EAACD,OAAO,CAAC;EAC9B,IAAAE,4BAAqB,EAACF,OAAO,CAAC;EAC9B,IAAAG,6BAAsB,EAACH,OAAO,CAAC;EAC/B,IAAAI,6BAAsB,EAACJ,OAAO,CAAC;EAC/B,IAAAK,4CAA6B,EAACL,OAAO,CAAC;EACtC,IAAAM,4CAA6B,EAACN,OAAO,CAAC;EACtC,IAAAO,4CAA6B,EAACP,OAAO,CAAC;EACtC,IAAAQ,6CAA8B,EAACR,OAAO,CAAC;EACvC,IAAAS,+CAAgC,EAACT,OAAO,CAAC;EACzC,IAAAU,iDAAgC,EAACV,OAAO,CAAC;EACzC,IAAAW,mCAAyB,EAACX,OAAO,CAAC;AACtC,CAAC;AAACY,OAAA,CAAAb,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,2 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onSettingsAfterUpdateHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onSettingsAfterUpdateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ const onSettingsAfterUpdateHook = context => {
12
+ context.formBuilder.onSettingsAfterUpdate.subscribe(async ({
13
+ settings,
14
+ original
15
+ }) => {
16
+ try {
17
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.FORM_BUILDER.SETTINGS.UPDATE);
18
+ await createAuditLog("Settings updated", {
19
+ before: original,
20
+ after: settings
21
+ }, "-", context);
22
+ } catch (error) {
23
+ throw _error.default.from(error, {
24
+ message: "Error while executing onSettingsAfterUpdateHook hook",
25
+ code: "AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK"
26
+ });
27
+ }
28
+ });
29
+ };
30
+ exports.onSettingsAfterUpdateHook = onSettingsAfterUpdateHook;
31
+
32
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onSettingsAfterUpdateHook","context","formBuilder","onSettingsAfterUpdate","subscribe","settings","original","createAuditLog","getAuditConfig","AUDIT","FORM_BUILDER","SETTINGS","UPDATE","before","after","error","WebinyError","from","message","code","exports"],"sources":["settings.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onSettingsAfterUpdateHook = (context: AuditLogsContext) => {\n context.formBuilder.onSettingsAfterUpdate.subscribe(async ({ settings, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.FORM_BUILDER.SETTINGS.UPDATE);\n\n await createAuditLog(\n \"Settings updated\",\n { before: original, after: settings },\n \"-\",\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onSettingsAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_SETTINGS_UPDATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAIC,OAAyB,IAAK;EACpEA,OAAO,CAACC,WAAW,CAACC,qBAAqB,CAACC,SAAS,CAAC,OAAO;IAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IAClF,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,QAAQ,CAACC,MAAM,CAAC;MAEzE,MAAML,cAAc,CAChB,kBAAkB,EAClB;QAAEM,MAAM,EAAEP,QAAQ;QAAEQ,KAAK,EAAET;MAAS,CAAC,EACrC,GAAG,EACHJ,OACJ,CAAC;IACL,CAAC,CAAC,OAAOc,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,sDAAsD;QAC/DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAApB,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1,8 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onEntryAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onEntryAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onEntryAfterDeleteHook: (context: AuditLogsContext) => void;
5
+ export declare const onEntryRevisionAfterCreateHook: (context: AuditLogsContext) => void;
6
+ export declare const onEntryRevisionAfterDeleteHook: (context: AuditLogsContext) => void;
7
+ export declare const onEntryAfterPublishHook: (context: AuditLogsContext) => void;
8
+ export declare const onEntryAfterUnpublishHook: (context: AuditLogsContext) => void;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.onEntryRevisionAfterDeleteHook = exports.onEntryRevisionAfterCreateHook = exports.onEntryAfterUpdateHook = exports.onEntryAfterUnpublishHook = exports.onEntryAfterPublishHook = exports.onEntryAfterDeleteHook = exports.onEntryAfterCreateHook = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _config = require("../../config");
10
+ var _getAuditConfig = require("../../utils/getAuditConfig");
11
+ var _isSearchModelEntry = require("./utils/isSearchModelEntry");
12
+ const onEntryAfterCreateHook = context => {
13
+ context.cms.onEntryAfterCreate.subscribe(async ({
14
+ model,
15
+ entry
16
+ }) => {
17
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
18
+ return;
19
+ }
20
+ try {
21
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY.CREATE);
22
+ await createAuditLog("Entry created", entry, entry.entryId, context);
23
+ } catch (error) {
24
+ throw _error.default.from(error, {
25
+ message: "Error while executing onEntryAfterCreateHook hook",
26
+ code: "AUDIT_LOGS_AFTER_ENTRY_CREATE_HOOK"
27
+ });
28
+ }
29
+ });
30
+ };
31
+ exports.onEntryAfterCreateHook = onEntryAfterCreateHook;
32
+ const onEntryAfterUpdateHook = context => {
33
+ context.cms.onEntryAfterUpdate.subscribe(async ({
34
+ model,
35
+ entry,
36
+ original
37
+ }) => {
38
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
39
+ return;
40
+ }
41
+ try {
42
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.UPDATE);
43
+ await createAuditLog("Entry revision updated", {
44
+ before: original,
45
+ after: entry
46
+ }, entry.id, context);
47
+ } catch (error) {
48
+ throw _error.default.from(error, {
49
+ message: "Error while executing onEntryRevisionAfterUpdateHook hook",
50
+ code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_UPDATE_HOOK"
51
+ });
52
+ }
53
+ });
54
+ };
55
+ exports.onEntryAfterUpdateHook = onEntryAfterUpdateHook;
56
+ const onEntryAfterDeleteHook = context => {
57
+ context.cms.onEntryAfterDelete.subscribe(async ({
58
+ model,
59
+ entry
60
+ }) => {
61
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
62
+ return;
63
+ }
64
+ try {
65
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY.DELETE);
66
+ await createAuditLog("Entry deleted", entry, entry.entryId, context);
67
+ } catch (error) {
68
+ throw _error.default.from(error, {
69
+ message: "Error while executing onEntryAfterDeleteHook hook",
70
+ code: "AUDIT_LOGS_AFTER_ENTRY_DELETE_HOOK"
71
+ });
72
+ }
73
+ });
74
+ };
75
+ exports.onEntryAfterDeleteHook = onEntryAfterDeleteHook;
76
+ const onEntryRevisionAfterCreateHook = context => {
77
+ context.cms.onEntryRevisionAfterCreate.subscribe(async ({
78
+ model,
79
+ entry
80
+ }) => {
81
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
82
+ return;
83
+ }
84
+ try {
85
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.CREATE);
86
+ await createAuditLog("Entry revision created", entry, entry.id, context);
87
+ } catch (error) {
88
+ throw _error.default.from(error, {
89
+ message: "Error while executing onEntryRevisionAfterCreateHook hook",
90
+ code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_CREATE_HOOK"
91
+ });
92
+ }
93
+ });
94
+ };
95
+ exports.onEntryRevisionAfterCreateHook = onEntryRevisionAfterCreateHook;
96
+ const onEntryRevisionAfterDeleteHook = context => {
97
+ context.cms.onEntryRevisionAfterDelete.subscribe(async ({
98
+ model,
99
+ entry
100
+ }) => {
101
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
102
+ return;
103
+ }
104
+ try {
105
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.DELETE);
106
+ await createAuditLog("Entry revision deleted", entry, entry.id, context);
107
+ } catch (error) {
108
+ throw _error.default.from(error, {
109
+ message: "Error while executing onEntryRevisionAfterDeleteHook hook",
110
+ code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_DELETE_HOOK"
111
+ });
112
+ }
113
+ });
114
+ };
115
+ exports.onEntryRevisionAfterDeleteHook = onEntryRevisionAfterDeleteHook;
116
+ const onEntryAfterPublishHook = context => {
117
+ context.cms.onEntryAfterPublish.subscribe(async ({
118
+ model,
119
+ entry
120
+ }) => {
121
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
122
+ return;
123
+ }
124
+ try {
125
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.PUBLISH);
126
+ await createAuditLog("Entry revision published", entry, entry.id, context);
127
+ } catch (error) {
128
+ throw _error.default.from(error, {
129
+ message: "Error while executing onEntryRevisionAfterPublishHook hook",
130
+ code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_PUBLISH_HOOK"
131
+ });
132
+ }
133
+ });
134
+ };
135
+ exports.onEntryAfterPublishHook = onEntryAfterPublishHook;
136
+ const onEntryAfterUnpublishHook = context => {
137
+ context.cms.onEntryAfterUnpublish.subscribe(async ({
138
+ model,
139
+ entry
140
+ }) => {
141
+ if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
142
+ return;
143
+ }
144
+ try {
145
+ const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.UNPUBLISH);
146
+ await createAuditLog("Entry revision unpublished", entry, entry.id, context);
147
+ } catch (error) {
148
+ throw _error.default.from(error, {
149
+ message: "Error while executing onEntryRevisionAfterUnpublishHook hook",
150
+ code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_UNPUBLISH_HOOK"
151
+ });
152
+ }
153
+ });
154
+ };
155
+ exports.onEntryAfterUnpublishHook = onEntryAfterUnpublishHook;
156
+
157
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","_isSearchModelEntry","onEntryAfterCreateHook","context","cms","onEntryAfterCreate","subscribe","model","entry","isPrivate","isSearchModelEntry","modelId","createAuditLog","getAuditConfig","AUDIT","HEADLESS_CMS","ENTRY","CREATE","entryId","error","WebinyError","from","message","code","exports","onEntryAfterUpdateHook","onEntryAfterUpdate","original","ENTRY_REVISION","UPDATE","before","after","id","onEntryAfterDeleteHook","onEntryAfterDelete","DELETE","onEntryRevisionAfterCreateHook","onEntryRevisionAfterCreate","onEntryRevisionAfterDeleteHook","onEntryRevisionAfterDelete","onEntryAfterPublishHook","onEntryAfterPublish","PUBLISH","onEntryAfterUnpublishHook","onEntryAfterUnpublish","UNPUBLISH"],"sources":["entries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport { isSearchModelEntry } from \"./utils/isSearchModelEntry\";\nimport { AuditLogsContext } from \"~/types\";\n\nexport const onEntryAfterCreateHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterCreate.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY.CREATE);\n\n await createAuditLog(\"Entry created\", entry, entry.entryId, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryAfterUpdateHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterUpdate.subscribe(async ({ model, entry, original }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY_REVISION.UPDATE);\n\n await createAuditLog(\n \"Entry revision updated\",\n { before: original, after: entry },\n entry.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryRevisionAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_REVISION_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryAfterDeleteHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterDelete.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY.DELETE);\n\n await createAuditLog(\"Entry deleted\", entry, entry.entryId, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_DELETE_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryRevisionAfterCreateHook = (context: AuditLogsContext) => {\n context.cms.onEntryRevisionAfterCreate.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY_REVISION.CREATE);\n\n await createAuditLog(\"Entry revision created\", entry, entry.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryRevisionAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_REVISION_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryRevisionAfterDeleteHook = (context: AuditLogsContext) => {\n context.cms.onEntryRevisionAfterDelete.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY_REVISION.DELETE);\n\n await createAuditLog(\"Entry revision deleted\", entry, entry.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryRevisionAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_REVISION_DELETE_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryAfterPublishHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterPublish.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY_REVISION.PUBLISH);\n\n await createAuditLog(\"Entry revision published\", entry, entry.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryRevisionAfterPublishHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_REVISION_PUBLISH_HOOK\"\n });\n }\n });\n};\n\nexport const onEntryAfterUnpublishHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterUnpublish.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY_REVISION.UNPUBLISH);\n\n await createAuditLog(\"Entry revision unpublished\", entry, entry.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryRevisionAfterUnpublishHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_REVISION_UNPUBLISH_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAGO,MAAMI,sBAAsB,GAAIC,OAAyB,IAAK;EACjEA,OAAO,CAACC,GAAG,CAACC,kBAAkB,CAACC,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IACjE,IAAID,KAAK,CAACE,SAAS,IAAI,IAAAC,sCAAkB,EAACF,KAAK,CAACG,OAAO,CAAC,EAAE;MACtD;IACJ;IACA,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,KAAK,CAACC,MAAM,CAAC;MAEtE,MAAML,cAAc,CAAC,eAAe,EAAEJ,KAAK,EAAEA,KAAK,CAACU,OAAO,EAAEf,OAAO,CAAC;IACxE,CAAC,CAAC,OAAOgB,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAAC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tC,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IACpE,IAAID,KAAK,CAACE,SAAS,IAAI,IAAAC,sCAAkB,EAACF,KAAK,CAACG,OAAO,CAAC,EAAE;MACtD;IACJ;IACA,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACa,cAAc,CAACiB,SAAS,CAAC;MAElF,MAAMjC,cAAc,CAAC,4BAA4B,EAAEJ,KAAK,EAAEA,KAAK,CAACwB,EAAE,EAAE7B,OAAO,CAAC;IAChF,CAAC,CAAC,OAAOgB,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,8DAA8D;QACvEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAmB,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1,4 @@
1
+ import { AuditLogsContext } from "../../types";
2
+ export declare const onGroupAfterCreateHook: (context: AuditLogsContext) => void;
3
+ export declare const onGroupAfterUpdateHook: (context: AuditLogsContext) => void;
4
+ export declare const onGroupAfterDeleteHook: (context: AuditLogsContext) => void;