@webiny/api-apw 0.0.0-unstable.5e7233243f → 0.0.0-unstable.6e5425ee89

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 (240) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +30 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +30 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +30 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +30 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +1 -6
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +21 -25
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +21 -26
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +71 -125
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +21 -26
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.d.ts +1 -1
  24. package/crud/createWorkflowMethods.js +37 -28
  25. package/crud/createWorkflowMethods.js.map +1 -1
  26. package/crud/index.js +3 -32
  27. package/crud/index.js.map +1 -1
  28. package/crud/utils.js +4 -36
  29. package/crud/utils.js.map +1 -1
  30. package/index.d.ts +3 -3
  31. package/index.js +7 -13
  32. package/index.js.map +1 -1
  33. package/package.json +38 -37
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
  35. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  36. package/plugins/cms/apwEntryPlugins.js +4 -16
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  38. package/plugins/cms/index.js +5 -10
  39. package/plugins/cms/index.js.map +1 -1
  40. package/plugins/cms/linkContentReviewToEntry.js +4 -21
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +7 -36
  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 +31 -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 +31 -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 +31 -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 +53 -0
  55. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  56. package/plugins/cms/triggerContentReview.js +3 -17
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +10 -32
  59. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  60. package/plugins/cms/utils.js +6 -55
  61. package/plugins/cms/utils.js.map +1 -1
  62. package/plugins/context.js +1 -32
  63. package/plugins/context.js.map +1 -1
  64. package/plugins/graphql/changeRequest.gql.js +2 -9
  65. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  66. package/plugins/graphql/comment.gql.js +2 -9
  67. package/plugins/graphql/comment.gql.js.map +1 -1
  68. package/plugins/graphql/contentReview.gql.js +5 -24
  69. package/plugins/graphql/contentReview.gql.js.map +1 -1
  70. package/plugins/graphql/reviewer.gql.js +4 -9
  71. package/plugins/graphql/reviewer.gql.js.map +1 -1
  72. package/plugins/graphql/workflow.gql.js +2 -9
  73. package/plugins/graphql/workflow.gql.js.map +1 -1
  74. package/plugins/graphql.js +2 -17
  75. package/plugins/graphql.js.map +1 -1
  76. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  77. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  78. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  80. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  82. package/plugins/hooks/index.js +4 -12
  83. package/plugins/hooks/index.js.map +1 -1
  84. package/plugins/hooks/initializeContentReviewSteps.js +7 -23
  85. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  86. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  87. package/plugins/hooks/initializeNotifications.js +15 -0
  88. package/plugins/hooks/initializeNotifications.js.map +1 -0
  89. package/plugins/hooks/listContentReviews.d.ts +10 -0
  90. package/plugins/hooks/listContentReviews.js +56 -0
  91. package/plugins/hooks/listContentReviews.js.map +1 -0
  92. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  93. package/plugins/hooks/notifications/appUrl.js +18 -0
  94. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  95. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  98. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  101. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  104. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  105. package/plugins/hooks/notifications/commentUrl.js +27 -0
  106. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  107. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  110. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  113. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  114. package/plugins/hooks/notifications/contentUrl.js +24 -0
  115. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  116. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  119. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  122. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  125. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  126. package/plugins/hooks/notifications/reviewers.js +44 -0
  127. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  128. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  131. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  134. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  137. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  138. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  139. package/plugins/hooks/updateTotalComments.js +14 -27
  140. package/plugins/hooks/updateTotalComments.js.map +1 -1
  141. package/plugins/hooks/validateChangeRequest.js +27 -18
  142. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  143. package/plugins/hooks/validateComment.js +13 -14
  144. package/plugins/hooks/validateComment.js.map +1 -1
  145. package/plugins/hooks/validateContentReview.js +2 -8
  146. package/plugins/hooks/validateContentReview.js.map +1 -1
  147. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  149. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  150. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  151. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  153. package/plugins/pageBuilder/index.js +5 -8
  154. package/plugins/pageBuilder/index.js.map +1 -1
  155. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  156. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  157. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  158. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  159. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  162. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  165. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  168. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  171. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  172. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  173. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  174. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  175. package/plugins/pageBuilder/utils.js +2 -36
  176. package/plugins/pageBuilder/utils.js.map +1 -1
  177. package/plugins/utils.d.ts +1 -1
  178. package/plugins/utils.js +4 -57
  179. package/plugins/utils.js.map +1 -1
  180. package/scheduler/createScheduleActionMethods.js +17 -33
  181. package/scheduler/createScheduleActionMethods.js.map +1 -1
  182. package/scheduler/handlers/executeAction/index.js +9 -33
  183. package/scheduler/handlers/executeAction/index.js.map +1 -1
  184. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -6
  185. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -22
  187. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  188. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +5 -28
  189. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  190. package/scheduler/handlers/executeAction/security.js +0 -11
  191. package/scheduler/handlers/executeAction/security.js.map +1 -1
  192. package/scheduler/handlers/scheduleAction/index.js +13 -34
  193. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  194. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +7 -32
  195. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  196. package/scheduler/handlers/utils.js +4 -41
  197. package/scheduler/handlers/utils.js.map +1 -1
  198. package/scheduler/index.js +0 -3
  199. package/scheduler/index.js.map +1 -1
  200. package/scheduler/types.js +0 -6
  201. package/scheduler/types.js.map +1 -1
  202. package/storageOperations/changeRequestStorageOperations.js +5 -28
  203. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  204. package/storageOperations/commentStorageOperations.js +4 -29
  205. package/storageOperations/commentStorageOperations.js.map +1 -1
  206. package/storageOperations/contentReviewStorageOperations.js +5 -26
  207. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  208. package/storageOperations/index.js +5 -23
  209. package/storageOperations/index.js.map +1 -1
  210. package/storageOperations/models/changeRequest.model.js +0 -9
  211. package/storageOperations/models/changeRequest.model.js.map +1 -1
  212. package/storageOperations/models/comment.model.js +0 -8
  213. package/storageOperations/models/comment.model.js.map +1 -1
  214. package/storageOperations/models/contentModelPluginFactory.js +3 -12
  215. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  216. package/storageOperations/models/contentReview.model.js +6 -31
  217. package/storageOperations/models/contentReview.model.js.map +1 -1
  218. package/storageOperations/models/index.js +3 -25
  219. package/storageOperations/models/index.js.map +1 -1
  220. package/storageOperations/models/reviewer.model.js +17 -9
  221. package/storageOperations/models/reviewer.model.js.map +1 -1
  222. package/storageOperations/models/utils.js +3 -6
  223. package/storageOperations/models/utils.js.map +1 -1
  224. package/storageOperations/models/workflow.model.js +0 -23
  225. package/storageOperations/models/workflow.model.js.map +1 -1
  226. package/storageOperations/reviewerStorageOperations.js +16 -29
  227. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  228. package/storageOperations/workflowStorageOperations.js +6 -31
  229. package/storageOperations/workflowStorageOperations.js.map +1 -1
  230. package/types.d.ts +99 -84
  231. package/types.js +0 -14
  232. package/types.js.map +1 -1
  233. package/utils/contentApwSettingsPlugin.js +0 -6
  234. package/utils/contentApwSettingsPlugin.js.map +1 -1
  235. package/utils/errors.js +1 -18
  236. package/utils/errors.js.map +1 -1
  237. package/utils/fieldResolver.js +5 -21
  238. package/utils/fieldResolver.js.map +1 -1
  239. package/utils/resolve.js +0 -3
  240. package/utils/resolve.js.map +1 -1
@@ -0,0 +1,27 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ApwChangeRequest, ApwContentReview, ApwContentTypes, ApwContext, ApwReviewerWithEmail, ApwWorkflow } from "./types";
3
+ export interface ApwChangeRequestNotificationCbParams {
4
+ context: ApwContext;
5
+ reviewers: ApwReviewerWithEmail[];
6
+ changeRequestUrl: string;
7
+ contentUrl: string;
8
+ changeRequest: ApwChangeRequest;
9
+ contentReview: ApwContentReview;
10
+ workflow: ApwWorkflow;
11
+ }
12
+ export interface ApwChangeRequestNotificationCbParamsResponse {
13
+ text: string;
14
+ html?: string;
15
+ }
16
+ export interface ApwChangeRequestNotificationCb {
17
+ (params: ApwChangeRequestNotificationCbParams): ApwChangeRequestNotificationCbParamsResponse | null | undefined;
18
+ }
19
+ export declare class ApwChangeRequestNotification extends Plugin {
20
+ static readonly type: string;
21
+ private readonly contentType;
22
+ private readonly cb;
23
+ constructor(contentType: ApwContentTypes, cb: ApwChangeRequestNotificationCb);
24
+ canUse(contentType: ApwContentTypes): boolean;
25
+ create(params: ApwChangeRequestNotificationCbParams): ApwChangeRequestNotificationCbParamsResponse | null | undefined;
26
+ }
27
+ export declare const createApwChangeRequestNotification: (contentType: ApwContentTypes, cb: ApwChangeRequestNotificationCb) => ApwChangeRequestNotification;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createApwChangeRequestNotification = exports.ApwChangeRequestNotification = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _plugins = require("@webiny/plugins");
10
+ class ApwChangeRequestNotification extends _plugins.Plugin {
11
+ constructor(contentType, cb) {
12
+ super();
13
+ (0, _defineProperty2.default)(this, "contentType", void 0);
14
+ (0, _defineProperty2.default)(this, "cb", void 0);
15
+ this.contentType = contentType;
16
+ this.cb = cb;
17
+ }
18
+ canUse(contentType) {
19
+ return contentType === this.contentType;
20
+ }
21
+ create(params) {
22
+ return this.cb(params);
23
+ }
24
+ }
25
+ exports.ApwChangeRequestNotification = ApwChangeRequestNotification;
26
+ (0, _defineProperty2.default)(ApwChangeRequestNotification, "type", "apw.notification.changeRequest");
27
+ const createApwChangeRequestNotification = (contentType, cb) => {
28
+ return new ApwChangeRequestNotification(contentType, cb);
29
+ };
30
+ exports.createApwChangeRequestNotification = createApwChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApwChangeRequestNotification","Plugin","constructor","contentType","cb","canUse","create","params","createApwChangeRequestNotification"],"sources":["ApwChangeRequestNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwChangeRequest,\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwChangeRequestNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n changeRequestUrl: string;\n contentUrl: string;\n changeRequest: ApwChangeRequest;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwChangeRequestNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwChangeRequestNotificationCb {\n (params: ApwChangeRequestNotificationCbParams):\n | ApwChangeRequestNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwChangeRequestNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.changeRequest\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwChangeRequestNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwChangeRequestNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwChangeRequestNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwChangeRequestNotification = (\n contentType: ApwContentTypes,\n cb: ApwChangeRequestNotificationCb\n) => {\n return new ApwChangeRequestNotification(contentType, cb);\n};\n"],"mappings":";;;;;;;;AAAA;AA6BO,MAAMA,4BAA4B,SAASC,eAAM,CAAC;EAM9CC,WAAW,CAACC,WAA4B,EAAEC,EAAkC,EAAE;IACjF,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAM,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAM,CAACC,MAA4C,EAAE;IACxD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAAC;AAAA,8BAnBYP,4BAA4B,UACU,gCAAgC;AAoB5E,MAAMQ,kCAAkC,GAAG,CAC9CL,WAA4B,EAC5BC,EAAkC,KACjC;EACD,OAAO,IAAIJ,4BAA4B,CAACG,WAAW,EAAEC,EAAE,CAAC;AAC5D,CAAC;AAAC"}
@@ -0,0 +1,27 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ApwChangeRequest, ApwContentReview, ApwContentTypes, ApwContext, ApwReviewerWithEmail, ApwWorkflow } from "./types";
3
+ export interface ApwCommentNotificationCbParams {
4
+ context: ApwContext;
5
+ reviewers: ApwReviewerWithEmail[];
6
+ commentUrl: string;
7
+ contentUrl: string;
8
+ changeRequest: ApwChangeRequest;
9
+ contentReview: ApwContentReview;
10
+ workflow: ApwWorkflow;
11
+ }
12
+ export interface ApwCommentNotificationCbParamsResponse {
13
+ text: string;
14
+ html?: string;
15
+ }
16
+ export interface ApwCommentNotificationCb {
17
+ (params: ApwCommentNotificationCbParams): ApwCommentNotificationCbParamsResponse | null | undefined;
18
+ }
19
+ export declare class ApwCommentNotification extends Plugin {
20
+ static readonly type: string;
21
+ private readonly contentType;
22
+ private readonly cb;
23
+ constructor(contentType: ApwContentTypes, cb: ApwCommentNotificationCb);
24
+ canUse(contentType: ApwContentTypes): boolean;
25
+ create(params: ApwCommentNotificationCbParams): ApwCommentNotificationCbParamsResponse | null | undefined;
26
+ }
27
+ export declare const createApwCommentNotification: (contentType: ApwContentTypes, cb: ApwCommentNotificationCb) => ApwCommentNotification;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createApwCommentNotification = exports.ApwCommentNotification = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _plugins = require("@webiny/plugins");
10
+ class ApwCommentNotification extends _plugins.Plugin {
11
+ constructor(contentType, cb) {
12
+ super();
13
+ (0, _defineProperty2.default)(this, "contentType", void 0);
14
+ (0, _defineProperty2.default)(this, "cb", void 0);
15
+ this.contentType = contentType;
16
+ this.cb = cb;
17
+ }
18
+ canUse(contentType) {
19
+ return contentType === this.contentType;
20
+ }
21
+ create(params) {
22
+ return this.cb(params);
23
+ }
24
+ }
25
+ exports.ApwCommentNotification = ApwCommentNotification;
26
+ (0, _defineProperty2.default)(ApwCommentNotification, "type", "apw.notification.comment");
27
+ const createApwCommentNotification = (contentType, cb) => {
28
+ return new ApwCommentNotification(contentType, cb);
29
+ };
30
+ exports.createApwCommentNotification = createApwCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApwCommentNotification","Plugin","constructor","contentType","cb","canUse","create","params","createApwCommentNotification"],"sources":["ApwCommentNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwChangeRequest,\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwCommentNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n commentUrl: string;\n contentUrl: string;\n changeRequest: ApwChangeRequest;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwCommentNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwCommentNotificationCb {\n (params: ApwCommentNotificationCbParams):\n | ApwCommentNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwCommentNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.comment\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwCommentNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwCommentNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwCommentNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwCommentNotification = (\n contentType: ApwContentTypes,\n cb: ApwCommentNotificationCb\n) => {\n return new ApwCommentNotification(contentType, cb);\n};\n"],"mappings":";;;;;;;;AAAA;AA6BO,MAAMA,sBAAsB,SAASC,eAAM,CAAC;EAMxCC,WAAW,CAACC,WAA4B,EAAEC,EAA4B,EAAE;IAC3E,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAM,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAM,CAACC,MAAsC,EAAE;IAClD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAAC;AAAA,8BAnBYP,sBAAsB,UACgB,0BAA0B;AAoBtE,MAAMQ,4BAA4B,GAAG,CACxCL,WAA4B,EAC5BC,EAA4B,KAC3B;EACD,OAAO,IAAIJ,sBAAsB,CAACG,WAAW,EAAEC,EAAE,CAAC;AACtD,CAAC;AAAC"}
@@ -0,0 +1,26 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ApwContentReview, ApwContentTypes, ApwContext, ApwReviewerWithEmail, ApwWorkflow } from "./types";
3
+ export interface ApwContentReviewNotificationCbParams {
4
+ context: ApwContext;
5
+ reviewers: ApwReviewerWithEmail[];
6
+ contentReviewUrl: string;
7
+ contentUrl: string;
8
+ contentReview: ApwContentReview;
9
+ workflow: ApwWorkflow;
10
+ }
11
+ export interface ApwContentReviewNotificationCbParamsResponse {
12
+ text: string;
13
+ html?: string;
14
+ }
15
+ export interface ApwContentReviewNotificationCb {
16
+ (params: ApwContentReviewNotificationCbParams): ApwContentReviewNotificationCbParamsResponse | null | undefined;
17
+ }
18
+ export declare class ApwContentReviewNotification extends Plugin {
19
+ static readonly type: string;
20
+ private readonly contentType;
21
+ private readonly cb;
22
+ constructor(contentType: ApwContentTypes, cb: ApwContentReviewNotificationCb);
23
+ canUse(contentType: ApwContentTypes): boolean;
24
+ create(params: ApwContentReviewNotificationCbParams): ApwContentReviewNotificationCbParamsResponse | null | undefined;
25
+ }
26
+ export declare const createApwContentReviewNotification: (contentType: ApwContentTypes, cb: ApwContentReviewNotificationCb) => ApwContentReviewNotification;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createApwContentReviewNotification = exports.ApwContentReviewNotification = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _plugins = require("@webiny/plugins");
10
+ class ApwContentReviewNotification extends _plugins.Plugin {
11
+ constructor(contentType, cb) {
12
+ super();
13
+ (0, _defineProperty2.default)(this, "contentType", void 0);
14
+ (0, _defineProperty2.default)(this, "cb", void 0);
15
+ this.contentType = contentType;
16
+ this.cb = cb;
17
+ }
18
+ canUse(contentType) {
19
+ return contentType === this.contentType;
20
+ }
21
+ create(params) {
22
+ return this.cb(params);
23
+ }
24
+ }
25
+ exports.ApwContentReviewNotification = ApwContentReviewNotification;
26
+ (0, _defineProperty2.default)(ApwContentReviewNotification, "type", "apw.notification.contentReview");
27
+ const createApwContentReviewNotification = (contentType, cb) => {
28
+ return new ApwContentReviewNotification(contentType, cb);
29
+ };
30
+ exports.createApwContentReviewNotification = createApwContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApwContentReviewNotification","Plugin","constructor","contentType","cb","canUse","create","params","createApwContentReviewNotification"],"sources":["ApwContentReviewNotification.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n ApwContentReview,\n ApwContentTypes,\n ApwContext,\n ApwReviewerWithEmail,\n ApwWorkflow\n} from \"~/types\";\n\nexport interface ApwContentReviewNotificationCbParams {\n context: ApwContext;\n reviewers: ApwReviewerWithEmail[];\n contentReviewUrl: string;\n contentUrl: string;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwContentReviewNotificationCbParamsResponse {\n text: string;\n html?: string;\n}\nexport interface ApwContentReviewNotificationCb {\n (params: ApwContentReviewNotificationCbParams):\n | ApwContentReviewNotificationCbParamsResponse\n | null\n | undefined;\n}\nexport class ApwContentReviewNotification extends Plugin {\n public static override readonly type: string = \"apw.notification.contentReview\";\n\n private readonly contentType: ApwContentTypes;\n private readonly cb: ApwContentReviewNotificationCb;\n\n public constructor(contentType: ApwContentTypes, cb: ApwContentReviewNotificationCb) {\n super();\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return contentType === this.contentType;\n }\n\n public create(params: ApwContentReviewNotificationCbParams) {\n return this.cb(params);\n }\n}\n\nexport const createApwContentReviewNotification = (\n contentType: ApwContentTypes,\n cb: ApwContentReviewNotificationCb\n) => {\n return new ApwContentReviewNotification(contentType, cb);\n};\n"],"mappings":";;;;;;;;AAAA;AA2BO,MAAMA,4BAA4B,SAASC,eAAM,CAAC;EAM9CC,WAAW,CAACC,WAA4B,EAAEC,EAAkC,EAAE;IACjF,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAM,CAACF,WAA4B,EAAW;IACjD,OAAOA,WAAW,KAAK,IAAI,CAACA,WAAW;EAC3C;EAEOG,MAAM,CAACC,MAA4C,EAAE;IACxD,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAAC;AAAA,8BAnBYP,4BAA4B,UACU,gCAAgC;AAoB5E,MAAMQ,kCAAkC,GAAG,CAC9CL,WAA4B,EAC5BC,EAAkC,KACjC;EACD,OAAO,IAAIJ,4BAA4B,CAACG,WAAW,EAAEC,EAAE,CAAC;AAC5D,CAAC;AAAC"}
@@ -0,0 +1,19 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import { ApwContentReview, ApwContentTypes, ApwWorkflow } from "./types";
3
+ export interface ApwContentUrlPluginCbParams {
4
+ baseUrl: string;
5
+ contentReview: ApwContentReview;
6
+ workflow: ApwWorkflow;
7
+ }
8
+ export interface ApwContentUrlPluginCb {
9
+ (params: ApwContentUrlPluginCbParams): string | null;
10
+ }
11
+ export declare class ApwContentUrlPlugin extends Plugin {
12
+ static type: string;
13
+ private readonly cb;
14
+ private readonly contentType;
15
+ constructor(contentType: ApwContentTypes, cb: ApwContentUrlPluginCb);
16
+ canUse(contentType: ApwContentTypes): boolean;
17
+ create(params: ApwContentUrlPluginCbParams): string | null;
18
+ }
19
+ export declare const createApwContentUrlPlugin: (contentType: ApwContentTypes, cb: ApwContentUrlPluginCb) => ApwContentUrlPlugin;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createApwContentUrlPlugin = exports.ApwContentUrlPlugin = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _plugins = require("@webiny/plugins");
10
+ class ApwContentUrlPlugin extends _plugins.Plugin {
11
+ constructor(contentType, cb) {
12
+ super();
13
+ (0, _defineProperty2.default)(this, "cb", void 0);
14
+ (0, _defineProperty2.default)(this, "contentType", void 0);
15
+ this.contentType = contentType;
16
+ this.cb = cb;
17
+ }
18
+ canUse(contentType) {
19
+ return this.contentType === contentType;
20
+ }
21
+ create(params) {
22
+ return this.cb(params);
23
+ }
24
+ }
25
+ exports.ApwContentUrlPlugin = ApwContentUrlPlugin;
26
+ (0, _defineProperty2.default)(ApwContentUrlPlugin, "type", "apw.contentUrl");
27
+ const createApwContentUrlPlugin = (contentType, cb) => {
28
+ return new ApwContentUrlPlugin(contentType, cb);
29
+ };
30
+ exports.createApwContentUrlPlugin = createApwContentUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApwContentUrlPlugin","Plugin","constructor","contentType","cb","canUse","create","params","createApwContentUrlPlugin"],"sources":["ApwContentUrlPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ApwContentReview, ApwContentTypes, ApwWorkflow } from \"~/types\";\n\nexport interface ApwContentUrlPluginCbParams {\n baseUrl: string;\n contentReview: ApwContentReview;\n workflow: ApwWorkflow;\n}\nexport interface ApwContentUrlPluginCb {\n (params: ApwContentUrlPluginCbParams): string | null;\n}\n\nexport class ApwContentUrlPlugin extends Plugin {\n public static override type = \"apw.contentUrl\";\n\n private readonly cb: ApwContentUrlPluginCb;\n private readonly contentType: ApwContentTypes;\n\n public constructor(contentType: ApwContentTypes, cb: ApwContentUrlPluginCb) {\n super();\n\n this.contentType = contentType;\n this.cb = cb;\n }\n\n public canUse(contentType: ApwContentTypes): boolean {\n return this.contentType === contentType;\n }\n\n public create(params: ApwContentUrlPluginCbParams): string | null {\n return this.cb(params);\n }\n}\n\nexport const createApwContentUrlPlugin = (\n contentType: ApwContentTypes,\n cb: ApwContentUrlPluginCb\n) => {\n return new ApwContentUrlPlugin(contentType, cb);\n};\n"],"mappings":";;;;;;;;AAAA;AAYO,MAAMA,mBAAmB,SAASC,eAAM,CAAC;EAMrCC,WAAW,CAACC,WAA4B,EAAEC,EAAyB,EAAE;IACxE,KAAK,EAAE;IAAC;IAAA;IAER,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAM,CAACF,WAA4B,EAAW;IACjD,OAAO,IAAI,CAACA,WAAW,KAAKA,WAAW;EAC3C;EAEOG,MAAM,CAACC,MAAmC,EAAiB;IAC9D,OAAO,IAAI,CAACH,EAAE,CAACG,MAAM,CAAC;EAC1B;AACJ;AAAC;AAAA,8BApBYP,mBAAmB,UACE,gBAAgB;AAqB3C,MAAMQ,yBAAyB,GAAG,CACrCL,WAA4B,EAC5BC,EAAyB,KACxB;EACD,OAAO,IAAIJ,mBAAmB,CAACG,WAAW,EAAEC,EAAE,CAAC;AACnD,CAAC;AAAC"}
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.ContentApwSettingsPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
14
10
  class ContentApwSettingsPlugin extends _Plugin.Plugin {}
15
-
16
11
  exports.ContentApwSettingsPlugin = ContentApwSettingsPlugin;
17
12
  (0, _defineProperty2.default)(ContentApwSettingsPlugin, "type", "apw.contentApwSettings");
@@ -1 +1 @@
1
- {"version":3,"names":["ContentApwSettingsPlugin","Plugin"],"sources":["ContentApwSettingsPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport abstract class ContentApwSettingsPlugin extends Plugin {\n public static override type = \"apw.contentApwSettings\";\n\n public abstract canUse(type: ApwContentTypes): boolean;\n\n public abstract setWorkflowId(content: any, id: string | null): void;\n\n public abstract getWorkflowId(content: any): string | null;\n\n public abstract setContentReviewId(content: any, id: string | null): void;\n\n public abstract getContentReviewId(content: any): string | null;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAGO,MAAeA,wBAAf,SAAgDC,cAAhD,CAAuD;;;8BAAxCD,wB,UACY,wB"}
1
+ {"version":3,"names":["ContentApwSettingsPlugin","Plugin"],"sources":["ContentApwSettingsPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport abstract class ContentApwSettingsPlugin extends Plugin {\n public static override type = \"apw.contentApwSettings\";\n\n public abstract canUse(type: ApwContentTypes): boolean;\n\n public abstract setWorkflowId(content: any, id: string | null): void;\n\n public abstract getWorkflowId(content: any): string | null;\n\n public abstract setContentReviewId(content: any, id: string | null): void;\n\n public abstract getContentReviewId(content: any): string | null;\n}\n"],"mappings":";;;;;;;;AAAA;AAGO,MAAeA,wBAAwB,SAASC,cAAM,CAAC;AAY7D;AAAA,8BAZqBD,wBAAwB,UACZ,wBAAwB"}
@@ -4,47 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createChangeRequestMethods = createChangeRequestMethods;
7
-
8
7
  var _pubsub = require("@webiny/pubsub");
9
-
10
8
  function createChangeRequestMethods({
11
9
  storageOperations
12
10
  }) {
13
- const onBeforeChangeRequestCreate = (0, _pubsub.createTopic)();
14
- const onAfterChangeRequestCreate = (0, _pubsub.createTopic)();
15
- const onBeforeChangeRequestUpdate = (0, _pubsub.createTopic)();
16
- const onAfterChangeRequestUpdate = (0, _pubsub.createTopic)();
17
- const onBeforeChangeRequestDelete = (0, _pubsub.createTopic)();
18
- const onAfterChangeRequestDelete = (0, _pubsub.createTopic)();
11
+ // create
12
+ const onChangeRequestBeforeCreate = (0, _pubsub.createTopic)("apw.onChangeRequestBeforeCreate");
13
+ const onChangeRequestAfterCreate = (0, _pubsub.createTopic)("apw.onChangeRequestAfterCreate");
14
+ // update
15
+ const onChangeRequestBeforeUpdate = (0, _pubsub.createTopic)("apw.onChangeRequestBeforeUpdate");
16
+ const onChangeRequestAfterUpdate = (0, _pubsub.createTopic)("apw.onChangeRequestAfterUpdate");
17
+ // delete
18
+ const onChangeRequestBeforeDelete = (0, _pubsub.createTopic)("apw.onChangeRequestBeforeDelete");
19
+ const onChangeRequestAfterDelete = (0, _pubsub.createTopic)("apw.onChangeRequestAfterDelete");
19
20
  return {
20
21
  async get(id) {
21
22
  return storageOperations.getChangeRequest({
22
23
  id
23
24
  });
24
25
  },
25
-
26
26
  async list(params) {
27
27
  return storageOperations.listChangeRequests(params);
28
28
  },
29
-
30
29
  async create(data) {
31
- await onBeforeChangeRequestCreate.publish({
30
+ await onChangeRequestBeforeCreate.publish({
32
31
  input: data
33
32
  });
34
33
  const changeRequest = await storageOperations.createChangeRequest({
35
34
  data
36
35
  });
37
- await onAfterChangeRequestCreate.publish({
36
+ await onChangeRequestAfterCreate.publish({
38
37
  changeRequest
39
38
  });
40
39
  return changeRequest;
41
40
  },
42
-
43
41
  async update(id, data) {
44
42
  const original = await storageOperations.getChangeRequest({
45
43
  id
46
44
  });
47
- await onBeforeChangeRequestUpdate.publish({
45
+ await onChangeRequestBeforeUpdate.publish({
48
46
  original,
49
47
  input: {
50
48
  id,
@@ -55,7 +53,7 @@ function createChangeRequestMethods({
55
53
  id,
56
54
  data
57
55
  });
58
- await onAfterChangeRequestUpdate.publish({
56
+ await onChangeRequestAfterUpdate.publish({
59
57
  original,
60
58
  input: {
61
59
  id,
@@ -65,31 +63,29 @@ function createChangeRequestMethods({
65
63
  });
66
64
  return changeRequest;
67
65
  },
68
-
69
66
  async delete(id) {
70
67
  const changeRequest = await storageOperations.getChangeRequest({
71
68
  id
72
69
  });
73
- await onBeforeChangeRequestDelete.publish({
70
+ await onChangeRequestBeforeDelete.publish({
74
71
  changeRequest
75
72
  });
76
73
  await storageOperations.deleteChangeRequest({
77
74
  id
78
75
  });
79
- await onAfterChangeRequestDelete.publish({
76
+ await onChangeRequestAfterDelete.publish({
80
77
  changeRequest
81
78
  });
82
79
  return true;
83
80
  },
84
-
85
81
  /**
86
82
  * Lifecycle events
87
83
  */
88
- onBeforeChangeRequestCreate,
89
- onAfterChangeRequestCreate,
90
- onBeforeChangeRequestUpdate,
91
- onAfterChangeRequestUpdate,
92
- onBeforeChangeRequestDelete,
93
- onAfterChangeRequestDelete
84
+ onChangeRequestBeforeCreate,
85
+ onChangeRequestAfterCreate,
86
+ onChangeRequestBeforeUpdate,
87
+ onChangeRequestAfterUpdate,
88
+ onChangeRequestBeforeDelete,
89
+ onChangeRequestAfterDelete
94
90
  };
95
91
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createChangeRequestMethods","storageOperations","onBeforeChangeRequestCreate","createTopic","onAfterChangeRequestCreate","onBeforeChangeRequestUpdate","onAfterChangeRequestUpdate","onBeforeChangeRequestDelete","onAfterChangeRequestDelete","get","id","getChangeRequest","list","params","listChangeRequests","create","data","publish","input","changeRequest","createChangeRequest","update","original","updateChangeRequest","delete","deleteChangeRequest"],"sources":["createChangeRequestMethods.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport {\n ApwChangeRequestCrud,\n CreateApwParams,\n OnAfterChangeRequestCreateTopicParams,\n OnAfterChangeRequestDeleteTopicParams,\n OnAfterChangeRequestUpdateTopicParams,\n OnBeforeChangeRequestCreateTopicParams,\n OnBeforeChangeRequestDeleteTopicParams,\n OnBeforeChangeRequestUpdateTopicParams\n} from \"~/types\";\n\nexport function createChangeRequestMethods({\n storageOperations\n}: CreateApwParams): ApwChangeRequestCrud {\n const onBeforeChangeRequestCreate = createTopic<OnBeforeChangeRequestCreateTopicParams>();\n const onAfterChangeRequestCreate = createTopic<OnAfterChangeRequestCreateTopicParams>();\n const onBeforeChangeRequestUpdate = createTopic<OnBeforeChangeRequestUpdateTopicParams>();\n const onAfterChangeRequestUpdate = createTopic<OnAfterChangeRequestUpdateTopicParams>();\n const onBeforeChangeRequestDelete = createTopic<OnBeforeChangeRequestDeleteTopicParams>();\n const onAfterChangeRequestDelete = createTopic<OnAfterChangeRequestDeleteTopicParams>();\n\n return {\n async get(id) {\n return storageOperations.getChangeRequest({ id });\n },\n async list(params) {\n return storageOperations.listChangeRequests(params);\n },\n async create(data) {\n await onBeforeChangeRequestCreate.publish({ input: data });\n\n const changeRequest = await storageOperations.createChangeRequest({ data });\n\n await onAfterChangeRequestCreate.publish({ changeRequest });\n\n return changeRequest;\n },\n async update(id, data) {\n const original = await storageOperations.getChangeRequest({ id });\n\n await onBeforeChangeRequestUpdate.publish({ original, input: { id, data } });\n\n const changeRequest = await storageOperations.updateChangeRequest({ id, data });\n\n await onAfterChangeRequestUpdate.publish({\n original,\n input: { id, data },\n changeRequest\n });\n\n return changeRequest;\n },\n async delete(id: string) {\n const changeRequest = await storageOperations.getChangeRequest({ id });\n\n await onBeforeChangeRequestDelete.publish({ changeRequest });\n\n await storageOperations.deleteChangeRequest({ id });\n\n await onAfterChangeRequestDelete.publish({ changeRequest });\n\n return true;\n },\n /**\n * Lifecycle events\n */\n onBeforeChangeRequestCreate,\n onAfterChangeRequestCreate,\n onBeforeChangeRequestUpdate,\n onAfterChangeRequestUpdate,\n onBeforeChangeRequestDelete,\n onAfterChangeRequestDelete\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAYO,SAASA,0BAAT,CAAoC;EACvCC;AADuC,CAApC,EAEmC;EACtC,MAAMC,2BAA2B,GAAG,IAAAC,mBAAA,GAApC;EACA,MAAMC,0BAA0B,GAAG,IAAAD,mBAAA,GAAnC;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAA,GAApC;EACA,MAAMG,0BAA0B,GAAG,IAAAH,mBAAA,GAAnC;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAA,GAApC;EACA,MAAMK,0BAA0B,GAAG,IAAAL,mBAAA,GAAnC;EAEA,OAAO;IACH,MAAMM,GAAN,CAAUC,EAAV,EAAc;MACV,OAAOT,iBAAiB,CAACU,gBAAlB,CAAmC;QAAED;MAAF,CAAnC,CAAP;IACH,CAHE;;IAIH,MAAME,IAAN,CAAWC,MAAX,EAAmB;MACf,OAAOZ,iBAAiB,CAACa,kBAAlB,CAAqCD,MAArC,CAAP;IACH,CANE;;IAOH,MAAME,MAAN,CAAaC,IAAb,EAAmB;MACf,MAAMd,2BAA2B,CAACe,OAA5B,CAAoC;QAAEC,KAAK,EAAEF;MAAT,CAApC,CAAN;MAEA,MAAMG,aAAa,GAAG,MAAMlB,iBAAiB,CAACmB,mBAAlB,CAAsC;QAAEJ;MAAF,CAAtC,CAA5B;MAEA,MAAMZ,0BAA0B,CAACa,OAA3B,CAAmC;QAAEE;MAAF,CAAnC,CAAN;MAEA,OAAOA,aAAP;IACH,CAfE;;IAgBH,MAAME,MAAN,CAAaX,EAAb,EAAiBM,IAAjB,EAAuB;MACnB,MAAMM,QAAQ,GAAG,MAAMrB,iBAAiB,CAACU,gBAAlB,CAAmC;QAAED;MAAF,CAAnC,CAAvB;MAEA,MAAML,2BAA2B,CAACY,OAA5B,CAAoC;QAAEK,QAAF;QAAYJ,KAAK,EAAE;UAAER,EAAF;UAAMM;QAAN;MAAnB,CAApC,CAAN;MAEA,MAAMG,aAAa,GAAG,MAAMlB,iBAAiB,CAACsB,mBAAlB,CAAsC;QAAEb,EAAF;QAAMM;MAAN,CAAtC,CAA5B;MAEA,MAAMV,0BAA0B,CAACW,OAA3B,CAAmC;QACrCK,QADqC;QAErCJ,KAAK,EAAE;UAAER,EAAF;UAAMM;QAAN,CAF8B;QAGrCG;MAHqC,CAAnC,CAAN;MAMA,OAAOA,aAAP;IACH,CA9BE;;IA+BH,MAAMK,MAAN,CAAad,EAAb,EAAyB;MACrB,MAAMS,aAAa,GAAG,MAAMlB,iBAAiB,CAACU,gBAAlB,CAAmC;QAAED;MAAF,CAAnC,CAA5B;MAEA,MAAMH,2BAA2B,CAACU,OAA5B,CAAoC;QAAEE;MAAF,CAApC,CAAN;MAEA,MAAMlB,iBAAiB,CAACwB,mBAAlB,CAAsC;QAAEf;MAAF,CAAtC,CAAN;MAEA,MAAMF,0BAA0B,CAACS,OAA3B,CAAmC;QAAEE;MAAF,CAAnC,CAAN;MAEA,OAAO,IAAP;IACH,CAzCE;;IA0CH;AACR;AACA;IACQjB,2BA7CG;IA8CHE,0BA9CG;IA+CHC,2BA/CG;IAgDHC,0BAhDG;IAiDHC,2BAjDG;IAkDHC;EAlDG,CAAP;AAoDH"}
1
+ {"version":3,"names":["createChangeRequestMethods","storageOperations","onChangeRequestBeforeCreate","createTopic","onChangeRequestAfterCreate","onChangeRequestBeforeUpdate","onChangeRequestAfterUpdate","onChangeRequestBeforeDelete","onChangeRequestAfterDelete","get","id","getChangeRequest","list","params","listChangeRequests","create","data","publish","input","changeRequest","createChangeRequest","update","original","updateChangeRequest","delete","deleteChangeRequest"],"sources":["createChangeRequestMethods.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport {\n ApwChangeRequestCrud,\n CreateApwParams,\n OnChangeRequestAfterCreateTopicParams,\n OnChangeRequestAfterDeleteTopicParams,\n OnChangeRequestAfterUpdateTopicParams,\n OnChangeRequestBeforeCreateTopicParams,\n OnChangeRequestBeforeDeleteTopicParams,\n OnChangeRequestBeforeUpdateTopicParams\n} from \"~/types\";\n\nexport function createChangeRequestMethods({\n storageOperations\n}: CreateApwParams): ApwChangeRequestCrud {\n // create\n const onChangeRequestBeforeCreate = createTopic<OnChangeRequestBeforeCreateTopicParams>(\n \"apw.onChangeRequestBeforeCreate\"\n );\n const onChangeRequestAfterCreate = createTopic<OnChangeRequestAfterCreateTopicParams>(\n \"apw.onChangeRequestAfterCreate\"\n );\n // update\n const onChangeRequestBeforeUpdate = createTopic<OnChangeRequestBeforeUpdateTopicParams>(\n \"apw.onChangeRequestBeforeUpdate\"\n );\n const onChangeRequestAfterUpdate = createTopic<OnChangeRequestAfterUpdateTopicParams>(\n \"apw.onChangeRequestAfterUpdate\"\n );\n // delete\n const onChangeRequestBeforeDelete = createTopic<OnChangeRequestBeforeDeleteTopicParams>(\n \"apw.onChangeRequestBeforeDelete\"\n );\n const onChangeRequestAfterDelete = createTopic<OnChangeRequestAfterDeleteTopicParams>(\n \"apw.onChangeRequestAfterDelete\"\n );\n\n return {\n async get(id) {\n return storageOperations.getChangeRequest({ id });\n },\n async list(params) {\n return storageOperations.listChangeRequests(params);\n },\n async create(data) {\n await onChangeRequestBeforeCreate.publish({ input: data });\n\n const changeRequest = await storageOperations.createChangeRequest({ data });\n\n await onChangeRequestAfterCreate.publish({ changeRequest });\n\n return changeRequest;\n },\n async update(id, data) {\n const original = await storageOperations.getChangeRequest({ id });\n\n await onChangeRequestBeforeUpdate.publish({ original, input: { id, data } });\n\n const changeRequest = await storageOperations.updateChangeRequest({ id, data });\n\n await onChangeRequestAfterUpdate.publish({\n original,\n input: { id, data },\n changeRequest\n });\n\n return changeRequest;\n },\n async delete(id: string) {\n const changeRequest = await storageOperations.getChangeRequest({ id });\n\n await onChangeRequestBeforeDelete.publish({ changeRequest });\n\n await storageOperations.deleteChangeRequest({ id });\n\n await onChangeRequestAfterDelete.publish({ changeRequest });\n\n return true;\n },\n /**\n * Lifecycle events\n */\n onChangeRequestBeforeCreate,\n onChangeRequestAfterCreate,\n onChangeRequestBeforeUpdate,\n onChangeRequestAfterUpdate,\n onChangeRequestBeforeDelete,\n onChangeRequestAfterDelete\n };\n}\n"],"mappings":";;;;;;AAAA;AAYO,SAASA,0BAA0B,CAAC;EACvCC;AACa,CAAC,EAAwB;EACtC;EACA,MAAMC,2BAA2B,GAAG,IAAAC,mBAAW,EAC3C,iCAAiC,CACpC;EACD,MAAMC,0BAA0B,GAAG,IAAAD,mBAAW,EAC1C,gCAAgC,CACnC;EACD;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAW,EAC3C,iCAAiC,CACpC;EACD,MAAMG,0BAA0B,GAAG,IAAAH,mBAAW,EAC1C,gCAAgC,CACnC;EACD;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAW,EAC3C,iCAAiC,CACpC;EACD,MAAMK,0BAA0B,GAAG,IAAAL,mBAAW,EAC1C,gCAAgC,CACnC;EAED,OAAO;IACH,MAAMM,GAAG,CAACC,EAAE,EAAE;MACV,OAAOT,iBAAiB,CAACU,gBAAgB,CAAC;QAAED;MAAG,CAAC,CAAC;IACrD,CAAC;IACD,MAAME,IAAI,CAACC,MAAM,EAAE;MACf,OAAOZ,iBAAiB,CAACa,kBAAkB,CAACD,MAAM,CAAC;IACvD,CAAC;IACD,MAAME,MAAM,CAACC,IAAI,EAAE;MACf,MAAMd,2BAA2B,CAACe,OAAO,CAAC;QAAEC,KAAK,EAAEF;MAAK,CAAC,CAAC;MAE1D,MAAMG,aAAa,GAAG,MAAMlB,iBAAiB,CAACmB,mBAAmB,CAAC;QAAEJ;MAAK,CAAC,CAAC;MAE3E,MAAMZ,0BAA0B,CAACa,OAAO,CAAC;QAAEE;MAAc,CAAC,CAAC;MAE3D,OAAOA,aAAa;IACxB,CAAC;IACD,MAAME,MAAM,CAACX,EAAE,EAAEM,IAAI,EAAE;MACnB,MAAMM,QAAQ,GAAG,MAAMrB,iBAAiB,CAACU,gBAAgB,CAAC;QAAED;MAAG,CAAC,CAAC;MAEjE,MAAML,2BAA2B,CAACY,OAAO,CAAC;QAAEK,QAAQ;QAAEJ,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK;MAAE,CAAC,CAAC;MAE5E,MAAMG,aAAa,GAAG,MAAMlB,iBAAiB,CAACsB,mBAAmB,CAAC;QAAEb,EAAE;QAAEM;MAAK,CAAC,CAAC;MAE/E,MAAMV,0BAA0B,CAACW,OAAO,CAAC;QACrCK,QAAQ;QACRJ,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK,CAAC;QACnBG;MACJ,CAAC,CAAC;MAEF,OAAOA,aAAa;IACxB,CAAC;IACD,MAAMK,MAAM,CAACd,EAAU,EAAE;MACrB,MAAMS,aAAa,GAAG,MAAMlB,iBAAiB,CAACU,gBAAgB,CAAC;QAAED;MAAG,CAAC,CAAC;MAEtE,MAAMH,2BAA2B,CAACU,OAAO,CAAC;QAAEE;MAAc,CAAC,CAAC;MAE5D,MAAMlB,iBAAiB,CAACwB,mBAAmB,CAAC;QAAEf;MAAG,CAAC,CAAC;MAEnD,MAAMF,0BAA0B,CAACS,OAAO,CAAC;QAAEE;MAAc,CAAC,CAAC;MAE3D,OAAO,IAAI;IACf,CAAC;IACD;AACR;AACA;IACQjB,2BAA2B;IAC3BE,0BAA0B;IAC1BC,2BAA2B;IAC3BC,0BAA0B;IAC1BC,2BAA2B;IAC3BC;EACJ,CAAC;AACL"}
@@ -4,57 +4,54 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createCommentMethods = createCommentMethods;
7
-
8
7
  var _pubsub = require("@webiny/pubsub");
9
-
10
8
  function createCommentMethods({
11
9
  storageOperations
12
10
  }) {
13
- const onBeforeCommentCreate = (0, _pubsub.createTopic)();
14
- const onAfterCommentCreate = (0, _pubsub.createTopic)();
15
- const onBeforeCommentUpdate = (0, _pubsub.createTopic)();
16
- const onAfterCommentUpdate = (0, _pubsub.createTopic)();
17
- const onBeforeCommentDelete = (0, _pubsub.createTopic)();
18
- const onAfterCommentDelete = (0, _pubsub.createTopic)();
11
+ // create
12
+ const onCommentBeforeCreate = (0, _pubsub.createTopic)("apw.onCommentBeforeCreate");
13
+ const onCommentAfterCreate = (0, _pubsub.createTopic)("apw.onCommentAfterCreate");
14
+ // update
15
+ const onCommentBeforeUpdate = (0, _pubsub.createTopic)("apw.onCommentBeforeUpdate");
16
+ const onCommentAfterUpdate = (0, _pubsub.createTopic)("apw.onCommentAfterUpdate");
17
+ // delete
18
+ const onCommentBeforeDelete = (0, _pubsub.createTopic)("apw.onCommentBeforeDelete");
19
+ const onCommentAfterDelete = (0, _pubsub.createTopic)("apw.onCommentAfterDelete");
19
20
  return {
20
21
  /**
21
22
  * Lifecycle events
22
23
  */
23
- onBeforeCommentCreate,
24
- onAfterCommentCreate,
25
- onBeforeCommentUpdate,
26
- onAfterCommentUpdate,
27
- onBeforeCommentDelete,
28
- onAfterCommentDelete,
29
-
24
+ onCommentBeforeCreate,
25
+ onCommentAfterCreate,
26
+ onCommentBeforeUpdate,
27
+ onCommentAfterUpdate,
28
+ onCommentBeforeDelete,
29
+ onCommentAfterDelete,
30
30
  async get(id) {
31
31
  return storageOperations.getComment({
32
32
  id
33
33
  });
34
34
  },
35
-
36
35
  async list(params) {
37
36
  return storageOperations.listComments(params);
38
37
  },
39
-
40
38
  async create(data) {
41
- await onBeforeCommentCreate.publish({
39
+ await onCommentBeforeCreate.publish({
42
40
  input: data
43
41
  });
44
42
  const comment = await storageOperations.createComment({
45
43
  data
46
44
  });
47
- await onAfterCommentCreate.publish({
45
+ await onCommentAfterCreate.publish({
48
46
  comment
49
47
  });
50
48
  return comment;
51
49
  },
52
-
53
50
  async update(id, data) {
54
51
  const original = await storageOperations.getComment({
55
52
  id
56
53
  });
57
- await onBeforeCommentUpdate.publish({
54
+ await onCommentBeforeUpdate.publish({
58
55
  original,
59
56
  input: {
60
57
  id,
@@ -65,7 +62,7 @@ function createCommentMethods({
65
62
  id,
66
63
  data
67
64
  });
68
- await onAfterCommentUpdate.publish({
65
+ await onCommentAfterUpdate.publish({
69
66
  original,
70
67
  comment,
71
68
  input: {
@@ -75,22 +72,20 @@ function createCommentMethods({
75
72
  });
76
73
  return comment;
77
74
  },
78
-
79
75
  async delete(id) {
80
76
  const comment = await storageOperations.getComment({
81
77
  id
82
78
  });
83
- await onBeforeCommentDelete.publish({
79
+ await onCommentBeforeDelete.publish({
84
80
  comment
85
81
  });
86
82
  await storageOperations.deleteComment({
87
83
  id
88
84
  });
89
- await onAfterCommentDelete.publish({
85
+ await onCommentAfterDelete.publish({
90
86
  comment
91
87
  });
92
88
  return true;
93
89
  }
94
-
95
90
  };
96
91
  }
@@ -1 +1 @@
1
- {"version":3,"names":["createCommentMethods","storageOperations","onBeforeCommentCreate","createTopic","onAfterCommentCreate","onBeforeCommentUpdate","onAfterCommentUpdate","onBeforeCommentDelete","onAfterCommentDelete","get","id","getComment","list","params","listComments","create","data","publish","input","comment","createComment","update","original","updateComment","delete","deleteComment"],"sources":["createCommentMethods.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport {\n ApwCommentCrud,\n CreateApwParams,\n OnBeforeCommentCreateTopicParams,\n OnAfterCommentCreateTopicParams,\n OnBeforeCommentUpdateTopicParams,\n OnAfterCommentUpdateTopicParams,\n OnBeforeCommentDeleteTopicParams,\n OnAfterCommentDeleteTopicParams\n} from \"~/types\";\n\nexport function createCommentMethods({ storageOperations }: CreateApwParams): ApwCommentCrud {\n const onBeforeCommentCreate = createTopic<OnBeforeCommentCreateTopicParams>();\n const onAfterCommentCreate = createTopic<OnAfterCommentCreateTopicParams>();\n const onBeforeCommentUpdate = createTopic<OnBeforeCommentUpdateTopicParams>();\n const onAfterCommentUpdate = createTopic<OnAfterCommentUpdateTopicParams>();\n const onBeforeCommentDelete = createTopic<OnBeforeCommentDeleteTopicParams>();\n const onAfterCommentDelete = createTopic<OnAfterCommentDeleteTopicParams>();\n\n return {\n /**\n * Lifecycle events\n */\n onBeforeCommentCreate,\n onAfterCommentCreate,\n onBeforeCommentUpdate,\n onAfterCommentUpdate,\n onBeforeCommentDelete,\n onAfterCommentDelete,\n async get(id) {\n return storageOperations.getComment({ id });\n },\n async list(params) {\n return storageOperations.listComments(params);\n },\n async create(data) {\n await onBeforeCommentCreate.publish({ input: data });\n\n const comment = await storageOperations.createComment({\n data\n });\n await onAfterCommentCreate.publish({ comment });\n\n return comment;\n },\n async update(id, data) {\n const original = await storageOperations.getComment({ id });\n\n await onBeforeCommentUpdate.publish({ original, input: { id, data } });\n\n const comment = await storageOperations.updateComment({ id, data });\n\n await onAfterCommentUpdate.publish({ original, comment, input: { id, data } });\n\n return comment;\n },\n async delete(id: string) {\n const comment = await storageOperations.getComment({ id });\n\n await onBeforeCommentDelete.publish({ comment });\n\n await storageOperations.deleteComment({ id });\n\n await onAfterCommentDelete.publish({ comment });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAYO,SAASA,oBAAT,CAA8B;EAAEC;AAAF,CAA9B,EAAsF;EACzF,MAAMC,qBAAqB,GAAG,IAAAC,mBAAA,GAA9B;EACA,MAAMC,oBAAoB,GAAG,IAAAD,mBAAA,GAA7B;EACA,MAAME,qBAAqB,GAAG,IAAAF,mBAAA,GAA9B;EACA,MAAMG,oBAAoB,GAAG,IAAAH,mBAAA,GAA7B;EACA,MAAMI,qBAAqB,GAAG,IAAAJ,mBAAA,GAA9B;EACA,MAAMK,oBAAoB,GAAG,IAAAL,mBAAA,GAA7B;EAEA,OAAO;IACH;AACR;AACA;IACQD,qBAJG;IAKHE,oBALG;IAMHC,qBANG;IAOHC,oBAPG;IAQHC,qBARG;IASHC,oBATG;;IAUH,MAAMC,GAAN,CAAUC,EAAV,EAAc;MACV,OAAOT,iBAAiB,CAACU,UAAlB,CAA6B;QAAED;MAAF,CAA7B,CAAP;IACH,CAZE;;IAaH,MAAME,IAAN,CAAWC,MAAX,EAAmB;MACf,OAAOZ,iBAAiB,CAACa,YAAlB,CAA+BD,MAA/B,CAAP;IACH,CAfE;;IAgBH,MAAME,MAAN,CAAaC,IAAb,EAAmB;MACf,MAAMd,qBAAqB,CAACe,OAAtB,CAA8B;QAAEC,KAAK,EAAEF;MAAT,CAA9B,CAAN;MAEA,MAAMG,OAAO,GAAG,MAAMlB,iBAAiB,CAACmB,aAAlB,CAAgC;QAClDJ;MADkD,CAAhC,CAAtB;MAGA,MAAMZ,oBAAoB,CAACa,OAArB,CAA6B;QAAEE;MAAF,CAA7B,CAAN;MAEA,OAAOA,OAAP;IACH,CAzBE;;IA0BH,MAAME,MAAN,CAAaX,EAAb,EAAiBM,IAAjB,EAAuB;MACnB,MAAMM,QAAQ,GAAG,MAAMrB,iBAAiB,CAACU,UAAlB,CAA6B;QAAED;MAAF,CAA7B,CAAvB;MAEA,MAAML,qBAAqB,CAACY,OAAtB,CAA8B;QAAEK,QAAF;QAAYJ,KAAK,EAAE;UAAER,EAAF;UAAMM;QAAN;MAAnB,CAA9B,CAAN;MAEA,MAAMG,OAAO,GAAG,MAAMlB,iBAAiB,CAACsB,aAAlB,CAAgC;QAAEb,EAAF;QAAMM;MAAN,CAAhC,CAAtB;MAEA,MAAMV,oBAAoB,CAACW,OAArB,CAA6B;QAAEK,QAAF;QAAYH,OAAZ;QAAqBD,KAAK,EAAE;UAAER,EAAF;UAAMM;QAAN;MAA5B,CAA7B,CAAN;MAEA,OAAOG,OAAP;IACH,CApCE;;IAqCH,MAAMK,MAAN,CAAad,EAAb,EAAyB;MACrB,MAAMS,OAAO,GAAG,MAAMlB,iBAAiB,CAACU,UAAlB,CAA6B;QAAED;MAAF,CAA7B,CAAtB;MAEA,MAAMH,qBAAqB,CAACU,OAAtB,CAA8B;QAAEE;MAAF,CAA9B,CAAN;MAEA,MAAMlB,iBAAiB,CAACwB,aAAlB,CAAgC;QAAEf;MAAF,CAAhC,CAAN;MAEA,MAAMF,oBAAoB,CAACS,OAArB,CAA6B;QAAEE;MAAF,CAA7B,CAAN;MAEA,OAAO,IAAP;IACH;;EA/CE,CAAP;AAiDH"}
1
+ {"version":3,"names":["createCommentMethods","storageOperations","onCommentBeforeCreate","createTopic","onCommentAfterCreate","onCommentBeforeUpdate","onCommentAfterUpdate","onCommentBeforeDelete","onCommentAfterDelete","get","id","getComment","list","params","listComments","create","data","publish","input","comment","createComment","update","original","updateComment","delete","deleteComment"],"sources":["createCommentMethods.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport {\n ApwCommentCrud,\n CreateApwParams,\n OnCommentBeforeCreateTopicParams,\n OnCommentAfterCreateTopicParams,\n OnCommentBeforeUpdateTopicParams,\n OnCommentAfterUpdateTopicParams,\n OnCommentBeforeDeleteTopicParams,\n OnCommentAfterDeleteTopicParams\n} from \"~/types\";\n\nexport function createCommentMethods({ storageOperations }: CreateApwParams): ApwCommentCrud {\n // create\n const onCommentBeforeCreate = createTopic<OnCommentBeforeCreateTopicParams>(\n \"apw.onCommentBeforeCreate\"\n );\n const onCommentAfterCreate = createTopic<OnCommentAfterCreateTopicParams>(\n \"apw.onCommentAfterCreate\"\n );\n // update\n const onCommentBeforeUpdate = createTopic<OnCommentBeforeUpdateTopicParams>(\n \"apw.onCommentBeforeUpdate\"\n );\n const onCommentAfterUpdate = createTopic<OnCommentAfterUpdateTopicParams>(\n \"apw.onCommentAfterUpdate\"\n );\n // delete\n const onCommentBeforeDelete = createTopic<OnCommentBeforeDeleteTopicParams>(\n \"apw.onCommentBeforeDelete\"\n );\n const onCommentAfterDelete = createTopic<OnCommentAfterDeleteTopicParams>(\n \"apw.onCommentAfterDelete\"\n );\n\n return {\n /**\n * Lifecycle events\n */\n onCommentBeforeCreate,\n onCommentAfterCreate,\n onCommentBeforeUpdate,\n onCommentAfterUpdate,\n onCommentBeforeDelete,\n onCommentAfterDelete,\n async get(id) {\n return storageOperations.getComment({ id });\n },\n async list(params) {\n return storageOperations.listComments(params);\n },\n async create(data) {\n await onCommentBeforeCreate.publish({ input: data });\n\n const comment = await storageOperations.createComment({\n data\n });\n await onCommentAfterCreate.publish({ comment });\n\n return comment;\n },\n async update(id, data) {\n const original = await storageOperations.getComment({ id });\n\n await onCommentBeforeUpdate.publish({ original, input: { id, data } });\n\n const comment = await storageOperations.updateComment({ id, data });\n\n await onCommentAfterUpdate.publish({ original, comment, input: { id, data } });\n\n return comment;\n },\n async delete(id: string) {\n const comment = await storageOperations.getComment({ id });\n\n await onCommentBeforeDelete.publish({ comment });\n\n await storageOperations.deleteComment({ id });\n\n await onCommentAfterDelete.publish({ comment });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;AAAA;AAYO,SAASA,oBAAoB,CAAC;EAAEC;AAAmC,CAAC,EAAkB;EACzF;EACA,MAAMC,qBAAqB,GAAG,IAAAC,mBAAW,EACrC,2BAA2B,CAC9B;EACD,MAAMC,oBAAoB,GAAG,IAAAD,mBAAW,EACpC,0BAA0B,CAC7B;EACD;EACA,MAAME,qBAAqB,GAAG,IAAAF,mBAAW,EACrC,2BAA2B,CAC9B;EACD,MAAMG,oBAAoB,GAAG,IAAAH,mBAAW,EACpC,0BAA0B,CAC7B;EACD;EACA,MAAMI,qBAAqB,GAAG,IAAAJ,mBAAW,EACrC,2BAA2B,CAC9B;EACD,MAAMK,oBAAoB,GAAG,IAAAL,mBAAW,EACpC,0BAA0B,CAC7B;EAED,OAAO;IACH;AACR;AACA;IACQD,qBAAqB;IACrBE,oBAAoB;IACpBC,qBAAqB;IACrBC,oBAAoB;IACpBC,qBAAqB;IACrBC,oBAAoB;IACpB,MAAMC,GAAG,CAACC,EAAE,EAAE;MACV,OAAOT,iBAAiB,CAACU,UAAU,CAAC;QAAED;MAAG,CAAC,CAAC;IAC/C,CAAC;IACD,MAAME,IAAI,CAACC,MAAM,EAAE;MACf,OAAOZ,iBAAiB,CAACa,YAAY,CAACD,MAAM,CAAC;IACjD,CAAC;IACD,MAAME,MAAM,CAACC,IAAI,EAAE;MACf,MAAMd,qBAAqB,CAACe,OAAO,CAAC;QAAEC,KAAK,EAAEF;MAAK,CAAC,CAAC;MAEpD,MAAMG,OAAO,GAAG,MAAMlB,iBAAiB,CAACmB,aAAa,CAAC;QAClDJ;MACJ,CAAC,CAAC;MACF,MAAMZ,oBAAoB,CAACa,OAAO,CAAC;QAAEE;MAAQ,CAAC,CAAC;MAE/C,OAAOA,OAAO;IAClB,CAAC;IACD,MAAME,MAAM,CAACX,EAAE,EAAEM,IAAI,EAAE;MACnB,MAAMM,QAAQ,GAAG,MAAMrB,iBAAiB,CAACU,UAAU,CAAC;QAAED;MAAG,CAAC,CAAC;MAE3D,MAAML,qBAAqB,CAACY,OAAO,CAAC;QAAEK,QAAQ;QAAEJ,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK;MAAE,CAAC,CAAC;MAEtE,MAAMG,OAAO,GAAG,MAAMlB,iBAAiB,CAACsB,aAAa,CAAC;QAAEb,EAAE;QAAEM;MAAK,CAAC,CAAC;MAEnE,MAAMV,oBAAoB,CAACW,OAAO,CAAC;QAAEK,QAAQ;QAAEH,OAAO;QAAED,KAAK,EAAE;UAAER,EAAE;UAAEM;QAAK;MAAE,CAAC,CAAC;MAE9E,OAAOG,OAAO;IAClB,CAAC;IACD,MAAMK,MAAM,CAACd,EAAU,EAAE;MACrB,MAAMS,OAAO,GAAG,MAAMlB,iBAAiB,CAACU,UAAU,CAAC;QAAED;MAAG,CAAC,CAAC;MAE1D,MAAMH,qBAAqB,CAACU,OAAO,CAAC;QAAEE;MAAQ,CAAC,CAAC;MAEhD,MAAMlB,iBAAiB,CAACwB,aAAa,CAAC;QAAEf;MAAG,CAAC,CAAC;MAE7C,MAAMF,oBAAoB,CAACS,OAAO,CAAC;QAAEE;MAAQ,CAAC,CAAC;MAE/C,OAAO,IAAI;IACf;EACJ,CAAC;AACL"}