@webiny/api-website-builder-scheduler 6.0.0-rc.6

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/context.d.ts +2 -0
  4. package/context.js +13 -0
  5. package/context.js.map +1 -0
  6. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnDeleteEventHandler.d.ts +20 -0
  7. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnDeleteEventHandler.js +48 -0
  8. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnDeleteEventHandler.js.map +1 -0
  9. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnPublishEventHandler.d.ts +19 -0
  10. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnPublishEventHandler.js +45 -0
  11. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnPublishEventHandler.js.map +1 -0
  12. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnUnpublishEventHandler.d.ts +19 -0
  13. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnUnpublishEventHandler.js +45 -0
  14. package/features/CancelScheduledActionOnPageChange/CancelScheduledActionOnUnpublishEventHandler.js.map +1 -0
  15. package/features/CancelScheduledActionOnPageChange/feature.d.ts +8 -0
  16. package/features/CancelScheduledActionOnPageChange/feature.js +22 -0
  17. package/features/CancelScheduledActionOnPageChange/feature.js.map +1 -0
  18. package/features/CancelScheduledPageAction/CancelScheduledPageActionUseCase.d.ts +15 -0
  19. package/features/CancelScheduledPageAction/CancelScheduledPageActionUseCase.js +25 -0
  20. package/features/CancelScheduledPageAction/CancelScheduledPageActionUseCase.js.map +1 -0
  21. package/features/CancelScheduledPageAction/abstractions.d.ts +22 -0
  22. package/features/CancelScheduledPageAction/abstractions.js +11 -0
  23. package/features/CancelScheduledPageAction/abstractions.js.map +1 -0
  24. package/features/CancelScheduledPageAction/feature.d.ts +6 -0
  25. package/features/CancelScheduledPageAction/feature.js +16 -0
  26. package/features/CancelScheduledPageAction/feature.js.map +1 -0
  27. package/features/CancelScheduledPageAction/index.d.ts +1 -0
  28. package/features/CancelScheduledPageAction/index.js +3 -0
  29. package/features/CancelScheduledPageAction/index.js.map +1 -0
  30. package/features/SchedulePageAction/SchedulePageActionUseCase.d.ts +25 -0
  31. package/features/SchedulePageAction/SchedulePageActionUseCase.js +74 -0
  32. package/features/SchedulePageAction/SchedulePageActionUseCase.js.map +1 -0
  33. package/features/SchedulePageAction/abstractions.d.ts +42 -0
  34. package/features/SchedulePageAction/abstractions.js +17 -0
  35. package/features/SchedulePageAction/abstractions.js.map +1 -0
  36. package/features/SchedulePageAction/actionHandlers/PublishPageActionHandler.d.ts +22 -0
  37. package/features/SchedulePageAction/actionHandlers/PublishPageActionHandler.js +34 -0
  38. package/features/SchedulePageAction/actionHandlers/PublishPageActionHandler.js.map +1 -0
  39. package/features/SchedulePageAction/actionHandlers/UnpublishPageActionHandler.d.ts +22 -0
  40. package/features/SchedulePageAction/actionHandlers/UnpublishPageActionHandler.js +34 -0
  41. package/features/SchedulePageAction/actionHandlers/UnpublishPageActionHandler.js.map +1 -0
  42. package/features/SchedulePageAction/feature.d.ts +7 -0
  43. package/features/SchedulePageAction/feature.js +21 -0
  44. package/features/SchedulePageAction/feature.js.map +1 -0
  45. package/features/SchedulePageAction/index.d.ts +1 -0
  46. package/features/SchedulePageAction/index.js +3 -0
  47. package/features/SchedulePageAction/index.js.map +1 -0
  48. package/graphql/ActionMapper.d.ts +12 -0
  49. package/graphql/ActionMapper.js +15 -0
  50. package/graphql/ActionMapper.js.map +1 -0
  51. package/graphql/dates.d.ts +6 -0
  52. package/graphql/dates.js +9 -0
  53. package/graphql/dates.js.map +1 -0
  54. package/graphql/index.d.ts +2 -0
  55. package/graphql/index.js +239 -0
  56. package/graphql/index.js.map +1 -0
  57. package/graphql/schema.d.ts +142 -0
  58. package/graphql/schema.js +76 -0
  59. package/graphql/schema.js.map +1 -0
  60. package/index.d.ts +6 -0
  61. package/index.js +12 -0
  62. package/index.js.map +1 -0
  63. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-website-builder-scheduler
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/context.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ export declare const createWebsiteBuilderScheduleContext: () => ContextPlugin<import("@webiny/api/types").Context>;
package/context.js ADDED
@@ -0,0 +1,13 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { SchedulePageActionFeature } from "./features/SchedulePageAction/feature.js";
3
+ import { CancelScheduledPageActionFeature } from "./features/CancelScheduledPageAction/feature.js";
4
+ import { CancelScheduledActionOnPageChangeFeature } from "./features/CancelScheduledActionOnPageChange/feature.js";
5
+ export const createWebsiteBuilderScheduleContext = () => {
6
+ return new ContextPlugin(async context => {
7
+ SchedulePageActionFeature.register(context.container);
8
+ CancelScheduledPageActionFeature.register(context.container);
9
+ CancelScheduledActionOnPageChangeFeature.register(context.container);
10
+ });
11
+ };
12
+
13
+ //# sourceMappingURL=context.js.map
package/context.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ContextPlugin","SchedulePageActionFeature","CancelScheduledPageActionFeature","CancelScheduledActionOnPageChangeFeature","createWebsiteBuilderScheduleContext","context","register","container"],"sources":["context.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { SchedulePageActionFeature } from \"~/features/SchedulePageAction/feature.js\";\nimport { CancelScheduledPageActionFeature } from \"~/features/CancelScheduledPageAction/feature.js\";\nimport { CancelScheduledActionOnPageChangeFeature } from \"~/features/CancelScheduledActionOnPageChange/feature.js\";\n\nexport const createWebsiteBuilderScheduleContext = () => {\n return new ContextPlugin(async context => {\n SchedulePageActionFeature.register(context.container);\n CancelScheduledPageActionFeature.register(context.container);\n CancelScheduledActionOnPageChangeFeature.register(context.container);\n });\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,yBAAyB;AAClC,SAASC,gCAAgC;AACzC,SAASC,wCAAwC;AAEjD,OAAO,MAAMC,mCAAmC,GAAGA,CAAA,KAAM;EACrD,OAAO,IAAIJ,aAAa,CAAC,MAAMK,OAAO,IAAI;IACtCJ,yBAAyB,CAACK,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;IACrDL,gCAAgC,CAACI,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;IAC5DJ,wCAAwC,CAACG,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;EACxE,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ import { PageAfterDeleteEventHandler } from "@webiny/api-website-builder/features/pages/DeletePage/abstractions.js";
2
+ import { ListScheduledActionsUseCase, CancelScheduledActionUseCase } from "@webiny/api-scheduler";
3
+ /**
4
+ * Cancels scheduled actions when a page is deleted.
5
+ *
6
+ * When a user deletes a page, any scheduled publish/unpublish
7
+ * actions for all of its revisions should be canceled since the page
8
+ * no longer exists.
9
+ */
10
+ declare class CancelScheduledActionOnDeleteEventHandlerImpl implements PageAfterDeleteEventHandler.Interface {
11
+ private listScheduledActions;
12
+ private cancelScheduledAction;
13
+ constructor(listScheduledActions: ListScheduledActionsUseCase.Interface, cancelScheduledAction: CancelScheduledActionUseCase.Interface);
14
+ handle(event: PageAfterDeleteEventHandler.Event): Promise<void>;
15
+ private listSchedules;
16
+ }
17
+ export declare const CancelScheduledActionOnDeleteEventHandler: typeof CancelScheduledActionOnDeleteEventHandlerImpl & {
18
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-core/features/EventPublisher").DomainEvent<import("@webiny/api-website-builder/features/pages/DeletePage/abstractions.js").PageAfterDeletePayload>>>;
19
+ };
20
+ export {};
@@ -0,0 +1,48 @@
1
+ import { PageAfterDeleteEventHandler } from "@webiny/api-website-builder/features/pages/DeletePage/abstractions.js";
2
+ import { ListScheduledActionsUseCase, CancelScheduledActionUseCase } from "@webiny/api-scheduler";
3
+
4
+ /**
5
+ * Cancels scheduled actions when a page is deleted.
6
+ *
7
+ * When a user deletes a page, any scheduled publish/unpublish
8
+ * actions for all of its revisions should be canceled since the page
9
+ * no longer exists.
10
+ */
11
+ class CancelScheduledActionOnDeleteEventHandlerImpl {
12
+ constructor(listScheduledActions, cancelScheduledAction) {
13
+ this.listScheduledActions = listScheduledActions;
14
+ this.cancelScheduledAction = cancelScheduledAction;
15
+ }
16
+ async handle(event) {
17
+ const {
18
+ page
19
+ } = event.payload;
20
+ const schedules = await this.listSchedules(page.entryId);
21
+ for (const action of schedules) {
22
+ const cancelRes = await this.cancelScheduledAction.execute(action.id);
23
+ if (cancelRes.isFail()) {
24
+ // Silently ignore errors - this is non-critical cleanup.
25
+ // The page was deleted successfully, cancelling scheduled actions is best-effort.
26
+ }
27
+ }
28
+ }
29
+ async listSchedules(entryId) {
30
+ const actionsResult = await this.listScheduledActions.execute({
31
+ limit: 10000,
32
+ where: {
33
+ namespace: "Wb/Page",
34
+ targetId_startsWith: `${entryId}#`
35
+ }
36
+ });
37
+ if (actionsResult.isFail()) {
38
+ return [];
39
+ }
40
+ return actionsResult.value.items;
41
+ }
42
+ }
43
+ export const CancelScheduledActionOnDeleteEventHandler = PageAfterDeleteEventHandler.createImplementation({
44
+ implementation: CancelScheduledActionOnDeleteEventHandlerImpl,
45
+ dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]
46
+ });
47
+
48
+ //# sourceMappingURL=CancelScheduledActionOnDeleteEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PageAfterDeleteEventHandler","ListScheduledActionsUseCase","CancelScheduledActionUseCase","CancelScheduledActionOnDeleteEventHandlerImpl","constructor","listScheduledActions","cancelScheduledAction","handle","event","page","payload","schedules","listSchedules","entryId","action","cancelRes","execute","id","isFail","actionsResult","limit","where","namespace","targetId_startsWith","value","items","CancelScheduledActionOnDeleteEventHandler","createImplementation","implementation","dependencies"],"sources":["CancelScheduledActionOnDeleteEventHandler.ts"],"sourcesContent":["import { PageAfterDeleteEventHandler } from \"@webiny/api-website-builder/features/pages/DeletePage/abstractions.js\";\nimport { ListScheduledActionsUseCase, CancelScheduledActionUseCase } from \"@webiny/api-scheduler\";\n\n/**\n * Cancels scheduled actions when a page is deleted.\n *\n * When a user deletes a page, any scheduled publish/unpublish\n * actions for all of its revisions should be canceled since the page\n * no longer exists.\n */\nclass CancelScheduledActionOnDeleteEventHandlerImpl\n implements PageAfterDeleteEventHandler.Interface\n{\n constructor(\n private listScheduledActions: ListScheduledActionsUseCase.Interface,\n private cancelScheduledAction: CancelScheduledActionUseCase.Interface\n ) {}\n\n async handle(event: PageAfterDeleteEventHandler.Event): Promise<void> {\n const { page } = event.payload;\n\n const schedules = await this.listSchedules(page.entryId);\n for (const action of schedules) {\n const cancelRes = await this.cancelScheduledAction.execute(action.id);\n if (cancelRes.isFail()) {\n // Silently ignore errors - this is non-critical cleanup.\n // The page was deleted successfully, cancelling scheduled actions is best-effort.\n }\n }\n }\n\n private async listSchedules(entryId: string) {\n const actionsResult = await this.listScheduledActions.execute({\n limit: 10000,\n where: {\n namespace: \"Wb/Page\",\n targetId_startsWith: `${entryId}#`\n }\n });\n\n if (actionsResult.isFail()) {\n return [];\n }\n\n return actionsResult.value.items;\n }\n}\n\nexport const CancelScheduledActionOnDeleteEventHandler =\n PageAfterDeleteEventHandler.createImplementation({\n implementation: CancelScheduledActionOnDeleteEventHandlerImpl,\n dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]\n });\n"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,uEAAuE;AACnH,SAASC,2BAA2B,EAAEC,4BAA4B,QAAQ,uBAAuB;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,6CAA6C,CAEnD;EACIC,WAAWA,CACCC,oBAA2D,EAC3DC,qBAA6D,EACvE;IAAA,KAFUD,oBAA2D,GAA3DA,oBAA2D;IAAA,KAC3DC,qBAA6D,GAA7DA,qBAA6D;EACtE;EAEH,MAAMC,MAAMA,CAACC,KAAwC,EAAiB;IAClE,MAAM;MAAEC;IAAK,CAAC,GAAGD,KAAK,CAACE,OAAO;IAE9B,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,aAAa,CAACH,IAAI,CAACI,OAAO,CAAC;IACxD,KAAK,MAAMC,MAAM,IAAIH,SAAS,EAAE;MAC5B,MAAMI,SAAS,GAAG,MAAM,IAAI,CAACT,qBAAqB,CAACU,OAAO,CAACF,MAAM,CAACG,EAAE,CAAC;MACrE,IAAIF,SAAS,CAACG,MAAM,CAAC,CAAC,EAAE;QACpB;QACA;MAAA;IAER;EACJ;EAEA,MAAcN,aAAaA,CAACC,OAAe,EAAE;IACzC,MAAMM,aAAa,GAAG,MAAM,IAAI,CAACd,oBAAoB,CAACW,OAAO,CAAC;MAC1DI,KAAK,EAAE,KAAK;MACZC,KAAK,EAAE;QACHC,SAAS,EAAE,SAAS;QACpBC,mBAAmB,EAAE,GAAGV,OAAO;MACnC;IACJ,CAAC,CAAC;IAEF,IAAIM,aAAa,CAACD,MAAM,CAAC,CAAC,EAAE;MACxB,OAAO,EAAE;IACb;IAEA,OAAOC,aAAa,CAACK,KAAK,CAACC,KAAK;EACpC;AACJ;AAEA,OAAO,MAAMC,yCAAyC,GAClD1B,2BAA2B,CAAC2B,oBAAoB,CAAC;EAC7CC,cAAc,EAAEzB,6CAA6C;EAC7D0B,YAAY,EAAE,CAAC5B,2BAA2B,EAAEC,4BAA4B;AAC5E,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import { PageAfterPublishEventHandler } from "@webiny/api-website-builder/features/pages/PublishPage/abstractions.js";
2
+ import { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from "@webiny/api-scheduler";
3
+ /**
4
+ * Cancels scheduled "publish" when a page is manually published.
5
+ *
6
+ * When a user manually publishes a page, any scheduled publish
7
+ * action for that page should be canceled since the manual action
8
+ * takes precedence.
9
+ */
10
+ declare class CancelScheduledActionOnPublishEventHandlerImpl implements PageAfterPublishEventHandler.Interface {
11
+ private listScheduledActions;
12
+ private cancelScheduledAction;
13
+ constructor(listScheduledActions: ListScheduledActionsUseCase.Interface, cancelScheduledAction: CancelScheduledActionUseCase.Interface);
14
+ handle(event: PageAfterPublishEventHandler.Event): Promise<void>;
15
+ }
16
+ export declare const CancelScheduledActionOnPublishEventHandler: typeof CancelScheduledActionOnPublishEventHandlerImpl & {
17
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-core/features/EventPublisher").DomainEvent<import("@webiny/api-website-builder/features/pages/PublishPage/abstractions.js").PageAfterPublishPayload>>>;
18
+ };
19
+ export {};
@@ -0,0 +1,45 @@
1
+ import { PageAfterPublishEventHandler } from "@webiny/api-website-builder/features/pages/PublishPage/abstractions.js";
2
+ import { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from "@webiny/api-scheduler";
3
+
4
+ /**
5
+ * Cancels scheduled "publish" when a page is manually published.
6
+ *
7
+ * When a user manually publishes a page, any scheduled publish
8
+ * action for that page should be canceled since the manual action
9
+ * takes precedence.
10
+ */
11
+ class CancelScheduledActionOnPublishEventHandlerImpl {
12
+ constructor(listScheduledActions, cancelScheduledAction) {
13
+ this.listScheduledActions = listScheduledActions;
14
+ this.cancelScheduledAction = cancelScheduledAction;
15
+ }
16
+ async handle(event) {
17
+ const {
18
+ page
19
+ } = event.payload;
20
+ const actionsResult = await this.listScheduledActions.execute({
21
+ where: {
22
+ namespace: "Wb/Page",
23
+ actionType: "Publish",
24
+ targetId: page.id
25
+ }
26
+ });
27
+ if (actionsResult.isFail()) {
28
+ return;
29
+ }
30
+ const actions = actionsResult.value.items;
31
+ for (const action of actions) {
32
+ const cancelRes = await this.cancelScheduledAction.execute(action.id);
33
+ if (cancelRes.isFail()) {
34
+ // Silently ignore errors - this is non-critical cleanup.
35
+ // Even if a schedule runs on an already published page, nothing bad will happen.
36
+ }
37
+ }
38
+ }
39
+ }
40
+ export const CancelScheduledActionOnPublishEventHandler = PageAfterPublishEventHandler.createImplementation({
41
+ implementation: CancelScheduledActionOnPublishEventHandlerImpl,
42
+ dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]
43
+ });
44
+
45
+ //# sourceMappingURL=CancelScheduledActionOnPublishEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PageAfterPublishEventHandler","CancelScheduledActionUseCase","ListScheduledActionsUseCase","CancelScheduledActionOnPublishEventHandlerImpl","constructor","listScheduledActions","cancelScheduledAction","handle","event","page","payload","actionsResult","execute","where","namespace","actionType","targetId","id","isFail","actions","value","items","action","cancelRes","CancelScheduledActionOnPublishEventHandler","createImplementation","implementation","dependencies"],"sources":["CancelScheduledActionOnPublishEventHandler.ts"],"sourcesContent":["import { PageAfterPublishEventHandler } from \"@webiny/api-website-builder/features/pages/PublishPage/abstractions.js\";\nimport { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from \"@webiny/api-scheduler\";\n\n/**\n * Cancels scheduled \"publish\" when a page is manually published.\n *\n * When a user manually publishes a page, any scheduled publish\n * action for that page should be canceled since the manual action\n * takes precedence.\n */\nclass CancelScheduledActionOnPublishEventHandlerImpl\n implements PageAfterPublishEventHandler.Interface\n{\n constructor(\n private listScheduledActions: ListScheduledActionsUseCase.Interface,\n private cancelScheduledAction: CancelScheduledActionUseCase.Interface\n ) {}\n\n async handle(event: PageAfterPublishEventHandler.Event): Promise<void> {\n const { page } = event.payload;\n\n const actionsResult = await this.listScheduledActions.execute({\n where: {\n namespace: \"Wb/Page\",\n actionType: \"Publish\",\n targetId: page.id\n }\n });\n\n if (actionsResult.isFail()) {\n return;\n }\n\n const actions = actionsResult.value.items;\n\n for (const action of actions) {\n const cancelRes = await this.cancelScheduledAction.execute(action.id);\n if (cancelRes.isFail()) {\n // Silently ignore errors - this is non-critical cleanup.\n // Even if a schedule runs on an already published page, nothing bad will happen.\n }\n }\n }\n}\n\nexport const CancelScheduledActionOnPublishEventHandler =\n PageAfterPublishEventHandler.createImplementation({\n implementation: CancelScheduledActionOnPublishEventHandlerImpl,\n dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]\n });\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,wEAAwE;AACrH,SAASC,4BAA4B,EAAEC,2BAA2B,QAAQ,uBAAuB;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,8CAA8C,CAEpD;EACIC,WAAWA,CACCC,oBAA2D,EAC3DC,qBAA6D,EACvE;IAAA,KAFUD,oBAA2D,GAA3DA,oBAA2D;IAAA,KAC3DC,qBAA6D,GAA7DA,qBAA6D;EACtE;EAEH,MAAMC,MAAMA,CAACC,KAAyC,EAAiB;IACnE,MAAM;MAAEC;IAAK,CAAC,GAAGD,KAAK,CAACE,OAAO;IAE9B,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACN,oBAAoB,CAACO,OAAO,CAAC;MAC1DC,KAAK,EAAE;QACHC,SAAS,EAAE,SAAS;QACpBC,UAAU,EAAE,SAAS;QACrBC,QAAQ,EAAEP,IAAI,CAACQ;MACnB;IACJ,CAAC,CAAC;IAEF,IAAIN,aAAa,CAACO,MAAM,CAAC,CAAC,EAAE;MACxB;IACJ;IAEA,MAAMC,OAAO,GAAGR,aAAa,CAACS,KAAK,CAACC,KAAK;IAEzC,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;MAC1B,MAAMI,SAAS,GAAG,MAAM,IAAI,CAACjB,qBAAqB,CAACM,OAAO,CAACU,MAAM,CAACL,EAAE,CAAC;MACrE,IAAIM,SAAS,CAACL,MAAM,CAAC,CAAC,EAAE;QACpB;QACA;MAAA;IAER;EACJ;AACJ;AAEA,OAAO,MAAMM,0CAA0C,GACnDxB,4BAA4B,CAACyB,oBAAoB,CAAC;EAC9CC,cAAc,EAAEvB,8CAA8C;EAC9DwB,YAAY,EAAE,CAACzB,2BAA2B,EAAED,4BAA4B;AAC5E,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import { PageAfterUnpublishEventHandler } from "@webiny/api-website-builder/features/pages/UnpublishPage/abstractions.js";
2
+ import { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from "@webiny/api-scheduler";
3
+ /**
4
+ * Cancels scheduled action when a page is manually unpublished.
5
+ *
6
+ * When a user manually unpublishes a page revision, any scheduled unpublish
7
+ * action for that revision should be canceled since the manual action
8
+ * takes precedence.
9
+ */
10
+ declare class CancelScheduledActionOnUnpublishEventHandlerImpl implements PageAfterUnpublishEventHandler.Interface {
11
+ private listScheduledActions;
12
+ private cancelScheduledAction;
13
+ constructor(listScheduledActions: ListScheduledActionsUseCase.Interface, cancelScheduledAction: CancelScheduledActionUseCase.Interface);
14
+ handle(event: PageAfterUnpublishEventHandler.Event): Promise<void>;
15
+ }
16
+ export declare const CancelScheduledActionOnUnpublishEventHandler: typeof CancelScheduledActionOnUnpublishEventHandlerImpl & {
17
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-core/features/EventPublisher").DomainEvent<import("@webiny/api-website-builder/features/pages/UnpublishPage/abstractions.js").PageAfterUnpublishPayload>>>;
18
+ };
19
+ export {};
@@ -0,0 +1,45 @@
1
+ import { PageAfterUnpublishEventHandler } from "@webiny/api-website-builder/features/pages/UnpublishPage/abstractions.js";
2
+ import { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from "@webiny/api-scheduler";
3
+
4
+ /**
5
+ * Cancels scheduled action when a page is manually unpublished.
6
+ *
7
+ * When a user manually unpublishes a page revision, any scheduled unpublish
8
+ * action for that revision should be canceled since the manual action
9
+ * takes precedence.
10
+ */
11
+ class CancelScheduledActionOnUnpublishEventHandlerImpl {
12
+ constructor(listScheduledActions, cancelScheduledAction) {
13
+ this.listScheduledActions = listScheduledActions;
14
+ this.cancelScheduledAction = cancelScheduledAction;
15
+ }
16
+ async handle(event) {
17
+ const {
18
+ page
19
+ } = event.payload;
20
+ const actionsResult = await this.listScheduledActions.execute({
21
+ where: {
22
+ namespace: "Wb/Page",
23
+ actionType: "Unpublish",
24
+ targetId: page.id
25
+ }
26
+ });
27
+ if (actionsResult.isFail()) {
28
+ return;
29
+ }
30
+ const actions = actionsResult.value.items;
31
+ for (const action of actions) {
32
+ const cancelRes = await this.cancelScheduledAction.execute(action.id);
33
+ if (cancelRes.isFail()) {
34
+ // Silently ignore errors - this is non-critical cleanup.
35
+ // Page was unpublished successfully, cancelling scheduled actions is best-effort.
36
+ }
37
+ }
38
+ }
39
+ }
40
+ export const CancelScheduledActionOnUnpublishEventHandler = PageAfterUnpublishEventHandler.createImplementation({
41
+ implementation: CancelScheduledActionOnUnpublishEventHandlerImpl,
42
+ dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]
43
+ });
44
+
45
+ //# sourceMappingURL=CancelScheduledActionOnUnpublishEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PageAfterUnpublishEventHandler","CancelScheduledActionUseCase","ListScheduledActionsUseCase","CancelScheduledActionOnUnpublishEventHandlerImpl","constructor","listScheduledActions","cancelScheduledAction","handle","event","page","payload","actionsResult","execute","where","namespace","actionType","targetId","id","isFail","actions","value","items","action","cancelRes","CancelScheduledActionOnUnpublishEventHandler","createImplementation","implementation","dependencies"],"sources":["CancelScheduledActionOnUnpublishEventHandler.ts"],"sourcesContent":["import { PageAfterUnpublishEventHandler } from \"@webiny/api-website-builder/features/pages/UnpublishPage/abstractions.js\";\nimport { CancelScheduledActionUseCase, ListScheduledActionsUseCase } from \"@webiny/api-scheduler\";\n\n/**\n * Cancels scheduled action when a page is manually unpublished.\n *\n * When a user manually unpublishes a page revision, any scheduled unpublish\n * action for that revision should be canceled since the manual action\n * takes precedence.\n */\nclass CancelScheduledActionOnUnpublishEventHandlerImpl\n implements PageAfterUnpublishEventHandler.Interface\n{\n constructor(\n private listScheduledActions: ListScheduledActionsUseCase.Interface,\n private cancelScheduledAction: CancelScheduledActionUseCase.Interface\n ) {}\n\n async handle(event: PageAfterUnpublishEventHandler.Event): Promise<void> {\n const { page } = event.payload;\n\n const actionsResult = await this.listScheduledActions.execute({\n where: {\n namespace: \"Wb/Page\",\n actionType: \"Unpublish\",\n targetId: page.id\n }\n });\n\n if (actionsResult.isFail()) {\n return;\n }\n\n const actions = actionsResult.value.items;\n\n for (const action of actions) {\n const cancelRes = await this.cancelScheduledAction.execute(action.id);\n if (cancelRes.isFail()) {\n // Silently ignore errors - this is non-critical cleanup.\n // Page was unpublished successfully, cancelling scheduled actions is best-effort.\n }\n }\n }\n}\n\nexport const CancelScheduledActionOnUnpublishEventHandler =\n PageAfterUnpublishEventHandler.createImplementation({\n implementation: CancelScheduledActionOnUnpublishEventHandlerImpl,\n dependencies: [ListScheduledActionsUseCase, CancelScheduledActionUseCase]\n });\n"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,0EAA0E;AACzH,SAASC,4BAA4B,EAAEC,2BAA2B,QAAQ,uBAAuB;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gDAAgD,CAEtD;EACIC,WAAWA,CACCC,oBAA2D,EAC3DC,qBAA6D,EACvE;IAAA,KAFUD,oBAA2D,GAA3DA,oBAA2D;IAAA,KAC3DC,qBAA6D,GAA7DA,qBAA6D;EACtE;EAEH,MAAMC,MAAMA,CAACC,KAA2C,EAAiB;IACrE,MAAM;MAAEC;IAAK,CAAC,GAAGD,KAAK,CAACE,OAAO;IAE9B,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACN,oBAAoB,CAACO,OAAO,CAAC;MAC1DC,KAAK,EAAE;QACHC,SAAS,EAAE,SAAS;QACpBC,UAAU,EAAE,WAAW;QACvBC,QAAQ,EAAEP,IAAI,CAACQ;MACnB;IACJ,CAAC,CAAC;IAEF,IAAIN,aAAa,CAACO,MAAM,CAAC,CAAC,EAAE;MACxB;IACJ;IAEA,MAAMC,OAAO,GAAGR,aAAa,CAACS,KAAK,CAACC,KAAK;IAEzC,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;MAC1B,MAAMI,SAAS,GAAG,MAAM,IAAI,CAACjB,qBAAqB,CAACM,OAAO,CAACU,MAAM,CAACL,EAAE,CAAC;MACrE,IAAIM,SAAS,CAACL,MAAM,CAAC,CAAC,EAAE;QACpB;QACA;MAAA;IAER;EACJ;AACJ;AAEA,OAAO,MAAMM,4CAA4C,GACrDxB,8BAA8B,CAACyB,oBAAoB,CAAC;EAChDC,cAAc,EAAEvB,gDAAgD;EAChEwB,YAAY,EAAE,CAACzB,2BAA2B,EAAED,4BAA4B;AAC5E,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CancelScheduledActionOnPageChange Feature
3
+ *
4
+ * Automatically cancels scheduled actions when pages are manually
5
+ * published, unpublished, or deleted. This ensures scheduled actions
6
+ * don't execute after a user has already performed the action manually.
7
+ */
8
+ export declare const CancelScheduledActionOnPageChangeFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,22 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CancelScheduledActionOnPublishEventHandler } from "./CancelScheduledActionOnPublishEventHandler.js";
3
+ import { CancelScheduledActionOnUnpublishEventHandler } from "./CancelScheduledActionOnUnpublishEventHandler.js";
4
+ import { CancelScheduledActionOnDeleteEventHandler } from "./CancelScheduledActionOnDeleteEventHandler.js";
5
+
6
+ /**
7
+ * CancelScheduledActionOnPageChange Feature
8
+ *
9
+ * Automatically cancels scheduled actions when pages are manually
10
+ * published, unpublished, or deleted. This ensures scheduled actions
11
+ * don't execute after a user has already performed the action manually.
12
+ */
13
+ export const CancelScheduledActionOnPageChangeFeature = createFeature({
14
+ name: "CancelScheduledActionOnPageChange",
15
+ register(container) {
16
+ container.register(CancelScheduledActionOnPublishEventHandler);
17
+ container.register(CancelScheduledActionOnUnpublishEventHandler);
18
+ container.register(CancelScheduledActionOnDeleteEventHandler);
19
+ }
20
+ });
21
+
22
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","CancelScheduledActionOnPublishEventHandler","CancelScheduledActionOnUnpublishEventHandler","CancelScheduledActionOnDeleteEventHandler","CancelScheduledActionOnPageChangeFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CancelScheduledActionOnPublishEventHandler } from \"./CancelScheduledActionOnPublishEventHandler.js\";\nimport { CancelScheduledActionOnUnpublishEventHandler } from \"./CancelScheduledActionOnUnpublishEventHandler.js\";\nimport { CancelScheduledActionOnDeleteEventHandler } from \"./CancelScheduledActionOnDeleteEventHandler.js\";\n\n/**\n * CancelScheduledActionOnPageChange Feature\n *\n * Automatically cancels scheduled actions when pages are manually\n * published, unpublished, or deleted. This ensures scheduled actions\n * don't execute after a user has already performed the action manually.\n */\nexport const CancelScheduledActionOnPageChangeFeature = createFeature({\n name: \"CancelScheduledActionOnPageChange\",\n register(container) {\n container.register(CancelScheduledActionOnPublishEventHandler);\n container.register(CancelScheduledActionOnUnpublishEventHandler);\n container.register(CancelScheduledActionOnDeleteEventHandler);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,0CAA0C;AACnD,SAASC,4CAA4C;AACrD,SAASC,yCAAyC;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wCAAwC,GAAGJ,aAAa,CAAC;EAClEK,IAAI,EAAE,mCAAmC;EACzCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,0CAA0C,CAAC;IAC9DM,SAAS,CAACD,QAAQ,CAACJ,4CAA4C,CAAC;IAChEK,SAAS,CAACD,QAAQ,CAACH,yCAAyC,CAAC;EACjE;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { CancelScheduledActionUseCase } from "@webiny/api-scheduler/features/CancelScheduledAction";
3
+ import { CancelScheduledPageActionUseCase as UseCaseAbstraction } from "./abstractions.js";
4
+ /**
5
+ * Cancels a scheduled WB page action.
6
+ */
7
+ declare class CancelScheduledPageActionUseCaseImpl implements UseCaseAbstraction.Interface {
8
+ private cancelScheduledAction;
9
+ constructor(cancelScheduledAction: CancelScheduledActionUseCase.Interface);
10
+ execute(scheduleId: string): Promise<Result<void, UseCaseAbstraction.Error>>;
11
+ }
12
+ export declare const CancelScheduledPageActionUseCase: typeof CancelScheduledPageActionUseCaseImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICancelScheduledPageActionUseCase>;
14
+ };
15
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { CancelScheduledActionUseCase } from "@webiny/api-scheduler/features/CancelScheduledAction";
3
+ import { CancelScheduledPageActionUseCase as UseCaseAbstraction } from "./abstractions.js";
4
+
5
+ /**
6
+ * Cancels a scheduled WB page action.
7
+ */
8
+ class CancelScheduledPageActionUseCaseImpl {
9
+ constructor(cancelScheduledAction) {
10
+ this.cancelScheduledAction = cancelScheduledAction;
11
+ }
12
+ async execute(scheduleId) {
13
+ const cancelRes = await this.cancelScheduledAction.execute(scheduleId);
14
+ if (cancelRes.isFail()) {
15
+ return Result.fail(cancelRes.error);
16
+ }
17
+ return Result.ok();
18
+ }
19
+ }
20
+ export const CancelScheduledPageActionUseCase = UseCaseAbstraction.createImplementation({
21
+ implementation: CancelScheduledPageActionUseCaseImpl,
22
+ dependencies: [CancelScheduledActionUseCase]
23
+ });
24
+
25
+ //# sourceMappingURL=CancelScheduledPageActionUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","CancelScheduledActionUseCase","CancelScheduledPageActionUseCase","UseCaseAbstraction","CancelScheduledPageActionUseCaseImpl","constructor","cancelScheduledAction","execute","scheduleId","cancelRes","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["CancelScheduledPageActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CancelScheduledActionUseCase } from \"@webiny/api-scheduler/features/CancelScheduledAction\";\nimport { CancelScheduledPageActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\n/**\n * Cancels a scheduled WB page action.\n */\nclass CancelScheduledPageActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private cancelScheduledAction: CancelScheduledActionUseCase.Interface) {}\n\n async execute(scheduleId: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n const cancelRes = await this.cancelScheduledAction.execute(scheduleId);\n if (cancelRes.isFail()) {\n return Result.fail(cancelRes.error);\n }\n return Result.ok();\n }\n}\n\nexport const CancelScheduledPageActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: CancelScheduledPageActionUseCaseImpl,\n dependencies: [CancelScheduledActionUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,QAAQ,sDAAsD;AACnG,SAASC,gCAAgC,IAAIC,kBAAkB;;AAE/D;AACA;AACA;AACA,MAAMC,oCAAoC,CAAyC;EAC/EC,WAAWA,CAASC,qBAA6D,EAAE;IAAA,KAA/DA,qBAA6D,GAA7DA,qBAA6D;EAAG;EAEpF,MAAMC,OAAOA,CAACC,UAAkB,EAAmD;IAC/E,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACH,qBAAqB,CAACC,OAAO,CAACC,UAAU,CAAC;IACtE,IAAIC,SAAS,CAACC,MAAM,CAAC,CAAC,EAAE;MACpB,OAAOV,MAAM,CAACW,IAAI,CAACF,SAAS,CAACG,KAAK,CAAC;IACvC;IACA,OAAOZ,MAAM,CAACa,EAAE,CAAC,CAAC;EACtB;AACJ;AAEA,OAAO,MAAMX,gCAAgC,GAAGC,kBAAkB,CAACW,oBAAoB,CAAC;EACpFC,cAAc,EAAEX,oCAAoC;EACpDY,YAAY,EAAE,CAACf,4BAA4B;AAC/C,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, SchedulerServiceError } from "@webiny/api-scheduler/domain/errors.js";
3
+ /**
4
+ * CancelScheduledPageActionUseCase - Cancel a scheduled WB page action.
5
+ *
6
+ * This is a convenience use case for canceling scheduled WB page actions.
7
+ */
8
+ export interface ICancelScheduledPageActionErrors {
9
+ notFound: ScheduledActionNotFoundError;
10
+ persistence: ScheduledActionPersistenceError;
11
+ schedulerService: SchedulerServiceError;
12
+ }
13
+ type CancelScheduledPageActionError = ICancelScheduledPageActionErrors[keyof ICancelScheduledPageActionErrors];
14
+ export interface ICancelScheduledPageActionUseCase {
15
+ execute(scheduleId: string): Promise<Result<void, CancelScheduledPageActionError>>;
16
+ }
17
+ export declare const CancelScheduledPageActionUseCase: import("@webiny/di").Abstraction<ICancelScheduledPageActionUseCase>;
18
+ export declare namespace CancelScheduledPageActionUseCase {
19
+ type Interface = ICancelScheduledPageActionUseCase;
20
+ type Error = CancelScheduledPageActionError;
21
+ }
22
+ export {};
@@ -0,0 +1,11 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+
3
+ /**
4
+ * CancelScheduledPageActionUseCase - Cancel a scheduled WB page action.
5
+ *
6
+ * This is a convenience use case for canceling scheduled WB page actions.
7
+ */
8
+
9
+ export const CancelScheduledPageActionUseCase = createAbstraction("CancelScheduledPageActionUseCase");
10
+
11
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","CancelScheduledPageActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport {\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n SchedulerServiceError\n} from \"@webiny/api-scheduler/domain/errors.js\";\n\n/**\n * CancelScheduledPageActionUseCase - Cancel a scheduled WB page action.\n *\n * This is a convenience use case for canceling scheduled WB page actions.\n */\n\nexport interface ICancelScheduledPageActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n schedulerService: SchedulerServiceError;\n}\n\ntype CancelScheduledPageActionError =\n ICancelScheduledPageActionErrors[keyof ICancelScheduledPageActionErrors];\n\nexport interface ICancelScheduledPageActionUseCase {\n execute(scheduleId: string): Promise<Result<void, CancelScheduledPageActionError>>;\n}\n\nexport const CancelScheduledPageActionUseCase =\n createAbstraction<ICancelScheduledPageActionUseCase>(\"CancelScheduledPageActionUseCase\");\n\nexport namespace CancelScheduledPageActionUseCase {\n export type Interface = ICancelScheduledPageActionUseCase;\n export type Error = CancelScheduledPageActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAQvD;AACA;AACA;AACA;AACA;;AAeA,OAAO,MAAMC,gCAAgC,GACzCD,iBAAiB,CAAoC,kCAAkC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * CancelScheduledPageAction Feature
3
+ *
4
+ * Provides the ability to cancel scheduled WB page actions (publish/unpublish).
5
+ */
6
+ export declare const CancelScheduledPageActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,16 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CancelScheduledPageActionUseCase } from "./CancelScheduledPageActionUseCase.js";
3
+
4
+ /**
5
+ * CancelScheduledPageAction Feature
6
+ *
7
+ * Provides the ability to cancel scheduled WB page actions (publish/unpublish).
8
+ */
9
+ export const CancelScheduledPageActionFeature = createFeature({
10
+ name: "CancelScheduledPageAction",
11
+ register(container) {
12
+ container.register(CancelScheduledPageActionUseCase);
13
+ }
14
+ });
15
+
16
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","CancelScheduledPageActionUseCase","CancelScheduledPageActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CancelScheduledPageActionUseCase } from \"./CancelScheduledPageActionUseCase.js\";\n\n/**\n * CancelScheduledPageAction Feature\n *\n * Provides the ability to cancel scheduled WB page actions (publish/unpublish).\n */\nexport const CancelScheduledPageActionFeature = createFeature({\n name: \"CancelScheduledPageAction\",\n register(container) {\n container.register(CancelScheduledPageActionUseCase);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gCAAgC;;AAEzC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAAGF,aAAa,CAAC;EAC1DG,IAAI,EAAE,2BAA2B;EACjCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,gCAAgC,CAAC;EACxD;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export * from "./abstractions.js";
@@ -0,0 +1,3 @@
1
+ export * from "./abstractions.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { type ISchedulePageActionPayload, SchedulePageActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
+ import type { IScheduledAction } from "@webiny/api-scheduler";
4
+ import { ScheduleActionUseCase } from "@webiny/api-scheduler";
5
+ import { RunActionUseCase } from "@webiny/api-scheduler";
6
+ import { GetPageByIdUseCase } from "@webiny/api-website-builder/features/pages/GetPageById/abstractions.js";
7
+ /**
8
+ * Schedules a WB page action (publish or unpublish).
9
+ *
10
+ * Flow:
11
+ * 1. If immediately=true, use RunAction for immediate execution (no title needed).
12
+ * 2. Otherwise, validate scheduleFor, fetch page to get title metadata.
13
+ * 3. Use ScheduleAction with page title for display in the scheduler UI.
14
+ */
15
+ declare class SchedulePageActionUseCaseImpl implements UseCaseAbstraction.Interface {
16
+ private scheduleActionUseCase;
17
+ private runActionUseCase;
18
+ private getPageByIdUseCase;
19
+ constructor(scheduleActionUseCase: ScheduleActionUseCase.Interface, runActionUseCase: RunActionUseCase.Interface, getPageByIdUseCase: GetPageByIdUseCase.Interface);
20
+ execute(input: UseCaseAbstraction.Input): Promise<Result<IScheduledAction<ISchedulePageActionPayload>, UseCaseAbstraction.Error>>;
21
+ }
22
+ export declare const SchedulePageActionUseCase: typeof SchedulePageActionUseCaseImpl & {
23
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISchedulePageActionUseCase>;
24
+ };
25
+ export {};
@@ -0,0 +1,74 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { SchedulePageActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
+ import { ScheduleActionUseCase } from "@webiny/api-scheduler";
4
+ import { RunActionUseCase } from "@webiny/api-scheduler";
5
+ import { GetPageByIdUseCase } from "@webiny/api-website-builder/features/pages/GetPageById/abstractions.js";
6
+ const WB_PAGE_NAMESPACE = "Wb/Page";
7
+
8
+ /**
9
+ * Schedules a WB page action (publish or unpublish).
10
+ *
11
+ * Flow:
12
+ * 1. If immediately=true, use RunAction for immediate execution (no title needed).
13
+ * 2. Otherwise, validate scheduleFor, fetch page to get title metadata.
14
+ * 3. Use ScheduleAction with page title for display in the scheduler UI.
15
+ */
16
+ class SchedulePageActionUseCaseImpl {
17
+ constructor(scheduleActionUseCase, runActionUseCase, getPageByIdUseCase) {
18
+ this.scheduleActionUseCase = scheduleActionUseCase;
19
+ this.runActionUseCase = runActionUseCase;
20
+ this.getPageByIdUseCase = getPageByIdUseCase;
21
+ }
22
+ async execute(input) {
23
+ const payload = {
24
+ _type: "Wb/Page"
25
+ };
26
+
27
+ // Handle immediate execution β€” RunAction executes now, no title needed.
28
+ if (input.immediately) {
29
+ const result = await this.runActionUseCase.execute({
30
+ namespace: WB_PAGE_NAMESPACE,
31
+ actionType: input.actionType,
32
+ targetId: input.targetId,
33
+ payload
34
+ });
35
+ if (result.isFail()) {
36
+ return Result.fail(result.error);
37
+ }
38
+ return Result.ok(result.value);
39
+ }
40
+
41
+ // Validate scheduleFor is provided for future scheduling.
42
+ if (!input.scheduleFor) {
43
+ throw new Error("scheduleFor is required when immediately is not true");
44
+ }
45
+
46
+ // Fetch page to get title for display in the scheduler UI.
47
+ const pageResult = await this.getPageByIdUseCase.execute(input.targetId);
48
+ if (pageResult.isFail()) {
49
+ return Result.fail(pageResult.error);
50
+ }
51
+ const page = pageResult.value;
52
+ const title = page.properties?.title || "Unknown page title";
53
+
54
+ // Schedule with title metadata.
55
+ const scheduleResult = await this.scheduleActionUseCase.execute({
56
+ namespace: WB_PAGE_NAMESPACE,
57
+ actionType: input.actionType,
58
+ targetId: input.targetId,
59
+ title,
60
+ scheduleFor: input.scheduleFor,
61
+ payload
62
+ });
63
+ if (scheduleResult.isFail()) {
64
+ return Result.fail(scheduleResult.error);
65
+ }
66
+ return Result.ok(scheduleResult.value);
67
+ }
68
+ }
69
+ export const SchedulePageActionUseCase = UseCaseAbstraction.createImplementation({
70
+ implementation: SchedulePageActionUseCaseImpl,
71
+ dependencies: [ScheduleActionUseCase, RunActionUseCase, GetPageByIdUseCase]
72
+ });
73
+
74
+ //# sourceMappingURL=SchedulePageActionUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","SchedulePageActionUseCase","UseCaseAbstraction","ScheduleActionUseCase","RunActionUseCase","GetPageByIdUseCase","WB_PAGE_NAMESPACE","SchedulePageActionUseCaseImpl","constructor","scheduleActionUseCase","runActionUseCase","getPageByIdUseCase","execute","input","payload","_type","immediately","result","namespace","actionType","targetId","isFail","fail","error","ok","value","scheduleFor","Error","pageResult","page","title","properties","scheduleResult","createImplementation","implementation","dependencies"],"sources":["SchedulePageActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type ISchedulePageActionPayload,\n SchedulePageActionUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport type { IScheduledAction } from \"@webiny/api-scheduler\";\nimport { ScheduleActionUseCase } from \"@webiny/api-scheduler\";\nimport { RunActionUseCase } from \"@webiny/api-scheduler\";\nimport { GetPageByIdUseCase } from \"@webiny/api-website-builder/features/pages/GetPageById/abstractions.js\";\n\nconst WB_PAGE_NAMESPACE = \"Wb/Page\";\n\n/**\n * Schedules a WB page action (publish or unpublish).\n *\n * Flow:\n * 1. If immediately=true, use RunAction for immediate execution (no title needed).\n * 2. Otherwise, validate scheduleFor, fetch page to get title metadata.\n * 3. Use ScheduleAction with page title for display in the scheduler UI.\n */\nclass SchedulePageActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private scheduleActionUseCase: ScheduleActionUseCase.Interface,\n private runActionUseCase: RunActionUseCase.Interface,\n private getPageByIdUseCase: GetPageByIdUseCase.Interface\n ) {}\n\n async execute(\n input: UseCaseAbstraction.Input\n ): Promise<Result<IScheduledAction<ISchedulePageActionPayload>, UseCaseAbstraction.Error>> {\n const payload: ISchedulePageActionPayload = { _type: \"Wb/Page\" };\n\n // Handle immediate execution β€” RunAction executes now, no title needed.\n if (input.immediately) {\n const result = await this.runActionUseCase.execute<ISchedulePageActionPayload>({\n namespace: WB_PAGE_NAMESPACE,\n actionType: input.actionType,\n targetId: input.targetId,\n payload\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n\n // Validate scheduleFor is provided for future scheduling.\n if (!input.scheduleFor) {\n throw new Error(\"scheduleFor is required when immediately is not true\");\n }\n\n // Fetch page to get title for display in the scheduler UI.\n const pageResult = await this.getPageByIdUseCase.execute(input.targetId);\n if (pageResult.isFail()) {\n return Result.fail(pageResult.error);\n }\n\n const page = pageResult.value;\n const title = page.properties?.title || \"Unknown page title\";\n\n // Schedule with title metadata.\n const scheduleResult = await this.scheduleActionUseCase.execute<ISchedulePageActionPayload>(\n {\n namespace: WB_PAGE_NAMESPACE,\n actionType: input.actionType,\n targetId: input.targetId,\n title,\n scheduleFor: input.scheduleFor,\n payload\n }\n );\n\n if (scheduleResult.isFail()) {\n return Result.fail(scheduleResult.error);\n }\n\n return Result.ok(scheduleResult.value);\n }\n}\n\nexport const SchedulePageActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: SchedulePageActionUseCaseImpl,\n dependencies: [ScheduleActionUseCase, RunActionUseCase, GetPageByIdUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAEIC,yBAAyB,IAAIC,kBAAkB;AAGnD,SAASC,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,kBAAkB,QAAQ,wEAAwE;AAE3G,MAAMC,iBAAiB,GAAG,SAAS;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,6BAA6B,CAAyC;EACxEC,WAAWA,CACCC,qBAAsD,EACtDC,gBAA4C,EAC5CC,kBAAgD,EAC1D;IAAA,KAHUF,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,gBAA4C,GAA5CA,gBAA4C;IAAA,KAC5CC,kBAAgD,GAAhDA,kBAAgD;EACzD;EAEH,MAAMC,OAAOA,CACTC,KAA+B,EACwD;IACvF,MAAMC,OAAmC,GAAG;MAAEC,KAAK,EAAE;IAAU,CAAC;;IAEhE;IACA,IAAIF,KAAK,CAACG,WAAW,EAAE;MACnB,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,gBAAgB,CAACE,OAAO,CAA6B;QAC3EM,SAAS,EAAEZ,iBAAiB;QAC5Ba,UAAU,EAAEN,KAAK,CAACM,UAAU;QAC5BC,QAAQ,EAAEP,KAAK,CAACO,QAAQ;QACxBN;MACJ,CAAC,CAAC;MAEF,IAAIG,MAAM,CAACI,MAAM,CAAC,CAAC,EAAE;QACjB,OAAOrB,MAAM,CAACsB,IAAI,CAACL,MAAM,CAACM,KAAK,CAAC;MACpC;MAEA,OAAOvB,MAAM,CAACwB,EAAE,CAACP,MAAM,CAACQ,KAAK,CAAC;IAClC;;IAEA;IACA,IAAI,CAACZ,KAAK,CAACa,WAAW,EAAE;MACpB,MAAM,IAAIC,KAAK,CAAC,sDAAsD,CAAC;IAC3E;;IAEA;IACA,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACjB,kBAAkB,CAACC,OAAO,CAACC,KAAK,CAACO,QAAQ,CAAC;IACxE,IAAIQ,UAAU,CAACP,MAAM,CAAC,CAAC,EAAE;MACrB,OAAOrB,MAAM,CAACsB,IAAI,CAACM,UAAU,CAACL,KAAK,CAAC;IACxC;IAEA,MAAMM,IAAI,GAAGD,UAAU,CAACH,KAAK;IAC7B,MAAMK,KAAK,GAAGD,IAAI,CAACE,UAAU,EAAED,KAAK,IAAI,oBAAoB;;IAE5D;IACA,MAAME,cAAc,GAAG,MAAM,IAAI,CAACvB,qBAAqB,CAACG,OAAO,CAC3D;MACIM,SAAS,EAAEZ,iBAAiB;MAC5Ba,UAAU,EAAEN,KAAK,CAACM,UAAU;MAC5BC,QAAQ,EAAEP,KAAK,CAACO,QAAQ;MACxBU,KAAK;MACLJ,WAAW,EAAEb,KAAK,CAACa,WAAW;MAC9BZ;IACJ,CACJ,CAAC;IAED,IAAIkB,cAAc,CAACX,MAAM,CAAC,CAAC,EAAE;MACzB,OAAOrB,MAAM,CAACsB,IAAI,CAACU,cAAc,CAACT,KAAK,CAAC;IAC5C;IAEA,OAAOvB,MAAM,CAACwB,EAAE,CAACQ,cAAc,CAACP,KAAK,CAAC;EAC1C;AACJ;AAEA,OAAO,MAAMxB,yBAAyB,GAAGC,kBAAkB,CAAC+B,oBAAoB,CAAC;EAC7EC,cAAc,EAAE3B,6BAA6B;EAC7C4B,YAAY,EAAE,CAAChC,qBAAqB,EAAEC,gBAAgB,EAAEC,kBAAkB;AAC9E,CAAC,CAAC","ignoreList":[]}