@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.
- package/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +40 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +40 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +40 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +40 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/crud/createContentReviewMethods.js +15 -5
- package/crud/createContentReviewMethods.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +5 -3
- package/index.js.map +1 -1
- package/package.json +32 -32
- package/plugins/cms/index.js +9 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +35 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +35 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +35 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +60 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/graphql/reviewer.gql.js +2 -0
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +28 -8
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/index.js +3 -0
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +20 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +1 -1
- package/plugins/hooks/listContentReviews.js +11 -23
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +22 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +31 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +29 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +51 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/validateChangeRequest.js +28 -3
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +12 -2
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/pageBuilder/index.js +9 -1
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +0 -1
- package/plugins/utils.js +1 -7
- package/plugins/utils.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +18 -2
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +13 -5
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/types.d.ts +21 -9
- 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,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,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,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
|
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
|
-
|
40
|
-
|
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","
|
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
|
-
|
27
|
+
let result;
|
28
|
+
|
29
|
+
try {
|
30
|
+
result = (0, _utils.parseIdentifier)(changeRequestId);
|
26
31
|
|
27
|
-
|
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","
|
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
|