@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.3386f66516

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 (125) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +40 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +40 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +40 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +40 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/crud/createContentReviewMethods.js +15 -5
  14. package/crud/createContentReviewMethods.js.map +1 -1
  15. package/index.d.ts +2 -3
  16. package/index.js +5 -9
  17. package/index.js.map +1 -1
  18. package/package.json +32 -32
  19. package/plugins/cms/index.js +9 -1
  20. package/plugins/cms/index.js.map +1 -1
  21. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  22. package/plugins/cms/notifications/changeRequestNotification.js +35 -0
  23. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  24. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  25. package/plugins/cms/notifications/commentNotification.js +35 -0
  26. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  27. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  28. package/plugins/cms/notifications/contentReviewNotification.js +35 -0
  29. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  30. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  31. package/plugins/cms/notifications/contentUrl.js +60 -0
  32. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  33. package/plugins/context.d.ts +0 -1
  34. package/plugins/context.js +2 -19
  35. package/plugins/context.js.map +1 -1
  36. package/plugins/graphql/reviewer.gql.js +2 -0
  37. package/plugins/graphql/reviewer.gql.js.map +1 -1
  38. package/plugins/graphql.js +2 -2
  39. package/plugins/graphql.js.map +1 -1
  40. package/plugins/hooks/createReviewerFromIdentity.js +28 -8
  41. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  42. package/plugins/hooks/index.js +3 -0
  43. package/plugins/hooks/index.js.map +1 -1
  44. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  45. package/plugins/hooks/initializeNotifications.js +20 -0
  46. package/plugins/hooks/initializeNotifications.js.map +1 -0
  47. package/plugins/hooks/listContentReviews.d.ts +1 -1
  48. package/plugins/hooks/listContentReviews.js +11 -23
  49. package/plugins/hooks/listContentReviews.js.map +1 -1
  50. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  51. package/plugins/hooks/notifications/appUrl.js +22 -0
  52. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  53. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  54. package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
  55. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  56. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  57. package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
  58. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  59. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  60. package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
  61. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  62. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  63. package/plugins/hooks/notifications/commentUrl.js +31 -0
  64. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  65. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  66. package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
  67. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  68. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  69. package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
  70. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  71. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  72. package/plugins/hooks/notifications/contentUrl.js +29 -0
  73. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  74. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  75. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
  76. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  77. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  78. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
  79. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  80. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  81. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
  82. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  83. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  84. package/plugins/hooks/notifications/reviewers.js +51 -0
  85. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  86. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  87. package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
  88. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  89. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  90. package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
  91. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  92. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  93. package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
  94. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  95. package/plugins/hooks/validateChangeRequest.js +28 -3
  96. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  97. package/plugins/hooks/validateComment.js +12 -2
  98. package/plugins/hooks/validateComment.js.map +1 -1
  99. package/plugins/pageBuilder/index.js +9 -1
  100. package/plugins/pageBuilder/index.js.map +1 -1
  101. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  102. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  103. package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
  104. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  105. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  106. package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
  107. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  108. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  109. package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
  110. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  111. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  112. package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
  113. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  114. package/plugins/pageBuilder/utils.js.map +1 -1
  115. package/plugins/utils.d.ts +0 -1
  116. package/plugins/utils.js +1 -7
  117. package/plugins/utils.js.map +1 -1
  118. package/storageOperations/models/reviewer.model.js +18 -2
  119. package/storageOperations/models/reviewer.model.js.map +1 -1
  120. package/storageOperations/reviewerStorageOperations.js +13 -5
  121. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  122. package/storageOperations/workflowStorageOperations.js +3 -1
  123. package/storageOperations/workflowStorageOperations.js.map +1 -1
  124. package/types.d.ts +21 -9
  125. package/types.js.map +1 -1
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.attachContentReviewAfterCreate = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _appUrl = require("./appUrl");
13
+
14
+ var _contentReviewUrl = require("./contentReviewUrl");
15
+
16
+ var _contentUrl = require("./contentUrl");
17
+
18
+ var _reviewers = require("./reviewers");
19
+
20
+ var _sendContentReviewNotification = require("./sendContentReviewNotification");
21
+
22
+ const attachContentReviewAfterCreate = context => {
23
+ context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
24
+ contentReview
25
+ }) => {
26
+ const execute = async () => {
27
+ if (contentReview.steps.length === 0) {
28
+ return;
29
+ }
30
+
31
+ const [step] = contentReview.steps;
32
+
33
+ if (!(step !== null && step !== void 0 && step.id)) {
34
+ return;
35
+ }
36
+
37
+ const settings = await (0, _appUrl.getAppUrl)(context);
38
+
39
+ if (!settings) {
40
+ return;
41
+ }
42
+
43
+ const contentReviewUrl = (0, _contentReviewUrl.createContentReviewUrl)({
44
+ baseUrl: settings.appUrl,
45
+ contentReviewId: contentReview.id,
46
+ stepId: step.id
47
+ });
48
+
49
+ if (!contentReviewUrl) {
50
+ return;
51
+ }
52
+ /**
53
+ * We go and check the workflow.
54
+ */
55
+
56
+
57
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
58
+
59
+ if (!workflow) {
60
+ throw new _error.default(`There is no workflow with Id "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
61
+ workflowId: contentReview.workflowId
62
+ });
63
+ }
64
+
65
+ const contentUrl = (0, _contentUrl.createContentUrl)({
66
+ plugins: context.plugins,
67
+ baseUrl: settings.appUrl,
68
+ contentReview,
69
+ workflow
70
+ });
71
+
72
+ if (!contentUrl) {
73
+ return;
74
+ }
75
+
76
+ const reviewers = await (0, _reviewers.fetchReviewers)({
77
+ context,
78
+ workflow,
79
+ exclude: [contentReview.createdBy.id]
80
+ });
81
+
82
+ if (reviewers.length === 0) {
83
+ return;
84
+ }
85
+
86
+ try {
87
+ await (0, _sendContentReviewNotification.sendContentReviewNotification)({
88
+ context,
89
+ reviewers,
90
+ contentReview,
91
+ workflow,
92
+ contentReviewUrl,
93
+ contentUrl
94
+ });
95
+ } catch (ex) {
96
+ throw new _error.default(`Could not send content review notifications.`, "CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT", {
97
+ workflowId: workflow.id,
98
+ contentReviewId: contentReview.id,
99
+ contentReviewUrl,
100
+ contentUrl,
101
+ error: {
102
+ message: ex.message,
103
+ code: ex.code,
104
+ data: ex.data,
105
+ stack: ex.stack
106
+ }
107
+ });
108
+ }
109
+ };
110
+
111
+ try {
112
+ context.security.disableAuthorization();
113
+ await execute();
114
+ } catch (ex) {
115
+ throw ex;
116
+ } finally {
117
+ context.security.enableAuthorization();
118
+ }
119
+ });
120
+ };
121
+
122
+ exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","disableAuthorization","enableAuthorization"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./appUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\n }\n });\n};\n"],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ interface Params {
2
+ baseUrl?: string;
3
+ contentReviewId: string;
4
+ stepId: string;
5
+ }
6
+ export declare const createContentReviewUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewUrl = void 0;
7
+
8
+ const createContentReviewUrl = params => {
9
+ /**
10
+ * All variables must exist for URL to be created.
11
+ * We go through all vars and throw a log if it does not exist.
12
+ */
13
+ for (const key in params) {
14
+ if (!!key) {
15
+ continue;
16
+ }
17
+
18
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
19
+ return null;
20
+ }
21
+
22
+ const {
23
+ baseUrl,
24
+ contentReviewId,
25
+ stepId
26
+ } = params;
27
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;
28
+ };
29
+
30
+ exports.createContentReviewUrl = createContentReviewUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentReviewUrl","params","key","console","log","baseUrl","contentReviewId","stepId"],"sources":["contentReviewUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createContentReviewUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;\n};\n"],"mappings":";;;;;;;AAKO,MAAMA,sBAAsB,GAAIC,MAAD,IAAoB;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,0CAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC,eAAX;IAA4BC;EAA5B,IAAuCN,MAA7C;EAEA,OAAQ,GAAEI,OAAQ,wBAAuBC,eAAgB,IAAGC,MAAO,EAAnE;AACH,CAfM"}
@@ -0,0 +1,7 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ApwContentUrlPluginCbParams } from "../../../ApwContentUrlPlugin";
3
+ interface Params extends ApwContentUrlPluginCbParams {
4
+ plugins: PluginsContainer;
5
+ }
6
+ export declare const createContentUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrl = void 0;
7
+
8
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
9
+
10
+ const createContentUrl = params => {
11
+ const {
12
+ plugins,
13
+ contentReview
14
+ } = params;
15
+ const {
16
+ type: contentType
17
+ } = contentReview.content;
18
+ const [contentUrlPlugin] = plugins.byType(_ApwContentUrlPlugin.ApwContentUrlPlugin.type).filter(plugin => {
19
+ return plugin.canUse(contentType);
20
+ }).reverse();
21
+
22
+ if (!contentUrlPlugin) {
23
+ return null;
24
+ }
25
+
26
+ return contentUrlPlugin.create(params);
27
+ };
28
+
29
+ exports.createContentUrl = createContentUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentUrl","params","plugins","contentReview","type","contentType","content","contentUrlPlugin","byType","ApwContentUrlPlugin","filter","plugin","canUse","reverse","create"],"sources":["contentUrl.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ApwContentUrlPlugin, ApwContentUrlPluginCbParams } from \"~/ApwContentUrlPlugin\";\n\ninterface Params extends ApwContentUrlPluginCbParams {\n plugins: PluginsContainer;\n}\n\nexport const createContentUrl = (params: Params): string | null => {\n const { plugins, contentReview } = params;\n\n const { type: contentType } = contentReview.content;\n\n const [contentUrlPlugin] = plugins\n .byType<ApwContentUrlPlugin>(ApwContentUrlPlugin.type)\n .filter(plugin => {\n return plugin.canUse(contentType);\n })\n .reverse();\n if (!contentUrlPlugin) {\n return null;\n }\n\n return contentUrlPlugin.create(params);\n};\n"],"mappings":";;;;;;;AACA;;AAMO,MAAMA,gBAAgB,GAAIC,MAAD,IAAmC;EAC/D,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAA6BF,MAAnC;EAEA,MAAM;IAAEG,IAAI,EAAEC;EAAR,IAAwBF,aAAa,CAACG,OAA5C;EAEA,MAAM,CAACC,gBAAD,IAAqBL,OAAO,CAC7BM,MADsB,CACMC,wCAAA,CAAoBL,IAD1B,EAEtBM,MAFsB,CAEfC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcP,WAAd,CAAP;EACH,CAJsB,EAKtBQ,OALsB,EAA3B;;EAMA,IAAI,CAACN,gBAAL,EAAuB;IACnB,OAAO,IAAP;EACH;;EAED,OAAOA,gBAAgB,CAACO,MAAjB,CAAwBb,MAAxB,CAAP;AACH,CAhBM"}
@@ -0,0 +1,11 @@
1
+ import { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwChangeRequestNotification } from "../../../ApwChangeRequestNotification";
3
+ interface GetLastChangeRequestNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastChangeRequestNotificationPlugin {
8
+ (params: GetLastChangeRequestNotificationPluginParams): ApwChangeRequestNotification | undefined;
9
+ }
10
+ export declare const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin;
11
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastChangeRequestNotificationPlugin = void 0;
7
+
8
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
9
+
10
+ const getLastChangeRequestNotificationPlugin = params => {
11
+ const {
12
+ context,
13
+ type
14
+ } = params;
15
+ /**
16
+ * We need the plugin to create the notification text.
17
+ */
18
+
19
+ const plugins = context.plugins.byType(_ApwChangeRequestNotification.ApwChangeRequestNotification.type).filter(plugin => {
20
+ return plugin.canUse(type);
21
+ });
22
+ return plugins.shift();
23
+ };
24
+
25
+ exports.getLastChangeRequestNotificationPlugin = getLastChangeRequestNotificationPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLastChangeRequestNotificationPlugin","params","context","type","plugins","byType","ApwChangeRequestNotification","filter","plugin","canUse","shift"],"sources":["lastChangeRequestNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\ninterface GetLastChangeRequestNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastChangeRequestNotificationPlugin {\n (params: GetLastChangeRequestNotificationPluginParams):\n | ApwChangeRequestNotification\n | undefined;\n}\nexport const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwChangeRequestNotification>(ApwChangeRequestNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;;AACA;;AAWO,MAAMA,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACR;AACA;;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CAC0BC,0DAAA,CAA6BH,IADvD,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAbE"}
@@ -0,0 +1,11 @@
1
+ import { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwCommentNotification } from "../../../ApwCommentNotification";
3
+ interface GetLastCommentNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastCommentNotificationPlugin {
8
+ (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;
9
+ }
10
+ export declare const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin;
11
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastCommentNotificationPlugin = void 0;
7
+
8
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
9
+
10
+ const getLastCommentNotificationPlugin = params => {
11
+ const {
12
+ context,
13
+ type
14
+ } = params;
15
+ /**
16
+ * We need the plugin to create the notification text.
17
+ */
18
+
19
+ const plugins = context.plugins.byType(_ApwCommentNotification.ApwCommentNotification.type).filter(plugin => {
20
+ return plugin.canUse(type);
21
+ });
22
+ return plugins.shift();
23
+ };
24
+
25
+ exports.getLastCommentNotificationPlugin = getLastCommentNotificationPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLastCommentNotificationPlugin","params","context","type","plugins","byType","ApwCommentNotification","filter","plugin","canUse","shift"],"sources":["lastCommentNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwCommentNotification } from \"~/ApwCommentNotification\";\n\ninterface GetLastCommentNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastCommentNotificationPlugin {\n (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;\n}\nexport const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin = params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwCommentNotification>(ApwCommentNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n};\n"],"mappings":";;;;;;;AACA;;AASO,MAAMA,gCAAkE,GAAGC,MAAM,IAAI;EACxF,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACJ;AACA;;EACI,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CACoBC,8CAAA,CAAuBH,IAD3C,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAZM"}
@@ -0,0 +1,11 @@
1
+ import { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwContentReviewNotification } from "../../../ApwContentReviewNotification";
3
+ interface GetLastContentReviewNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastContentReviewNotificationPlugin {
8
+ (params: GetLastContentReviewNotificationPluginParams): ApwContentReviewNotification | undefined;
9
+ }
10
+ export declare const getLastContentReviewNotificationPlugin: GetLastContentReviewNotificationPlugin;
11
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastContentReviewNotificationPlugin = void 0;
7
+
8
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
9
+
10
+ const getLastContentReviewNotificationPlugin = params => {
11
+ const {
12
+ context,
13
+ type
14
+ } = params;
15
+ /**
16
+ * We need the plugin to create the notification text.
17
+ */
18
+
19
+ const plugins = context.plugins.byType(_ApwContentReviewNotification.ApwContentReviewNotification.type).filter(plugin => {
20
+ return plugin.canUse(type);
21
+ });
22
+ return plugins.shift();
23
+ };
24
+
25
+ exports.getLastContentReviewNotificationPlugin = getLastContentReviewNotificationPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLastContentReviewNotificationPlugin","params","context","type","plugins","byType","ApwContentReviewNotification","filter","plugin","canUse","shift"],"sources":["lastContentReviewNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\ninterface GetLastContentReviewNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastContentReviewNotificationPlugin {\n (params: GetLastContentReviewNotificationPluginParams):\n | ApwContentReviewNotification\n | undefined;\n}\nexport const getLastContentReviewNotificationPlugin: GetLastContentReviewNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwContentReviewNotification>(ApwContentReviewNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;;AACA;;AAWO,MAAMA,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACR;AACA;;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CAC0BC,0DAAA,CAA6BH,IADvD,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAbE"}
@@ -0,0 +1,15 @@
1
+ import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from "../../../types";
2
+ interface GetReviewerIdListParams {
3
+ steps: ApwWorkflowStep[];
4
+ }
5
+ interface GetReviewerIdList {
6
+ (params: GetReviewerIdListParams): string[];
7
+ }
8
+ export declare const getReviewerIdList: GetReviewerIdList;
9
+ interface FetchReviewersParams {
10
+ context: ApwContext;
11
+ workflow: ApwWorkflow;
12
+ exclude: string[];
13
+ }
14
+ export declare const fetchReviewers: (params: FetchReviewersParams) => Promise<ApwReviewerWithEmail[]>;
15
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getReviewerIdList = exports.fetchReviewers = void 0;
7
+
8
+ const getReviewerIdList = ({
9
+ steps
10
+ }) => {
11
+ return steps.reduce((collection, step) => {
12
+ for (const reviewer of step.reviewers) {
13
+ if (collection.includes(reviewer.id)) {
14
+ return collection;
15
+ }
16
+
17
+ collection.push(reviewer.id);
18
+ }
19
+
20
+ return collection;
21
+ }, []);
22
+ };
23
+
24
+ exports.getReviewerIdList = getReviewerIdList;
25
+
26
+ const fetchReviewers = async params => {
27
+ const {
28
+ context,
29
+ workflow,
30
+ exclude
31
+ } = params;
32
+ const idList = getReviewerIdList(workflow);
33
+ context.security.disableAuthorization();
34
+ const [reviewers] = await context.apw.reviewer.list({
35
+ where: {
36
+ id_in: idList
37
+ },
38
+ limit: 10000
39
+ });
40
+ return reviewers.filter(item => {
41
+ if (!item.email) {
42
+ return false;
43
+ } else if (exclude.includes(item.identityId)) {
44
+ return false;
45
+ }
46
+
47
+ return true;
48
+ });
49
+ };
50
+
51
+ exports.fetchReviewers = fetchReviewers;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getReviewerIdList","steps","reduce","collection","step","reviewer","reviewers","includes","id","push","fetchReviewers","params","context","workflow","exclude","idList","security","disableAuthorization","apw","list","where","id_in","limit","filter","item","email","identityId"],"sources":["reviewers.ts"],"sourcesContent":["import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from \"~/types\";\n\ninterface GetReviewerIdListParams {\n steps: ApwWorkflowStep[];\n}\ninterface GetReviewerIdList {\n (params: GetReviewerIdListParams): string[];\n}\nexport const getReviewerIdList: GetReviewerIdList = ({ steps }) => {\n return steps.reduce<string[]>((collection, step) => {\n for (const reviewer of step.reviewers) {\n if (collection.includes(reviewer.id)) {\n return collection;\n }\n collection.push(reviewer.id);\n }\n\n return collection;\n }, []);\n};\n\ninterface FetchReviewersParams {\n context: ApwContext;\n workflow: ApwWorkflow;\n exclude: string[];\n}\nexport const fetchReviewers = async (\n params: FetchReviewersParams\n): Promise<ApwReviewerWithEmail[]> => {\n const { context, workflow, exclude } = params;\n\n const idList = getReviewerIdList(workflow);\n\n context.security.disableAuthorization();\n\n const [reviewers] = await context.apw.reviewer.list({\n where: {\n id_in: idList\n },\n limit: 10000\n });\n return reviewers.filter(item => {\n if (!item.email) {\n return false;\n } else if (exclude.includes(item.identityId)) {\n return false;\n }\n\n return true;\n }) as ApwReviewerWithEmail[];\n};\n"],"mappings":";;;;;;;AAQO,MAAMA,iBAAoC,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAe;EAC/D,OAAOA,KAAK,CAACC,MAAN,CAAuB,CAACC,UAAD,EAAaC,IAAb,KAAsB;IAChD,KAAK,MAAMC,QAAX,IAAuBD,IAAI,CAACE,SAA5B,EAAuC;MACnC,IAAIH,UAAU,CAACI,QAAX,CAAoBF,QAAQ,CAACG,EAA7B,CAAJ,EAAsC;QAClC,OAAOL,UAAP;MACH;;MACDA,UAAU,CAACM,IAAX,CAAgBJ,QAAQ,CAACG,EAAzB;IACH;;IAED,OAAOL,UAAP;EACH,CATM,EASJ,EATI,CAAP;AAUH,CAXM;;;;AAkBA,MAAMO,cAAc,GAAG,MAC1BC,MAD0B,IAEQ;EAClC,MAAM;IAAEC,OAAF;IAAWC,QAAX;IAAqBC;EAArB,IAAiCH,MAAvC;EAEA,MAAMI,MAAM,GAAGf,iBAAiB,CAACa,QAAD,CAAhC;EAEAD,OAAO,CAACI,QAAR,CAAiBC,oBAAjB;EAEA,MAAM,CAACX,SAAD,IAAc,MAAMM,OAAO,CAACM,GAAR,CAAYb,QAAZ,CAAqBc,IAArB,CAA0B;IAChDC,KAAK,EAAE;MACHC,KAAK,EAAEN;IADJ,CADyC;IAIhDO,KAAK,EAAE;EAJyC,CAA1B,CAA1B;EAMA,OAAOhB,SAAS,CAACiB,MAAV,CAAiBC,IAAI,IAAI;IAC5B,IAAI,CAACA,IAAI,CAACC,KAAV,EAAiB;MACb,OAAO,KAAP;IACH,CAFD,MAEO,IAAIX,OAAO,CAACP,QAAR,CAAiBiB,IAAI,CAACE,UAAtB,CAAJ,EAAuC;MAC1C,OAAO,KAAP;IACH;;IAED,OAAO,IAAP;EACH,CARM,CAAP;AASH,CAxBM"}
@@ -0,0 +1,2 @@
1
+ import { ApwChangeRequestNotificationCbParams } from "../../../ApwChangeRequestNotification";
2
+ export declare const sendChangeRequestNotification: (params: ApwChangeRequestNotificationCbParams) => Promise<void>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendChangeRequestNotification = void 0;
7
+
8
+ var _lastChangeRequestNotificationPlugin = require("./lastChangeRequestNotificationPlugin");
9
+
10
+ const sendChangeRequestNotification = async params => {
11
+ const {
12
+ context,
13
+ reviewers,
14
+ contentReview
15
+ } = params;
16
+
17
+ if (reviewers.length === 0) {
18
+ return;
19
+ }
20
+
21
+ const changeRequestPlugin = (0, _lastChangeRequestNotificationPlugin.getLastChangeRequestNotificationPlugin)({
22
+ context,
23
+ type: contentReview.content.type
24
+ });
25
+
26
+ if (!changeRequestPlugin) {
27
+ console.log("No e-mail body change request plugin.");
28
+ return;
29
+ }
30
+
31
+ const body = changeRequestPlugin.create(params);
32
+
33
+ if (!body) {
34
+ console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);
35
+ return;
36
+ }
37
+
38
+ const result = await context.mailer.sendMail({
39
+ bcc: reviewers.map(r => r.email),
40
+ subject: "There is a new change request on the Content Review you are assigned on.",
41
+ text: body.text,
42
+ html: body.html || body.text
43
+ });
44
+
45
+ if (!result.error) {
46
+ return;
47
+ }
48
+
49
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
50
+ };
51
+
52
+ exports.sendChangeRequestNotification = sendChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendChangeRequestNotification","params","context","reviewers","contentReview","length","changeRequestPlugin","getLastChangeRequestNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendChangeRequestNotification.ts"],"sourcesContent":["import { getLastChangeRequestNotificationPlugin } from \"./lastChangeRequestNotificationPlugin\";\nimport { ApwChangeRequestNotificationCbParams } from \"~/ApwChangeRequestNotification\";\n\nexport const sendChangeRequestNotification = async (\n params: ApwChangeRequestNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const changeRequestPlugin = getLastChangeRequestNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!changeRequestPlugin) {\n console.log(\"No e-mail body change request plugin.\");\n return;\n }\n\n const body = changeRequestPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new change request on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,6BAA6B,GAAG,MACzCC,MADyC,IAEzB;EAChB,MAAM;IAAEC,OAAF;IAAWC,SAAX;IAAsBC;EAAtB,IAAwCH,MAA9C;;EACA,IAAIE,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B;IACxB;EACH;;EAED,MAAMC,mBAAmB,GAAG,IAAAC,2EAAA,EAAuC;IAC/DL,OAD+D;IAE/DM,IAAI,EAAEJ,aAAa,CAACK,OAAd,CAAsBD;EAFmC,CAAvC,CAA5B;;EAIA,IAAI,CAACF,mBAAL,EAA0B;IACtBI,OAAO,CAACC,GAAR,CAAY,uCAAZ;IACA;EACH;;EAED,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAApB,CAA2BZ,MAA3B,CAAb;;EACA,IAAI,CAACW,IAAL,EAAW;IACPF,OAAO,CAACC,GAAR,CAAa,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAvF;IACA;EACH;;EAED,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAR,CAAeC,QAAf,CAAwB;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAV,CAAcC,CAAC,IAAIA,CAAC,CAACC,KAArB,CADoC;IAEzCC,OAAO,EAAE,0EAFgC;IAGzCC,IAAI,EAAEX,IAAI,CAACW,IAH8B;IAIzCC,IAAI,EAAEZ,IAAI,CAACY,IAAL,IAAaZ,IAAI,CAACW;EAJiB,CAAxB,CAArB;;EAMA,IAAI,CAACR,MAAM,CAACU,KAAZ,EAAmB;IACf;EACH;;EACDf,OAAO,CAACC,GAAR,CAAY,4BAAZ,EAA0Ce,IAAI,CAACC,SAAL,CAAeZ,MAAM,CAACU,KAAtB,CAA1C;AACH,CAjCM"}
@@ -0,0 +1,2 @@
1
+ import { ApwCommentNotificationCbParams } from "../../../ApwCommentNotification";
2
+ export declare const sendCommentNotification: (params: ApwCommentNotificationCbParams) => Promise<void>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendCommentNotification = void 0;
7
+
8
+ var _lastCommentNotificationPlugin = require("./lastCommentNotificationPlugin");
9
+
10
+ const sendCommentNotification = async params => {
11
+ const {
12
+ context,
13
+ reviewers,
14
+ contentReview
15
+ } = params;
16
+
17
+ if (reviewers.length === 0) {
18
+ return;
19
+ }
20
+
21
+ const commentPlugin = (0, _lastCommentNotificationPlugin.getLastCommentNotificationPlugin)({
22
+ context,
23
+ type: contentReview.content.type
24
+ });
25
+
26
+ if (!commentPlugin) {
27
+ console.log("No e-mail body comment plugin.");
28
+ return;
29
+ }
30
+
31
+ const body = commentPlugin.create(params);
32
+
33
+ if (!body) {
34
+ console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);
35
+ return;
36
+ }
37
+
38
+ const result = await context.mailer.sendMail({
39
+ bcc: reviewers.map(r => r.email),
40
+ subject: "There is a new comment on the Content Review you are assigned on.",
41
+ text: body.text,
42
+ html: body.html || body.text
43
+ });
44
+
45
+ if (!result.error) {
46
+ return;
47
+ }
48
+
49
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
50
+ };
51
+
52
+ exports.sendCommentNotification = sendCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendCommentNotification","params","context","reviewers","contentReview","length","commentPlugin","getLastCommentNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendCommentNotification.ts"],"sourcesContent":["import { getLastCommentNotificationPlugin } from \"./lastCommentNotificationPlugin\";\nimport { ApwCommentNotificationCbParams } from \"~/ApwCommentNotification\";\n\nexport const sendCommentNotification = async (\n params: ApwCommentNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const commentPlugin = getLastCommentNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!commentPlugin) {\n console.log(\"No e-mail body comment plugin.\");\n return;\n }\n\n const body = commentPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new comment on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,uBAAuB,GAAG,MACnCC,MADmC,IAEnB;EAChB,MAAM;IAAEC,OAAF;IAAWC,SAAX;IAAsBC;EAAtB,IAAwCH,MAA9C;;EACA,IAAIE,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B;IACxB;EACH;;EAED,MAAMC,aAAa,GAAG,IAAAC,+DAAA,EAAiC;IACnDL,OADmD;IAEnDM,IAAI,EAAEJ,aAAa,CAACK,OAAd,CAAsBD;EAFuB,CAAjC,CAAtB;;EAIA,IAAI,CAACF,aAAL,EAAoB;IAChBI,OAAO,CAACC,GAAR,CAAY,gCAAZ;IACA;EACH;;EAED,MAAMC,IAAI,GAAGN,aAAa,CAACO,MAAd,CAAqBZ,MAArB,CAAb;;EACA,IAAI,CAACW,IAAL,EAAW;IACPF,OAAO,CAACC,GAAR,CAAa,2CAA0CL,aAAa,CAACQ,IAAK,EAA1E;IACA;EACH;;EAED,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAR,CAAeC,QAAf,CAAwB;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAV,CAAcC,CAAC,IAAIA,CAAC,CAACC,KAArB,CADoC;IAEzCC,OAAO,EAAE,mEAFgC;IAGzCC,IAAI,EAAEX,IAAI,CAACW,IAH8B;IAIzCC,IAAI,EAAEZ,IAAI,CAACY,IAAL,IAAaZ,IAAI,CAACW;EAJiB,CAAxB,CAArB;;EAMA,IAAI,CAACR,MAAM,CAACU,KAAZ,EAAmB;IACf;EACH;;EACDf,OAAO,CAACC,GAAR,CAAY,4BAAZ,EAA0Ce,IAAI,CAACC,SAAL,CAAeZ,MAAM,CAACU,KAAtB,CAA1C;AACH,CAjCM"}
@@ -0,0 +1,2 @@
1
+ import { ApwContentReviewNotificationCbParams } from "../../../ApwContentReviewNotification";
2
+ export declare const sendContentReviewNotification: (params: ApwContentReviewNotificationCbParams) => Promise<void>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendContentReviewNotification = void 0;
7
+
8
+ var _lastContentReviewNotificationPlugin = require("./lastContentReviewNotificationPlugin");
9
+
10
+ const sendContentReviewNotification = async params => {
11
+ const {
12
+ context,
13
+ reviewers,
14
+ contentReview
15
+ } = params;
16
+
17
+ if (reviewers.length === 0) {
18
+ return;
19
+ }
20
+
21
+ const contentReviewPlugin = (0, _lastContentReviewNotificationPlugin.getLastContentReviewNotificationPlugin)({
22
+ context,
23
+ type: contentReview.content.type
24
+ });
25
+
26
+ if (!contentReviewPlugin) {
27
+ console.log("No e-mail body content review plugin.");
28
+ return;
29
+ }
30
+
31
+ const body = contentReviewPlugin.create(params);
32
+
33
+ if (!body) {
34
+ console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);
35
+ return;
36
+ }
37
+
38
+ const result = await context.mailer.sendMail({
39
+ bcc: reviewers.map(r => r.email),
40
+ subject: "There is a new content review which you are assigned on.",
41
+ text: body.text,
42
+ html: body.html || body.text
43
+ });
44
+
45
+ if (!result.error) {
46
+ return;
47
+ }
48
+
49
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
50
+ };
51
+
52
+ exports.sendContentReviewNotification = sendContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendContentReviewNotification","params","context","reviewers","contentReview","length","contentReviewPlugin","getLastContentReviewNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendContentReviewNotification.ts"],"sourcesContent":["import { getLastContentReviewNotificationPlugin } from \"./lastContentReviewNotificationPlugin\";\nimport { ApwContentReviewNotificationCbParams } from \"~/ApwContentReviewNotification\";\n\nexport const sendContentReviewNotification = async (\n params: ApwContentReviewNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const contentReviewPlugin = getLastContentReviewNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!contentReviewPlugin) {\n console.log(\"No e-mail body content review plugin.\");\n return;\n }\n\n const body = contentReviewPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new content review which you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,6BAA6B,GAAG,MACzCC,MADyC,IAEzB;EAChB,MAAM;IAAEC,OAAF;IAAWC,SAAX;IAAsBC;EAAtB,IAAwCH,MAA9C;;EACA,IAAIE,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B;IACxB;EACH;;EAED,MAAMC,mBAAmB,GAAG,IAAAC,2EAAA,EAAuC;IAC/DL,OAD+D;IAE/DM,IAAI,EAAEJ,aAAa,CAACK,OAAd,CAAsBD;EAFmC,CAAvC,CAA5B;;EAIA,IAAI,CAACF,mBAAL,EAA0B;IACtBI,OAAO,CAACC,GAAR,CAAY,uCAAZ;IACA;EACH;;EAED,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAApB,CAA2BZ,MAA3B,CAAb;;EACA,IAAI,CAACW,IAAL,EAAW;IACPF,OAAO,CAACC,GAAR,CAAa,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAvF;IACA;EACH;;EAED,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAR,CAAeC,QAAf,CAAwB;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAV,CAAcC,CAAC,IAAIA,CAAC,CAACC,KAArB,CADoC;IAEzCC,OAAO,EAAE,0DAFgC;IAGzCC,IAAI,EAAEX,IAAI,CAACW,IAH8B;IAIzCC,IAAI,EAAEZ,IAAI,CAACY,IAAL,IAAaZ,IAAI,CAACW;EAJiB,CAAxB,CAArB;;EAMA,IAAI,CAACR,MAAM,CAACU,KAAZ,EAAmB;IACf;EACH;;EACDf,OAAO,CAACC,GAAR,CAAY,4BAAZ,EAA0Ce,IAAI,CAACC,SAAL,CAAeZ,MAAM,CAACU,KAAtB,CAA1C;AACH,CAjCM"}