@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2696f9d9e8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +28 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +28 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +28 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +28 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +5 -9
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/README.md +3 -3
  16. package/crud/createChangeRequestMethods.js +7 -12
  17. package/crud/createChangeRequestMethods.js.map +1 -1
  18. package/crud/createCommentMethods.js +7 -13
  19. package/crud/createCommentMethods.js.map +1 -1
  20. package/crud/createContentReviewMethods.js +83 -111
  21. package/crud/createContentReviewMethods.js.map +1 -1
  22. package/crud/createReviewerMethods.js +7 -13
  23. package/crud/createReviewerMethods.js.map +1 -1
  24. package/crud/createWorkflowMethods.js +7 -18
  25. package/crud/createWorkflowMethods.js.map +1 -1
  26. package/crud/index.js +5 -29
  27. package/crud/index.js.map +1 -1
  28. package/crud/utils.js +6 -33
  29. package/crud/utils.js.map +1 -1
  30. package/index.d.ts +2 -3
  31. package/index.js +6 -16
  32. package/index.js.map +1 -1
  33. package/package.json +40 -47
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
  35. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  36. package/plugins/cms/apwEntryPlugins.js +8 -13
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  38. package/plugins/cms/index.js +7 -10
  39. package/plugins/cms/index.js.map +1 -1
  40. package/plugins/cms/linkContentReviewToEntry.js +4 -20
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +17 -45
  43. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  44. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js +33 -0
  46. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  47. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  48. package/plugins/cms/notifications/commentNotification.js +33 -0
  49. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js +33 -0
  52. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  53. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  54. package/plugins/cms/notifications/contentUrl.js +55 -0
  55. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  56. package/plugins/cms/triggerContentReview.js +5 -18
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +14 -30
  59. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  60. package/plugins/cms/utils.d.ts +3 -2
  61. package/plugins/cms/utils.js +23 -60
  62. package/plugins/cms/utils.js.map +1 -1
  63. package/plugins/context.d.ts +0 -1
  64. package/plugins/context.js +2 -45
  65. package/plugins/context.js.map +1 -1
  66. package/plugins/graphql/changeRequest.gql.js +16 -19
  67. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  68. package/plugins/graphql/comment.gql.js +41 -42
  69. package/plugins/graphql/comment.gql.js.map +1 -1
  70. package/plugins/graphql/contentReview.gql.js +25 -34
  71. package/plugins/graphql/contentReview.gql.js.map +1 -1
  72. package/plugins/graphql/reviewer.gql.js +17 -19
  73. package/plugins/graphql/reviewer.gql.js.map +1 -1
  74. package/plugins/graphql/utils.d.ts +2 -0
  75. package/plugins/graphql/utils.js +12 -0
  76. package/plugins/graphql/utils.js.map +1 -0
  77. package/plugins/graphql/workflow.gql.js +15 -19
  78. package/plugins/graphql/workflow.gql.js.map +1 -1
  79. package/plugins/graphql.js +5 -18
  80. package/plugins/graphql.js.map +1 -1
  81. package/plugins/hooks/createReviewerFromIdentity.js +28 -15
  82. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  83. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
  84. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  85. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
  86. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  87. package/plugins/hooks/index.js +4 -13
  88. package/plugins/hooks/index.js.map +1 -1
  89. package/plugins/hooks/initializeContentReviewSteps.js +15 -20
  90. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  91. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  92. package/plugins/hooks/initializeNotifications.js +17 -0
  93. package/plugins/hooks/initializeNotifications.js.map +1 -0
  94. package/plugins/hooks/listContentReviews.d.ts +1 -1
  95. package/plugins/hooks/listContentReviews.js +11 -33
  96. package/plugins/hooks/listContentReviews.js.map +1 -1
  97. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  98. package/plugins/hooks/notifications/appUrl.js +20 -0
  99. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  100. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  101. package/plugins/hooks/notifications/changeRequestAfterCreate.js +113 -0
  102. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  103. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  104. package/plugins/hooks/notifications/changeRequestUrl.js +29 -0
  105. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  106. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  107. package/plugins/hooks/notifications/commentAfterCreate.js +124 -0
  108. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  109. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  110. package/plugins/hooks/notifications/commentUrl.js +29 -0
  111. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  112. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  113. package/plugins/hooks/notifications/contentReviewAfterCreate.js +96 -0
  114. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  115. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  116. package/plugins/hooks/notifications/contentReviewUrl.js +28 -0
  117. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  118. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  119. package/plugins/hooks/notifications/contentUrl.js +26 -0
  120. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  121. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  122. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +23 -0
  123. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  124. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  125. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +23 -0
  126. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  127. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  128. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +23 -0
  129. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  130. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  131. package/plugins/hooks/notifications/reviewers.js +47 -0
  132. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  133. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  134. package/plugins/hooks/notifications/sendChangeRequestNotification.js +43 -0
  135. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  136. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  137. package/plugins/hooks/notifications/sendCommentNotification.js +43 -0
  138. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  139. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  140. package/plugins/hooks/notifications/sendContentReviewNotification.js +43 -0
  141. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  142. package/plugins/hooks/updatePendingChangeRequests.js +7 -13
  143. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  144. package/plugins/hooks/updateTotalComments.js +21 -23
  145. package/plugins/hooks/updateTotalComments.js.map +1 -1
  146. package/plugins/hooks/validateChangeRequest.js +27 -16
  147. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  148. package/plugins/hooks/validateComment.js +13 -12
  149. package/plugins/hooks/validateComment.js.map +1 -1
  150. package/plugins/hooks/validateContentReview.js +2 -6
  151. package/plugins/hooks/validateContentReview.js.map +1 -1
  152. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +4 -19
  153. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  154. package/plugins/pageBuilder/apwContentPagePlugins.js +2 -4
  155. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  156. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +3 -6
  157. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  158. package/plugins/pageBuilder/index.js +7 -8
  159. package/plugins/pageBuilder/index.js.map +1 -1
  160. package/plugins/pageBuilder/linkContentReviewToPage.js +15 -27
  161. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  162. package/plugins/pageBuilder/linkWorkflowToPage.js +3 -31
  163. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  164. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  165. package/plugins/pageBuilder/notifications/changeRequestNotification.js +33 -0
  166. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  167. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  168. package/plugins/pageBuilder/notifications/commentNotification.js +33 -0
  169. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  170. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  171. package/plugins/pageBuilder/notifications/contentReviewNotification.js +33 -0
  172. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  173. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  174. package/plugins/pageBuilder/notifications/contentUrl.js +49 -0
  175. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  176. package/plugins/pageBuilder/triggerContentReview.js +2 -11
  177. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  178. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -17
  179. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  180. package/plugins/pageBuilder/utils.d.ts +2 -2
  181. package/plugins/pageBuilder/utils.js +3 -35
  182. package/plugins/pageBuilder/utils.js.map +1 -1
  183. package/plugins/utils.d.ts +1 -2
  184. package/plugins/utils.js +6 -52
  185. package/plugins/utils.js.map +1 -1
  186. package/scheduler/createScheduleActionMethods.js +45 -50
  187. package/scheduler/createScheduleActionMethods.js.map +1 -1
  188. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  189. package/scheduler/handlers/executeAction/index.js +47 -40
  190. package/scheduler/handlers/executeAction/index.js.map +1 -1
  191. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  192. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +19 -9
  193. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  194. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  195. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +11 -28
  196. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  197. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  198. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
  199. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  200. package/scheduler/handlers/executeAction/security.js +2 -11
  201. package/scheduler/handlers/executeAction/security.js.map +1 -1
  202. package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
  203. package/scheduler/handlers/scheduleAction/index.js +24 -37
  204. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  205. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
  206. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  207. package/scheduler/handlers/utils.d.ts +2 -4
  208. package/scheduler/handlers/utils.js +8 -47
  209. package/scheduler/handlers/utils.js.map +1 -1
  210. package/scheduler/index.js +2 -3
  211. package/scheduler/index.js.map +1 -1
  212. package/scheduler/types.d.ts +12 -28
  213. package/scheduler/types.js +13 -22
  214. package/scheduler/types.js.map +1 -1
  215. package/storageOperations/changeRequestStorageOperations.js +59 -45
  216. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  217. package/storageOperations/commentStorageOperations.js +35 -50
  218. package/storageOperations/commentStorageOperations.js.map +1 -1
  219. package/storageOperations/contentReviewStorageOperations.d.ts +1 -1
  220. package/storageOperations/contentReviewStorageOperations.js +34 -43
  221. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  222. package/storageOperations/index.d.ts +1 -7
  223. package/storageOperations/index.js +10 -29
  224. package/storageOperations/index.js.map +1 -1
  225. package/storageOperations/models/changeRequest.model.d.ts +1 -2
  226. package/storageOperations/models/changeRequest.model.js +6 -15
  227. package/storageOperations/models/changeRequest.model.js.map +1 -1
  228. package/storageOperations/models/comment.model.d.ts +1 -2
  229. package/storageOperations/models/comment.model.js +6 -14
  230. package/storageOperations/models/comment.model.js.map +1 -1
  231. package/storageOperations/models/contentReview.model.d.ts +1 -2
  232. package/storageOperations/models/contentReview.model.js +13 -37
  233. package/storageOperations/models/contentReview.model.js.map +1 -1
  234. package/storageOperations/models/index.js +6 -50
  235. package/storageOperations/models/index.js.map +1 -1
  236. package/storageOperations/models/reviewer.model.d.ts +1 -2
  237. package/storageOperations/models/reviewer.model.js +22 -14
  238. package/storageOperations/models/reviewer.model.js.map +1 -1
  239. package/storageOperations/models/utils.js +2 -4
  240. package/storageOperations/models/utils.js.map +1 -1
  241. package/storageOperations/models/workflow.model.d.ts +1 -2
  242. package/storageOperations/models/workflow.model.js +19 -42
  243. package/storageOperations/models/workflow.model.js.map +1 -1
  244. package/storageOperations/reviewerStorageOperations.d.ts +1 -1
  245. package/storageOperations/reviewerStorageOperations.js +34 -40
  246. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  247. package/storageOperations/types.js +3 -1
  248. package/storageOperations/workflowStorageOperations.js +40 -47
  249. package/storageOperations/workflowStorageOperations.js.map +1 -1
  250. package/types.d.ts +39 -25
  251. package/types.js +126 -42
  252. package/types.js.map +1 -1
  253. package/utils/contentApwSettingsPlugin.js +2 -6
  254. package/utils/contentApwSettingsPlugin.js.map +1 -1
  255. package/utils/errors.js +2 -17
  256. package/utils/errors.js.map +1 -1
  257. package/utils/fieldResolver.js +8 -18
  258. package/utils/fieldResolver.js.map +1 -1
  259. package/utils/pickEntryFieldValues.d.ts +3 -0
  260. package/utils/pickEntryFieldValues.js +31 -0
  261. package/utils/pickEntryFieldValues.js.map +1 -0
  262. package/utils/resolve.d.ts +1 -1
  263. package/utils/resolve.js +2 -3
  264. package/utils/resolve.js.map +1 -1
  265. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
  266. package/storageOperations/models/contentModelPluginFactory.js +0 -28
  267. package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.linkContentReviewToEntry = void 0;
9
-
10
8
  var _types = require("../../types");
11
-
12
9
  var _utils = require("./utils");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  const linkContentReviewToEntry = params => {
17
12
  const {
18
13
  apw,
@@ -24,11 +19,9 @@ const linkContentReviewToEntry = params => {
24
19
  const {
25
20
  content
26
21
  } = contentReview;
27
-
28
22
  if (content.type !== _types.ApwContentTypes.CMS_ENTRY) {
29
23
  return;
30
24
  }
31
-
32
25
  const model = await (0, _utils.fetchModel)(cms, content.id, content.settings);
33
26
  await (0, _utils.updateEntryMeta)({
34
27
  cms,
@@ -47,11 +40,9 @@ const linkContentReviewToEntry = params => {
47
40
  const {
48
41
  content
49
42
  } = contentReview;
50
-
51
43
  if (content.type !== _types.ApwContentTypes.CMS_ENTRY) {
52
44
  return;
53
45
  }
54
-
55
46
  const model = await (0, _utils.fetchModel)(cms, content.id, content.settings);
56
47
  await (0, _utils.updateEntryMeta)({
57
48
  cms,
@@ -68,20 +59,14 @@ const linkContentReviewToEntry = params => {
68
59
  entry,
69
60
  model
70
61
  }) => {
71
- var _entry$meta, _entry$meta$apw;
72
-
73
- if ((0, _utils.isAwpModel)(model)) {
62
+ if ((0, _utils.isApwDisabledOnModel)(model)) {
74
63
  return;
75
64
  }
76
-
77
- const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.contentReviewId;
78
-
65
+ const contentReviewId = entry.meta?.apw?.contentReviewId;
79
66
  if (!contentReviewId) {
80
67
  return;
81
68
  }
82
-
83
69
  let contentReview;
84
-
85
70
  try {
86
71
  contentReview = await apw.contentReview.get(contentReviewId);
87
72
  } catch (ex) {
@@ -93,16 +78,15 @@ const linkContentReviewToEntry = params => {
93
78
  throw ex;
94
79
  }
95
80
  }
96
-
97
81
  if (!contentReview) {
98
82
  return;
99
83
  }
100
-
101
84
  throw new _error.default(`Cannot delete the entry because a peer review has been requested. Please delete the review first.`, "CANNOT_DELETE_REVIEW_EXIST", {
102
85
  contentReviewId,
103
86
  entry
104
87
  });
105
88
  });
106
89
  };
90
+ exports.linkContentReviewToEntry = linkContentReviewToEntry;
107
91
 
108
- exports.linkContentReviewToEntry = linkContentReviewToEntry;
92
+ //# sourceMappingURL=linkContentReviewToEntry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["linkContentReviewToEntry","params","apw","cms","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onContentReviewAfterDelete","onEntryBeforeDelete","entry","isAwpModel","get","ex","code","Error"],"sources":["linkContentReviewToEntry.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, isAwpModel, 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 (isAwpModel(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;;AACA;;AACA;;AAOO,MAAMA,wBAAwB,GAAIC,MAAD,IAA4C;EAChF,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;EAEAC,GAAG,CAACE,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,SAArC,EAAgD;MAC5C;IACH;;IAED,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWT,GAAX,EAAgBI,OAAO,CAACM,EAAxB,EAA4BN,OAAO,CAACO,QAApC,CAApB;IAEA,MAAM,IAAAC,sBAAA,EAAgB;MAClBZ,GADkB;MAElBQ,KAFkB;MAGlBK,IAAI,EAAE;QACFd,GAAG,EAAE;UACDe,eAAe,EAAEb,aAAa,CAACS;QAD9B;MADH,CAHY;MAQlBK,OAAO,EAAEX,OAAO,CAACM;IARC,CAAhB,CAAN;EAUH,CAnBD;EAqBAX,GAAG,CAACE,aAAJ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,CA9EM"}
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","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;IACrB,CAAC,CAAC;EACN,CAAC,CAAC;EAEFX,GAAG,CAACE,aAAa,CAACe,0BAA0B,CAACb,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IACjC,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,EAAE;QACrB;MACJ,CAAC;MACDC,OAAO,EAAEX,OAAO,CAACM;IACrB,CAAC,CAAC;EACN,CAAC,CAAC;EAEFV,GAAG,CAACiB,mBAAmB,CAACd,SAAS,CAAC,OAAO;IAAEe,KAAK;IAAEV;EAAM,CAAC,KAAK;IAC1D,IAAI,IAAAW,2BAAoB,EAACX,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA,MAAMM,eAAe,GAAGI,KAAK,CAACL,IAAI,EAAEd,GAAG,EAAEe,eAAe;IAExD,IAAI,CAACA,eAAe,EAAE;MAClB;IACJ;IACA,IAAIb,aAAa;IACjB,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAa,CAACmB,GAAG,CAACN,eAAe,CAAC;IAChE,CAAC,CAAC,OAAOO,EAAE,EAAE;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;QACzB,MAAMD,EAAE;MACZ;IACJ;IAEA,IAAI,CAACpB,aAAa,EAAE;MAChB;IACJ;IACA,MAAM,IAAIsB,cAAK,CACV,mGAAkG,EACnG,4BAA4B,EAC5B;MACIT,eAAe;MACfI;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACM,OAAA,CAAA3B,wBAAA,GAAAA,wBAAA"}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.linkWorkflowToEntry = void 0;
9
-
10
8
  var _set = _interopRequireDefault(require("lodash/set"));
11
-
12
9
  var _utils = require("./utils");
13
-
14
10
  const linkWorkflowToEntry = params => {
15
11
  const {
16
12
  apw,
@@ -20,13 +16,13 @@ const linkWorkflowToEntry = params => {
20
16
  entry,
21
17
  model
22
18
  }) => {
23
- if ((0, _utils.isAwpModel)(model)) {
19
+ if ((0, _utils.isApwDisabledOnModel)(model)) {
24
20
  return;
25
21
  }
26
-
27
22
  await (0, _utils.assignWorkflowToEntry)({
28
23
  apw,
29
- entry
24
+ entry,
25
+ model
30
26
  });
31
27
  });
32
28
  cms.onEntryRevisionBeforeCreate.subscribe(async ({
@@ -34,41 +30,33 @@ const linkWorkflowToEntry = params => {
34
30
  original,
35
31
  model
36
32
  }) => {
37
- var _original$meta, _original$meta$apw, _original$meta2, _original$meta2$apw;
38
-
39
- if ((0, _utils.isAwpModel)(model)) {
33
+ if ((0, _utils.isApwDisabledOnModel)(model)) {
40
34
  return;
41
35
  }
42
36
  /**
43
37
  * If the previous revision(original) already had the "contentReviewId",
44
38
  * we need to unlink it so that new "contentReview" can be request for the new revision.
45
39
  */
46
-
47
-
48
- const previousContentReviewId = (_original$meta = original.meta) === null || _original$meta === void 0 ? void 0 : (_original$meta$apw = _original$meta.apw) === null || _original$meta$apw === void 0 ? void 0 : _original$meta$apw.contentReviewId;
49
-
40
+ const previousContentReviewId = original.meta?.apw?.contentReviewId;
50
41
  if (previousContentReviewId) {
51
42
  entry.meta = (0, _set.default)(entry.meta || {}, "apw.contentReviewId", null);
52
43
  }
44
+
53
45
  /**
54
46
  * If the previous revision(original) already had the "workflowId",
55
47
  * we don't need to do anything we'll just let it be copied over.
56
48
  */
57
-
58
-
59
- const previousWorkflowId = (_original$meta2 = original.meta) === null || _original$meta2 === void 0 ? void 0 : (_original$meta2$apw = _original$meta2.apw) === null || _original$meta2$apw === void 0 ? void 0 : _original$meta2$apw.workflowId;
60
-
49
+ const previousWorkflowId = original.meta?.apw?.workflowId;
61
50
  if (previousWorkflowId) {
62
51
  return;
63
52
  }
64
53
  /**
65
54
  * Lookup and assign "workflowId".
66
55
  */
67
-
68
-
69
56
  await (0, _utils.assignWorkflowToEntry)({
70
57
  apw,
71
- entry
58
+ entry,
59
+ model
72
60
  });
73
61
  });
74
62
  cms.onEntryBeforeUpdate.subscribe(async ({
@@ -76,20 +64,16 @@ const linkWorkflowToEntry = params => {
76
64
  original,
77
65
  model
78
66
  }) => {
79
- var _original$meta3, _original$meta3$apw, _entry$meta, _entry$meta$apw, _entry$meta2, _entry$meta2$apw;
80
-
81
- if ((0, _utils.isAwpModel)(model)) {
67
+ if ((0, _utils.isApwDisabledOnModel)(model)) {
82
68
  return;
83
69
  }
84
-
85
- const prevApwWorkflowId = (_original$meta3 = original.meta) === null || _original$meta3 === void 0 ? void 0 : (_original$meta3$apw = _original$meta3.apw) === null || _original$meta3$apw === void 0 ? void 0 : _original$meta3$apw.workflowId;
86
- const currentApwWorkflowId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.workflowId;
70
+ const prevApwWorkflowId = original.meta?.apw?.workflowId;
71
+ const currentApwWorkflowId = entry.meta?.apw?.workflowId;
87
72
  /**
88
73
  * Make sure the apw property doesn't get lost between updates.
89
74
  * It can happen because we run modal validation in "onBeforePageUpdate" event,
90
75
  * which doesn't have the "apw" property.
91
76
  */
92
-
93
77
  if (prevApwWorkflowId && !currentApwWorkflowId) {
94
78
  entry.meta = (0, _set.default)(entry.meta || {}, "apw", (original.meta || {}).apw || {});
95
79
  }
@@ -97,58 +81,45 @@ const linkWorkflowToEntry = params => {
97
81
  * If there is a linked "contentReview" for this page and the page "title" has changed.
98
82
  * Let's update the "title" field in "contentReview".
99
83
  */
100
-
101
-
102
- const linkedContentReviewId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 ? void 0 : (_entry$meta2$apw = _entry$meta2.apw) === null || _entry$meta2$apw === void 0 ? void 0 : _entry$meta2$apw.contentReviewId;
84
+ const linkedContentReviewId = entry.meta?.apw?.contentReviewId;
103
85
  const prevTitle = (0, _utils.getEntryTitle)(model, original);
104
86
  const newTitle = (0, _utils.getEntryTitle)(model, entry);
105
-
106
87
  if (!linkedContentReviewId || prevTitle === newTitle) {
107
88
  return;
108
89
  }
109
-
110
90
  await apw.contentReview.update(linkedContentReviewId, {
111
91
  title: newTitle
112
92
  });
113
93
  });
94
+
114
95
  /**
115
96
  * Link created workflow to associated entries.
116
97
  */
117
-
118
98
  apw.workflow.onWorkflowAfterCreate.subscribe(async ({
119
99
  workflow
120
100
  }) => {
121
- var _scope$data;
122
-
123
101
  const {
124
102
  scope
125
103
  } = workflow;
126
104
  /**
127
105
  * If the workflow has entries in it's scope, we'll link that workflow for each of those entries.
128
106
  */
129
-
130
107
  if ((0, _utils.hasEntries)(workflow) === false) {
131
108
  return;
132
109
  }
133
-
134
110
  const models = await cms.listModels();
135
- const values = (_scope$data = scope.data) === null || _scope$data === void 0 ? void 0 : _scope$data.entries;
136
-
111
+ const values = scope.data?.entries;
137
112
  if (!values || Array.isArray(values) === false || values.length === 0) {
138
113
  return;
139
114
  }
140
-
141
115
  for (const value of values) {
142
116
  if (!value || !value.modelId || !value.id) {
143
117
  continue;
144
118
  }
145
-
146
119
  const model = models.find(m => m.modelId === value.modelId);
147
-
148
120
  if (!model) {
149
121
  continue;
150
122
  }
151
-
152
123
  await (0, _utils.updateEntryMeta)({
153
124
  cms,
154
125
  model,
@@ -162,5 +133,6 @@ const linkWorkflowToEntry = params => {
162
133
  }
163
134
  });
164
135
  };
136
+ exports.linkWorkflowToEntry = linkWorkflowToEntry;
165
137
 
166
- exports.linkWorkflowToEntry = linkWorkflowToEntry;
138
+ //# sourceMappingURL=linkWorkflowToEntry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["linkWorkflowToEntry","params","apw","cms","onEntryBeforeCreate","subscribe","entry","model","isAwpModel","assignWorkflowToEntry","onEntryRevisionBeforeCreate","original","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onEntryBeforeUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onWorkflowAfterCreate","scope","hasEntries","models","listModels","values","data","entries","Array","isArray","length","value","modelId","id","find","m","updateEntryMeta","entryId"],"sources":["linkWorkflowToEntry.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport {\n assignWorkflowToEntry,\n getEntryTitle,\n hasEntries,\n isAwpModel,\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 (isAwpModel(model)) {\n return;\n }\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onEntryRevisionBeforeCreate.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(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 });\n });\n\n cms.onEntryBeforeUpdate.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(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;;AAEA;;AAkBO,MAAMA,mBAAmB,GAAIC,MAAD,IAAuC;EACtE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;EAEAE,GAAG,CAACC,mBAAJ,CAAwBC,SAAxB,CAAkC,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAC1D,IAAI,IAAAC,iBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAM,IAAAE,4BAAA,EAAsB;M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AU,CAACA,KAAK,CAACC,OAAjB,IAA4B,CAACD,KAAK,CAACE,EAAvC,EAA2C;QACvC;MACH;;MACD,MAAMnC,KAAK,GAAGyB,MAAM,CAACW,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACH,OAAF,KAAcD,KAAK,CAACC,OAArC,CAAd;;MACA,IAAI,CAAClC,KAAL,EAAY;QACR;MACH;;MACD,MAAM,IAAAsC,sBAAA,EAAgB;QAClB1C,GADkB;QAElBI,KAFkB;QAGlBuC,OAAO,EAAEN,KAAK,CAACE,EAHG;QAIlB7B,IAAI,EAAE;UACFX,GAAG,EAAE;YACDe,UAAU,EAAEW,QAAQ,CAACc;UADpB;QADH;MAJY,CAAhB,CAAN;IAUH;EACJ,CAnCD;AAoCH,CAhHM"}
1
+ {"version":3,"names":["_set","_interopRequireDefault","require","_utils","linkWorkflowToEntry","params","apw","cms","onEntryBeforeCreate","subscribe","entry","model","isApwDisabledOnModel","assignWorkflowToEntry","onEntryRevisionBeforeCreate","original","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onEntryBeforeUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onWorkflowAfterCreate","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;IAC5E,IAAI,IAAAC,2BAAoB,EAACD,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMK,uBAAuB,GAAGD,QAAQ,CAACE,IAAI,EAAEX,GAAG,EAAEY,eAAe;IACnE,IAAIF,uBAAuB,EAAE;MACzBN,KAAK,CAACO,IAAI,GAAG,IAAAE,YAAG,EAACT,KAAK,CAACO,IAAI,IAAI,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,CAAC;IACnE;;IAEA;AACR;AAC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,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACItB,GAAG,CAAC0B,QAAQ,CAACC,qBAAqB,CAACxB,SAAS,CAAC,OAAO;IAAEuB;EAAS,CAAC,KAAK;IACjE,MAAM;MAAEE;IAAM,CAAC,GAAGF,QAAQ;IAC1B;AACR;AACA;IACQ,IAAI,IAAAG,iBAAU,EAACH,QAAQ,CAAC,KAAK,KAAK,EAAE;MAChC;IACJ;IAEA,MAAMI,MAAM,GAAG,MAAM7B,GAAG,CAAC8B,UAAU,CAAC,CAAC;IAErC,MAAMC,MAA2B,GAAGJ,KAAK,CAACK,IAAI,EAAEC,OAAO;IACvD,IAAI,CAACF,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,IAAIA,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MACnE;IACJ;IAEA,KAAK,MAAMC,KAAK,IAAIN,MAAM,EAAE;MACxB,IAAI,CAACM,KAAK,IAAI,CAACA,KAAK,CAACC,OAAO,IAAI,CAACD,KAAK,CAACE,EAAE,EAAE;QACvC;MACJ;MACA,MAAMnC,KAAK,GAAGyB,MAAM,CAACW,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKD,KAAK,CAACC,OAAO,CAAC;MAC3D,IAAI,CAAClC,KAAK,EAAE;QACR;MACJ;MACA,MAAM,IAAAsC,sBAAe,EAAC;QAClB1C,GAAG;QACHI,KAAK;QACLuC,OAAO,EAAEN,KAAK,CAACE,EAAE;QACjB7B,IAAI,EAAE;UACFX,GAAG,EAAE;YACDe,UAAU,EAAEW,QAAQ,CAACc;UACzB;QACJ;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAA/C,mBAAA,GAAAA,mBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createChangeRequestNotification: () => import("../../../ApwChangeRequestNotification").ApwChangeRequestNotification;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
9
+ const createChangeRequestNotification = () => {
10
+ const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ changeRequestUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> content entry.<br /><br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Change Request: ${changeRequestUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createChangeRequestNotification = createChangeRequestNotification;
32
+
33
+ //# sourceMappingURL=changeRequestNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwChangeRequestNotification","createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","CMS_ENTRY","params","changeRequestUrl","contentUrl","text","name","type","exports"],"sources":["changeRequestNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\nexport const createChangeRequestNotification = () => {\n const plugin = createApwChangeRequestNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { changeRequestUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${changeRequestUrl}\">change request</a>, for <a href=\"${contentUrl}\">this</a> content entry.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Change Request: ${changeRequestUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAE/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1 @@
1
+ export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentNotification = void 0;
7
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
8
+ var _types = require("../../../types");
9
+ const createCommentNotification = () => {
10
+ const plugin = (0, _ApwCommentNotification.createApwCommentNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ commentUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${commentUrl}">comment</a>, on a change request, for <a href="${contentUrl}">this</a> content entry.<br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Comment: ${commentUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createCommentNotification = createCommentNotification;
32
+
33
+ //# sourceMappingURL=commentNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwCommentNotification","require","_types","createCommentNotification","plugin","createApwCommentNotification","ApwContentTypes","CMS_ENTRY","params","commentUrl","contentUrl","text","name","type","exports"],"sources":["commentNotification.ts"],"sourcesContent":["import { createApwCommentNotification } from \"~/ApwCommentNotification\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport const createCommentNotification = () => {\n const plugin = createApwCommentNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { commentUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${commentUrl}\">comment</a>, on a change request, for <a href=\"${contentUrl}\">this</a> content entry.<br />\n \n Here are the full URLs:<br /><br />\n \n Comment: ${commentUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAAC,oDAA4B,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IAC7E,MAAM;MAAEC,UAAU;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAEzC,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,UAAW,oDAAmDC,UAAW;AACxH;AACA;AACA;AACA,2BAA2BD,UAAW;AACtC,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createContentReviewNotification: () => import("../../../ApwContentReviewNotification").ApwContentReviewNotification;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
9
+ const createContentReviewNotification = () => {
10
+ const plugin = (0, _ApwContentReviewNotification.createApwContentReviewNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ contentReviewUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${contentReviewUrl}">content review</a>, for <a href="${contentUrl}">this</a> content entry.<br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Content Review: ${contentReviewUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createContentReviewNotification = createContentReviewNotification;
32
+
33
+ //# sourceMappingURL=contentReviewNotification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwContentReviewNotification","createContentReviewNotification","plugin","createApwContentReviewNotification","ApwContentTypes","CMS_ENTRY","params","contentReviewUrl","contentUrl","text","name","type","exports"],"sources":["contentReviewNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\nexport const createContentReviewNotification = () => {\n const plugin = createApwContentReviewNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { contentReviewUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${contentReviewUrl}\">content review</a>, for <a href=\"${contentUrl}\">this</a> content entry.<br />\n \n Here are the full URLs:<br /><br />\n \n Content Review: ${contentReviewUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAE/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1,8 @@
1
+ interface CreateContentEntryUrlParams {
2
+ baseUrl?: string;
3
+ modelId?: string;
4
+ id: string;
5
+ }
6
+ export declare const createContentEntryUrl: (params: CreateContentEntryUrlParams) => string | null;
7
+ export declare const createContentUrlPlugin: () => import("../../../ApwContentUrlPlugin").ApwContentUrlPlugin;
8
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrlPlugin = exports.createContentEntryUrl = void 0;
7
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
8
+ var _types = require("../../../types");
9
+ /**
10
+ * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
11
+ * Due to multiple content types for the APW, everything needs to be pluginable.
12
+ */
13
+
14
+ const createContentEntryUrl = params => {
15
+ /**
16
+ * All variables must exist for URL to be created.
17
+ * We go through all vars and throw a log if it does not exist.
18
+ */
19
+ for (const key in params) {
20
+ if (!!key) {
21
+ continue;
22
+ }
23
+ console.log(`Missing variable "${key}", which we use to create a content entry URL.`);
24
+ return null;
25
+ }
26
+ const {
27
+ baseUrl,
28
+ modelId,
29
+ id
30
+ } = params;
31
+ return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;
32
+ };
33
+ exports.createContentEntryUrl = createContentEntryUrl;
34
+ const createContentUrlPlugin = () => {
35
+ return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.CMS_ENTRY, params => {
36
+ const {
37
+ baseUrl,
38
+ contentReview
39
+ } = params;
40
+ const {
41
+ id
42
+ } = contentReview.content;
43
+ const {
44
+ modelId
45
+ } = contentReview.content.settings;
46
+ return createContentEntryUrl({
47
+ baseUrl,
48
+ modelId,
49
+ id
50
+ });
51
+ });
52
+ };
53
+ exports.createContentUrlPlugin = createContentUrlPlugin;
54
+
55
+ //# sourceMappingURL=contentUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwContentUrlPlugin","require","_types","createContentEntryUrl","params","key","console","log","baseUrl","modelId","id","exports","createContentUrlPlugin","createApwContentUrlPlugin","ApwContentTypes","CMS_ENTRY","contentReview","content","settings"],"sources":["contentUrl.ts"],"sourcesContent":["/**\n * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.\n * Due to multiple content types for the APW, everything needs to be pluginable.\n */\nimport { createApwContentUrlPlugin } from \"~/ApwContentUrlPlugin\";\nimport { ApwContentTypes } from \"~/types\";\n\ninterface CreateContentEntryUrlParams {\n baseUrl?: string;\n modelId?: string;\n id: string;\n}\nexport const createContentEntryUrl = (params: CreateContentEntryUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a content entry URL.`);\n return null;\n }\n const { baseUrl, modelId, id } = params;\n return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;\n};\n\nexport const createContentUrlPlugin = () => {\n return createApwContentUrlPlugin(ApwContentTypes.CMS_ENTRY, params => {\n const { baseUrl, contentReview } = params;\n const { id } = contentReview.content;\n const { modelId } = contentReview.content.settings;\n return createContentEntryUrl({\n baseUrl,\n modelId,\n id\n });\n });\n};\n"],"mappings":";;;;;;AAIA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AASO,MAAME,qBAAqB,GAAIC,MAAmC,IAAoB;EACzF;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,gDAA+C,CAAC;IACrF,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,OAAO;IAAEC;EAAG,CAAC,GAAGN,MAAM;EACvC,OAAQ,GAAEI,OAAQ,wBAAuBC,OAAQ,OAAMC,EAAG,EAAC;AAC/D,CAAC;AAACC,OAAA,CAAAR,qBAAA,GAAAA,qBAAA;AAEK,MAAMS,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAO,IAAAC,8CAAyB,EAACC,sBAAe,CAACC,SAAS,EAAEX,MAAM,IAAI;IAClE,MAAM;MAAEI,OAAO;MAAEQ;IAAc,CAAC,GAAGZ,MAAM;IACzC,MAAM;MAAEM;IAAG,CAAC,GAAGM,aAAa,CAACC,OAAO;IACpC,MAAM;MAAER;IAAQ,CAAC,GAAGO,aAAa,CAACC,OAAO,CAACC,QAAQ;IAClD,OAAOf,qBAAqB,CAAC;MACzBK,OAAO;MACPC,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.triggerContentReview = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _types = require("../../types");
13
-
14
10
  var _utils = require("./utils");
15
-
16
11
  const triggerContentReview = params => {
17
12
  const {
18
13
  cms,
@@ -22,38 +17,30 @@ const triggerContentReview = params => {
22
17
  entry,
23
18
  model
24
19
  }) => {
25
- var _entry$meta, _entry$meta$apw, _entry$meta2, _entry$meta2$apw;
26
-
27
- if ((0, _utils.isAwpModel)(model)) {
20
+ if ((0, _utils.isApwDisabledOnModel)(model)) {
28
21
  return;
29
22
  }
30
-
31
- const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.contentReviewId;
32
-
23
+ const contentReviewId = entry.meta?.apw?.contentReviewId;
33
24
  if (contentReviewId) {
34
25
  const contentReview = await apw.contentReview.get(contentReviewId);
35
-
36
26
  if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
37
27
  return;
38
28
  }
39
-
40
29
  throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
41
30
  contentReviewId,
42
31
  entry
43
32
  });
44
33
  }
45
-
46
- const workflowId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 ? void 0 : (_entry$meta2$apw = _entry$meta2.apw) === null || _entry$meta2$apw === void 0 ? void 0 : _entry$meta2$apw.workflowId;
47
-
34
+ const workflowId = entry.meta?.apw?.workflowId;
48
35
  if (!workflowId) {
49
36
  return;
50
37
  }
51
-
52
38
  throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
53
39
  workflowId,
54
40
  entry
55
41
  });
56
42
  });
57
43
  };
44
+ exports.triggerContentReview = triggerContentReview;
58
45
 
59
- exports.triggerContentReview = triggerContentReview;
46
+ //# sourceMappingURL=triggerContentReview.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["triggerContentReview","params","cms","apw","onEntryBeforePublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","reviewStatus","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId"],"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 { isAwpModel } 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 (isAwpModel(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;;AACA;;AAMA;;AAMO,MAAMA,oBAAoB,GAAIC,MAAD,IAAwC;EACxE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;EAEAC,GAAG,CAACE,oBAAJ,CAAyBC,SAAzB,CACI,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAAA;;IACxB,IAAI,IAAAC,iBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAME,eAAe,kBAAGH,KAAK,CAACI,IAAT,mEAAG,YAAYP,GAAf,oDAAG,gBAAiBM,eAAzC;;IACA,IAAIA,eAAJ,EAAqB;MACjB,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBC,GAAlB,CAAsBH,eAAtB,CAA5B;;MAEA,IAAIE,aAAa,CAACE,YAAd,KAA+BC,6BAAA,CAAuBC,YAA1D,EAAwE;QACpE;MACH;;MACD,MAAM,IAAIC,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;QACIP,eADJ;QAEIH;MAFJ,CAHE,CAAN;IAQH;;IAED,MAAMW,UAAU,mBAAGX,KAAK,CAACI,IAAT,qEAAG,aAAYP,GAAf,qDAAG,iBAAiBc,UAApC;;IAEA,IAAI,CAACA,UAAL,EAAiB;MACb;IACH;;IACD,MAAM,IAAID,cAAJ,CACF,wEADE,EAEF,iBAFE,EAGF;MACIC,UADJ;MAEIX;IAFJ,CAHE,CAAN;EAQH,CAnCL;AAqCH,CAxCM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_types","_utils","triggerContentReview","params","cms","apw","onEntryBeforePublish","subscribe","entry","model","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;IACxB,IAAI,IAAAC,2BAAoB,EAACD,KAAK,CAAC,EAAE;MAC7B;IACJ;IACA,MAAME,eAAe,GAAGH,KAAK,CAACI,IAAI,EAAEP,GAAG,EAAEM,eAAe;IACxD,IAAIA,eAAe,EAAE;MACjB,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,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;QACfH;MACJ,CACJ,CAAC;IACL;IAEA,MAAMW,UAAU,GAAGX,KAAK,CAACI,IAAI,EAAEP,GAAG,EAAEc,UAAU;IAE9C,IAAI,CAACA,UAAU,EAAE;MACb;IACJ;IACA,MAAM,IAAID,cAAK,CACX,wEAAwE,EACxE,iBAAiB,EACjB;MACIC,UAAU;MACVX;IACJ,CACJ,CAAC;EACL,CACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAAlB,oBAAA,GAAAA,oBAAA"}