@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.
Files changed (108) 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 +119 -0
  5. package/app/app.js.map +1 -0
  6. package/app/contants.d.ts +2 -0
  7. package/app/contants.js +10 -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 +14 -0
  19. package/config.js +293 -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 +47 -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 +80 -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/headlessCms/entries.d.ts +9 -0
  56. package/subscriptions/headlessCms/entries.js +183 -0
  57. package/subscriptions/headlessCms/entries.js.map +1 -0
  58. package/subscriptions/headlessCms/groups.d.ts +4 -0
  59. package/subscriptions/headlessCms/groups.js +64 -0
  60. package/subscriptions/headlessCms/groups.js.map +1 -0
  61. package/subscriptions/headlessCms/index.d.ts +2 -0
  62. package/subscriptions/headlessCms/index.js +31 -0
  63. package/subscriptions/headlessCms/index.js.map +1 -0
  64. package/subscriptions/headlessCms/models.d.ts +4 -0
  65. package/subscriptions/headlessCms/models.js +64 -0
  66. package/subscriptions/headlessCms/models.js.map +1 -0
  67. package/subscriptions/headlessCms/utils/isSearchModelEntry.d.ts +1 -0
  68. package/subscriptions/headlessCms/utils/isSearchModelEntry.js +13 -0
  69. package/subscriptions/headlessCms/utils/isSearchModelEntry.js.map +1 -0
  70. package/subscriptions/i18n/index.d.ts +2 -0
  71. package/subscriptions/i18n/index.js +15 -0
  72. package/subscriptions/i18n/index.js.map +1 -0
  73. package/subscriptions/i18n/locales.d.ts +4 -0
  74. package/subscriptions/i18n/locales.js +64 -0
  75. package/subscriptions/i18n/locales.js.map +1 -0
  76. package/subscriptions/index.d.ts +2 -0
  77. package/subscriptions/index.js +25 -0
  78. package/subscriptions/index.js.map +1 -0
  79. package/subscriptions/mailer/index.d.ts +2 -0
  80. package/subscriptions/mailer/index.js +13 -0
  81. package/subscriptions/mailer/index.js.map +1 -0
  82. package/subscriptions/mailer/settings.d.ts +2 -0
  83. package/subscriptions/mailer/settings.js +32 -0
  84. package/subscriptions/mailer/settings.js.map +1 -0
  85. package/subscriptions/security/apiKeys.d.ts +4 -0
  86. package/subscriptions/security/apiKeys.js +85 -0
  87. package/subscriptions/security/apiKeys.js.map +1 -0
  88. package/subscriptions/security/index.d.ts +2 -0
  89. package/subscriptions/security/index.js +27 -0
  90. package/subscriptions/security/index.js.map +1 -0
  91. package/subscriptions/security/roles.d.ts +4 -0
  92. package/subscriptions/security/roles.js +64 -0
  93. package/subscriptions/security/roles.js.map +1 -0
  94. package/subscriptions/security/teams.d.ts +4 -0
  95. package/subscriptions/security/teams.js +64 -0
  96. package/subscriptions/security/teams.js.map +1 -0
  97. package/subscriptions/security/users.d.ts +4 -0
  98. package/subscriptions/security/users.js +64 -0
  99. package/subscriptions/security/users.js.map +1 -0
  100. package/types.d.ts +53 -0
  101. package/types.js +18 -0
  102. package/types.js.map +1 -0
  103. package/utils/getAuditConfig.d.ts +36 -0
  104. package/utils/getAuditConfig.js +149 -0
  105. package/utils/getAuditConfig.js.map +1 -0
  106. package/utils/getAuditObject.d.ts +2 -0
  107. package/utils/getAuditObject.js +25 -0
  108. package/utils/getAuditObject.js.map +1 -0
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getAuditConfig = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _utils = require("@webiny/utils");
10
+ const createAuditLog = async params => {
11
+ const {
12
+ app,
13
+ payload
14
+ } = params;
15
+ const compressor = app.context.compressor;
16
+ const payloadData = JSON.stringify(payload.data);
17
+ try {
18
+ const entry = {
19
+ id: (0, _utils.mdbid)(),
20
+ title: payload.message,
21
+ content: payload.message,
22
+ tags: [],
23
+ type: "AuditLogs",
24
+ location: {
25
+ folderId: "root"
26
+ },
27
+ data: {
28
+ ...payload,
29
+ data: payloadData
30
+ }
31
+ };
32
+ const data = await compressor.compress(entry.data.data);
33
+ await app.search.create({
34
+ ...entry,
35
+ data: {
36
+ ...entry.data,
37
+ data: JSON.stringify(data)
38
+ }
39
+ });
40
+ return entry;
41
+ } catch (error) {
42
+ throw _error.default.from(error, {
43
+ message: "Error while creating new audit log",
44
+ code: "CREATE_AUDIT_LOG"
45
+ });
46
+ }
47
+ };
48
+ const createOrMergeAuditLog = async params => {
49
+ const {
50
+ app,
51
+ payload,
52
+ delay
53
+ } = params;
54
+ const compressor = app.context.compressor;
55
+ // Get the latest audit log of this entry.
56
+ const [records] = await app.search.list({
57
+ where: {
58
+ type: "AuditLogs",
59
+ data: {
60
+ entityId: payload.entityId,
61
+ initiator: payload.initiator
62
+ }
63
+ },
64
+ limit: 1
65
+ });
66
+ const existingLog = records?.[0];
67
+ if (existingLog) {
68
+ const existingLogDate = Date.parse(existingLog.savedOn);
69
+ const newLogDate = payload.timestamp.getTime();
70
+
71
+ // Check if the latest audit log is saved within delay range.
72
+ if (newLogDate - existingLogDate < delay * 1000) {
73
+ const existingLogData = await compressor.decompress(existingLog.data);
74
+ // Update latest audit log with new "after" payload.
75
+ const beforePayloadData = JSON.parse(existingLogData?.data.data)?.before;
76
+ const afterPayloadData = payload.data?.after;
77
+ const updatedPayloadData = beforePayloadData ? JSON.stringify({
78
+ before: beforePayloadData,
79
+ after: afterPayloadData
80
+ }) : JSON.stringify(payload.data);
81
+ const data = await compressor.compress(updatedPayloadData);
82
+ try {
83
+ await app.search.update(existingLog.id, {
84
+ data: {
85
+ ...payload,
86
+ data
87
+ }
88
+ });
89
+ return {
90
+ ...existingLog,
91
+ data: updatedPayloadData
92
+ };
93
+ } catch (error) {
94
+ throw _error.default.from(error, {
95
+ message: "Error while updating audit log",
96
+ code: "UPDATE_AUDIT_LOG"
97
+ });
98
+ }
99
+ }
100
+ }
101
+ return createAuditLog(params);
102
+ };
103
+ const getAuditConfig = audit => {
104
+ return async (message, data, entityId, context) => {
105
+ const {
106
+ aco,
107
+ security
108
+ } = context;
109
+ if (!aco) {
110
+ console.log("No ACO defined.");
111
+ return;
112
+ }
113
+ const identity = security.getIdentity();
114
+ const auditLogPayload = {
115
+ message,
116
+ app: audit.app.app,
117
+ entity: audit.entity.type,
118
+ entityId,
119
+ action: audit.action.type,
120
+ data,
121
+ timestamp: new Date(),
122
+ initiator: identity?.id
123
+ };
124
+ const app = aco.getApp("AuditLogs");
125
+ const delay = audit.action.newEntryDelay;
126
+
127
+ // Check if there is delay on audit log creation for this action.
128
+ if (delay) {
129
+ try {
130
+ return await createOrMergeAuditLog({
131
+ app,
132
+ payload: auditLogPayload,
133
+ delay
134
+ });
135
+ } catch {
136
+ // Don't care at this point!
137
+ } finally {
138
+ return JSON.stringify({});
139
+ }
140
+ }
141
+ return await createAuditLog({
142
+ app,
143
+ payload: auditLogPayload
144
+ });
145
+ };
146
+ };
147
+ exports.getAuditConfig = getAuditConfig;
148
+
149
+ //# sourceMappingURL=getAuditConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_utils","createAuditLog","params","app","payload","compressor","context","payloadData","JSON","stringify","data","entry","id","mdbid","title","message","content","tags","type","location","folderId","compress","search","create","error","WebinyError","from","code","createOrMergeAuditLog","delay","records","list","where","entityId","initiator","limit","existingLog","existingLogDate","Date","parse","savedOn","newLogDate","timestamp","getTime","existingLogData","decompress","beforePayloadData","before","afterPayloadData","after","updatedPayloadData","update","getAuditConfig","audit","aco","security","console","log","identity","getIdentity","auditLogPayload","entity","action","getApp","newEntryDelay","exports"],"sources":["getAuditConfig.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { mdbid } from \"@webiny/utils\";\nimport type { IAcoApp } from \"@webiny/api-aco/types\";\nimport type { AuditAction, AuditLog, AuditLogsContext } from \"~/types\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\ninterface AuditLogPayload extends Omit<AuditLog, \"id\" | \"data\"> {\n data: Record<string, any>;\n}\n\ninterface CreateAuditLogParams {\n app: IAcoApp;\n payload: AuditLogPayload;\n}\n\nconst createAuditLog = async (params: CreateAuditLogParams) => {\n const { app, payload } = params;\n\n const compressor = app.context.compressor;\n\n const payloadData = JSON.stringify(payload.data);\n\n try {\n const entry = {\n id: mdbid(),\n title: payload.message,\n content: payload.message,\n tags: [],\n type: \"AuditLogs\",\n location: { folderId: \"root\" },\n data: {\n ...payload,\n data: payloadData\n }\n };\n const data = await compressor.compress(entry.data.data);\n await app.search.create({\n ...entry,\n data: {\n ...entry.data,\n data: JSON.stringify(data)\n }\n });\n return entry;\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while creating new audit log\",\n code: \"CREATE_AUDIT_LOG\"\n });\n }\n};\n\ninterface CreateOrMergeAuditLogParams {\n app: IAcoApp;\n payload: AuditLogPayload;\n delay: number;\n}\n\nconst createOrMergeAuditLog = async (params: CreateOrMergeAuditLogParams) => {\n const { app, payload, delay } = params;\n\n const compressor = app.context.compressor;\n // Get the latest audit log of this entry.\n const [records] = await app.search.list({\n where: {\n type: \"AuditLogs\",\n data: {\n entityId: payload.entityId,\n initiator: payload.initiator\n }\n },\n limit: 1\n });\n const existingLog = records?.[0];\n\n if (existingLog) {\n const existingLogDate = Date.parse(existingLog.savedOn);\n const newLogDate = payload.timestamp.getTime();\n\n // Check if the latest audit log is saved within delay range.\n if (newLogDate - existingLogDate < delay * 1000) {\n const existingLogData = (await compressor.decompress(\n existingLog.data\n )) as unknown as GenericRecord;\n // Update latest audit log with new \"after\" payload.\n const beforePayloadData = JSON.parse(existingLogData?.data.data)?.before;\n const afterPayloadData = payload.data?.after;\n const updatedPayloadData = beforePayloadData\n ? JSON.stringify({ before: beforePayloadData, after: afterPayloadData })\n : JSON.stringify(payload.data);\n\n const data = await compressor.compress(updatedPayloadData);\n try {\n await app.search.update(existingLog.id, {\n data: {\n ...payload,\n data\n }\n });\n\n return {\n ...existingLog,\n data: updatedPayloadData\n };\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while updating audit log\",\n code: \"UPDATE_AUDIT_LOG\"\n });\n }\n }\n }\n\n return createAuditLog(params);\n};\n\nexport const getAuditConfig = (audit: AuditAction) => {\n return async (\n message: string,\n data: Record<string, any>,\n entityId: string,\n context: AuditLogsContext\n ) => {\n const { aco, security } = context;\n\n if (!aco) {\n console.log(\"No ACO defined.\");\n return;\n }\n\n const identity = security.getIdentity();\n\n const auditLogPayload = {\n message,\n app: audit.app.app,\n entity: audit.entity.type,\n entityId,\n action: audit.action.type,\n data,\n timestamp: new Date(),\n initiator: identity?.id\n };\n\n const app = aco.getApp(\"AuditLogs\");\n const delay = audit.action.newEntryDelay;\n\n // Check if there is delay on audit log creation for this action.\n if (delay) {\n try {\n return await createOrMergeAuditLog({\n app,\n payload: auditLogPayload,\n delay\n });\n } catch {\n // Don't care at this point!\n } finally {\n return JSON.stringify({});\n }\n }\n return await createAuditLog({\n app,\n payload: auditLogPayload\n });\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAcA,MAAME,cAAc,GAAG,MAAOC,MAA4B,IAAK;EAC3D,MAAM;IAAEC,GAAG;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/B,MAAMG,UAAU,GAAGF,GAAG,CAACG,OAAO,CAACD,UAAU;EAEzC,MAAME,WAAW,GAAGC,IAAI,CAACC,SAAS,CAACL,OAAO,CAACM,IAAI,CAAC;EAEhD,IAAI;IACA,MAAMC,KAAK,GAAG;MACVC,EAAE,EAAE,IAAAC,YAAK,EAAC,CAAC;MACXC,KAAK,EAAEV,OAAO,CAACW,OAAO;MACtBC,OAAO,EAAEZ,OAAO,CAACW,OAAO;MACxBE,IAAI,EAAE,EAAE;MACRC,IAAI,EAAE,WAAW;MACjBC,QAAQ,EAAE;QAAEC,QA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AAC,GAAGjD,OAAO;IAEjC,IAAI,CAACgD,GAAG,EAAE;MACNE,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC;MAC9B;IACJ;IAEA,MAAMC,QAAQ,GAAGH,QAAQ,CAACI,WAAW,CAAC,CAAC;IAEvC,MAAMC,eAAe,GAAG;MACpB7C,OAAO;MACPZ,GAAG,EAAEkD,KAAK,CAAClD,GAAG,CAACA,GAAG;MAClB0D,MAAM,EAAER,KAAK,CAACQ,MAAM,CAAC3C,IAAI;MACzBe,QAAQ;MACR6B,MAAM,EAAET,KAAK,CAACS,MAAM,CAAC5C,IAAI;MACzBR,IAAI;MACJgC,SAAS,EAAE,IAAIJ,IAAI,CAAC,CAAC;MACrBJ,SAAS,EAAEwB,QAAQ,EAAE9C;IACzB,CAAC;IAED,MAAMT,GAAG,GAAGmD,GAAG,CAACS,MAAM,CAAC,WAAW,CAAC;IACnC,MAAMlC,KAAK,GAAGwB,KAAK,CAACS,MAAM,CAACE,aAAa;;IAExC;IACA,IAAInC,KAAK,EAAE;MACP,IAAI;QACA,OAAO,MAAMD,qBAAqB,CAAC;UAC/BzB,GAAG;UACHC,OAAO,EAAEwD,eAAe;UACxB/B;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,MAAM;QACJ;MAAA,CACH,SAAS;QACN,OAAOrB,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC,CAAC;MAC7B;IACJ;IACA,OAAO,MAAMR,cAAc,CAAC;MACxBE,GAAG;MACHC,OAAO,EAAEwD;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACK,OAAA,CAAAb,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { App, AuditObject } from "../types";
2
+ export declare const getAuditObject: (apps: App[]) => AuditObject;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAuditObject = void 0;
7
+ const getAuditObject = apps => {
8
+ return apps.reduce((result, app) => {
9
+ result[app.app] = app.entities.reduce((entities, entity) => {
10
+ entities[entity.type] = entity.actions.reduce((actions, action) => {
11
+ actions[action.type] = {
12
+ app,
13
+ entity,
14
+ action
15
+ };
16
+ return actions;
17
+ }, {});
18
+ return entities;
19
+ }, {});
20
+ return result;
21
+ }, {});
22
+ };
23
+ exports.getAuditObject = getAuditObject;
24
+
25
+ //# sourceMappingURL=getAuditObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getAuditObject","apps","reduce","result","app","entities","entity","type","actions","action","exports"],"sources":["getAuditObject.ts"],"sourcesContent":["import type { ActionObject, App, AuditObject, EntityObject } from \"~/types\";\n\nexport const getAuditObject = (apps: App[]) => {\n return apps.reduce<AuditObject>((result, app) => {\n result[app.app] = app.entities.reduce<EntityObject>((entities, entity) => {\n entities[entity.type] = entity.actions.reduce<ActionObject>((actions, action) => {\n actions[action.type] = {\n app,\n entity,\n action\n };\n\n return actions;\n }, {});\n\n return entities;\n }, {});\n\n return result;\n }, {});\n};\n"],"mappings":";;;;;;AAEO,MAAMA,cAAc,GAAIC,IAAW,IAAK;EAC3C,OAAOA,IAAI,CAACC,MAAM,CAAc,CAACC,MAAM,EAAEC,GAAG,KAAK;IAC7CD,MAAM,CAACC,GAAG,CAACA,GAAG,CAAC,GAAGA,GAAG,CAACC,QAAQ,CAACH,MAAM,CAAe,CAACG,QAAQ,EAAEC,MAAM,KAAK;MACtED,QAAQ,CAACC,MAAM,CAACC,IAAI,CAAC,GAAGD,MAAM,CAACE,OAAO,CAACN,MAAM,CAAe,CAACM,OAAO,EAAEC,MAAM,KAAK;QAC7ED,OAAO,CAACC,MAAM,CAACF,IAAI,CAAC,GAAG;UACnBH,GAAG;UACHE,MAAM;UACNG;QACJ,CAAC;QAED,OAAOD,OAAO;MAClB,CAAC,EAAE,CAAC,CAAC,CAAC;MAEN,OAAOH,QAAQ;IACnB,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,OAAOF,MAAM;EACjB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAACO,OAAA,CAAAV,cAAA,GAAAA,cAAA","ignoreList":[]}