@webiny/api-apw 5.39.0-beta.1 → 5.39.0-beta.2
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.js +1 -5
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +1 -5
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +1 -5
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +1 -5
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +3 -4
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createContentReviewMethods.js +37 -28
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/index.js +3 -4
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -5
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +27 -27
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +2 -4
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +6 -5
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +1 -2
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +6 -9
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +2 -3
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +10 -10
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +1 -1
- package/plugins/cms/utils.js +5 -6
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +13 -11
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +38 -34
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +20 -12
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +12 -11
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/utils.d.ts +2 -0
- package/plugins/graphql/utils.js +12 -0
- package/plugins/graphql/utils.js.map +1 -0
- package/plugins/graphql/workflow.gql.js +12 -11
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +3 -3
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +1 -1
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +5 -5
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +19 -14
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +2 -4
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +13 -11
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +8 -5
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.d.ts +2 -2
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +3 -2
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +39 -22
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +2 -3
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +3 -4
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +3 -6
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +1 -6
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +9 -8
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +14 -13
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +2 -3
- package/scheduler/handlers/utils.js +3 -6
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/types.d.ts +8 -5
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +15 -11
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +12 -10
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +1 -1
- package/storageOperations/contentReviewStorageOperations.js +15 -11
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +1 -7
- package/storageOperations/index.js +8 -15
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -2
- package/storageOperations/models/changeRequest.model.js +4 -6
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +4 -6
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -2
- package/storageOperations/models/contentReview.model.js +9 -9
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +3 -23
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +5 -7
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +1 -2
- package/storageOperations/models/workflow.model.js +12 -12
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +1 -1
- package/storageOperations/reviewerStorageOperations.js +15 -11
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +20 -14
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +15 -14
- package/types.js.map +1 -1
- package/utils/fieldResolver.js +4 -6
- package/utils/fieldResolver.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +31 -0
- package/utils/pickEntryFieldValues.js.map +1 -0
- package/utils/resolve.d.ts +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +0 -8
- package/storageOperations/models/contentModelPluginFactory.js +0 -22
- package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -1,17 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.createApwChangeRequestNotification = exports.ApwChangeRequestNotification = void 0;
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
7
|
var _plugins = require("@webiny/plugins");
|
10
8
|
class ApwChangeRequestNotification extends _plugins.Plugin {
|
9
|
+
static type = "apw.notification.changeRequest";
|
11
10
|
constructor(contentType, cb) {
|
12
11
|
super();
|
13
|
-
(0, _defineProperty2.default)(this, "contentType", void 0);
|
14
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
15
12
|
this.contentType = contentType;
|
16
13
|
this.cb = cb;
|
17
14
|
}
|
@@ -23,7 +20,6 @@ class ApwChangeRequestNotification extends _plugins.Plugin {
|
|
23
20
|
}
|
24
21
|
}
|
25
22
|
exports.ApwChangeRequestNotification = ApwChangeRequestNotification;
|
26
|
-
(0, _defineProperty2.default)(ApwChangeRequestNotification, "type", "apw.notification.changeRequest");
|
27
23
|
const createApwChangeRequestNotification = (contentType, cb) => {
|
28
24
|
return new ApwChangeRequestNotification(contentType, cb);
|
29
25
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_plugins","require","ApwChangeRequestNotification","Plugin","constructor","contentType","cb","
|
1
|
+
{"version":3,"names":["_plugins","require","ApwChangeRequestNotification","Plugin","type","constructor","contentType","cb","canUse","create","params","exports","createApwChangeRequestNotification"],"sources":["ApwChangeRequestNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwChangeRequest,\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwChangeRequestNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n changeRequestUrl: string;\n contentUrl: string;\n changeRequest: ApwChangeRequest;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwChangeRequestNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwChangeRequestNotificationCb {\n (params: ApwChangeRequestNotificationCbParams):\n | ApwChangeRequestNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwChangeRequestNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.changeRequest\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwChangeRequestNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwChangeRequestNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwChangeRequestNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwChangeRequestNotification = (\n contentType: ApwContentTypes,\n cb: ApwChangeRequestNotificationCb\n) => {\n return new ApwChangeRequestNotification(contentType, cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AA6BO,MAAMC,4BAA4B,SAASC,eAAM,CAAC;EACrD,OAAgCC,IAAI,GAAW,gCAAgC;EAKxEC,WAAWA,CAACC,WAA4B,EAAEC,EAAkC,EAAE;IACjF,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAMA,CAACC,MAA4C,EAAE;IACxD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAT,4BAAA,GAAAA,4BAAA;AAEM,MAAMU,kCAAkC,GAAGA,CAC9CN,WAA4B,EAC5BC,EAAkC,KACjC;EACD,OAAO,IAAIL,4BAA4B,CAACI,WAAW,EAAEC,EAAE,CAAC;AAC5D,CAAC;AAACI,OAAA,CAAAC,kCAAA,GAAAA,kCAAA"}
|
@@ -1,17 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.createApwCommentNotification = exports.ApwCommentNotification = void 0;
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
7
|
var _plugins = require("@webiny/plugins");
|
10
8
|
class ApwCommentNotification extends _plugins.Plugin {
|
9
|
+
static type = "apw.notification.comment";
|
11
10
|
constructor(contentType, cb) {
|
12
11
|
super();
|
13
|
-
(0, _defineProperty2.default)(this, "contentType", void 0);
|
14
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
15
12
|
this.contentType = contentType;
|
16
13
|
this.cb = cb;
|
17
14
|
}
|
@@ -23,7 +20,6 @@ class ApwCommentNotification extends _plugins.Plugin {
|
|
23
20
|
}
|
24
21
|
}
|
25
22
|
exports.ApwCommentNotification = ApwCommentNotification;
|
26
|
-
(0, _defineProperty2.default)(ApwCommentNotification, "type", "apw.notification.comment");
|
27
23
|
const createApwCommentNotification = (contentType, cb) => {
|
28
24
|
return new ApwCommentNotification(contentType, cb);
|
29
25
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_plugins","require","ApwCommentNotification","Plugin","constructor","contentType","cb","
|
1
|
+
{"version":3,"names":["_plugins","require","ApwCommentNotification","Plugin","type","constructor","contentType","cb","canUse","create","params","exports","createApwCommentNotification"],"sources":["ApwCommentNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwChangeRequest,\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwCommentNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n commentUrl: string;\n contentUrl: string;\n changeRequest: ApwChangeRequest;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwCommentNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwCommentNotificationCb {\n (params: ApwCommentNotificationCbParams):\n | ApwCommentNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwCommentNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.comment\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwCommentNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwCommentNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwCommentNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwCommentNotification = (\n contentType: ApwContentTypes,\n cb: ApwCommentNotificationCb\n) => {\n return new ApwCommentNotification(contentType, cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AA6BO,MAAMC,sBAAsB,SAASC,eAAM,CAAC;EAC/C,OAAgCC,IAAI,GAAW,0BAA0B;EAKlEC,WAAWA,CAACC,WAA4B,EAAEC,EAA4B,EAAE;IAC3E,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAMA,CAACC,MAAsC,EAAE;IAClD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAT,sBAAA,GAAAA,sBAAA;AAEM,MAAMU,4BAA4B,GAAGA,CACxCN,WAA4B,EAC5BC,EAA4B,KAC3B;EACD,OAAO,IAAIL,sBAAsB,CAACI,WAAW,EAAEC,EAAE,CAAC;AACtD,CAAC;AAACI,OAAA,CAAAC,4BAAA,GAAAA,4BAAA"}
|
@@ -1,17 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.createApwContentReviewNotification = exports.ApwContentReviewNotification = void 0;
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
7
|
var _plugins = require("@webiny/plugins");
|
10
8
|
class ApwContentReviewNotification extends _plugins.Plugin {
|
9
|
+
static type = "apw.notification.contentReview";
|
11
10
|
constructor(contentType, cb) {
|
12
11
|
super();
|
13
|
-
(0, _defineProperty2.default)(this, "contentType", void 0);
|
14
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
15
12
|
this.contentType = contentType;
|
16
13
|
this.cb = cb;
|
17
14
|
}
|
@@ -23,7 +20,6 @@ class ApwContentReviewNotification extends _plugins.Plugin {
|
|
23
20
|
}
|
24
21
|
}
|
25
22
|
exports.ApwContentReviewNotification = ApwContentReviewNotification;
|
26
|
-
(0, _defineProperty2.default)(ApwContentReviewNotification, "type", "apw.notification.contentReview");
|
27
23
|
const createApwContentReviewNotification = (contentType, cb) => {
|
28
24
|
return new ApwContentReviewNotification(contentType, cb);
|
29
25
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_plugins","require","ApwContentReviewNotification","Plugin","constructor","contentType","cb","
|
1
|
+
{"version":3,"names":["_plugins","require","ApwContentReviewNotification","Plugin","type","constructor","contentType","cb","canUse","create","params","exports","createApwContentReviewNotification"],"sources":["ApwContentReviewNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwContentReviewNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n contentReviewUrl: string;\n contentUrl: string;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwContentReviewNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwContentReviewNotificationCb {\n (params: ApwContentReviewNotificationCbParams):\n | ApwContentReviewNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwContentReviewNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.contentReview\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwContentReviewNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwContentReviewNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwContentReviewNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwContentReviewNotification = (\n contentType: ApwContentTypes,\n cb: ApwContentReviewNotificationCb\n) => {\n return new ApwContentReviewNotification(contentType, cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AA2BO,MAAMC,4BAA4B,SAASC,eAAM,CAAC;EACrD,OAAgCC,IAAI,GAAW,gCAAgC;EAKxEC,WAAWA,CAACC,WAA4B,EAAEC,EAAkC,EAAE;IACjF,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAMA,CAACC,MAA4C,EAAE;IACxD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAT,4BAAA,GAAAA,4BAAA;AAEM,MAAMU,kCAAkC,GAAGA,CAC9CN,WAA4B,EAC5BC,EAAkC,KACjC;EACD,OAAO,IAAIL,4BAA4B,CAACI,WAAW,EAAEC,EAAE,CAAC;AAC5D,CAAC;AAACI,OAAA,CAAAC,kCAAA,GAAAA,kCAAA"}
|
package/ApwContentUrlPlugin.js
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.createApwContentUrlPlugin = exports.ApwContentUrlPlugin = void 0;
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
7
|
var _plugins = require("@webiny/plugins");
|
10
8
|
class ApwContentUrlPlugin extends _plugins.Plugin {
|
9
|
+
static type = "apw.contentUrl";
|
11
10
|
constructor(contentType, cb) {
|
12
11
|
super();
|
13
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
14
|
-
(0, _defineProperty2.default)(this, "contentType", void 0);
|
15
12
|
this.contentType = contentType;
|
16
13
|
this.cb = cb;
|
17
14
|
}
|
@@ -23,7 +20,6 @@ class ApwContentUrlPlugin extends _plugins.Plugin {
|
|
23
20
|
}
|
24
21
|
}
|
25
22
|
exports.ApwContentUrlPlugin = ApwContentUrlPlugin;
|
26
|
-
(0, _defineProperty2.default)(ApwContentUrlPlugin, "type", "apw.contentUrl");
|
27
23
|
const createApwContentUrlPlugin = (contentType, cb) => {
|
28
24
|
return new ApwContentUrlPlugin(contentType, cb);
|
29
25
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_plugins","require","ApwContentUrlPlugin","Plugin","constructor","contentType","cb","
|
1
|
+
{"version":3,"names":["_plugins","require","ApwContentUrlPlugin","Plugin","type","constructor","contentType","cb","canUse","create","params","exports","createApwContentUrlPlugin"],"sources":["ApwContentUrlPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ApwContentReview, ApwContentTypes, ApwWorkflow } from \"~/types\";\n\nexport interface ApwContentUrlPluginCbParams {\n baseUrl: string;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwContentUrlPluginCb {\n (params: ApwContentUrlPluginCbParams): string | null;\n}\n\nexport class ApwContentUrlPlugin extends Plugin {\n public static override type = \"apw.contentUrl\";\n\n private readonly cb: ApwContentUrlPluginCb;\n private readonly contentType: ApwContentTypes;\n\n public constructor(contentType: ApwContentTypes, cb: ApwContentUrlPluginCb) {\n super();\n\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return this.contentType === contentType;\n }\n\n public create(params: ApwContentUrlPluginCbParams): string | null {\n return this.cb(params);\n }\n}\n\nexport const createApwContentUrlPlugin = (\n contentType: ApwContentTypes,\n cb: ApwContentUrlPluginCb\n) => {\n return new ApwContentUrlPlugin(contentType, cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAYO,MAAMC,mBAAmB,SAASC,eAAM,CAAC;EAC5C,OAAuBC,IAAI,GAAG,gBAAgB;EAKvCC,WAAWA,CAACC,WAA4B,EAAEC,EAAyB,EAAE;IACxE,KAAK,CAAC,CAAC;IAEP,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACF,WAA4B,EAAW;IACjD,OAAO,IAAI,CAACA,WAAW,KAAKA,WAAW;EAC3C;EAEOG,MAAMA,CAACC,MAAmC,EAAiB;IAC9D,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAT,mBAAA,GAAAA,mBAAA;AAEM,MAAMU,yBAAyB,GAAGA,CACrCN,WAA4B,EAC5BC,EAAyB,KACxB;EACD,OAAO,IAAIL,mBAAmB,CAACI,WAAW,EAAEC,EAAE,CAAC;AACnD,CAAC;AAACI,OAAA,CAAAC,yBAAA,GAAAA,yBAAA"}
|
@@ -1,14 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.ContentApwSettingsPlugin = void 0;
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
7
|
var _Plugin = require("@webiny/plugins/Plugin");
|
10
|
-
class ContentApwSettingsPlugin extends _Plugin.Plugin {
|
8
|
+
class ContentApwSettingsPlugin extends _Plugin.Plugin {
|
9
|
+
static type = "apw.contentApwSettings";
|
10
|
+
}
|
11
11
|
exports.ContentApwSettingsPlugin = ContentApwSettingsPlugin;
|
12
|
-
(0, _defineProperty2.default)(ContentApwSettingsPlugin, "type", "apw.contentApwSettings");
|
13
12
|
|
14
13
|
//# sourceMappingURL=ContentApwSettingsPlugin.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Plugin","require","ContentApwSettingsPlugin","Plugin","
|
1
|
+
{"version":3,"names":["_Plugin","require","ContentApwSettingsPlugin","Plugin","type","exports"],"sources":["ContentApwSettingsPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport abstract class ContentApwSettingsPlugin extends Plugin {\n public static override type = \"apw.contentApwSettings\";\n\n public abstract canUse(type: ApwContentTypes): boolean;\n\n public abstract setWorkflowId(content: any, id: string | null): void;\n\n public abstract getWorkflowId(content: any): string | null;\n\n public abstract setContentReviewId(content: any, id: string | null): void;\n\n public abstract getContentReviewId(content: any): string | null;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGO,MAAeC,wBAAwB,SAASC,cAAM,CAAC;EAC1D,OAAuBC,IAAI,GAAG,wBAAwB;AAW1D;AAACC,OAAA,CAAAH,wBAAA,GAAAA,wBAAA"}
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
6
6
|
});
|
7
7
|
exports.createContentReviewMethods = createContentReviewMethods;
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
10
9
|
var _pubsub = require("@webiny/pubsub");
|
11
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
@@ -64,22 +63,25 @@ function createContentReviewMethods(params) {
|
|
64
63
|
});
|
65
64
|
if (where.reviewStatus === "requiresMyAttention") {
|
66
65
|
return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
|
67
|
-
listParams:
|
66
|
+
listParams: {
|
67
|
+
...params,
|
68
68
|
where
|
69
|
-
}
|
69
|
+
},
|
70
70
|
listContentReviews: storageOperations.listContentReviews,
|
71
71
|
getReviewer,
|
72
72
|
getIdentity
|
73
73
|
});
|
74
74
|
}
|
75
|
-
return storageOperations.listContentReviews(
|
75
|
+
return storageOperations.listContentReviews({
|
76
|
+
...params,
|
76
77
|
where
|
77
|
-
})
|
78
|
+
});
|
78
79
|
},
|
79
80
|
async create(data) {
|
80
|
-
const input =
|
81
|
+
const input = {
|
82
|
+
...data,
|
81
83
|
reviewStatus: _types.ApwContentReviewStatus.UNDER_REVIEW
|
82
|
-
}
|
84
|
+
};
|
83
85
|
await onContentReviewBeforeCreate.publish({
|
84
86
|
input
|
85
87
|
});
|
@@ -202,11 +204,12 @@ function createContentReviewMethods(params) {
|
|
202
204
|
const updatedSteps = steps.map((step, index) => {
|
203
205
|
if (index === stepIndex) {
|
204
206
|
previousStepStatus = _types.ApwContentReviewStepStatus.DONE;
|
205
|
-
return
|
207
|
+
return {
|
208
|
+
...step,
|
206
209
|
status: _types.ApwContentReviewStepStatus.DONE,
|
207
210
|
signOffProvidedOn: new Date().toISOString(),
|
208
211
|
signOffProvidedBy: identity
|
209
|
-
}
|
212
|
+
};
|
210
213
|
}
|
211
214
|
/**
|
212
215
|
* Update next steps status based on type.
|
@@ -214,9 +217,10 @@ function createContentReviewMethods(params) {
|
|
214
217
|
if (index > stepIndex) {
|
215
218
|
const previousStep = steps[index - 1];
|
216
219
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
217
|
-
return
|
220
|
+
return {
|
221
|
+
...step,
|
218
222
|
status: previousStepStatus
|
219
|
-
}
|
223
|
+
};
|
220
224
|
}
|
221
225
|
return step;
|
222
226
|
});
|
@@ -243,7 +247,6 @@ function createContentReviewMethods(params) {
|
|
243
247
|
return true;
|
244
248
|
},
|
245
249
|
async retractSignOff(id, stepId) {
|
246
|
-
var _contentReview$conten;
|
247
250
|
const contentReview = await this.get(id);
|
248
251
|
const {
|
249
252
|
steps,
|
@@ -291,11 +294,12 @@ function createContentReviewMethods(params) {
|
|
291
294
|
const updatedSteps = steps.map((step, index) => {
|
292
295
|
if (index === stepIndex) {
|
293
296
|
previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
|
294
|
-
return
|
297
|
+
return {
|
298
|
+
...step,
|
295
299
|
status: previousStepStatus,
|
296
300
|
signOffProvidedOn: null,
|
297
301
|
signOffProvidedBy: null
|
298
|
-
}
|
302
|
+
};
|
299
303
|
}
|
300
304
|
/**
|
301
305
|
* Set next step status as "inactive".
|
@@ -303,9 +307,10 @@ function createContentReviewMethods(params) {
|
|
303
307
|
if (index > stepIndex) {
|
304
308
|
const previousStep = steps[index - 1];
|
305
309
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
306
|
-
return
|
310
|
+
return {
|
311
|
+
...step,
|
307
312
|
status: previousStepStatus
|
308
|
-
}
|
313
|
+
};
|
309
314
|
}
|
310
315
|
return step;
|
311
316
|
});
|
@@ -325,16 +330,17 @@ function createContentReviewMethods(params) {
|
|
325
330
|
/**
|
326
331
|
* We need to delete the scheduled action if one was created.
|
327
332
|
*/
|
328
|
-
const scheduledActionId =
|
333
|
+
const scheduledActionId = contentReview.content?.scheduledActionId;
|
329
334
|
if (!!scheduledActionId) {
|
330
335
|
await scheduler.delete(scheduledActionId);
|
331
336
|
}
|
332
337
|
await this.update(id, {
|
333
|
-
content:
|
338
|
+
content: {
|
339
|
+
...content,
|
334
340
|
scheduledOn: null,
|
335
341
|
scheduledBy: null,
|
336
342
|
scheduledActionId: null
|
337
|
-
}
|
343
|
+
},
|
338
344
|
steps: updatedSteps,
|
339
345
|
reviewStatus: newStatus
|
340
346
|
});
|
@@ -362,7 +368,6 @@ function createContentReviewMethods(params) {
|
|
362
368
|
};
|
363
369
|
},
|
364
370
|
async publishContent(id, datetime) {
|
365
|
-
var _content$settings;
|
366
371
|
const {
|
367
372
|
content,
|
368
373
|
reviewStatus
|
@@ -394,7 +399,7 @@ function createContentReviewMethods(params) {
|
|
394
399
|
action: _types2.ApwScheduleActionTypes.PUBLISH,
|
395
400
|
type: content.type,
|
396
401
|
entryId: content.id,
|
397
|
-
modelId:
|
402
|
+
modelId: content.settings?.modelId,
|
398
403
|
datetime
|
399
404
|
};
|
400
405
|
const scheduledActionId = await this.scheduleAction(data);
|
@@ -402,16 +407,16 @@ function createContentReviewMethods(params) {
|
|
402
407
|
* Update scheduled related meta data.
|
403
408
|
*/
|
404
409
|
await this.update(id, {
|
405
|
-
content:
|
410
|
+
content: {
|
411
|
+
...content,
|
406
412
|
scheduledOn: datetime,
|
407
413
|
scheduledBy: identity.id,
|
408
414
|
scheduledActionId
|
409
|
-
}
|
415
|
+
}
|
410
416
|
});
|
411
417
|
return true;
|
412
418
|
},
|
413
419
|
async unpublishContent(id, datetime) {
|
414
|
-
var _content$settings2;
|
415
420
|
const {
|
416
421
|
content,
|
417
422
|
reviewStatus
|
@@ -443,18 +448,19 @@ function createContentReviewMethods(params) {
|
|
443
448
|
action: _types2.ApwScheduleActionTypes.UNPUBLISH,
|
444
449
|
type: content.type,
|
445
450
|
entryId: content.id,
|
446
|
-
modelId:
|
451
|
+
modelId: content.settings?.modelId,
|
447
452
|
datetime
|
448
453
|
});
|
449
454
|
/**
|
450
455
|
* Update scheduled related meta data.
|
451
456
|
*/
|
452
457
|
await this.update(id, {
|
453
|
-
content:
|
458
|
+
content: {
|
459
|
+
...content,
|
454
460
|
scheduledOn: datetime,
|
455
461
|
scheduledBy: identity.id,
|
456
462
|
scheduledActionId
|
457
|
-
}
|
463
|
+
}
|
458
464
|
});
|
459
465
|
return true;
|
460
466
|
},
|
@@ -505,7 +511,10 @@ function createContentReviewMethods(params) {
|
|
505
511
|
* Reset scheduled related meta data.
|
506
512
|
*/
|
507
513
|
await this.update(id, {
|
508
|
-
content:
|
514
|
+
content: {
|
515
|
+
...contentReview.content,
|
516
|
+
..._utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META
|
517
|
+
}
|
509
518
|
});
|
510
519
|
return true;
|
511
520
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_get","_interopRequireDefault","require","_pubsub","_error","_types","_utils","_errors","_types2","_utils2","_contentApwSettingsPlugin","createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onContentReviewBeforeCreate","createTopic","onContentReviewAfterCreate","onContentReviewBeforeUpdate","onContentReviewAfterUpdate","onContentReviewBeforeDelete","onContentReviewAfterDelete","onContentReviewBeforeList","get","id","getContentReview","list","where","publish","reviewStatus","filterContentReviewsByRequiresMyAttention","listParams","_objectSpread2","default","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","status","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","_contentReview$conten","content","NoSignOffProvidedError","scheduledActionId","scheduledOn","scheduledBy","isReviewRequired","contentGetter","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","_content$settings","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduleAction","unpublishContent","_content$settings2","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwContentReviewParams,\n CreateApwParams,\n OnContentReviewAfterCreateTopicParams,\n OnContentReviewAfterDeleteTopicParams,\n OnContentReviewAfterUpdateTopicParams,\n OnContentReviewBeforeCreateTopicParams,\n OnContentReviewBeforeDeleteTopicParams,\n OnContentReviewBeforeListTopicParams,\n OnContentReviewBeforeUpdateTopicParams,\n UpdateApwContentReviewParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n // create\n const onContentReviewBeforeCreate = createTopic<OnContentReviewBeforeCreateTopicParams>(\n \"apw.onContentReviewBeforeCreate\"\n );\n const onContentReviewAfterCreate = createTopic<OnContentReviewAfterCreateTopicParams>(\n \"apw.onContentReviewAfterCreate\"\n );\n // update\n const onContentReviewBeforeUpdate = createTopic<OnContentReviewBeforeUpdateTopicParams>(\n \"apw.onContentReviewBeforeUpdate\"\n );\n const onContentReviewAfterUpdate = createTopic<OnContentReviewAfterUpdateTopicParams>(\n \"apw.onContentReviewAfterUpdate\"\n );\n // delete\n const onContentReviewBeforeDelete = createTopic<OnContentReviewBeforeDeleteTopicParams>(\n \"apw.onContentReviewBeforeDelete\"\n );\n const onContentReviewAfterDelete = createTopic<OnContentReviewAfterDeleteTopicParams>(\n \"apw.onContentReviewAfterDelete\"\n );\n // list\n const onContentReviewBeforeList = createTopic<OnContentReviewBeforeListTopicParams>(\n \"apw.onContentReviewBeforeList\"\n );\n return {\n /**\n * Lifecycle events\n */\n onContentReviewBeforeCreate,\n onContentReviewAfterCreate,\n onContentReviewBeforeUpdate,\n onContentReviewAfterUpdate,\n onContentReviewBeforeDelete,\n onContentReviewAfterDelete,\n onContentReviewBeforeList,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n const where = params.where || {};\n\n await onContentReviewBeforeList.publish({\n where\n });\n\n if (where.reviewStatus === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: {\n ...params,\n where\n },\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews({\n ...params,\n where\n });\n },\n async create(data: Omit<CreateApwContentReviewParams, \"reviewStatus\">) {\n const input: CreateApwContentReviewParams = {\n ...data,\n reviewStatus: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onContentReviewBeforeCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onContentReviewAfterCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data: UpdateApwContentReviewParams) {\n const original = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onContentReviewAfterUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onContentReviewAfterDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, reviewStatus } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const contentReview = await this.get(id);\n const { steps, reviewStatus, content } = contentReview;\n\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({\n entry: contentReview,\n input: {\n id,\n step: stepId\n }\n });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({\n entry: contentReview,\n input: {\n id,\n step: stepId\n }\n });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n /**\n * We need to delete the scheduled action if one was created.\n */\n const scheduledActionId = contentReview.content?.scheduledActionId;\n if (!!scheduledActionId) {\n await scheduler.delete(scheduledActionId);\n }\n\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: null,\n scheduledBy: null,\n scheduledActionId: null\n },\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAoBA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAOA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAMA,IAAAQ,yBAAA,GAAAR,OAAA;AAWO,SAASS,0BAA0BA,CACtCC,MAAwC,EACpB;EACpB,MAAM;IACFC,WAAW;IACXC,iBAAiB;IACjBC,WAAW;IACXC,gBAAgB;IAChBC,mBAAmB;IACnBC,qBAAqB;IACrBC,SAAS;IACTC,aAAa;IACbC,SAAS;IACTC,SAAS;IACTC;EACJ,CAAC,GAAGX,MAAM;;EAEV;EACA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAW,EAC3C,iCACJ,CAAC;EACD,MAAMC,0BAA0B,GAAG,IAAAD,mBAAW,EAC1C,gCACJ,CAAC;EACD;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAW,EAC3C,iCACJ,CAAC;E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{"version":3,"names":["_get","_interopRequireDefault","require","_pubsub","_error","_types","_utils","_errors","_types2","_utils2","_contentApwSettingsPlugin","createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onContentReviewBeforeCreate","createTopic","onContentReviewAfterCreate","onContentReviewBeforeUpdate","onContentReviewAfterUpdate","onContentReviewBeforeDelete","onContentReviewAfterDelete","onContentReviewBeforeList","get","id","getContentReview","list","where","publish","reviewStatus","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","status","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","content","NoSignOffProvidedError","scheduledActionId","scheduledOn","scheduledBy","isReviewRequired","contentGetter","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduleAction","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwContentReviewParams,\n CreateApwParams,\n OnContentReviewAfterCreateTopicParams,\n OnContentReviewAfterDeleteTopicParams,\n OnContentReviewAfterUpdateTopicParams,\n OnContentReviewBeforeCreateTopicParams,\n OnContentReviewBeforeDeleteTopicParams,\n OnContentReviewBeforeListTopicParams,\n OnContentReviewBeforeUpdateTopicParams,\n UpdateApwContentReviewParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n // create\n const onContentReviewBeforeCreate = createTopic<OnContentReviewBeforeCreateTopicParams>(\n \"apw.onContentReviewBeforeCreate\"\n );\n const onContentReviewAfterCreate = createTopic<OnContentReviewAfterCreateTopicParams>(\n \"apw.onContentReviewAfterCreate\"\n );\n // update\n const onContentReviewBeforeUpdate = createTopic<OnContentReviewBeforeUpdateTopicParams>(\n \"apw.onContentReviewBeforeUpdate\"\n );\n const onContentReviewAfterUpdate = createTopic<OnContentReviewAfterUpdateTopicParams>(\n \"apw.onContentReviewAfterUpdate\"\n );\n // delete\n const onContentReviewBeforeDelete = createTopic<OnContentReviewBeforeDeleteTopicParams>(\n \"apw.onContentReviewBeforeDelete\"\n );\n const onContentReviewAfterDelete = createTopic<OnContentReviewAfterDeleteTopicParams>(\n \"apw.onContentReviewAfterDelete\"\n );\n // list\n const onContentReviewBeforeList = createTopic<OnContentReviewBeforeListTopicParams>(\n \"apw.onContentReviewBeforeList\"\n );\n return {\n /**\n * Lifecycle events\n */\n onContentReviewBeforeCreate,\n onContentReviewAfterCreate,\n onContentReviewBeforeUpdate,\n onContentReviewAfterUpdate,\n onContentReviewBeforeDelete,\n onContentReviewAfterDelete,\n onContentReviewBeforeList,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n const where = params.where || {};\n\n await onContentReviewBeforeList.publish({\n where\n });\n\n if (where.reviewStatus === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: {\n ...params,\n where\n },\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews({\n ...params,\n where\n });\n },\n async create(data: Omit<CreateApwContentReviewParams, \"reviewStatus\">) {\n const input: CreateApwContentReviewParams = {\n ...data,\n reviewStatus: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onContentReviewBeforeCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onContentReviewAfterCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data: UpdateApwContentReviewParams) {\n const original = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onContentReviewAfterUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onContentReviewAfterDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, reviewStatus } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const contentReview = await this.get(id);\n const { steps, reviewStatus, content } = contentReview;\n\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({\n entry: contentReview,\n input: {\n id,\n step: stepId\n }\n });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({\n entry: contentReview,\n input: {\n id,\n step: stepId\n }\n });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n /**\n * We need to delete the scheduled action if one was created.\n */\n const scheduledActionId = contentReview.content?.scheduledActionId;\n if (!!scheduledActionId) {\n await scheduler.delete(scheduledActionId);\n }\n\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: null,\n scheduledBy: null,\n scheduledActionId: null\n },\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAoBA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAOA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAMA,IAAAQ,yBAAA,GAAAR,OAAA;AAWO,SAASS,0BAA0BA,CACtCC,MAAwC,EACpB;EACpB,MAAM;IACFC,WAAW;IACXC,iBAAiB;IACjBC,WAAW;IACXC,gBAAgB;IAChBC,mBAAmB;IACnBC,qBAAqB;IACrBC,SAAS;IACTC,aAAa;IACbC,SAAS;IACTC,SAAS;IACTC;EACJ,CAAC,GAAGX,MAAM;;EAEV;EACA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAW,EAC3C,iCACJ,CAAC;EACD,MAAMC,0BAA0B,GAAG,IAAAD,mBAAW,EAC1C,gCACJ,CAAC;EACD;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAW,EAC3C,iCACJ,CAAC;EACD,MAAMG,0BAA0B,GAAG,IAAAH,mBAAW,EAC1C,gCACJ,CAAC;EACD;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAW,EAC3C,iCACJ,CAAC;EACD,MAAMK,0BAA0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QACpB,MAAM,IAAIc,cAAK,CAAC;UACZC,OAAO,EAAG,kDAAiD;UAC3DC,IAAI,EAAE,qBAAqB;UAC3BpE,IAAI,EAAE;YACFV;UACJ;QACJ,CAAC,CAAC;MACN;MACA;AACZ;AACA;MACY,MAAMd,SAAS,CAACiC,MAAM,CAAC2C,iBAAiB,CAAC;;MAEzC;AACZ;AACA;MACY,MAAM,IAAI,CAAC9C,MAAM,CAAChB,EAAE,EAAE;QAClB4D,OAAO,EAAE;UACL,GAAG9C,aAAa,CAAC8C,OAAO;UACxB,GAAG6C;QACP;MACJ,CAAC,CAAC;MAEF,OAAO,IAAI;IACf;EACJ,CAAC;AACL"}
|
package/crud/index.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
7
6
|
exports.createApw = void 0;
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
7
|
var _createWorkflowMethods = require("./createWorkflowMethods");
|
10
8
|
var _createReviewerMethods = require("./createReviewerMethods");
|
11
9
|
var _createCommentMethods = require("./createCommentMethods");
|
@@ -56,12 +54,13 @@ const createApw = params => {
|
|
56
54
|
reviewer: reviewerMethods,
|
57
55
|
changeRequest: changeRequestMethods,
|
58
56
|
comment: (0, _createCommentMethods.createCommentMethods)(params),
|
59
|
-
contentReview: (0, _createContentReviewMethods.createContentReviewMethods)(
|
57
|
+
contentReview: (0, _createContentReviewMethods.createContentReviewMethods)({
|
58
|
+
...params,
|
60
59
|
getReviewer: reviewerMethods.get.bind(reviewerMethods),
|
61
60
|
getContentGetter,
|
62
61
|
getContentPublisher,
|
63
62
|
getContentUnPublisher
|
64
|
-
})
|
63
|
+
}),
|
65
64
|
/**
|
66
65
|
* Add scheduler to context so that we can access it later. For example, during testing.
|
67
66
|
*/
|
package/crud/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_createWorkflowMethods","require","_createReviewerMethods","_createCommentMethods","_createChangeRequestMethods","_createContentReviewMethods","createApw","params","contentGetters","Map","contentPublisher","contentUnPublisher","workflowMethods","createWorkflowMethods","reviewerMethods","createReviewerMethods","changeRequestMethods","createChangeRequestMethods","getContentGetter","type","getter","get","Error","getContentUnPublisher","getContentPublisher","addContentPublisher","func","set","addContentGetter","addContentUnPublisher","workflow","reviewer","changeRequest","comment","createCommentMethods","contentReview","createContentReviewMethods","
|
1
|
+
{"version":3,"names":["_createWorkflowMethods","require","_createReviewerMethods","_createCommentMethods","_createChangeRequestMethods","_createContentReviewMethods","createApw","params","contentGetters","Map","contentPublisher","contentUnPublisher","workflowMethods","createWorkflowMethods","reviewerMethods","createReviewerMethods","changeRequestMethods","createChangeRequestMethods","getContentGetter","type","getter","get","Error","getContentUnPublisher","getContentPublisher","addContentPublisher","func","set","addContentGetter","addContentUnPublisher","workflow","reviewer","changeRequest","comment","createCommentMethods","contentReview","createContentReviewMethods","getReviewer","bind","scheduleAction","scheduler","exports"],"sources":["index.ts"],"sourcesContent":["import { createWorkflowMethods } from \"./createWorkflowMethods\";\nimport { createReviewerMethods } from \"./createReviewerMethods\";\nimport { createCommentMethods } from \"./createCommentMethods\";\nimport { createChangeRequestMethods } from \"./createChangeRequestMethods\";\nimport { createContentReviewMethods } from \"./createContentReviewMethods\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentTypes,\n ContentGetter,\n ContentPublisher,\n ContentUnPublisher,\n CreateApwParams\n} from \"~/types\";\n\nexport const createApw = (params: CreateApwParams): AdvancedPublishingWorkflow => {\n const contentGetters = new Map<ApwContentTypes, ContentGetter>();\n const contentPublisher = new Map<ApwContentTypes, ContentPublisher>();\n const contentUnPublisher = new Map<ApwContentTypes, ContentUnPublisher>();\n\n const workflowMethods = createWorkflowMethods(params);\n const reviewerMethods = createReviewerMethods(params);\n const changeRequestMethods = createChangeRequestMethods(params);\n\n function getContentGetter(type: ApwContentTypes) {\n const getter = contentGetters.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentGetter\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentUnPublisher(type: ApwContentTypes) {\n const getter = contentUnPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"Content UnPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentPublisher(type: ApwContentTypes) {\n const getter = contentPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n return {\n addContentPublisher(type, func) {\n contentPublisher.set(type, func);\n },\n getContentPublisher,\n addContentGetter(type, func) {\n contentGetters.set(type, func);\n },\n getContentGetter,\n addContentUnPublisher(type, func) {\n contentUnPublisher.set(type, func);\n },\n getContentUnPublisher,\n workflow: workflowMethods,\n reviewer: reviewerMethods,\n changeRequest: changeRequestMethods,\n comment: createCommentMethods(params),\n contentReview: createContentReviewMethods({\n ...params,\n getReviewer: reviewerMethods.get.bind(reviewerMethods),\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher\n }),\n /**\n * Add scheduler to context so that we can access it later. For example, during testing.\n */\n scheduleAction: params.scheduler\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,2BAAA,GAAAJ,OAAA;AAUO,MAAMK,SAAS,GAAIC,MAAuB,IAAiC;EAC9E,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAiC,CAAC;EAChE,MAAMC,gBAAgB,GAAG,IAAID,GAAG,CAAoC,CAAC;EACrE,MAAME,kBAAkB,GAAG,IAAIF,GAAG,CAAsC,CAAC;EAEzE,MAAMG,eAAe,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