@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.40876133bb

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 (118) 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 +3 -3
  16. package/index.js +5 -3
  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/graphql/reviewer.gql.js +2 -0
  34. package/plugins/graphql/reviewer.gql.js.map +1 -1
  35. package/plugins/hooks/createReviewerFromIdentity.js +28 -8
  36. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  37. package/plugins/hooks/index.js +3 -0
  38. package/plugins/hooks/index.js.map +1 -1
  39. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  40. package/plugins/hooks/initializeNotifications.js +20 -0
  41. package/plugins/hooks/initializeNotifications.js.map +1 -0
  42. package/plugins/hooks/listContentReviews.d.ts +1 -1
  43. package/plugins/hooks/listContentReviews.js +11 -23
  44. package/plugins/hooks/listContentReviews.js.map +1 -1
  45. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  46. package/plugins/hooks/notifications/appUrl.js +22 -0
  47. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  48. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  49. package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
  50. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  51. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  52. package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
  53. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  54. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  55. package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
  56. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  57. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  58. package/plugins/hooks/notifications/commentUrl.js +31 -0
  59. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  60. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  61. package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
  62. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  63. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  64. package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
  65. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  66. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  67. package/plugins/hooks/notifications/contentUrl.js +29 -0
  68. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  69. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  70. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
  71. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  72. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  73. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
  74. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  75. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  76. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
  77. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  78. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  79. package/plugins/hooks/notifications/reviewers.js +51 -0
  80. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  81. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  82. package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
  83. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  84. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  85. package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
  86. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  87. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  88. package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
  89. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  90. package/plugins/hooks/validateChangeRequest.js +28 -3
  91. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  92. package/plugins/hooks/validateComment.js +12 -2
  93. package/plugins/hooks/validateComment.js.map +1 -1
  94. package/plugins/pageBuilder/index.js +9 -1
  95. package/plugins/pageBuilder/index.js.map +1 -1
  96. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  97. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  98. package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
  99. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  100. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  101. package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
  102. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  103. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  104. package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
  105. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  106. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  107. package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
  108. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  109. package/plugins/pageBuilder/utils.js.map +1 -1
  110. package/plugins/utils.d.ts +0 -1
  111. package/plugins/utils.js +1 -7
  112. package/plugins/utils.js.map +1 -1
  113. package/storageOperations/models/reviewer.model.js +18 -2
  114. package/storageOperations/models/reviewer.model.js.map +1 -1
  115. package/storageOperations/reviewerStorageOperations.js +13 -5
  116. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  117. package/types.d.ts +21 -9
  118. package/types.js.map +1 -1
@@ -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"}
@@ -11,6 +11,10 @@ var _error = _interopRequireDefault(require("@webiny/error"));
11
11
 
12
12
  var _handlerGraphql = require("@webiny/handler-graphql");
13
13
 
14
+ var _utils = require("../utils");
15
+
16
+ var _utils2 = require("@webiny/utils");
17
+
14
18
  const validateChangeRequest = ({
15
19
  apw
16
20
  }) => {
@@ -24,7 +28,14 @@ const validateChangeRequest = ({
24
28
  * We need step to be in a particular format i.e. "contentReviewId#version#stepId"
25
29
  */
26
30
 
27
- const [entryId, version, stepId] = step.split("#");
31
+ const {
32
+ id: revisionId,
33
+ stepId
34
+ } = (0, _utils.extractContentReviewIdAndStep)(step);
35
+ const {
36
+ id: entryId,
37
+ version
38
+ } = (0, _utils2.parseIdentifier)(revisionId);
28
39
 
29
40
  if (!entryId || !version || !stepId) {
30
41
  throw new _error.default(`The step property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_STEP", {
@@ -36,8 +47,22 @@ const validateChangeRequest = ({
36
47
  */
37
48
 
38
49
 
39
- const revisionId = `${entryId}#${version}`;
40
- const contentReview = await apw.contentReview.get(revisionId);
50
+ let contentReview = undefined;
51
+
52
+ try {
53
+ contentReview = await apw.contentReview.get(revisionId);
54
+ } catch (ex) {
55
+ /**
56
+ * There is no need to output the log if this is the test environment.
57
+ */
58
+ if (process.env.NODE_ENV !== "test") {
59
+ console.log({
60
+ message: ex.message,
61
+ code: ex.data,
62
+ data: ex.data
63
+ });
64
+ }
65
+ }
41
66
 
42
67
  if (!contentReview) {
43
68
  throw new _handlerGraphql.NotFoundError(`Unable to found "ContentReview" with given id "${revisionId}"`);
@@ -1 +1 @@
1
- {"version":3,"names":["validateChangeRequest","apw","changeRequest","onChangeRequestBeforeCreate","subscribe","input","step","entryId","version","stepId","split","WebinyError","revisionId","contentReview","get","NotFoundError","steps","currentStep","find","id","signOffProvidedOn"],"sources":["validateChangeRequest.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateChangeRequest = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({ input }) => {\n const { step } = input;\n /**\n * We need step to be in a particular format i.e. \"contentReviewId#version#stepId\"\n */\n const [entryId, version, stepId] = step.split(\"#\");\n if (!entryId || !version || !stepId) {\n throw new WebinyError(\n `The step property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_STEP\",\n {\n step\n }\n );\n }\n /**\n * Check whether a contentReview entry exists with provided id.\n */\n const revisionId = `${entryId}#${version}`;\n\n const contentReview = await apw.contentReview.get(revisionId);\n if (!contentReview) {\n throw new NotFoundError(\n `Unable to found \"ContentReview\" with given id \"${revisionId}\"`\n );\n }\n /**\n * Don't allow \"change request\" creation once the sign-off has been provided.\n */\n const { steps } = contentReview;\n const currentStep = steps.find(step => step.id === stepId);\n\n if (currentStep && currentStep.signOffProvidedOn) {\n throw new WebinyError(\n `Please retract the sign-off before opening a new change request.`,\n \"SIGN_OFF_PROVIDED\",\n {\n step: currentStep,\n stepId: stepId\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAWD,KAAjB;IACA;AACR;AACA;;IACQ,MAAM,CAACE,OAAD,EAAUC,OAAV,EAAmBC,MAAnB,IAA6BH,IAAI,CAACI,KAAL,CAAW,GAAX,CAAnC;;IACA,IAAI,CAACH,OAAD,IAAY,CAACC,OAAb,IAAwB,CAACC,MAA7B,EAAqC;MACjC,MAAM,IAAIE,cAAJ,CACD,uDADC,EAEF,+BAFE,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;IACD;AACR;AACA;;;IACQ,MAAMM,UAAU,GAAI,GAAEL,OAAQ,IAAGC,OAAQ,EAAzC;IAEA,MAAMK,aAAa,GAAG,MAAMZ,GAAG,CAACY,aAAJ,CAAkBC,GAAlB,CAAsBF,UAAtB,CAA5B;;IACA,IAAI,CAACC,aAAL,EAAoB;MAChB,MAAM,IAAIE,6BAAJ,CACD,kDAAiDH,UAAW,GAD3D,CAAN;IAGH;IACD;AACR;AACA;;;IACQ,MAAM;MAAEI;IAAF,IAAYH,aAAlB;IACA,MAAMI,WAAW,GAAGD,KAAK,CAACE,IAAN,CAAWZ,IAAI,IAAIA,IAAI,CAACa,EAAL,KAAYV,MAA/B,CAApB;;IAEA,IAAIQ,WAAW,IAAIA,WAAW,CAACG,iBAA/B,EAAkD;MAC9C,MAAM,IAAIT,cAAJ,CACD,kEADC,EAEF,mBAFE,EAGF;QACIL,IAAI,EAAEW,WADV;QAEIR,MAAM,EAAEA;MAFZ,CAHE,CAAN;IAQH;EACJ,CA1CD;AA2CH,CA5CM"}
1
+ {"version":3,"names":["validateChangeRequest","apw","changeRequest","onChangeRequestBeforeCreate","subscribe","input","step","id","revisionId","stepId","extractContentReviewIdAndStep","entryId","version","parseIdentifier","WebinyError","contentReview","undefined","get","ex","process","env","NODE_ENV","console","log","message","code","data","NotFoundError","steps","currentStep","find","signOffProvidedOn"],"sources":["validateChangeRequest.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ApwContentReview, LifeCycleHookCallbackParams } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const validateChangeRequest = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({ input }) => {\n const { step } = input;\n /**\n * We need step to be in a particular format i.e. \"contentReviewId#version#stepId\"\n */\n const { id: revisionId, stepId } = extractContentReviewIdAndStep(step);\n\n const { id: entryId, version } = parseIdentifier(revisionId);\n if (!entryId || !version || !stepId) {\n throw new WebinyError(\n `The step property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_STEP\",\n {\n step\n }\n );\n }\n /**\n * Check whether a contentReview entry exists with provided id.\n */\n let contentReview: ApwContentReview | undefined = undefined;\n try {\n contentReview = await apw.contentReview.get(revisionId);\n } catch (ex) {\n /**\n * There is no need to output the log if this is the test environment.\n */\n if (process.env.NODE_ENV !== \"test\") {\n console.log({\n message: ex.message,\n code: ex.data,\n data: ex.data\n });\n }\n }\n if (!contentReview) {\n throw new NotFoundError(\n `Unable to found \"ContentReview\" with given id \"${revisionId}\"`\n );\n }\n /**\n * Don't allow \"change request\" creation once the sign-off has been provided.\n */\n const { steps } = contentReview;\n const currentStep = steps.find(step => step.id === stepId);\n\n if (currentStep && currentStep.signOffProvidedOn) {\n throw new WebinyError(\n `Please retract the sign-off before opening a new change request.`,\n \"SIGN_OFF_PROVIDED\",\n {\n step: currentStep,\n stepId: stepId\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAWD,KAAjB;IACA;AACR;AACA;;IACQ,MAAM;MAAEE,EAAE,EAAEC,UAAN;MAAkBC;IAAlB,IAA6B,IAAAC,oCAAA,EAA8BJ,IAA9B,CAAnC;IAEA,MAAM;MAAEC,EAAE,EAAEI,OAAN;MAAeC;IAAf,IAA2B,IAAAC,uBAAA,EAAgBL,UAAhB,CAAjC;;IACA,IAAI,CAACG,OAAD,IAAY,CAACC,OAAb,IAAwB,CAACH,MAA7B,EAAqC;MACjC,MAAM,IAAIK,cAAJ,CACD,uDADC,EAEF,+BAFE,EAGF;QACIR;MADJ,CAHE,CAAN;IAOH;IACD;AACR;AACA;;;IACQ,IAAIS,aAA2C,GAAGC,SAAlD;;IACA,IAAI;MACAD,aAAa,GAAG,MAAMd,GAAG,CAACc,aAAJ,CAAkBE,GAAlB,CAAsBT,UAAtB,CAAtB;IACH,CAFD,CAEE,OAAOU,EAAP,EAAW;MACT;AACZ;AACA;MACY,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAA7B,EAAqC;QACjCC,OAAO,CAACC,GAAR,CAAY;UACRC,OAAO,EAAEN,EAAE,CAACM,OADJ;UAERC,IAAI,EAAEP,EAAE,CAACQ,IAFD;UAGRA,IAAI,EAAER,EAAE,CAACQ;QAHD,CAAZ;MAKH;IACJ;;IACD,IAAI,CAACX,aAAL,EAAoB;MAChB,MAAM,IAAIY,6BAAJ,CACD,kDAAiDnB,UAAW,GAD3D,CAAN;IAGH;IACD;AACR;AACA;;;IACQ,MAAM;MAAEoB;IAAF,IAAYb,aAAlB;IACA,MAAMc,WAAW,GAAGD,KAAK,CAACE,IAAN,CAAWxB,IAAI,IAAIA,IAAI,CAACC,EAAL,KAAYE,MAA/B,CAApB;;IAEA,IAAIoB,WAAW,IAAIA,WAAW,CAACE,iBAA/B,EAAkD;MAC9C,MAAM,IAAIjB,cAAJ,CACD,kEADC,EAEF,mBAFE,EAGF;QACIR,IAAI,EAAEuB,WADV;QAEIpB,MAAM,EAAEA;MAFZ,CAHE,CAAN;IAQH;EACJ,CAxDD;AAyDH,CA1DM"}
@@ -9,6 +9,8 @@ exports.validateComment = void 0;
9
9
 
10
10
  var _error = _interopRequireDefault(require("@webiny/error"));
11
11
 
12
+ var _utils = require("@webiny/utils");
13
+
12
14
  const validateComment = ({
13
15
  apw
14
16
  }) => {
@@ -22,9 +24,17 @@ const validateComment = ({
22
24
  * We need changeRequest to be in a particular format i.e. "contentReviewUniqueId#version"
23
25
  */
24
26
 
25
- const [entryId, version] = changeRequestId.split("#");
27
+ let result;
28
+
29
+ try {
30
+ result = (0, _utils.parseIdentifier)(changeRequestId);
26
31
 
27
- if (!entryId || !version) {
32
+ if (!result) {
33
+ throw new _error.default("Could not parse changeRequestId.", "MALFORMED_CHANGE_REQUEST_ID", {
34
+ changeRequestId
35
+ });
36
+ }
37
+ } catch (ex) {
28
38
  throw new _error.default(`The"changeRequest" property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_ID", {
29
39
  input
30
40
  });
@@ -1 +1 @@
1
- {"version":3,"names":["validateComment","apw","comment","onCommentBeforeCreate","subscribe","input","changeRequest","changeRequestId","entryId","version","split","WebinyError","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentBeforeCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n const [entryId, version] = changeRequestId.split(\"#\");\n if (!entryId || !version) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAClFA,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,CAAkCC,SAAlC,CAA4C,OAAO;IAAEC;EAAF,CAAP,KAAqB;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAjB,IAAqCF,KAA3C;IACA;AACR;AACA;;IACQ,MAAM,CAACG,OAAD,EAAUC,OAAV,IAAqBF,eAAe,CAACG,KAAhB,CAAsB,GAAtB,CAA3B;;IACA,IAAI,CAACF,OAAD,IAAY,CAACC,OAAjB,EAA0B;MACtB,MAAM,IAAIE,cAAJ,CACD,iEADC,EAEF,6BAFE,EAGF;QACIN;MADJ,CAHE,CAAN;IAOH;IAED;AACR;AACA;;;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAJ,CAAkBM,GAAlB,CAAsBL,eAAtB,CAA5B;;IACA,IAAI,CAACD,aAAL,EAAoB;MAChB;IACH;;IACDD,KAAK,CAACQ,IAAN,GAAaP,aAAa,CAACO,IAA3B;EACH,CAxBD;AAyBH,CA1BM"}
1
+ {"version":3,"names":["validateComment","apw","comment","onCommentBeforeCreate","subscribe","input","changeRequest","changeRequestId","result","parseIdentifier","WebinyError","ex","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\nimport { parseIdentifier, ParseIdentifierResult } from \"@webiny/utils\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentBeforeCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n let result: ParseIdentifierResult;\n try {\n result = parseIdentifier(changeRequestId);\n if (!result) {\n throw new WebinyError(\n \"Could not parse changeRequestId.\",\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n changeRequestId\n }\n );\n }\n } catch (ex) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAClFA,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,CAAkCC,SAAlC,CAA4C,OAAO;IAAEC;EAAF,CAAP,KAAqB;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAjB,IAAqCF,KAA3C;IACA;AACR;AACA;;IACQ,IAAIG,MAAJ;;IACA,IAAI;MACAA,MAAM,GAAG,IAAAC,sBAAA,EAAgBF,eAAhB,CAAT;;MACA,IAAI,CAACC,MAAL,EAAa;QACT,MAAM,IAAIE,cAAJ,CACF,kCADE,EAEF,6BAFE,EAGF;UACIH;QADJ,CAHE,CAAN;MAOH;IACJ,CAXD,CAWE,OAAOI,EAAP,EAAW;MACT,MAAM,IAAID,cAAJ,CACD,iEADC,EAEF,6BAFE,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;IAED;AACR;AACA;;;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAJ,CAAkBM,GAAlB,CAAsBL,eAAtB,CAA5B;;IACA,IAAI,CAACD,aAAL,EAAoB;MAChB;IACH;;IACDD,KAAK,CAACQ,IAAN,GAAaP,aAAa,CAACO,IAA3B;EACH,CAnCD;AAoCH,CArCM"}
@@ -15,6 +15,14 @@ var _linkWorkflowToPage = require("./linkWorkflowToPage");
15
15
 
16
16
  var _PageApwSettingsGetterPlugin = require("./PageApwSettingsGetterPlugin");
17
17
 
18
+ var _commentNotification = require("./notifications/commentNotification");
19
+
20
+ var _contentUrl = require("./notifications/contentUrl");
21
+
22
+ var _changeRequestNotification = require("./notifications/changeRequestNotification");
23
+
24
+ var _contentReviewNotification = require("./notifications/contentReviewNotification");
25
+
18
26
  const apwPageBuilderHooks = params => {
19
27
  const {
20
28
  pageBuilder,
@@ -22,7 +30,7 @@ const apwPageBuilderHooks = params => {
22
30
  security,
23
31
  plugins
24
32
  } = params;
25
- plugins.register(new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin());
33
+ plugins.register([new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin(), (0, _commentNotification.createCommentNotification)(), (0, _changeRequestNotification.createChangeRequestNotification)(), (0, _contentUrl.createContentUrlPlugin)(), (0, _contentReviewNotification.createContentReviewNotification)()]);
26
34
  (0, _triggerContentReview.triggerContentReview)({
27
35
  apw,
28
36
  pageBuilder