@webiny/api-audit-logs 0.0.0-unstable.06b2ede40f
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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/app/app.d.ts +2 -0
- package/app/app.js +119 -0
- package/app/app.js.map +1 -0
- package/app/contants.d.ts +2 -0
- package/app/contants.js +10 -0
- package/app/contants.js.map +1 -0
- package/app/createAppModifier.d.ts +4 -0
- package/app/createAppModifier.js +14 -0
- package/app/createAppModifier.js.map +1 -0
- package/app/index.d.ts +4 -0
- package/app/index.js +43 -0
- package/app/index.js.map +1 -0
- package/app/types.d.ts +7 -0
- package/app/types.js +7 -0
- package/app/types.js.map +1 -0
- package/config.d.ts +14 -0
- package/config.js +293 -0
- package/config.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.js +49 -0
- package/index.js.map +1 -0
- package/package.json +47 -0
- package/subscriptions/aco/folders.d.ts +4 -0
- package/subscriptions/aco/folders.js +94 -0
- package/subscriptions/aco/folders.js.map +1 -0
- package/subscriptions/aco/index.d.ts +2 -0
- package/subscriptions/aco/index.js +18 -0
- package/subscriptions/aco/index.js.map +1 -0
- package/subscriptions/apw/changeRequests.d.ts +4 -0
- package/subscriptions/apw/changeRequests.js +80 -0
- package/subscriptions/apw/changeRequests.js.map +1 -0
- package/subscriptions/apw/comments.d.ts +2 -0
- package/subscriptions/apw/comments.js +28 -0
- package/subscriptions/apw/comments.js.map +1 -0
- package/subscriptions/apw/contentReviews.d.ts +2 -0
- package/subscriptions/apw/contentReviews.js +28 -0
- package/subscriptions/apw/contentReviews.js.map +1 -0
- package/subscriptions/apw/index.d.ts +2 -0
- package/subscriptions/apw/index.js +26 -0
- package/subscriptions/apw/index.js.map +1 -0
- package/subscriptions/apw/workflows.d.ts +4 -0
- package/subscriptions/apw/workflows.js +64 -0
- package/subscriptions/apw/workflows.js.map +1 -0
- package/subscriptions/fileManager/files.d.ts +4 -0
- package/subscriptions/fileManager/files.js +64 -0
- package/subscriptions/fileManager/files.js.map +1 -0
- package/subscriptions/fileManager/index.d.ts +2 -0
- package/subscriptions/fileManager/index.js +17 -0
- package/subscriptions/fileManager/index.js.map +1 -0
- package/subscriptions/fileManager/settings.d.ts +2 -0
- package/subscriptions/fileManager/settings.js +32 -0
- package/subscriptions/fileManager/settings.js.map +1 -0
- package/subscriptions/headlessCms/entries.d.ts +9 -0
- package/subscriptions/headlessCms/entries.js +183 -0
- package/subscriptions/headlessCms/entries.js.map +1 -0
- package/subscriptions/headlessCms/groups.d.ts +4 -0
- package/subscriptions/headlessCms/groups.js +64 -0
- package/subscriptions/headlessCms/groups.js.map +1 -0
- package/subscriptions/headlessCms/index.d.ts +2 -0
- package/subscriptions/headlessCms/index.js +31 -0
- package/subscriptions/headlessCms/index.js.map +1 -0
- package/subscriptions/headlessCms/models.d.ts +4 -0
- package/subscriptions/headlessCms/models.js +64 -0
- package/subscriptions/headlessCms/models.js.map +1 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +1 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.js +13 -0
- package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +1 -0
- package/subscriptions/i18n/index.d.ts +2 -0
- package/subscriptions/i18n/index.js +15 -0
- package/subscriptions/i18n/index.js.map +1 -0
- package/subscriptions/i18n/locales.d.ts +4 -0
- package/subscriptions/i18n/locales.js +64 -0
- package/subscriptions/i18n/locales.js.map +1 -0
- package/subscriptions/index.d.ts +2 -0
- package/subscriptions/index.js +25 -0
- package/subscriptions/index.js.map +1 -0
- package/subscriptions/mailer/index.d.ts +2 -0
- package/subscriptions/mailer/index.js +13 -0
- package/subscriptions/mailer/index.js.map +1 -0
- package/subscriptions/mailer/settings.d.ts +2 -0
- package/subscriptions/mailer/settings.js +32 -0
- package/subscriptions/mailer/settings.js.map +1 -0
- package/subscriptions/security/apiKeys.d.ts +4 -0
- package/subscriptions/security/apiKeys.js +85 -0
- package/subscriptions/security/apiKeys.js.map +1 -0
- package/subscriptions/security/index.d.ts +2 -0
- package/subscriptions/security/index.js +27 -0
- package/subscriptions/security/index.js.map +1 -0
- package/subscriptions/security/roles.d.ts +4 -0
- package/subscriptions/security/roles.js +64 -0
- package/subscriptions/security/roles.js.map +1 -0
- package/subscriptions/security/teams.d.ts +4 -0
- package/subscriptions/security/teams.js +64 -0
- package/subscriptions/security/teams.js.map +1 -0
- package/subscriptions/security/users.d.ts +4 -0
- package/subscriptions/security/users.js +64 -0
- package/subscriptions/security/users.js.map +1 -0
- package/types.d.ts +53 -0
- package/types.js +18 -0
- package/types.js.map +1 -0
- package/utils/getAuditConfig.d.ts +36 -0
- package/utils/getAuditConfig.js +149 -0
- package/utils/getAuditConfig.js.map +1 -0
- package/utils/getAuditObject.d.ts +2 -0
- package/utils/getAuditObject.js +25 -0
- 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 type { 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,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A,qBAAA","ignoreList":[]}
|
|
@@ -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 type { 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","ignoreList":[]}
|
|
@@ -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 type { 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","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { 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 onEntryAfterRestoreFromTrashHook: (context: AuditLogsContext) => void;
|
|
6
|
+
export declare const onEntryRevisionAfterCreateHook: (context: AuditLogsContext) => void;
|
|
7
|
+
export declare const onEntryRevisionAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
8
|
+
export declare const onEntryAfterPublishHook: (context: AuditLogsContext) => void;
|
|
9
|
+
export declare const onEntryAfterUnpublishHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,183 @@
|
|
|
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.onEntryAfterRestoreFromTrashHook = 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
|
+
permanent
|
|
61
|
+
}) => {
|
|
62
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
if (permanent) {
|
|
67
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY.DELETE);
|
|
68
|
+
await createAuditLog("Entry deleted", entry, entry.entryId, context);
|
|
69
|
+
} else {
|
|
70
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY.MOVE_TO_TRASH);
|
|
71
|
+
await createAuditLog("Entry moved to trash", entry, entry.entryId, context);
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw _error.default.from(error, {
|
|
75
|
+
message: "Error while executing onEntryAfterDeleteHook hook",
|
|
76
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_DELETE_HOOK"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.onEntryAfterDeleteHook = onEntryAfterDeleteHook;
|
|
82
|
+
const onEntryAfterRestoreFromTrashHook = context => {
|
|
83
|
+
context.cms.onEntryAfterRestoreFromBin.subscribe(async ({
|
|
84
|
+
model,
|
|
85
|
+
entry
|
|
86
|
+
}) => {
|
|
87
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY.RESTORE_FROM_TRASH);
|
|
92
|
+
await createAuditLog("Entry restored from trash", entry, entry.entryId, context);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw _error.default.from(error, {
|
|
95
|
+
message: "Error while executing onEntryAfterRestoreFromTrashHook hook",
|
|
96
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_RESTORE_FROM_TRASH_HOOK"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
exports.onEntryAfterRestoreFromTrashHook = onEntryAfterRestoreFromTrashHook;
|
|
102
|
+
const onEntryRevisionAfterCreateHook = context => {
|
|
103
|
+
context.cms.onEntryRevisionAfterCreate.subscribe(async ({
|
|
104
|
+
model,
|
|
105
|
+
entry
|
|
106
|
+
}) => {
|
|
107
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.CREATE);
|
|
112
|
+
await createAuditLog("Entry revision created", entry, entry.id, context);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw _error.default.from(error, {
|
|
115
|
+
message: "Error while executing onEntryRevisionAfterCreateHook hook",
|
|
116
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_CREATE_HOOK"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
exports.onEntryRevisionAfterCreateHook = onEntryRevisionAfterCreateHook;
|
|
122
|
+
const onEntryRevisionAfterDeleteHook = context => {
|
|
123
|
+
context.cms.onEntryRevisionAfterDelete.subscribe(async ({
|
|
124
|
+
model,
|
|
125
|
+
entry
|
|
126
|
+
}) => {
|
|
127
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.DELETE);
|
|
132
|
+
await createAuditLog("Entry revision deleted", entry, entry.id, context);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw _error.default.from(error, {
|
|
135
|
+
message: "Error while executing onEntryRevisionAfterDeleteHook hook",
|
|
136
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_DELETE_HOOK"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
exports.onEntryRevisionAfterDeleteHook = onEntryRevisionAfterDeleteHook;
|
|
142
|
+
const onEntryAfterPublishHook = context => {
|
|
143
|
+
context.cms.onEntryAfterPublish.subscribe(async ({
|
|
144
|
+
model,
|
|
145
|
+
entry
|
|
146
|
+
}) => {
|
|
147
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.PUBLISH);
|
|
152
|
+
await createAuditLog("Entry revision published", entry, entry.id, context);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
throw _error.default.from(error, {
|
|
155
|
+
message: "Error while executing onEntryRevisionAfterPublishHook hook",
|
|
156
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_PUBLISH_HOOK"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
exports.onEntryAfterPublishHook = onEntryAfterPublishHook;
|
|
162
|
+
const onEntryAfterUnpublishHook = context => {
|
|
163
|
+
context.cms.onEntryAfterUnpublish.subscribe(async ({
|
|
164
|
+
model,
|
|
165
|
+
entry
|
|
166
|
+
}) => {
|
|
167
|
+
if (model.isPrivate || (0, _isSearchModelEntry.isSearchModelEntry)(entry.modelId)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.ENTRY_REVISION.UNPUBLISH);
|
|
172
|
+
await createAuditLog("Entry revision unpublished", entry, entry.id, context);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
throw _error.default.from(error, {
|
|
175
|
+
message: "Error while executing onEntryRevisionAfterUnpublishHook hook",
|
|
176
|
+
code: "AUDIT_LOGS_AFTER_ENTRY_REVISION_UNPUBLISH_HOOK"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
exports.onEntryAfterUnpublishHook = onEntryAfterUnpublishHook;
|
|
182
|
+
|
|
183
|
+
//# 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","permanent","DELETE","MOVE_TO_TRASH","onEntryAfterRestoreFromTrashHook","onEntryAfterRestoreFromBin","RESTORE_FROM_TRASH","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 type { 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, permanent }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n if (permanent) {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY.DELETE);\n await createAuditLog(\"Entry deleted\", entry, entry.entryId, context);\n } else {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY.MOVE_TO_TRASH);\n await createAuditLog(\"Entry moved to trash\", entry, entry.entryId, context);\n }\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 onEntryAfterRestoreFromTrashHook = (context: AuditLogsContext) => {\n context.cms.onEntryAfterRestoreFromBin.subscribe(async ({ model, entry }) => {\n if (model.isPrivate || isSearchModelEntry(entry.modelId)) {\n return;\n }\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.ENTRY.RESTORE_FROM_TRASH);\n await createAuditLog(\"Entry restored from trash\", entry, entry.entryId, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryAfterRestoreFromTrashHook hook\",\n code: \"AUDIT_LOGS_AFTER_ENTRY_RESTORE_FROM_TRASH_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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AAC,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,CAAAwB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { 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;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onGroupAfterUpdateHook = exports.onGroupAfterDeleteHook = exports.onGroupAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onGroupAfterCreateHook = context => {
|
|
12
|
+
context.cms.onGroupAfterCreate.subscribe(async ({
|
|
13
|
+
group
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.GROUP.CREATE);
|
|
17
|
+
await createAuditLog("Group created", group, group.id, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onGroupAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_GROUP_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onGroupAfterCreateHook = onGroupAfterCreateHook;
|
|
27
|
+
const onGroupAfterUpdateHook = context => {
|
|
28
|
+
context.cms.onGroupAfterUpdate.subscribe(async ({
|
|
29
|
+
group,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.GROUP.UPDATE);
|
|
34
|
+
await createAuditLog("Group updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: group
|
|
37
|
+
}, group.id, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onGroupAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_GROUP_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onGroupAfterUpdateHook = onGroupAfterUpdateHook;
|
|
47
|
+
const onGroupAfterDeleteHook = context => {
|
|
48
|
+
context.cms.onGroupAfterDelete.subscribe(async ({
|
|
49
|
+
group
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.GROUP.DELETE);
|
|
53
|
+
await createAuditLog("Group deleted", group, group.id, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onGroupAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_GROUP_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onGroupAfterDeleteHook = onGroupAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onGroupAfterCreateHook","context","cms","onGroupAfterCreate","subscribe","group","createAuditLog","getAuditConfig","AUDIT","HEADLESS_CMS","GROUP","CREATE","id","error","WebinyError","from","message","code","exports","onGroupAfterUpdateHook","onGroupAfterUpdate","original","UPDATE","before","after","onGroupAfterDeleteHook","onGroupAfterDelete","DELETE"],"sources":["groups.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onGroupAfterCreateHook = (context: AuditLogsContext) => {\n context.cms.onGroupAfterCreate.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.GROUP.CREATE);\n\n await createAuditLog(\"Group created\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onGroupAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_GROUP_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onGroupAfterUpdateHook = (context: AuditLogsContext) => {\n context.cms.onGroupAfterUpdate.subscribe(async ({ group, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.GROUP.UPDATE);\n\n await createAuditLog(\n \"Group updated\",\n { before: original, after: group },\n group.id,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onGroupAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_GROUP_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onGroupAfterDeleteHook = (context: AuditLogsContext) => {\n context.cms.onGroupAfterDelete.subscribe(async ({ group }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.GROUP.DELETE);\n\n await createAuditLog(\"Group deleted\", group, group.id, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onGroupAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_GROUP_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,sBAAsB,GAAIC,OAAyB,IAAK;EACjEA,OAAO,CAACC,GAAG,CAACC,kBAAkB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC1D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,KAAK,CAACC,MAAM,CAAC;MAEtE,MAAML,cAAc,CAAC,eAAe,EAAED,KAAK,EAAEA,KAAK,CAACO,EAAE,EAAEX,OAAO,CAAC;IACnE,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,CAAAlB,sBAAA,GAAAA,sBAAA;AAEK,MAAMmB,sBAAsB,GAAIlB,OAAyB,IAAK;EACjEA,OAAO,CAACC,GAAG,CAACkB,kBAAkB,CAAChB,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEgB;EAAS,CAAC,KAAK;IACpE,IAAI;MACA,MAAMf,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,KAAK,CAACY,MAAM,CAAC;MAEtE,MAAMhB,cAAc,CAChB,eAAe,EACf;QAAEiB,MAAM,EAAEF,QAAQ;QAAEG,KAAK,EAAEnB;MAAM,CAAC,EAClCA,KAAK,CAACO,EAAE,EACRX,OACJ,CAAC;IACL,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,CAAAC,sBAAA,GAAAA,sBAAA;AAEK,MAAMM,sBAAsB,GAAIxB,OAAyB,IAAK;EACjEA,OAAO,CAACC,GAAG,CAACwB,kBAAkB,CAACtB,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC1D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,KAAK,CAACiB,MAAM,CAAC;MAEtE,MAAMrB,cAAc,CAAC,eAAe,EAAED,KAAK,EAAEA,KAAK,CAACO,EAAE,EAAEX,OAAO,CAAC;IACnE,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,CAAAO,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHeadlessCmsHooks = void 0;
|
|
7
|
+
var _models = require("./models");
|
|
8
|
+
var _groups = require("./groups");
|
|
9
|
+
var _entries = require("./entries");
|
|
10
|
+
const createHeadlessCmsHooks = context => {
|
|
11
|
+
// groups
|
|
12
|
+
(0, _groups.onGroupAfterCreateHook)(context);
|
|
13
|
+
(0, _groups.onGroupAfterUpdateHook)(context);
|
|
14
|
+
(0, _groups.onGroupAfterDeleteHook)(context);
|
|
15
|
+
// models
|
|
16
|
+
(0, _models.onModelAfterCreateHook)(context);
|
|
17
|
+
(0, _models.onModelAfterUpdateHook)(context);
|
|
18
|
+
(0, _models.onModelAfterDeleteHook)(context);
|
|
19
|
+
// entries
|
|
20
|
+
(0, _entries.onEntryAfterCreateHook)(context);
|
|
21
|
+
(0, _entries.onEntryAfterUpdateHook)(context);
|
|
22
|
+
(0, _entries.onEntryAfterDeleteHook)(context);
|
|
23
|
+
(0, _entries.onEntryAfterRestoreFromTrashHook)(context);
|
|
24
|
+
(0, _entries.onEntryAfterPublishHook)(context);
|
|
25
|
+
(0, _entries.onEntryAfterUnpublishHook)(context);
|
|
26
|
+
(0, _entries.onEntryRevisionAfterCreateHook)(context);
|
|
27
|
+
(0, _entries.onEntryRevisionAfterDeleteHook)(context);
|
|
28
|
+
};
|
|
29
|
+
exports.createHeadlessCmsHooks = createHeadlessCmsHooks;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_models","require","_groups","_entries","createHeadlessCmsHooks","context","onGroupAfterCreateHook","onGroupAfterUpdateHook","onGroupAfterDeleteHook","onModelAfterCreateHook","onModelAfterUpdateHook","onModelAfterDeleteHook","onEntryAfterCreateHook","onEntryAfterUpdateHook","onEntryAfterDeleteHook","onEntryAfterRestoreFromTrashHook","onEntryAfterPublishHook","onEntryAfterUnpublishHook","onEntryRevisionAfterCreateHook","onEntryRevisionAfterDeleteHook","exports"],"sources":["index.ts"],"sourcesContent":["import { onModelAfterCreateHook, onModelAfterDeleteHook, onModelAfterUpdateHook } from \"./models\";\nimport { onGroupAfterCreateHook, onGroupAfterDeleteHook, onGroupAfterUpdateHook } from \"./groups\";\nimport {\n onEntryAfterCreateHook,\n onEntryAfterUpdateHook,\n onEntryAfterDeleteHook,\n onEntryAfterPublishHook,\n onEntryAfterUnpublishHook,\n onEntryRevisionAfterCreateHook,\n onEntryRevisionAfterDeleteHook,\n onEntryAfterRestoreFromTrashHook\n} from \"./entries\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const createHeadlessCmsHooks = (context: AuditLogsContext) => {\n // groups\n onGroupAfterCreateHook(context);\n onGroupAfterUpdateHook(context);\n onGroupAfterDeleteHook(context);\n // models\n onModelAfterCreateHook(context);\n onModelAfterUpdateHook(context);\n onModelAfterDeleteHook(context);\n // entries\n onEntryAfterCreateHook(context);\n onEntryAfterUpdateHook(context);\n onEntryAfterDeleteHook(context);\n onEntryAfterRestoreFromTrashHook(context);\n onEntryAfterPublishHook(context);\n onEntryAfterUnpublishHook(context);\n onEntryRevisionAfterCreateHook(context);\n onEntryRevisionAfterDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAYO,MAAMG,sBAAsB,GAAIC,OAAyB,IAAK;EACjE;EACA,IAAAC,8BAAsB,EAACD,OAAO,CAAC;EAC/B,IAAAE,8BAAsB,EAACF,OAAO,CAAC;EAC/B,IAAAG,8BAAsB,EAACH,OAAO,CAAC;EAC/B;EACA,IAAAI,8BAAsB,EAACJ,OAAO,CAAC;EAC/B,IAAAK,8BAAsB,EAACL,OAAO,CAAC;EAC/B,IAAAM,8BAAsB,EAACN,OAAO,CAAC;EAC/B;EACA,IAAAO,+BAAsB,EAACP,OAAO,CAAC;EAC/B,IAAAQ,+BAAsB,EAACR,OAAO,CAAC;EAC/B,IAAAS,+BAAsB,EAACT,OAAO,CAAC;EAC/B,IAAAU,yCAAgC,EAACV,OAAO,CAAC;EACzC,IAAAW,gCAAuB,EAACX,OAAO,CAAC;EAChC,IAAAY,kCAAyB,EAACZ,OAAO,CAAC;EAClC,IAAAa,uCAA8B,EAACb,OAAO,CAAC;EACvC,IAAAc,uCAA8B,EAACd,OAAO,CAAC;AAC3C,CAAC;AAACe,OAAA,CAAAhB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onModelAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onModelAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onModelAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onModelAfterUpdateHook = exports.onModelAfterDeleteHook = exports.onModelAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onModelAfterCreateHook = context => {
|
|
12
|
+
context.cms.onModelAfterCreate.subscribe(async ({
|
|
13
|
+
model
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.MODEL.CREATE);
|
|
17
|
+
await createAuditLog("Model created", model, model.modelId, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onModelAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_MODEL_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onModelAfterCreateHook = onModelAfterCreateHook;
|
|
27
|
+
const onModelAfterUpdateHook = context => {
|
|
28
|
+
context.cms.onModelAfterUpdate.subscribe(async ({
|
|
29
|
+
model,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.MODEL.UPDATE);
|
|
34
|
+
await createAuditLog("Model updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: model
|
|
37
|
+
}, model.modelId, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onModelAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_MODEL_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onModelAfterUpdateHook = onModelAfterUpdateHook;
|
|
47
|
+
const onModelAfterDeleteHook = context => {
|
|
48
|
+
context.cms.onModelAfterDelete.subscribe(async ({
|
|
49
|
+
model
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.HEADLESS_CMS.MODEL.DELETE);
|
|
53
|
+
await createAuditLog("Model deleted", model, model.modelId, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onModelAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_MODEL_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onModelAfterDeleteHook = onModelAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_config","_getAuditConfig","onModelAfterCreateHook","context","cms","onModelAfterCreate","subscribe","model","createAuditLog","getAuditConfig","AUDIT","HEADLESS_CMS","MODEL","CREATE","modelId","error","WebinyError","from","message","code","exports","onModelAfterUpdateHook","onModelAfterUpdate","original","UPDATE","before","after","onModelAfterDeleteHook","onModelAfterDelete","DELETE"],"sources":["models.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { AUDIT } from \"~/config\";\nimport { getAuditConfig } from \"~/utils/getAuditConfig\";\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const onModelAfterCreateHook = (context: AuditLogsContext) => {\n context.cms.onModelAfterCreate.subscribe(async ({ model }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.MODEL.CREATE);\n\n await createAuditLog(\"Model created\", model, model.modelId, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onModelAfterCreateHook hook\",\n code: \"AUDIT_LOGS_AFTER_MODEL_CREATE_HOOK\"\n });\n }\n });\n};\n\nexport const onModelAfterUpdateHook = (context: AuditLogsContext) => {\n context.cms.onModelAfterUpdate.subscribe(async ({ model, original }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.MODEL.UPDATE);\n\n await createAuditLog(\n \"Model updated\",\n { before: original, after: model },\n model.modelId,\n context\n );\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onModelAfterUpdateHook hook\",\n code: \"AUDIT_LOGS_AFTER_MODEL_UPDATE_HOOK\"\n });\n }\n });\n};\n\nexport const onModelAfterDeleteHook = (context: AuditLogsContext) => {\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n try {\n const createAuditLog = getAuditConfig(AUDIT.HEADLESS_CMS.MODEL.DELETE);\n\n await createAuditLog(\"Model deleted\", model, model.modelId, context);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onModelAfterDeleteHook hook\",\n code: \"AUDIT_LOGS_AFTER_MODEL_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,sBAAsB,GAAIC,OAAyB,IAAK;EACjEA,OAAO,CAACC,GAAG,CAAC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AAC,KAAK;IAC1D,IAAI;MACA,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAACC,aAAK,CAACC,YAAY,CAACC,KAAK,CAACiB,MAAM,CAAC;MAEtE,MAAMrB,cAAc,CAAC,eAAe,EAAED,KAAK,EAAEA,KAAK,CAACO,OAAO,EAAEX,OAAO,CAAC;IACxE,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,CAAAO,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isSearchModelEntry: (modelId: string) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isSearchModelEntry = void 0;
|
|
7
|
+
var _record = require("@webiny/api-aco/record/record.model");
|
|
8
|
+
const isSearchModelEntry = modelId => {
|
|
9
|
+
return modelId.startsWith(_record.SEARCH_RECORD_MODEL_ID);
|
|
10
|
+
};
|
|
11
|
+
exports.isSearchModelEntry = isSearchModelEntry;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=isSearchModelEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_record","require","isSearchModelEntry","modelId","startsWith","SEARCH_RECORD_MODEL_ID","exports"],"sources":["isSearchModelEntry.ts"],"sourcesContent":["import { SEARCH_RECORD_MODEL_ID } from \"@webiny/api-aco/record/record.model\";\n\nexport const isSearchModelEntry = (modelId: string): boolean => {\n return modelId.startsWith(SEARCH_RECORD_MODEL_ID);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,OAAe,IAAc;EAC5D,OAAOA,OAAO,CAACC,UAAU,CAACC,8BAAsB,CAAC;AACrD,CAAC;AAACC,OAAA,CAAAJ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createI18NHooks = void 0;
|
|
7
|
+
var _locales = require("./locales");
|
|
8
|
+
const createI18NHooks = context => {
|
|
9
|
+
(0, _locales.onLocaleAfterCreateHook)(context);
|
|
10
|
+
(0, _locales.onLocaleAfterUpdateHook)(context);
|
|
11
|
+
(0, _locales.onLocaleAfterDeleteHook)(context);
|
|
12
|
+
};
|
|
13
|
+
exports.createI18NHooks = createI18NHooks;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_locales","require","createI18NHooks","context","onLocaleAfterCreateHook","onLocaleAfterUpdateHook","onLocaleAfterDeleteHook","exports"],"sources":["index.ts"],"sourcesContent":["import {\n onLocaleAfterCreateHook,\n onLocaleAfterUpdateHook,\n onLocaleAfterDeleteHook\n} from \"./locales\";\n\nimport type { AuditLogsContext } from \"~/types\";\n\nexport const createI18NHooks = (context: AuditLogsContext) => {\n onLocaleAfterCreateHook(context);\n onLocaleAfterUpdateHook(context);\n onLocaleAfterDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,eAAe,GAAIC,OAAyB,IAAK;EAC1D,IAAAC,gCAAuB,EAACD,OAAO,CAAC;EAChC,IAAAE,gCAAuB,EAACF,OAAO,CAAC;EAChC,IAAAG,gCAAuB,EAACH,OAAO,CAAC;AACpC,CAAC;AAACI,OAAA,CAAAL,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuditLogsContext } from "../../types";
|
|
2
|
+
export declare const onLocaleAfterCreateHook: (context: AuditLogsContext) => void;
|
|
3
|
+
export declare const onLocaleAfterUpdateHook: (context: AuditLogsContext) => void;
|
|
4
|
+
export declare const onLocaleAfterDeleteHook: (context: AuditLogsContext) => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.onLocaleAfterUpdateHook = exports.onLocaleAfterDeleteHook = exports.onLocaleAfterCreateHook = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _config = require("../../config");
|
|
10
|
+
var _getAuditConfig = require("../../utils/getAuditConfig");
|
|
11
|
+
const onLocaleAfterCreateHook = context => {
|
|
12
|
+
context.i18n.locales.onLocaleAfterCreate.subscribe(async ({
|
|
13
|
+
locale
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.I18N.LOCALE.CREATE);
|
|
17
|
+
await createAuditLog("Locale created", locale, locale.code, context);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw _error.default.from(error, {
|
|
20
|
+
message: "Error while executing onLocaleAfterCreateHook hook",
|
|
21
|
+
code: "AUDIT_LOGS_AFTER_LOCALE_CREATE_HOOK"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.onLocaleAfterCreateHook = onLocaleAfterCreateHook;
|
|
27
|
+
const onLocaleAfterUpdateHook = context => {
|
|
28
|
+
context.i18n.locales.onLocaleAfterUpdate.subscribe(async ({
|
|
29
|
+
locale,
|
|
30
|
+
original
|
|
31
|
+
}) => {
|
|
32
|
+
try {
|
|
33
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.I18N.LOCALE.UPDATE);
|
|
34
|
+
await createAuditLog("Locale updated", {
|
|
35
|
+
before: original,
|
|
36
|
+
after: locale
|
|
37
|
+
}, locale.code, context);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw _error.default.from(error, {
|
|
40
|
+
message: "Error while executing onLocaleAfterUpdateHook hook",
|
|
41
|
+
code: "AUDIT_LOGS_AFTER_LOCALE_UPDATE_HOOK"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.onLocaleAfterUpdateHook = onLocaleAfterUpdateHook;
|
|
47
|
+
const onLocaleAfterDeleteHook = context => {
|
|
48
|
+
context.i18n.locales.onLocaleAfterDelete.subscribe(async ({
|
|
49
|
+
locale
|
|
50
|
+
}) => {
|
|
51
|
+
try {
|
|
52
|
+
const createAuditLog = (0, _getAuditConfig.getAuditConfig)(_config.AUDIT.I18N.LOCALE.DELETE);
|
|
53
|
+
await createAuditLog("Locale deleted", locale, locale.code, context);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw _error.default.from(error, {
|
|
56
|
+
message: "Error while executing onLocaleAfterDeleteHook hook",
|
|
57
|
+
code: "AUDIT_LOGS_AFTER_LOCALE_DELETE_HOOK"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.onLocaleAfterDeleteHook = onLocaleAfterDeleteHook;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=locales.js.map
|