@webiny/api-apw 5.37.8 → 5.38.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/ApwChangeRequestNotification.js +3 -1
- package/ApwCommentNotification.js +3 -1
- package/ApwContentReviewNotification.js +3 -1
- package/ApwContentUrlPlugin.js +3 -1
- package/ContentApwSettingsPlugin.js +3 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.js +3 -1
- package/crud/createCommentMethods.js +3 -1
- package/crud/createContentReviewMethods.js +3 -1
- package/crud/createReviewerMethods.js +3 -1
- package/crud/createWorkflowMethods.js +3 -1
- package/crud/index.js +3 -1
- package/crud/utils.js +3 -1
- package/index.js +3 -1
- package/package.json +26 -26
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +3 -1
- package/plugins/cms/apwEntryPlugins.js +3 -1
- package/plugins/cms/index.js +3 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -2
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +10 -6
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +3 -1
- package/plugins/cms/notifications/commentNotification.js +3 -1
- package/plugins/cms/notifications/contentReviewNotification.js +3 -1
- package/plugins/cms/notifications/contentUrl.js +3 -1
- package/plugins/cms/triggerContentReview.js +4 -2
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +5 -3
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +2 -1
- package/plugins/cms/utils.js +17 -8
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +3 -1
- package/plugins/graphql/changeRequest.gql.js +3 -1
- package/plugins/graphql/comment.gql.js +3 -1
- package/plugins/graphql/contentReview.gql.js +3 -1
- package/plugins/graphql/reviewer.gql.js +3 -1
- package/plugins/graphql/workflow.gql.js +3 -1
- package/plugins/graphql.js +3 -1
- package/plugins/hooks/createReviewerFromIdentity.js +3 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -1
- package/plugins/hooks/index.js +3 -1
- package/plugins/hooks/initializeContentReviewSteps.js +3 -1
- package/plugins/hooks/initializeNotifications.js +3 -1
- package/plugins/hooks/listContentReviews.js +3 -1
- package/plugins/hooks/notifications/appUrl.js +3 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +3 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +3 -1
- package/plugins/hooks/notifications/commentUrl.js +3 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +3 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +3 -1
- package/plugins/hooks/notifications/contentUrl.js +3 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +3 -1
- package/plugins/hooks/notifications/reviewers.js +3 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +3 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +3 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +3 -1
- package/plugins/hooks/updatePendingChangeRequests.js +3 -1
- package/plugins/hooks/updateTotalComments.js +3 -1
- package/plugins/hooks/validateChangeRequest.js +3 -1
- package/plugins/hooks/validateComment.js +3 -1
- package/plugins/hooks/validateContentReview.js +3 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +3 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +3 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +3 -1
- package/plugins/pageBuilder/index.js +3 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +3 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +3 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +3 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +3 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +3 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +3 -1
- package/plugins/pageBuilder/triggerContentReview.js +3 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +3 -1
- package/plugins/pageBuilder/utils.js +3 -1
- package/plugins/utils.js +3 -1
- package/scheduler/createScheduleActionMethods.js +3 -1
- package/scheduler/handlers/executeAction/index.js +3 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +3 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +3 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +3 -1
- package/scheduler/handlers/executeAction/security.js +3 -1
- package/scheduler/handlers/scheduleAction/index.js +3 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +3 -1
- package/scheduler/handlers/utils.js +3 -1
- package/scheduler/index.js +3 -1
- package/scheduler/types.d.ts +2 -3
- package/scheduler/types.js +3 -1
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +28 -1
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +3 -1
- package/storageOperations/contentReviewStorageOperations.js +3 -1
- package/storageOperations/index.js +3 -1
- package/storageOperations/models/changeRequest.model.js +3 -1
- package/storageOperations/models/comment.model.js +3 -1
- package/storageOperations/models/contentModelPluginFactory.js +3 -1
- package/storageOperations/models/contentReview.model.js +4 -2
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +3 -1
- package/storageOperations/models/reviewer.model.js +3 -1
- package/storageOperations/models/utils.js +3 -1
- package/storageOperations/models/workflow.model.js +7 -7
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +3 -1
- package/storageOperations/types.js +3 -1
- package/storageOperations/workflowStorageOperations.js +3 -1
- package/types.js +3 -1
- package/utils/contentApwSettingsPlugin.js +3 -1
- package/utils/errors.js +3 -1
- package/utils/fieldResolver.js +3 -1
- package/utils/resolve.js +3 -1
@@ -27,4 +27,6 @@ exports.ApwChangeRequestNotification = ApwChangeRequestNotification;
|
|
27
27
|
const createApwChangeRequestNotification = (contentType, cb) => {
|
28
28
|
return new ApwChangeRequestNotification(contentType, cb);
|
29
29
|
};
|
30
|
-
exports.createApwChangeRequestNotification = createApwChangeRequestNotification;
|
30
|
+
exports.createApwChangeRequestNotification = createApwChangeRequestNotification;
|
31
|
+
|
32
|
+
//# sourceMappingURL=ApwChangeRequestNotification.js.map
|
@@ -27,4 +27,6 @@ exports.ApwCommentNotification = ApwCommentNotification;
|
|
27
27
|
const createApwCommentNotification = (contentType, cb) => {
|
28
28
|
return new ApwCommentNotification(contentType, cb);
|
29
29
|
};
|
30
|
-
exports.createApwCommentNotification = createApwCommentNotification;
|
30
|
+
exports.createApwCommentNotification = createApwCommentNotification;
|
31
|
+
|
32
|
+
//# sourceMappingURL=ApwCommentNotification.js.map
|
@@ -27,4 +27,6 @@ exports.ApwContentReviewNotification = ApwContentReviewNotification;
|
|
27
27
|
const createApwContentReviewNotification = (contentType, cb) => {
|
28
28
|
return new ApwContentReviewNotification(contentType, cb);
|
29
29
|
};
|
30
|
-
exports.createApwContentReviewNotification = createApwContentReviewNotification;
|
30
|
+
exports.createApwContentReviewNotification = createApwContentReviewNotification;
|
31
|
+
|
32
|
+
//# sourceMappingURL=ApwContentReviewNotification.js.map
|
package/ApwContentUrlPlugin.js
CHANGED
@@ -27,4 +27,6 @@ exports.ApwContentUrlPlugin = ApwContentUrlPlugin;
|
|
27
27
|
const createApwContentUrlPlugin = (contentType, cb) => {
|
28
28
|
return new ApwContentUrlPlugin(contentType, cb);
|
29
29
|
};
|
30
|
-
exports.createApwContentUrlPlugin = createApwContentUrlPlugin;
|
30
|
+
exports.createApwContentUrlPlugin = createApwContentUrlPlugin;
|
31
|
+
|
32
|
+
//# sourceMappingURL=ApwContentUrlPlugin.js.map
|
@@ -9,4 +9,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
9
9
|
var _Plugin = require("@webiny/plugins/Plugin");
|
10
10
|
class ContentApwSettingsPlugin extends _Plugin.Plugin {}
|
11
11
|
exports.ContentApwSettingsPlugin = ContentApwSettingsPlugin;
|
12
|
-
(0, _defineProperty2.default)(ContentApwSettingsPlugin, "type", "apw.contentApwSettings");
|
12
|
+
(0, _defineProperty2.default)(ContentApwSettingsPlugin, "type", "apw.contentApwSettings");
|
13
|
+
|
14
|
+
//# sourceMappingURL=ContentApwSettingsPlugin.js.map
|
package/README.md
CHANGED
@@ -24,11 +24,11 @@ To run tests api-apw tests with targeted storage operations loaded use:
|
|
24
24
|
#### DynamoDB
|
25
25
|
|
26
26
|
```
|
27
|
-
yarn test packages/api-apw --keyword=apw:ddb --keyword=apw:base
|
27
|
+
yarn test packages/api-apw --storage:ddb --keyword=apw:ddb --keyword=apw:base
|
28
28
|
```
|
29
29
|
|
30
30
|
#### Note
|
31
31
|
|
32
32
|
> All the tests in `@webiny/api-apw` package are being tested against ddb-only storage operations because
|
33
|
-
current jest setup doesn't allow usage of more than one storage operations at a time with the help of --keyword flag.
|
34
|
-
We should revisit these tests once we have the ability to load multiple storage operations in the jest setup.
|
33
|
+
> current jest setup doesn't allow usage of more than one storage operations at a time with the help of --keyword flag.
|
34
|
+
> We should revisit these tests once we have the ability to load multiple storage operations in the jest setup.
|
package/crud/index.js
CHANGED
package/crud/utils.js
CHANGED
@@ -107,4 +107,6 @@ const filterContentReviewsByRequiresMyAttention = async params => {
|
|
107
107
|
totalCount: filteredItems.length
|
108
108
|
})];
|
109
109
|
};
|
110
|
-
exports.filterContentReviewsByRequiresMyAttention = filterContentReviewsByRequiresMyAttention;
|
110
|
+
exports.filterContentReviewsByRequiresMyAttention = filterContentReviewsByRequiresMyAttention;
|
111
|
+
|
112
|
+
//# sourceMappingURL=utils.js.map
|
package/index.js
CHANGED
@@ -21,4 +21,6 @@ exports.createApwPageBuilderContext = createApwPageBuilderContext;
|
|
21
21
|
const createApwGraphQL = () => {
|
22
22
|
return [(0, _graphql.default)()];
|
23
23
|
};
|
24
|
-
exports.createApwGraphQL = createApwGraphQL;
|
24
|
+
exports.createApwGraphQL = createApwGraphQL;
|
25
|
+
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@webiny/api-apw",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.38.0-beta.0",
|
4
4
|
"keywords": [
|
5
5
|
"apw:base"
|
6
6
|
],
|
@@ -17,26 +17,26 @@
|
|
17
17
|
"@aws-sdk/client-cloudwatch-events": "3.54.1",
|
18
18
|
"@babel/runtime": "7.22.6",
|
19
19
|
"@commodo/fields": "1.1.2-beta.20",
|
20
|
-
"@webiny/api": "5.
|
21
|
-
"@webiny/api-admin-settings": "5.
|
22
|
-
"@webiny/api-headless-cms": "5.
|
23
|
-
"@webiny/api-i18n": "5.
|
24
|
-
"@webiny/api-mailer": "5.
|
25
|
-
"@webiny/api-page-builder": "5.
|
26
|
-
"@webiny/api-security": "5.
|
27
|
-
"@webiny/api-tenancy": "5.
|
28
|
-
"@webiny/api-wcp": "5.
|
29
|
-
"@webiny/db-dynamodb": "5.
|
30
|
-
"@webiny/error": "5.
|
31
|
-
"@webiny/handler": "5.
|
32
|
-
"@webiny/handler-client": "5.
|
33
|
-
"@webiny/handler-db": "5.
|
34
|
-
"@webiny/handler-graphql": "5.
|
35
|
-
"@webiny/handler-logs": "5.
|
36
|
-
"@webiny/plugins": "5.
|
37
|
-
"@webiny/pubsub": "5.
|
38
|
-
"@webiny/utils": "5.
|
39
|
-
"@webiny/validation": "5.
|
20
|
+
"@webiny/api": "5.38.0-beta.0",
|
21
|
+
"@webiny/api-admin-settings": "5.38.0-beta.0",
|
22
|
+
"@webiny/api-headless-cms": "5.38.0-beta.0",
|
23
|
+
"@webiny/api-i18n": "5.38.0-beta.0",
|
24
|
+
"@webiny/api-mailer": "5.38.0-beta.0",
|
25
|
+
"@webiny/api-page-builder": "5.38.0-beta.0",
|
26
|
+
"@webiny/api-security": "5.38.0-beta.0",
|
27
|
+
"@webiny/api-tenancy": "5.38.0-beta.0",
|
28
|
+
"@webiny/api-wcp": "5.38.0-beta.0",
|
29
|
+
"@webiny/db-dynamodb": "5.38.0-beta.0",
|
30
|
+
"@webiny/error": "5.38.0-beta.0",
|
31
|
+
"@webiny/handler": "5.38.0-beta.0",
|
32
|
+
"@webiny/handler-client": "5.38.0-beta.0",
|
33
|
+
"@webiny/handler-db": "5.38.0-beta.0",
|
34
|
+
"@webiny/handler-graphql": "5.38.0-beta.0",
|
35
|
+
"@webiny/handler-logs": "5.38.0-beta.0",
|
36
|
+
"@webiny/plugins": "5.38.0-beta.0",
|
37
|
+
"@webiny/pubsub": "5.38.0-beta.0",
|
38
|
+
"@webiny/utils": "5.38.0-beta.0",
|
39
|
+
"@webiny/validation": "5.38.0-beta.0",
|
40
40
|
"dayjs": "1.11.7",
|
41
41
|
"lodash": "4.17.21"
|
42
42
|
},
|
@@ -44,10 +44,10 @@
|
|
44
44
|
"@babel/cli": "7.22.6",
|
45
45
|
"@babel/core": "7.22.8",
|
46
46
|
"@babel/preset-env": "7.22.7",
|
47
|
-
"@webiny/cli": "5.
|
48
|
-
"@webiny/handler-aws": "5.
|
49
|
-
"@webiny/project-utils": "5.
|
50
|
-
"@webiny/wcp": "5.
|
47
|
+
"@webiny/cli": "5.38.0-beta.0",
|
48
|
+
"@webiny/handler-aws": "5.38.0-beta.0",
|
49
|
+
"@webiny/project-utils": "5.38.0-beta.0",
|
50
|
+
"@webiny/wcp": "5.38.0-beta.0",
|
51
51
|
"get-yarn-workspaces": "1.0.2",
|
52
52
|
"graphql": "15.8.0",
|
53
53
|
"jest": "29.5.0",
|
@@ -65,5 +65,5 @@
|
|
65
65
|
"build": "yarn webiny run build",
|
66
66
|
"watch": "yarn webiny run watch"
|
67
67
|
},
|
68
|
-
"gitHead": "
|
68
|
+
"gitHead": "5746389d4988626b50e2523ccfa0a9a5e398e0ed"
|
69
69
|
}
|
@@ -33,4 +33,6 @@ class CmsEntryApwSettingsGetterPlugin extends _ContentApwSettingsPlugin.ContentA
|
|
33
33
|
return ((_entry$meta$apw2 = entry.meta.apw) === null || _entry$meta$apw2 === void 0 ? void 0 : _entry$meta$apw2.contentReviewId) || null;
|
34
34
|
}
|
35
35
|
}
|
36
|
-
exports.CmsEntryApwSettingsGetterPlugin = CmsEntryApwSettingsGetterPlugin;
|
36
|
+
exports.CmsEntryApwSettingsGetterPlugin = CmsEntryApwSettingsGetterPlugin;
|
37
|
+
|
38
|
+
//# sourceMappingURL=CmsEntryApwSettingsGetterPlugin.js.map
|
package/plugins/cms/index.js
CHANGED
@@ -29,4 +29,6 @@ const apwCmsHooks = params => {
|
|
29
29
|
(0, _triggerContentReview.triggerContentReview)(params);
|
30
30
|
(0, _updateContentReviewStatus.updateContentReviewStatus)(params);
|
31
31
|
};
|
32
|
-
exports.apwCmsHooks = apwCmsHooks;
|
32
|
+
exports.apwCmsHooks = apwCmsHooks;
|
33
|
+
|
34
|
+
//# sourceMappingURL=index.js.map
|
@@ -60,7 +60,7 @@ const linkContentReviewToEntry = params => {
|
|
60
60
|
model
|
61
61
|
}) => {
|
62
62
|
var _entry$meta;
|
63
|
-
if ((0, _utils.
|
63
|
+
if ((0, _utils.isApwDisabledOnModel)(model)) {
|
64
64
|
return;
|
65
65
|
}
|
66
66
|
const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.contentReviewId;
|
@@ -88,4 +88,6 @@ const linkContentReviewToEntry = params => {
|
|
88
88
|
});
|
89
89
|
});
|
90
90
|
};
|
91
|
-
exports.linkContentReviewToEntry = linkContentReviewToEntry;
|
91
|
+
exports.linkContentReviewToEntry = linkContentReviewToEntry;
|
92
|
+
|
93
|
+
//# sourceMappingURL=linkContentReviewToEntry.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_utils","_error","_interopRequireDefault","linkContentReviewToEntry","params","apw","cms","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onContentReviewAfterDelete","onEntryBeforeDelete","entry","_entry$meta","
|
1
|
+
{"version":3,"names":["_types","require","_utils","_error","_interopRequireDefault","linkContentReviewToEntry","params","apw","cms","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onContentReviewAfterDelete","onEntryBeforeDelete","entry","_entry$meta","isApwDisabledOnModel","get","ex","code","Error","exports"],"sources":["linkContentReviewToEntry.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, isApwDisabledOnModel, updateEntryMeta } from \"~/plugins/cms/utils\";\nimport Error from \"@webiny/error\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface LinkContentReviewToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkContentReviewToEntry = (params: LinkContentReviewToEntryParams) => {\n const { apw, cms } = params;\n\n apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: contentReview.id\n }\n },\n entryId: content.id\n });\n });\n\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: null\n }\n },\n entryId: content.id\n });\n });\n\n cms.onEntryBeforeDelete.subscribe(async ({ entry, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n\n if (!contentReviewId) {\n return;\n }\n let contentReview;\n try {\n contentReview = await apw.contentReview.get(contentReviewId);\n } catch (ex) {\n /**\n * We're handling the case whereby \"contentReviewId\" is still linked to page;\n * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.\n */\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n\n if (!contentReview) {\n return;\n }\n throw new Error(\n `Cannot delete the entry because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n entry\n }\n );\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAOO,MAAMI,wBAAwB,GAAIC,MAAsC,IAAK;EAChF,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAE3BC,GAAG,CAACE,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IAEjC,IAAIG,OAAO,CAACC,IAAI,KAAKC,sBAAe,CAACC,SAAS,EAAE;MAC5C;IACJ;IAEA,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAU,EAACT,GAAG,EAAEI,OAAO,CAACM,EAAE,EAAEN,OAAO,CAACO,QAAQ,CAAC;IAEjE,MAAM,IAAAC,sBAAe,EAAC;MAClBZ,GAAG;MACHQ,KAAK;MACLK,IAAI,EAAE;QACFd,GAAG,EAAE;UACDe,eAAe,EAAEb,aAAa,CAACS;QACnC;MACJ,CAAC;MACDK,OAAO,EAAEX,OAAO,CAACM;IAC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IAAIuB,cAAK,CACV,mGAAkG,EACnG,4BAA4B,EAC5B;MACIV,eAAe;MACfI;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAA5B,wBAAA,GAAAA,wBAAA"}
|
@@ -16,12 +16,13 @@ const linkWorkflowToEntry = params => {
|
|
16
16
|
entry,
|
17
17
|
model
|
18
18
|
}) => {
|
19
|
-
if ((0, _utils.
|
19
|
+
if ((0, _utils.isApwDisabledOnModel)(model)) {
|
20
20
|
return;
|
21
21
|
}
|
22
22
|
await (0, _utils.assignWorkflowToEntry)({
|
23
23
|
apw,
|
24
|
-
entry
|
24
|
+
entry,
|
25
|
+
model
|
25
26
|
});
|
26
27
|
});
|
27
28
|
cms.onEntryRevisionBeforeCreate.subscribe(async ({
|
@@ -30,7 +31,7 @@ const linkWorkflowToEntry = params => {
|
|
30
31
|
model
|
31
32
|
}) => {
|
32
33
|
var _original$meta, _original$meta2;
|
33
|
-
if ((0, _utils.
|
34
|
+
if ((0, _utils.isApwDisabledOnModel)(model)) {
|
34
35
|
return;
|
35
36
|
}
|
36
37
|
/**
|
@@ -55,7 +56,8 @@ const linkWorkflowToEntry = params => {
|
|
55
56
|
*/
|
56
57
|
await (0, _utils.assignWorkflowToEntry)({
|
57
58
|
apw,
|
58
|
-
entry
|
59
|
+
entry,
|
60
|
+
model
|
59
61
|
});
|
60
62
|
});
|
61
63
|
cms.onEntryBeforeUpdate.subscribe(async ({
|
@@ -64,7 +66,7 @@ const linkWorkflowToEntry = params => {
|
|
64
66
|
model
|
65
67
|
}) => {
|
66
68
|
var _original$meta3, _entry$meta, _entry$meta2;
|
67
|
-
if ((0, _utils.
|
69
|
+
if ((0, _utils.isApwDisabledOnModel)(model)) {
|
68
70
|
return;
|
69
71
|
}
|
70
72
|
const prevApwWorkflowId = (_original$meta3 = original.meta) === null || _original$meta3 === void 0 || (_original$meta3 = _original$meta3.apw) === null || _original$meta3 === void 0 ? void 0 : _original$meta3.workflowId;
|
@@ -134,4 +136,6 @@ const linkWorkflowToEntry = params => {
|
|
134
136
|
}
|
135
137
|
});
|
136
138
|
};
|
137
|
-
exports.linkWorkflowToEntry = linkWorkflowToEntry;
|
139
|
+
exports.linkWorkflowToEntry = linkWorkflowToEntry;
|
140
|
+
|
141
|
+
//# sourceMappingURL=linkWorkflowToEntry.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_set","_interopRequireDefault","require","_utils","linkWorkflowToEntry","params","apw","cms","onEntryBeforeCreate","subscribe","entry","model","
|
1
|
+
{"version":3,"names":["_set","_interopRequireDefault","require","_utils","linkWorkflowToEntry","params","apw","cms","onEntryBeforeCreate","subscribe","entry","model","isApwDisabledOnModel","assignWorkflowToEntry","onEntryRevisionBeforeCreate","original","_original$meta","_original$meta2","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onEntryBeforeUpdate","_original$meta3","_entry$meta","_entry$meta2","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onWorkflowAfterCreate","_scope$data","scope","hasEntries","models","listModels","values","data","entries","Array","isArray","length","value","modelId","id","find","m","updateEntryMeta","entryId","exports"],"sources":["linkWorkflowToEntry.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport {\n assignWorkflowToEntry,\n getEntryTitle,\n hasEntries,\n isApwDisabledOnModel,\n updateEntryMeta\n} from \"~/plugins/cms/utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface Value {\n id: string;\n modelId: string;\n}\n\ninterface LinkWorkflowToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkWorkflowToEntry = (params: LinkWorkflowToEntryParams) => {\n const { apw, cms } = params;\n\n cms.onEntryBeforeCreate.subscribe(async ({ entry, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n await assignWorkflowToEntry({\n apw,\n entry,\n model\n });\n });\n\n cms.onEntryRevisionBeforeCreate.subscribe(async ({ entry, original, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = original.meta?.apw?.contentReviewId;\n if (previousContentReviewId) {\n entry.meta = set(entry.meta || {}, \"apw.contentReviewId\", null);\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = original.meta?.apw?.workflowId;\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToEntry({\n apw,\n entry,\n model\n });\n });\n\n cms.onEntryBeforeUpdate.subscribe(async ({ entry, original, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n const prevApwWorkflowId = original.meta?.apw?.workflowId;\n const currentApwWorkflowId = entry.meta?.apw?.workflowId;\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n entry.meta = set(entry.meta || {}, \"apw\", (original.meta || {}).apw || {});\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = entry.meta?.apw?.contentReviewId;\n const prevTitle = getEntryTitle(model, original);\n const newTitle = getEntryTitle(model, entry);\n\n if (!linkedContentReviewId || prevTitle === newTitle) {\n return;\n }\n await apw.contentReview.update(linkedContentReviewId, {\n title: newTitle\n });\n });\n\n /**\n * Link created workflow to associated entries.\n */\n apw.workflow.onWorkflowAfterCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n /**\n * If the workflow has entries in it's scope, we'll link that workflow for each of those entries.\n */\n if (hasEntries(workflow) === false) {\n return;\n }\n\n const models = await cms.listModels();\n\n const values: Value[] | undefined = scope.data?.entries;\n if (!values || Array.isArray(values) === false || values.length === 0) {\n return;\n }\n\n for (const value of values) {\n if (!value || !value.modelId || !value.id) {\n continue;\n }\n const model = models.find(m => m.modelId === value.modelId);\n if (!model) {\n continue;\n }\n await updateEntryMeta({\n cms,\n model,\n entryId: value.id,\n meta: {\n apw: {\n workflowId: workflow.id\n }\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAkBO,MAAME,mBAAmB,GAAIC,MAAiC,IAAK;EACtE,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAE3BE,GAAG,CAACC,mBAAmB,CAACC,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IAC1D,IAAI,IAAAC,2BAAoB,EAACD,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA,MAAM,IAAAE,4BAAqB,EAAC;MACxBP,GAAG;MACHI,KAAK;MACLC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFJ,GAAG,CAACO,2BAA2B,CAACL,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEK,QAAQ;IAAEJ;EAAM,CAAC,KAAK;IAAA,IAAAK,cAAA,EAAAC,eAAA;IAC5E,IAAI,IAAAL,2BAAoB,EAACD,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMO,uBAAuB,IAAAF,cAAA,GAAGD,QAAQ,CAACI,IAAI,cAAAH,cAAA,gBAAAA,cAAA,GAAbA,cAAA,CAAeV,GAAG,cAAAU,cAAA,uBAAlBA,cAAA,CAAoBI,eAAe;IACnE,IAAIF,uBAAuB,EAAE;MACzBR,KAAK,CAACS,IAAI,GAAG,IAAAE,YAAG,EAACX,KAAK,CAACS,IAAI,IAAI,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,CAA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C,CAACH,OAAO,KAAKD,KAAK,CAACC,OAAO,CAAC;MAC3D,IAAI,CAACxC,KAAK,EAAE;QACR;MACJ;MACA,MAAM,IAAA4C,sBAAe,EAAC;QAClBhD,GAAG;QACHI,KAAK;QACL6C,OAAO,EAAEN,KAAK,CAACE,EAAE;QACjBjC,IAAI,EAAE;UACFb,GAAG,EAAE;YACDiB,UAAU,EAAEc,QAAQ,CAACe;UACzB;QACJ;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAArD,mBAAA,GAAAA,mBAAA"}
|
@@ -28,4 +28,6 @@ const createChangeRequestNotification = () => {
|
|
28
28
|
plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
|
29
29
|
return plugin;
|
30
30
|
};
|
31
|
-
exports.createChangeRequestNotification = createChangeRequestNotification;
|
31
|
+
exports.createChangeRequestNotification = createChangeRequestNotification;
|
32
|
+
|
33
|
+
//# sourceMappingURL=changeRequestNotification.js.map
|
@@ -28,4 +28,6 @@ const createCommentNotification = () => {
|
|
28
28
|
plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
|
29
29
|
return plugin;
|
30
30
|
};
|
31
|
-
exports.createCommentNotification = createCommentNotification;
|
31
|
+
exports.createCommentNotification = createCommentNotification;
|
32
|
+
|
33
|
+
//# sourceMappingURL=commentNotification.js.map
|
@@ -28,4 +28,6 @@ const createContentReviewNotification = () => {
|
|
28
28
|
plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
|
29
29
|
return plugin;
|
30
30
|
};
|
31
|
-
exports.createContentReviewNotification = createContentReviewNotification;
|
31
|
+
exports.createContentReviewNotification = createContentReviewNotification;
|
32
|
+
|
33
|
+
//# sourceMappingURL=contentReviewNotification.js.map
|
@@ -18,7 +18,7 @@ const triggerContentReview = params => {
|
|
18
18
|
model
|
19
19
|
}) => {
|
20
20
|
var _entry$meta, _entry$meta2;
|
21
|
-
if ((0, _utils.
|
21
|
+
if ((0, _utils.isApwDisabledOnModel)(model)) {
|
22
22
|
return;
|
23
23
|
}
|
24
24
|
const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.contentReviewId;
|
@@ -42,4 +42,6 @@ const triggerContentReview = params => {
|
|
42
42
|
});
|
43
43
|
});
|
44
44
|
};
|
45
|
-
exports.triggerContentReview = triggerContentReview;
|
45
|
+
exports.triggerContentReview = triggerContentReview;
|
46
|
+
|
47
|
+
//# sourceMappingURL=triggerContentReview.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_utils","triggerContentReview","params","cms","apw","onEntryBeforePublish","subscribe","entry","model","_entry$meta","_entry$meta2","
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_utils","triggerContentReview","params","cms","apw","onEntryBeforePublish","subscribe","entry","model","_entry$meta","_entry$meta2","isApwDisabledOnModel","contentReviewId","meta","contentReview","get","reviewStatus","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId","exports"],"sources":["triggerContentReview.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnCmsEntryBeforePublishTopicParams\n} from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { isApwDisabledOnModel } from \"~/plugins/cms/utils\";\n\ninterface TriggerContentReviewParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const triggerContentReview = (params: TriggerContentReviewParams) => {\n const { cms, apw } = params;\n\n cms.onEntryBeforePublish.subscribe<OnCmsEntryBeforePublishTopicParams>(\n async ({ entry, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n if (contentReviewId) {\n const contentReview = await apw.contentReview.get(contentReviewId);\n\n if (contentReview.reviewStatus !== ApwContentReviewStatus.UNDER_REVIEW) {\n return;\n }\n throw new Error(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n entry\n }\n );\n }\n\n const workflowId = entry.meta?.apw?.workflowId;\n\n if (!workflowId) {\n return;\n }\n throw new Error(\n \"This content requires peer review approval before it can be published.\",\n \"REVIEW_REQUIRED\",\n {\n workflowId,\n entry\n }\n );\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,MAAA,GAAAF,OAAA;AAMO,MAAMG,oBAAoB,GAAIC,MAAkC,IAAK;EACxE,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAE3BC,GAAG,CAACE,oBAAoB,CAACC,SAAS,CAC9B,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IAAA,IAAAC,WAAA,EAAAC,YAAA;IACxB,IAAI,IAAAC,2BAAoB,EAACH,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA,MAAMI,eAAe,IAAAH,WAAA,GAAGF,KAAK,CAACM,IAAI,cAAAJ,WAAA,gBAAAA,WAAA,GAAVA,WAAA,CAAYL,GAAG,cAAAK,WAAA,uBAAfA,WAAA,CAAiBG,eAAe;IACxD,IAAIA,eAAe,EAAE;MACjB,MAAME,aAAa,GAAG,MAAMV,GAAG,CAACU,aAAa,CAACC,GAAG,CAACH,eAAe,CAAC;MAElE,IAAIE,aAAa,CAACE,YAAY,KAAKC,6BAAsB,CAACC,YAAY,EAAE;QACpE;MACJ;MACA,MAAM,IAAIC,cAAK,CACV,4DAA2D,EAC5D,sBAAsB,EACtB;QACIP,eAAe;QACfL;MACJ,CACJ,CAAC;IACL;IAEA,MAAMa,UAAU,IAAAV,YAAA,GAAGH,KAAK,CAACM,IAAI,cAAAH,YAAA,gBAAAA,YAAA,GAAVA,YAAA,CAAYN,GAAG,cAAAM,YAAA,uBAAfA,YAAA,CAAiBU,UAAU;IAE9C,IAAI,CAACA,UAAU,EAAE;MACb;IACJ;IACA,MAAM,IAAID,cAAK,CACX,wEAAwE,EACxE,iBAAiB,EACjB;MACIC,UAAU;MACVb;IACJ,CACJ,CAAC;EACL,CACJ,CAAC;AACL,CAAC;AAACc,OAAA,CAAApB,oBAAA,GAAAA,oBAAA"}
|
@@ -20,7 +20,7 @@ const updateContentReviewStatus = params => {
|
|
20
20
|
model
|
21
21
|
}) => {
|
22
22
|
var _entry$meta;
|
23
|
-
if ((0, _utils2.
|
23
|
+
if ((0, _utils2.isApwDisabledOnModel)(model)) {
|
24
24
|
return;
|
25
25
|
}
|
26
26
|
const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.contentReviewId;
|
@@ -50,7 +50,7 @@ const updateContentReviewStatus = params => {
|
|
50
50
|
model
|
51
51
|
}) => {
|
52
52
|
var _entry$meta2;
|
53
|
-
if ((0, _utils2.
|
53
|
+
if ((0, _utils2.isApwDisabledOnModel)(model)) {
|
54
54
|
return;
|
55
55
|
}
|
56
56
|
const contentReviewId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 || (_entry$meta2 = _entry$meta2.apw) === null || _entry$meta2 === void 0 ? void 0 : _entry$meta2.contentReviewId;
|
@@ -76,4 +76,6 @@ const updateContentReviewStatus = params => {
|
|
76
76
|
});
|
77
77
|
});
|
78
78
|
};
|
79
|
-
exports.updateContentReviewStatus = updateContentReviewStatus;
|
79
|
+
exports.updateContentReviewStatus = updateContentReviewStatus;
|
80
|
+
|
81
|
+
//# sourceMappingURL=updateContentReviewStatus.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_utils","_utils2","updateContentReviewStatus","params","apw","cms","security","onEntryAfterPublish","subscribe","entry","model","_entry$meta","
|
1
|
+
{"version":3,"names":["_types","require","_utils","_utils2","updateContentReviewStatus","params","apw","cms","security","onEntryAfterPublish","subscribe","entry","model","_entry$meta","isApwDisabledOnModel","contentReviewId","meta","contentReview","get","identity","getIdentity","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","_objectSpread2","default","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onEntryAfterUnpublish","_entry$meta2","exports"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnCmsEntryAfterPublishTopicParams,\n OnCmsEntryAfterUnpublishTopicParams\n} from \"~/types\";\nimport { INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META } from \"~/crud/utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport { isApwDisabledOnModel } from \"~/plugins/cms/utils\";\n\ninterface UpdateContentReviewStatusParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\n\nexport const updateContentReviewStatus = (params: UpdateContentReviewStatusParams) => {\n const { apw, cms, security } = params;\n\n cms.onEntryAfterPublish.subscribe<OnCmsEntryAfterPublishTopicParams>(\n async ({ entry, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n const identity = security.getIdentity();\n /**\n * If content review is \"readyToBePublished set its status as \"published\" after page publish.\n */\n if (contentReview.reviewStatus !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n );\n cms.onEntryAfterUnpublish.subscribe<OnCmsEntryAfterUnpublishTopicParams>(\n async ({ entry, model }) => {\n if (isApwDisabledOnModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n /**\n * If content review is \"published set its status as \"readyToBePublished\" after page unpublish.\n */\n\n if (contentReview.reviewStatus !== ApwContentReviewStatus.PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.READY_TO_BE_PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: null\n }\n });\n }\n );\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,OAAA,GAAAF,OAAA;AAQO,MAAMG,yBAAyB,GAAIC,MAAuC,IAAK;EAClF,MAAM;IAAEC,GAAG;IAAEC,GAAG;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAErCE,GAAG,CAACE,mBAAmB,CAACC,SAAS,CAC7B,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IAAA,IAAAC,WAAA;IACxB,IAAI,IAAAC,4BAAoB,EAACF,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA,MAAMG,eAAe,IAAAF,WAAA,GAAGF,KAAK,CAACK,IAAI,cAAAH,WAAA,gBAAAA,WAAA,GAAVA,WAAA,CAAYP,GAAG,cAAAO,WAAA,uBAAfA,WAAA,CAAiBE,eAAe;IACxD;AACZ;AACA;IACY,IAAI,CAACA,eAAe,EAAE;MAClB;IACJ;IAEA,MAAME,aAAa,GAAG,MAAMX,GAAG,CAACW,aAAa,CAACC,GAAG,CAACH,eAAe,CAAC;IAClE,MAAMI,QAAQ,GAAGX,QAA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O,GACrBG,mDAA4C;QAC/CC,WAAW,EAAE;MAAI;IAEzB,CAAC,CAAC;EACN,CACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAA9B,yBAAA,GAAAA,yBAAA"}
|
package/plugins/cms/utils.d.ts
CHANGED
@@ -20,8 +20,9 @@ export declare const updateEntryMeta: (params: UpdateEntryMetaParams) => Promise
|
|
20
20
|
interface AssignWorkflowToEntryParams {
|
21
21
|
apw: AdvancedPublishingWorkflow;
|
22
22
|
entry: CmsEntry;
|
23
|
+
model: CmsModel;
|
23
24
|
}
|
24
25
|
export declare const assignWorkflowToEntry: (params: AssignWorkflowToEntryParams) => Promise<void>;
|
25
26
|
export declare const hasEntries: (workflow: ApwWorkflow) => Boolean;
|
26
|
-
export declare const
|
27
|
+
export declare const isApwDisabledOnModel: (model: Pick<CmsModel, "modelId" | "isPrivate">) => boolean;
|
27
28
|
export {};
|
package/plugins/cms/utils.js
CHANGED
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
-
exports.updateEntryMeta = exports.
|
7
|
+
exports.updateEntryMeta = exports.isApwDisabledOnModel = exports.hasEntries = exports.getLatestEntryRevision = exports.getEntryTitle = exports.fetchModel = exports.assignWorkflowToEntry = void 0;
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
10
10
|
var _types = require("../../types");
|
@@ -51,11 +51,11 @@ const getLatestEntryRevision = async params => {
|
|
51
51
|
model,
|
52
52
|
entryId
|
53
53
|
} = params;
|
54
|
-
const
|
55
|
-
const item = items.shift();
|
54
|
+
const [item] = await cms.getLatestEntriesByIds(model, [entryId]);
|
56
55
|
if (!item) {
|
57
56
|
throw new _error.default("There is no entry with given ID.", "ENTRY_NOT_FOUND", {
|
58
|
-
entryId
|
57
|
+
entryId,
|
58
|
+
model: model.modelId
|
59
59
|
});
|
60
60
|
}
|
61
61
|
return item;
|
@@ -103,7 +103,8 @@ const isWorkflowApplicable = (entry, workflow) => {
|
|
103
103
|
const assignWorkflowToEntry = async params => {
|
104
104
|
const {
|
105
105
|
apw,
|
106
|
-
entry
|
106
|
+
entry,
|
107
|
+
model
|
107
108
|
} = params;
|
108
109
|
/**
|
109
110
|
* Lookup and assign "workflowId".
|
@@ -117,7 +118,7 @@ const assignWorkflowToEntry = async params => {
|
|
117
118
|
app: _types.ApwWorkflowApplications.CMS
|
118
119
|
}
|
119
120
|
});
|
120
|
-
console.log(`Found ${entries.length}
|
121
|
+
console.log(`Found ${entries.length} workflow(s) for model ${model.modelId}.`);
|
121
122
|
|
122
123
|
/*
|
123
124
|
* Re-order them based on workflow scope and pre-defined rule i.e.
|
@@ -156,7 +157,15 @@ const hasEntries = workflow => {
|
|
156
157
|
return app === _types.ApwWorkflowApplications.CMS && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.entries);
|
157
158
|
};
|
158
159
|
exports.hasEntries = hasEntries;
|
159
|
-
const
|
160
|
+
const isApwDisabledOnModel = model => {
|
161
|
+
/**
|
162
|
+
* We should not run APW on private models as well.
|
163
|
+
*/
|
164
|
+
if (model.isPrivate) {
|
165
|
+
return true;
|
166
|
+
}
|
160
167
|
return [_changeRequest.CHANGE_REQUEST_MODEL_ID, _comment.COMMENT_MODEL_ID, _contentReview.CONTENT_REVIEW_MODEL_ID, _reviewer.REVIEWER_MODEL_ID, _workflow.WORKFLOW_MODEL_ID].includes(model.modelId);
|
161
168
|
};
|
162
|
-
exports.
|
169
|
+
exports.isApwDisabledOnModel = isApwDisabledOnModel;
|
170
|
+
|
171
|
+
//# sourceMappingURL=utils.js.map
|