@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.97a151f74d

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 (207) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +40 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +40 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +40 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +40 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +1 -1
  14. package/crud/createChangeRequestMethods.js +21 -18
  15. package/crud/createChangeRequestMethods.js.map +1 -1
  16. package/crud/createCommentMethods.js +21 -18
  17. package/crud/createCommentMethods.js.map +1 -1
  18. package/crud/createContentReviewMethods.js +60 -50
  19. package/crud/createContentReviewMethods.js.map +1 -1
  20. package/crud/createReviewerMethods.js +21 -18
  21. package/crud/createReviewerMethods.js.map +1 -1
  22. package/crud/createWorkflowMethods.d.ts +1 -1
  23. package/crud/createWorkflowMethods.js +42 -20
  24. package/crud/createWorkflowMethods.js.map +1 -1
  25. package/crud/index.js +3 -7
  26. package/crud/index.js.map +1 -1
  27. package/crud/utils.js +4 -8
  28. package/crud/utils.js.map +1 -1
  29. package/index.d.ts +3 -3
  30. package/index.js +8 -4
  31. package/index.js.map +1 -1
  32. package/package.json +38 -37
  33. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -1
  34. package/plugins/cms/apwEntryPlugins.js +4 -8
  35. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  36. package/plugins/cms/index.js +9 -1
  37. package/plugins/cms/index.js.map +1 -1
  38. package/plugins/cms/linkContentReviewToEntry.js +4 -4
  39. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  40. package/plugins/cms/linkWorkflowToEntry.js +5 -5
  41. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  42. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  43. package/plugins/cms/notifications/changeRequestNotification.js +35 -0
  44. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  45. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  46. package/plugins/cms/notifications/commentNotification.js +35 -0
  47. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  48. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  49. package/plugins/cms/notifications/contentReviewNotification.js +35 -0
  50. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  51. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  52. package/plugins/cms/notifications/contentUrl.js +60 -0
  53. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  54. package/plugins/cms/triggerContentReview.js +3 -3
  55. package/plugins/cms/triggerContentReview.js.map +1 -1
  56. package/plugins/cms/updateContentReviewStatus.js +10 -14
  57. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  58. package/plugins/cms/utils.js +4 -8
  59. package/plugins/cms/utils.js.map +1 -1
  60. package/plugins/context.js +1 -1
  61. package/plugins/graphql/changeRequest.gql.js +1 -1
  62. package/plugins/graphql/comment.gql.js +1 -1
  63. package/plugins/graphql/contentReview.gql.js +4 -4
  64. package/plugins/graphql/contentReview.gql.js.map +1 -1
  65. package/plugins/graphql/reviewer.gql.js +3 -1
  66. package/plugins/graphql/reviewer.gql.js.map +1 -1
  67. package/plugins/graphql/workflow.gql.js +1 -1
  68. package/plugins/graphql.js +1 -1
  69. package/plugins/hooks/createReviewerFromIdentity.js +28 -8
  70. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  71. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -1
  72. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  73. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -1
  74. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  75. package/plugins/hooks/index.js +6 -0
  76. package/plugins/hooks/index.js.map +1 -1
  77. package/plugins/hooks/initializeContentReviewSteps.js +5 -8
  78. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  79. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  80. package/plugins/hooks/initializeNotifications.js +20 -0
  81. package/plugins/hooks/initializeNotifications.js.map +1 -0
  82. package/plugins/hooks/listContentReviews.d.ts +10 -0
  83. package/plugins/hooks/listContentReviews.js +68 -0
  84. package/plugins/hooks/listContentReviews.js.map +1 -0
  85. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  86. package/plugins/hooks/notifications/appUrl.js +22 -0
  87. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  88. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  89. package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
  90. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  91. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  92. package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
  93. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  94. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  95. package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
  96. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  97. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  98. package/plugins/hooks/notifications/commentUrl.js +31 -0
  99. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  100. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  101. package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
  102. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  103. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  104. package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
  105. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  106. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  107. package/plugins/hooks/notifications/contentUrl.js +29 -0
  108. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  109. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  110. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
  111. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  112. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  113. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
  114. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  115. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  116. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
  117. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  118. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  119. package/plugins/hooks/notifications/reviewers.js +51 -0
  120. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  121. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  122. package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
  123. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  124. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  125. package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
  126. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  127. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  128. package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
  129. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  130. package/plugins/hooks/updatePendingChangeRequests.js +7 -11
  131. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  132. package/plugins/hooks/updateTotalComments.js +14 -18
  133. package/plugins/hooks/updateTotalComments.js.map +1 -1
  134. package/plugins/hooks/validateChangeRequest.js +30 -5
  135. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  136. package/plugins/hooks/validateComment.js +14 -4
  137. package/plugins/hooks/validateComment.js.map +1 -1
  138. package/plugins/hooks/validateContentReview.js +2 -2
  139. package/plugins/hooks/validateContentReview.js.map +1 -1
  140. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -1
  141. package/plugins/pageBuilder/index.js +9 -1
  142. package/plugins/pageBuilder/index.js.map +1 -1
  143. package/plugins/pageBuilder/linkContentReviewToPage.js +41 -29
  144. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  145. package/plugins/pageBuilder/linkWorkflowToPage.js +18 -6
  146. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  147. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  148. package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
  149. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  150. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  151. package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
  152. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  153. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  154. package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
  155. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  156. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  157. package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
  158. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  159. package/plugins/pageBuilder/triggerContentReview.js +3 -3
  160. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  161. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -14
  162. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  163. package/plugins/pageBuilder/utils.js +1 -1
  164. package/plugins/pageBuilder/utils.js.map +1 -1
  165. package/plugins/utils.d.ts +1 -1
  166. package/plugins/utils.js +4 -14
  167. package/plugins/utils.js.map +1 -1
  168. package/scheduler/createScheduleActionMethods.js +17 -14
  169. package/scheduler/createScheduleActionMethods.js.map +1 -1
  170. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  171. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -1
  172. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -1
  173. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +1 -1
  174. package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
  175. package/scheduler/handlers/scheduleAction/index.js +8 -9
  176. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  177. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +5 -9
  178. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  179. package/scheduler/handlers/utils.d.ts +1 -1
  180. package/scheduler/handlers/utils.js +1 -1
  181. package/storageOperations/changeRequestStorageOperations.js +5 -9
  182. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  183. package/storageOperations/commentStorageOperations.js +4 -8
  184. package/storageOperations/commentStorageOperations.js.map +1 -1
  185. package/storageOperations/contentReviewStorageOperations.js +5 -9
  186. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  187. package/storageOperations/index.js +5 -9
  188. package/storageOperations/index.js.map +1 -1
  189. package/storageOperations/models/contentModelPluginFactory.js +3 -7
  190. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  191. package/storageOperations/models/contentReview.model.js +6 -5
  192. package/storageOperations/models/contentReview.model.js.map +1 -1
  193. package/storageOperations/models/index.js +1 -1
  194. package/storageOperations/models/reviewer.model.js +18 -2
  195. package/storageOperations/models/reviewer.model.js.map +1 -1
  196. package/storageOperations/models/utils.js +3 -2
  197. package/storageOperations/models/utils.js.map +1 -1
  198. package/storageOperations/reviewerStorageOperations.js +18 -14
  199. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  200. package/storageOperations/workflowStorageOperations.js +8 -12
  201. package/storageOperations/workflowStorageOperations.js.map +1 -1
  202. package/types.d.ts +99 -84
  203. package/types.js.map +1 -1
  204. package/utils/errors.js +1 -1
  205. package/utils/fieldResolver.js +3 -9
  206. package/utils/fieldResolver.js.map +1 -1
  207. package/utils/resolve.d.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["linkContentReviewToEntry","params","apw","cms","contentReview","onAfterContentReviewCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onAfterContentReviewDelete","onBeforeEntryDelete","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.onAfterContentReviewCreate.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.onAfterContentReviewDelete.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.onBeforeEntryDelete.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,CAAkBe,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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,CAAkBe,0BAAlB,CAA6Cb,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IACA,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,EAAE;QADhB;MADH,CAHY;MAQlBC,OAAO,EAAEX,OAAO,CAACM;IARC,CAAhB,CAAN;EAUH,CAlBD;EAoBAV,GAAG,CAACiB,mBAAJ,CAAwBd,SAAxB,CAAkC,OAAO;IAAEe,KAAF;IAASV;EAAT,CAAP,KAA4B;IAAA;;IAC1D,IAAI,IAAAW,iBAAA,EAAWX,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAMM,eAAe,kBAAGI,KAAK,CAACL,IAAT,mEAAG,YAAYd,GAAf,oDAAG,gBAAiBe,eAAzC;;IAEA,IAAI,CAACA,eAAL,EAAsB;MAClB;IACH;;IACD,IAAIb,aAAJ;;IACA,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAJ,CAAkBmB,GAAlB,CAAsBN,eAAtB,CAAtB;IACH,CAFD,CAEE,OAAOO,EAAP,EAAW;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAH,KAAY,WAAhB,EAA6B;QACzB,MAAMD,EAAN;MACH;IACJ;;IAED,IAAI,CAACpB,aAAL,EAAoB;MAChB;IACH;;IACD,MAAM,IAAIsB,cAAJ,CACD,mGADC,EAEF,4BAFE,EAGF;MACIT,eADJ;MAEII;IAFJ,CAHE,CAAN;EAQH,CAjCD;AAkCH,CA9EM"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -16,7 +16,7 @@ const linkWorkflowToEntry = params => {
16
16
  apw,
17
17
  cms
18
18
  } = params;
19
- cms.onBeforeEntryCreate.subscribe(async ({
19
+ cms.onEntryBeforeCreate.subscribe(async ({
20
20
  entry,
21
21
  model
22
22
  }) => {
@@ -29,7 +29,7 @@ const linkWorkflowToEntry = params => {
29
29
  entry
30
30
  });
31
31
  });
32
- cms.onBeforeEntryCreateRevision.subscribe(async ({
32
+ cms.onEntryRevisionBeforeCreate.subscribe(async ({
33
33
  entry,
34
34
  original,
35
35
  model
@@ -71,7 +71,7 @@ const linkWorkflowToEntry = params => {
71
71
  entry
72
72
  });
73
73
  });
74
- cms.onBeforeEntryUpdate.subscribe(async ({
74
+ cms.onEntryBeforeUpdate.subscribe(async ({
75
75
  entry,
76
76
  original,
77
77
  model
@@ -115,7 +115,7 @@ const linkWorkflowToEntry = params => {
115
115
  * Link created workflow to associated entries.
116
116
  */
117
117
 
118
- apw.workflow.onAfterWorkflowCreate.subscribe(async ({
118
+ apw.workflow.onWorkflowAfterCreate.subscribe(async ({
119
119
  workflow
120
120
  }) => {
121
121
  var _scope$data;
@@ -1 +1 @@
1
- {"version":3,"names":["linkWorkflowToEntry","params","apw","cms","onBeforeEntryCreate","subscribe","entry","model","isAwpModel","assignWorkflowToEntry","onBeforeEntryCreateRevision","original","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onBeforeEntryUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onAfterWorkflowCreate","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.onBeforeEntryCreate.subscribe(async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onBeforeEntryCreateRevision.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.onBeforeEntryUpdate.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.onAfterWorkflowCreate.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;MACxBP,GADwB;MAExBI;IAFwB,CAAtB,CAAN;EAIH,CARD;EAUAH,GAAG,CAACO,2BAAJ,CAAgCL,SAAhC,CAA0C,OAAO;IAAEC,KAAF;IAASK,QAAT;IAAmBJ;EAAnB,CAAP,KAAsC;IAAA;;IAC5E,IAAI,IAAAC,iBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;IACD;AACR;AACA;AACA;;;IACQ,MAAMK,uBAAuB,qBAAGD,QAAQ,CAACE,IAAZ,yEAAG,eAAeX,GAAlB,uDAAG,mBAAoBY,eAApD;;IACA,IAAIF,uBAAJ,EAA6B;MACzBN,KAAK,CAACO,IAAN,GAAa,IAAAE,YAAA,EAAIT,KAAK,CAACO,IAAN,IAAc,EAAlB,EAAsB,qBAAtB,EAA6C,IAA7C,CAAb;IACH;IAED;AACR;AACA;AACA;;;IACQ,MAAMG,kBAAk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AAkBC,MAAlB,CAAyBL,qBAAzB,EAAgD;MAClDM,KAAK,EAAEH;IAD2C,CAAhD,CAAN;EAGH,CA5BD;EA8BA;AACJ;AACA;;EACItB,GAAG,CAAC0B,QAAJ,CAAaC,qBAAb,CAAmCxB,SAAnC,CAA6C,OAAO;IAAEuB;EAAF,CAAP,KAAwB;IAAA;;IACjE,MAAM;MAAEE;IAAF,IAAYF,QAAlB;IACA;AACR;AACA;;IACQ,IAAI,IAAAG,iBAAA,EAAWH,QAAX,MAAyB,KAA7B,EAAoC;MAChC;IACH;;IAED,MAAMI,MAAM,GAAG,MAAM7B,GAAG,CAAC8B,UAAJ,EAArB;IAEA,MAAMC,MAA2B,kBAAGJ,KAAK,CAACK,IAAT,gDAAG,YAAYC,OAAhD;;IACA,IAAI,CAACF,MAAD,IAAWG,KAAK,CAACC,OAAN,CAAcJ,MAAd,MAA0B,KAArC,IAA8CA,MAAM,CAACK,MAAP,KAAkB,CAApE,EAAuE;MACnE;IACH;;IAED,KAAK,MAAMC,KAAX,IAAoBN,MAApB,EAA4B;MACxB,IAAI,CAACM,KAAD,IAAU,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":["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,CA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MC,KAAX,IAAoBN,MAApB,EAA4B;MACxB,IAAI,CAACM,KAAD,IAAU,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"}
@@ -0,0 +1 @@
1
+ export declare const createChangeRequestNotification: () => import("../../../ApwChangeRequestNotification").ApwChangeRequestNotification;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestNotification = void 0;
7
+
8
+ var _types = require("../../../types");
9
+
10
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
11
+
12
+ const createChangeRequestNotification = () => {
13
+ const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ changeRequestUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> content entry.<br /><br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Change Request: ${changeRequestUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createChangeRequestNotification = createChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","CMS_ENTRY","params","changeRequestUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,+BAA+B,GAAG,MAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAA,EAAmCC,sBAAA,CAAgBC,SAAnD,EAA8DC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAF;MAAoBC;IAApB,IAAmCF,MAAzC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -0,0 +1 @@
1
+ export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentNotification = void 0;
7
+
8
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
9
+
10
+ var _types = require("../../../types");
11
+
12
+ const createCommentNotification = () => {
13
+ const plugin = (0, _ApwCommentNotification.createApwCommentNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ commentUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${commentUrl}">comment</a>, on a change request, for <a href="${contentUrl}">this</a> content entry.<br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Comment: ${commentUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createCommentNotification = createCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommentNotification","plugin","createApwCommentNotification","ApwContentTypes","CMS_ENTRY","params","commentUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,MAAMC,MAAM,GAAG,IAAAC,oDAAA,EAA6BC,sBAAA,CAAgBC,SAA7C,EAAwDC,MAAM,IAAI;IAC7E,MAAM;MAAEC,UAAF;MAAcC;IAAd,IAA6BF,MAAnC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,UAAW,oDAAmDC,UAAW;AACxH;AACA;AACA;AACA,2BAA2BD,UAAW;AACtC,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -0,0 +1 @@
1
+ export declare const createContentReviewNotification: () => import("../../../ApwContentReviewNotification").ApwContentReviewNotification;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewNotification = void 0;
7
+
8
+ var _types = require("../../../types");
9
+
10
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
11
+
12
+ const createContentReviewNotification = () => {
13
+ const plugin = (0, _ApwContentReviewNotification.createApwContentReviewNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ contentReviewUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${contentReviewUrl}">content review</a>, for <a href="${contentUrl}">this</a> content entry.<br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Content Review: ${contentReviewUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createContentReviewNotification = createContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentReviewNotification","plugin","createApwContentReviewNotification","ApwContentTypes","CMS_ENTRY","params","contentReviewUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,+BAA+B,GAAG,MAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAA,EAAmCC,sBAAA,CAAgBC,SAAnD,EAA8DC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAF;MAAoBC;IAApB,IAAmCF,MAAzC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -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,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrlPlugin = exports.createContentEntryUrl = void 0;
7
+
8
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
9
+
10
+ var _types = require("../../../types");
11
+
12
+ /**
13
+ * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
14
+ * Due to multiple content types for the APW, everything needs to be pluginable.
15
+ */
16
+ const createContentEntryUrl = params => {
17
+ /**
18
+ * All variables must exist for URL to be created.
19
+ * We go through all vars and throw a log if it does not exist.
20
+ */
21
+ for (const key in params) {
22
+ if (!!key) {
23
+ continue;
24
+ }
25
+
26
+ console.log(`Missing variable "${key}", which we use to create a content entry URL.`);
27
+ return null;
28
+ }
29
+
30
+ const {
31
+ baseUrl,
32
+ modelId,
33
+ id
34
+ } = params;
35
+ return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;
36
+ };
37
+
38
+ exports.createContentEntryUrl = createContentEntryUrl;
39
+
40
+ const createContentUrlPlugin = () => {
41
+ return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.CMS_ENTRY, params => {
42
+ const {
43
+ baseUrl,
44
+ contentReview
45
+ } = params;
46
+ const {
47
+ id
48
+ } = contentReview.content;
49
+ const {
50
+ modelId
51
+ } = contentReview.content.settings;
52
+ return createContentEntryUrl({
53
+ baseUrl,
54
+ modelId,
55
+ id
56
+ });
57
+ });
58
+ };
59
+
60
+ exports.createContentUrlPlugin = createContentUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentEntryUrl","params","key","console","log","baseUrl","modelId","id","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;;AACA;;AALA;AACA;AACA;AACA;AASO,MAAMA,qBAAqB,GAAIC,MAAD,IAAwD;EACzF;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,gDAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC,OAAX;IAAoBC;EAApB,IAA2BN,MAAjC;EACA,OAAQ,GAAEI,OAAQ,wBAAuBC,OAAQ,OAAMC,EAAG,EAA1D;AACH,CAdM;;;;AAgBA,MAAMC,sBAAsB,GAAG,MAAM;EACxC,OAAO,IAAAC,8CAAA,EAA0BC,sBAAA,CAAgBC,SAA1C,EAAqDV,MAAM,IAAI;IAClE,MAAM;MAAEI,OAAF;MAAWO;IAAX,IAA6BX,MAAnC;IACA,MAAM;MAAEM;IAAF,IAASK,aAAa,CAACC,OAA7B;IACA,MAAM;MAAEP;IAAF,IAAcM,aAAa,CAACC,OAAd,CAAsBC,QAA1C;IACA,OAAOd,qBAAqB,CAAC;MACzBK,OADyB;MAEzBC,OAFyB;MAGzBC;IAHyB,CAAD,CAA5B;EAKH,CATM,CAAP;AAUH,CAXM"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -18,7 +18,7 @@ const triggerContentReview = params => {
18
18
  cms,
19
19
  apw
20
20
  } = params;
21
- cms.onBeforeEntryPublish.subscribe(async ({
21
+ cms.onEntryBeforePublish.subscribe(async ({
22
22
  entry,
23
23
  model
24
24
  }) => {
@@ -33,7 +33,7 @@ const triggerContentReview = params => {
33
33
  if (contentReviewId) {
34
34
  const contentReview = await apw.contentReview.get(contentReviewId);
35
35
 
36
- if (contentReview.status !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
36
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
37
37
  return;
38
38
  }
39
39
 
@@ -1 +1 @@
1
- {"version":3,"names":["triggerContentReview","params","cms","apw","onBeforeEntryPublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","status","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId"],"sources":["triggerContentReview.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnBeforeCmsEntryPublishTopicParams\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.onBeforeEntryPublish.subscribe<OnBeforeCmsEntryPublishTopicParams>(\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.status !== 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,MAAd,KAAyBC,6BAAA,CAAuBC,YAApD,EAAkE;QAC9D;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":["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,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.updateContentReviewStatus = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _types = require("../../types");
13
13
 
@@ -15,17 +15,13 @@ var _utils = require("../../crud/utils");
15
15
 
16
16
  var _utils2 = require("./utils");
17
17
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
22
18
  const updateContentReviewStatus = params => {
23
19
  const {
24
20
  apw,
25
21
  cms,
26
22
  security
27
23
  } = params;
28
- cms.onAfterEntryPublish.subscribe(async ({
24
+ cms.onEntryAfterPublish.subscribe(async ({
29
25
  entry,
30
26
  model
31
27
  }) => {
@@ -50,18 +46,18 @@ const updateContentReviewStatus = params => {
50
46
  * If content review is "readyToBePublished set its status as "published" after page publish.
51
47
  */
52
48
 
53
- if (contentReview.status !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
49
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
54
50
  return;
55
51
  }
56
52
 
57
53
  await apw.contentReview.update(contentReviewId, {
58
- status: _types.ApwContentReviewStatus.PUBLISHED,
59
- content: _objectSpread(_objectSpread(_objectSpread({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
54
+ reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
55
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
60
56
  publishedBy: identity.id
61
57
  })
62
58
  });
63
59
  });
64
- cms.onAfterEntryUnpublish.subscribe(async ({
60
+ cms.onEntryAfterUnpublish.subscribe(async ({
65
61
  entry,
66
62
  model
67
63
  }) => {
@@ -85,13 +81,13 @@ const updateContentReviewStatus = params => {
85
81
  * If content review is "published set its status as "readyToBePublished" after page unpublish.
86
82
  */
87
83
 
88
- if (contentReview.status !== _types.ApwContentReviewStatus.PUBLISHED) {
84
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
89
85
  return;
90
86
  }
91
87
 
92
88
  await apw.contentReview.update(contentReviewId, {
93
- status: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
94
- content: _objectSpread(_objectSpread(_objectSpread({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
89
+ reviewStatus: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
90
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
95
91
  publishedBy: null
96
92
  })
97
93
  });
@@ -1 +1 @@
1
- {"version":3,"names":["updateContentReviewStatus","params","apw","cms","security","onAfterEntryPublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","identity","getIdentity","status","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onAfterEntryUnpublish"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnAfterCmsEntryPublishTopicParams,\n OnAfterCmsEntryUnpublishTopicParams\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 { isAwpModel } 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.onAfterEntryPublish.subscribe<OnAfterCmsEntryPublishTopicParams>(\n async ({ entry, model }) => {\n if (isAwpModel(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.status !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n status: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n );\n cms.onAfterEntryUnpublish.subscribe<OnAfterCmsEntryUnpublishTopicParams>(\n async ({ entry, model }) => {\n if (isAwpModel(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.status !== ApwContentReviewStatus.PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n status: 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;;AAMA;;AAGA;;;;;;AAQO,MAAMA,yBAAyB,GAAIC,MAAD,IAA6C;EAClF,MAAM;IAAEC,GAAF;IAAOC,GA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ACA;AACZ;AACA;;IAEY,IAAIE,aAAa,CAACI,MAAd,KAAyBC,6BAAA,CAAuBG,SAApD,EAA+D;MAC3D;IACH;;IACD,MAAMlB,GAAG,CAACU,aAAJ,CAAkBO,MAAlB,CAAyBT,eAAzB,EAA0C;MAC5CM,MAAM,EAAEC,6BAAA,CAAuBC,qBADa;MAE5CG,OAAO,gDACAT,aAAa,CAACS,OADd,GAEAC,mDAFA;QAGHC,WAAW,EAAE;MAHV;IAFqC,CAA1C,CAAN;EAQH,CA7BL;AA+BH,CAjEM"}
1
+ {"version":3,"names":["updateContentReviewStatus","params","apw","cms","security","onEntryAfterPublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","identity","getIdentity","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onEntryAfterUnpublish"],"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 { isAwpModel } 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 (isAwpModel(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 (isAwpModel(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;;AAMA;;AAGA;;AAQO,MAAMA,yBAAyB,GAAIC,MAAD,IAA6C;EAClF,MAAM;IAAEC,GAAF;IAAOC,GAAP;IAAYC;EAAZ,IAAyBH,MAA/B;EAEAE,GAAG,CAACE,mBAAJ,CAAwBC,SAAxB,CACI,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAAA;;IACxB,IAAI,IAAAC,kBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAME,eAAe,kBAAGH,KAAK,CAACI,IAAT,mEAAG,YAAYT,GAAf,oDAAG,gBAAiBQ,eAAzC;IACA;AACZ;AACA;;IACY,IAAI,CAACA,eAAL,EAA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,CAjEM"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.updateEntryMeta = exports.isAwpModel = exports.hasEntries = exports.getLatestEntryRevision = exports.getEntryTitle = exports.fetchModel = exports.assignWorkflowToEntry = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
@@ -25,10 +25,6 @@ var _reviewer = require("../../storageOperations/models/reviewer.model");
25
25
 
26
26
  var _workflow = require("../../storageOperations/models/workflow.model");
27
27
 
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
-
32
28
  const fetchModel = async (cms, id, settings) => {
33
29
  if (!settings) {
34
30
  throw new _error.default("Missing settings.", "SETTINGS_ERROR", {
@@ -153,7 +149,7 @@ const assignWorkflowToEntry = async params => {
153
149
 
154
150
  try {
155
151
  /*
156
- * List all workflows for app pageBuilder
152
+ * List all workflows for app cms
157
153
  */
158
154
  const [entries] = await apw.workflow.list({
159
155
  where: {
@@ -179,7 +175,7 @@ const assignWorkflowToEntry = async params => {
179
175
  continue;
180
176
  }
181
177
 
182
- entry.meta = _objectSpread(_objectSpread({}, entry.meta || {}), {}, {
178
+ entry.meta = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry.meta || {}), {}, {
183
179
  apw: {
184
180
  workflowId: workflow.id,
185
181
  contentReviewId: null
@@ -1 +1 @@
1
- {"version":3,"names":["fetchModel","cms","id","settings","WebinyError","modelId","model","getModel","getEntryTitle","entry","titleFieldId","values","getLatestEntryRevision","params","entryId","items","getLatestEntriesByIds","item","shift","updateEntryMeta","meta","updateEntry","isWorkflowApplicable","workflow","application","app","ApwWorkflowApplications","CMS","scopeType","scope","type","WorkflowScopeTypes","DEFAULT","CUSTOM","models","data","Array","isArray","includes","entries","some","value","assignWorkflowToEntry","apw","list","where","console","log","length","sortedWorkflows","sort","workflowByPrecedenceDesc","workflowByCreatedOnDesc","workflowId","contentReviewId","ex","code","hasEntries","isAwpModel","CHANGE_REQUEST_MODEL_ID","COMMENT_MODEL_ID","CONTENT_REVIEW_MODEL_ID","REVIEWER_MODEL_ID","WORKFLOW_MODEL_ID"],"sources":["utils.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport {\n AdvancedPublishingWorkflow,\n ApwWorkflow,\n ApwWorkflowApplications,\n WorkflowScopeTypes\n} from \"~/types\";\nimport { workflowByCreatedOnDesc, workflowByPrecedenceDesc } from \"~/plugins/utils\";\nimport { CHANGE_REQUEST_MODEL_ID } from \"~/storageOperations/models/changeRequest.model\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\nimport { REVIEWER_MODEL_ID } from \"~/storageOperations/models/reviewer.model\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\nexport const fetchModel = async (\n cms: HeadlessCms,\n id: string,\n settings?: { modelId?: string } | null\n): Promise<CmsModel> => {\n if (!settings) {\n throw new WebinyError(\"Missing settings.\", \"SETTINGS_ERROR\", {\n id\n });\n }\n const modelId = settings.modelId;\n if (!modelId) {\n throw new WebinyError(\"Missing modelId in settings.\", \"MODEL_ID_ERROR\", {\n id,\n settings\n });\n }\n const model = await cms.getModel(modelId);\n if (model) {\n return model;\n }\n throw new WebinyError(\"There is no requested model in the system.\", \"MODEL_NOT_EXISTS\", {\n id,\n settings\n });\n};\n\nexport const getEntryTitle = (model: CmsModel, entry: CmsEntry): string => {\n const titleFieldId = model.titleFieldId;\n if (!titleFieldId || !entry.values[titleFieldId]) {\n return entry.id;\n }\n return entry.values[titleFieldId];\n};\n\ninterface GetLatestEntryRevisionParams {\n cms: HeadlessCms;\n model: CmsModel;\n entryId: string;\n}\nexport const getLatestEntryRevision = async (\n params: GetLatestEntryRevisionParams\n): Promise<CmsEntry> => {\n const { cms, model, entryId } = params;\n const items = await cms.getLatestEntriesByIds(model, [entryId]);\n\n const item = items.shift();\n if (!item) {\n throw new WebinyError(\"There is no entry with given ID.\", \"ENTRY_NOT_FOUND\", {\n entryId\n });\n }\n return item;\n};\n\ninterface UpdateEntryMetaParams {\n meta: Record<string, any>;\n entryId: string;\n cms: HeadlessCms;\n model: CmsModel;\n}\nexport const updateEntryMeta = async (params: UpdateEntryMetaParams): Promise<void> => {\n const { entryId, cms, model, meta } = params;\n\n const entry = await getLatestEntryRevision({\n cms,\n model,\n entryId\n });\n\n await cms.updateEntry(model, entry.id, {}, meta);\n};\n\nconst isWorkflowApplicable = (entry: CmsEntry, workflow: ApwWorkflow): boolean => {\n const application = workflow.app;\n if (application !== ApwWorkflowApplications.CMS) {\n return false;\n }\n\n const scopeType = workflow.scope.type;\n\n if (scopeType === WorkflowScopeTypes.DEFAULT) {\n return true;\n } else if (scopeType === WorkflowScopeTypes.CUSTOM) {\n const models = workflow.scope.data?.models;\n\n if (Array.isArray(models) && models.includes(entry.modelId)) {\n return true;\n }\n\n const entries = workflow.scope.data?.entries || [];\n if (Array.isArray(entries) && entries.some(value => value.id === entry.entryId)) {\n return true;\n }\n return false;\n }\n throw new WebinyError(`Unknown scope type \"${scopeType}\".`, \"UNKNOWN_SCOPE_TYPE\", {\n workflow\n });\n};\n\ninterface AssignWorkflowToEntryParams {\n apw: AdvancedPublishingWorkflow;\n entry: CmsEntry;\n}\nexport const assignWorkflowToEntry = async (params: AssignWorkflowToEntryParams): Promise<void> => {\n const { apw, entry } = params;\n /**\n * Lookup and assign \"workflowId\".\n */\n try {\n /*\n * List all workflows for app pageBuilder\n */\n const [entries] = await apw.workflow.list({\n where: {\n app: ApwWorkflowApplications.CMS\n }\n });\n\n console.log(`Found ${entries.length} workflows.`);\n\n /*\n * Re-order them based on workflow scope and pre-defined rule i.e.\n * \"specific\" entry -> entry for a \"category\" -> \"default\".\n * There can be more than one workflow with same \"scope\" and \"app\".\n * Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.\n */\n const sortedWorkflows = entries\n .sort(workflowByPrecedenceDesc)\n .sort(workflowByCreatedOnDesc);\n\n /**\n * Assign the first applicable workflow to the page and exit.\n */\n for (const workflow of sortedWorkflows) {\n if (isWorkflowApplicable(entry, workflow) === false) {\n console.log(`Not applying workflow ${workflow.id} to entry ${entry.id}.`);\n continue;\n }\n entry.meta = {\n ...(entry.meta || {}),\n apw: {\n workflowId: workflow.id,\n contentReviewId: null\n }\n };\n return;\n }\n } catch (ex) {\n throw new WebinyError(\n `Failed to assign workflow to CMS entry \"${entry.id}\".`,\n ex.code,\n ex.data\n );\n }\n};\n\nexport const hasEntries = (workflow: ApwWorkflow): Boolean => {\n const { app, scope } = workflow;\n return (\n app === ApwWorkflowApplications.CMS &&\n scope.type === WorkflowScopeTypes.CUSTOM &&\n scope.data &&\n Array.isArray(scope.data.entries)\n );\n};\n\nexport const isAwpModel = (model: CmsModel): boolean => {\n return [\n CHANGE_REQUEST_MODEL_ID,\n COMMENT_MODEL_ID,\n CONTENT_REVIEW_MODEL_ID,\n REVIEWER_MODEL_ID,\n WORKFLOW_MODEL_ID\n ].includes(model.modelId);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,MAAMA,UAAU,GAAG,OACtBC,GADsB,EAEtBC,EAFsB,EAGtBC,QAHsB,KAIF;EACpB,IAAI,CAACA,QAAL,EAAe;IACX,MAAM,IAAIC,cAAJ,CAAgB,mBAAhB,EAAqC,gBAArC,EAAuD;MACzDF;IADyD,CAAvD,CAAN;EAGH;;EACD,MAAMG,OAAO,GAAGF,QAAQ,CAACE,OAAzB;;EACA,IAAI,CAACA,OAAL,EAAc;IACV,MAAM,IAAID,cAAJ,CAAgB,8BAAhB,EAAgD,gBAAhD,EAAkE;MACpEF,EADoE;MAEpEC;IAFoE,CAAlE,CAAN;EAIH;;EACD,MAAMG,KAAK,GAAG,MAAML,GAAG,CAACM,QAAJ,CAAaF,OAAb,CAApB;;EACA,IAAIC,KAAJ,EAAW;IACP,OAAOA,KAAP;EACH;;EACD,MAAM,IAAIF,cAAJ,CAAgB,4CAAhB,EAA8D,kBAA9D,EAAkF;IACpFF,EADoF;IAEpFC;EAFoF,CAAlF,CAAN;AAIH,CAzBM;;;;AA2BA,MAAMK,aAAa,GAAG,CAACF,KAAD,EAAkBG,KAAlB,KAA8C;EACvE,MAAMC,YAAY,GAAGJ,KAAK,CAACI,YAA3B;;EACA,IAAI,CAACA,YAAD,IAAiB,CAACD,KAAK,CAACE,MAAN,CAAaD,YAAb,CAAtB,EAAkD;IAC9C,OAAOD,KAAK,CAACP,EAAb;EACH;;EACD,OAAOO,KAAK,CAACE,MAAN,CAAaD,YAAb,CAAP;AACH,CANM;;;;AAaA,MAAME,sBAAsB,GAAG,MAClCC,MADkC,IAEd;EACpB,MAAM;IAAEZ,GAAF;IAAOK,KA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AG,aAAYO,KAAK,CAACP,EAAG,GAAtE;QACA;MACH;;MACDO,KAAK,CAACW,IAAN,mCACQX,KAAK,CAACW,IAAN,IAAc,EADtB;QAEIuB,GAAG,EAAE;UACDU,UAAU,EAAE9B,QAAQ,CAACrB,EADpB;UAEDoD,eAAe,EAAE;QAFhB;MAFT;MAOA;IACH;EACJ,CAvCD,CAuCE,OAAOC,EAAP,EAAW;IACT,MAAM,IAAInD,cAAJ,CACD,2CAA0CK,KAAK,CAACP,EAAG,IADlD,EAEFqD,EAAE,CAACC,IAFD,EAGFD,EAAE,CAACpB,IAHD,CAAN;EAKH;AACJ,CAnDM;;;;AAqDA,MAAMsB,UAAU,GAAIlC,QAAD,IAAoC;EAC1D,MAAM;IAAEE,GAAF;IAAOI;EAAP,IAAiBN,QAAvB;EACA,OACIE,GAAG,KAAKC,8BAAA,CAAwBC,GAAhC,IACAE,KAAK,CAACC,IAAN,KAAeC,yBAAA,CAAmBE,MADlC,IAEAJ,KAAK,CAACM,IAFN,IAGAC,KAAK,CAACC,OAAN,CAAcR,KAAK,CAACM,IAAN,CAAWI,OAAzB,CAJJ;AAMH,CARM;;;;AAUA,MAAMmB,UAAU,GAAIpD,KAAD,IAA8B;EACpD,OAAO,CACHqD,sCADG,EAEHC,yBAFG,EAGHC,sCAHG,EAIHC,2BAJG,EAKHC,2BALG,EAMLzB,QANK,CAMIhC,KAAK,CAACD,OANV,CAAP;AAOH,CARM"}
1
+ {"version":3,"names":["fetchModel","cms","id","settings","WebinyError","modelId","model","getModel","getEntryTitle","entry","titleFieldId","values","getLatestEntryRevision","params","entryId","items","getLatestEntriesByIds","item","shift","updateEntryMeta","meta","updateEntry","isWorkflowApplicable","workflow","application","app","ApwWorkflowApplications","CMS","scopeType","scope","type","WorkflowScopeTypes","DEFAULT","CUSTOM","models","data","Array","isArray","includes","entries","some","value","assignWorkflowToEntry","apw","list","where","console","log","length","sortedWorkflows","sort","workflowByPrecedenceDesc","workflowByCreatedOnDesc","workflowId","contentReviewId","ex","code","hasEntries","isAwpModel","CHANGE_REQUEST_MODEL_ID","COMMENT_MODEL_ID","CONTENT_REVIEW_MODEL_ID","REVIEWER_MODEL_ID","WORKFLOW_MODEL_ID"],"sources":["utils.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport {\n AdvancedPublishingWorkflow,\n ApwWorkflow,\n ApwWorkflowApplications,\n WorkflowScopeTypes\n} from \"~/types\";\nimport { workflowByCreatedOnDesc, workflowByPrecedenceDesc } from \"~/plugins/utils\";\nimport { CHANGE_REQUEST_MODEL_ID } from \"~/storageOperations/models/changeRequest.model\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\nimport { REVIEWER_MODEL_ID } from \"~/storageOperations/models/reviewer.model\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\nexport const fetchModel = async (\n cms: HeadlessCms,\n id: string,\n settings?: { modelId?: string } | null\n): Promise<CmsModel> => {\n if (!settings) {\n throw new WebinyError(\"Missing settings.\", \"SETTINGS_ERROR\", {\n id\n });\n }\n const modelId = settings.modelId;\n if (!modelId) {\n throw new WebinyError(\"Missing modelId in settings.\", \"MODEL_ID_ERROR\", {\n id,\n settings\n });\n }\n const model = await cms.getModel(modelId);\n if (model) {\n return model;\n }\n throw new WebinyError(\"There is no requested model in the system.\", \"MODEL_NOT_EXISTS\", {\n id,\n settings\n });\n};\n\nexport const getEntryTitle = (model: CmsModel, entry: CmsEntry): string => {\n const titleFieldId = model.titleFieldId;\n if (!titleFieldId || !entry.values[titleFieldId]) {\n return entry.id;\n }\n return entry.values[titleFieldId];\n};\n\ninterface GetLatestEntryRevisionParams {\n cms: HeadlessCms;\n model: CmsModel;\n entryId: string;\n}\nexport const getLatestEntryRevision = async (\n params: GetLatestEntryRevisionParams\n): Promise<CmsEntry> => {\n const { cms, model, entryId } = params;\n const items = await cms.getLatestEntriesByIds(model, [entryId]);\n\n const item = items.shift();\n if (!item) {\n throw new WebinyError(\"There is no entry with given ID.\", \"ENTRY_NOT_FOUND\", {\n entryId\n });\n }\n return item;\n};\n\ninterface UpdateEntryMetaParams {\n meta: Record<string, any>;\n entryId: string;\n cms: HeadlessCms;\n model: CmsModel;\n}\nexport const updateEntryMeta = async (params: UpdateEntryMetaParams): Promise<void> => {\n const { entryId, cms, model, meta } = params;\n\n const entry = await getLatestEntryRevision({\n cms,\n model,\n entryId\n });\n\n await cms.updateEntry(model, entry.id, {}, meta);\n};\n\nconst isWorkflowApplicable = (entry: CmsEntry, workflow: ApwWorkflow): boolean => {\n const application = workflow.app;\n if (application !== ApwWorkflowApplications.CMS) {\n return false;\n }\n\n const scopeType = workflow.scope.type;\n\n if (scopeType === WorkflowScopeTypes.DEFAULT) {\n return true;\n } else if (scopeType === WorkflowScopeTypes.CUSTOM) {\n const models = workflow.scope.data?.models;\n\n if (Array.isArray(models) && models.includes(entry.modelId)) {\n return true;\n }\n\n const entries = workflow.scope.data?.entries || [];\n if (Array.isArray(entries) && entries.some(value => value.id === entry.entryId)) {\n return true;\n }\n return false;\n }\n throw new WebinyError(`Unknown scope type \"${scopeType}\".`, \"UNKNOWN_SCOPE_TYPE\", {\n workflow\n });\n};\n\ninterface AssignWorkflowToEntryParams {\n apw: AdvancedPublishingWorkflow;\n entry: CmsEntry;\n}\nexport const assignWorkflowToEntry = async (params: AssignWorkflowToEntryParams): Promise<void> => {\n const { apw, entry } = params;\n /**\n * Lookup and assign \"workflowId\".\n */\n try {\n /*\n * List all workflows for app cms\n */\n const [entries] = await apw.workflow.list({\n where: {\n app: ApwWorkflowApplications.CMS\n }\n });\n\n console.log(`Found ${entries.length} workflows.`);\n\n /*\n * Re-order them based on workflow scope and pre-defined rule i.e.\n * \"specific\" entry -> entry for a \"category\" -> \"default\".\n * There can be more than one workflow with same \"scope\" and \"app\".\n * Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.\n */\n const sortedWorkflows = entries\n .sort(workflowByPrecedenceDesc)\n .sort(workflowByCreatedOnDesc);\n\n /**\n * Assign the first applicable workflow to the page and exit.\n */\n for (const workflow of sortedWorkflows) {\n if (isWorkflowApplicable(entry, workflow) === false) {\n console.log(`Not applying workflow ${workflow.id} to entry ${entry.id}.`);\n continue;\n }\n entry.meta = {\n ...(entry.meta || {}),\n apw: {\n workflowId: workflow.id,\n contentReviewId: null\n }\n };\n return;\n }\n } catch (ex) {\n throw new WebinyError(\n `Failed to assign workflow to CMS entry \"${entry.id}\".`,\n ex.code,\n ex.data\n );\n }\n};\n\nexport const hasEntries = (workflow: ApwWorkflow): Boolean => {\n const { app, scope } = workflow;\n return (\n app === ApwWorkflowApplications.CMS &&\n scope.type === WorkflowScopeTypes.CUSTOM &&\n scope.data &&\n Array.isArray(scope.data.entries)\n );\n};\n\nexport const isAwpModel = (model: CmsModel): boolean => {\n return [\n CHANGE_REQUEST_MODEL_ID,\n COMMENT_MODEL_ID,\n CONTENT_REVIEW_MODEL_ID,\n REVIEWER_MODEL_ID,\n WORKFLOW_MODEL_ID\n ].includes(model.modelId);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,UAAU,GAAG,OACtBC,GADsB,EAEtBC,EAFsB,EAGtBC,QAHsB,KAIF;EACpB,IAAI,CAACA,QAAL,EAAe;IACX,MAAM,IAAIC,cAAJ,CAAgB,mBAAhB,EAAqC,gBAArC,EAAuD;MACzDF;IADyD,CAAvD,CAAN;EAGH;;EACD,MAAMG,OAAO,GAAGF,QAAQ,CAACE,OAAzB;;EACA,IAAI,CAACA,OAAL,EAAc;IACV,MAAM,IAAID,cAAJ,CAAgB,8BAAhB,EAAgD,gBAAhD,EAAkE;MACpEF,EADoE;MAEpEC;IAFoE,CAAlE,CAAN;EAIH;;EACD,MAAMG,KAAK,GAAG,MAA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OAAN,CAAcR,KAAK,CAACM,IAAN,CAAWI,OAAzB,CAJJ;AAMH,CARM;;;;AAUA,MAAMmB,UAAU,GAAIpD,KAAD,IAA8B;EACpD,OAAO,CACHqD,sCADG,EAEHC,yBAFG,EAGHC,sCAHG,EAIHC,2BAJG,EAKHC,2BALG,EAMLzB,QANK,CAMIhC,KAAK,CAACD,OANV,CAAP;AAOH,CARM"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true