@webiny/api-headless-cms-scheduler 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (89) hide show
  1. package/context.js +14 -9
  2. package/context.js.map +1 -1
  3. package/exports/api/cms/scheduler.d.ts +2 -0
  4. package/exports/api/cms/scheduler.js +2 -0
  5. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.d.ts +4 -4
  6. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js +32 -43
  7. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js.map +1 -1
  8. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.d.ts +4 -4
  9. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js +27 -40
  10. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js.map +1 -1
  11. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.d.ts +4 -4
  12. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js +26 -39
  13. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js.map +1 -1
  14. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.d.ts +4 -4
  15. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js +27 -40
  16. package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js.map +1 -1
  17. package/features/CancelScheduledActionOnEntryChange/feature.d.ts +4 -1
  18. package/features/CancelScheduledActionOnEntryChange/feature.js +9 -16
  19. package/features/CancelScheduledActionOnEntryChange/feature.js.map +1 -1
  20. package/features/NamespaceHandler/NamespaceHandler.d.ts +15 -0
  21. package/features/NamespaceHandler/NamespaceHandler.js +44 -0
  22. package/features/NamespaceHandler/NamespaceHandler.js.map +1 -0
  23. package/features/{ScheduleEntryAction/actionHandlers → PublishActionHandler}/PublishEntryActionHandler.d.ts +4 -4
  24. package/features/PublishActionHandler/PublishEntryActionHandler.js +92 -0
  25. package/features/PublishActionHandler/PublishEntryActionHandler.js.map +1 -0
  26. package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.d.ts +15 -0
  27. package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js +46 -0
  28. package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js.map +1 -0
  29. package/features/SchedulePublishEntryUseCase/abstractions.d.ts +23 -0
  30. package/features/SchedulePublishEntryUseCase/abstractions.js +5 -0
  31. package/features/SchedulePublishEntryUseCase/abstractions.js.map +1 -0
  32. package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.d.ts +15 -0
  33. package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.js +46 -0
  34. package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.js.map +1 -0
  35. package/features/ScheduleUnpublishEntryUseCase/abstractions.d.ts +23 -0
  36. package/features/ScheduleUnpublishEntryUseCase/abstractions.js +5 -0
  37. package/features/ScheduleUnpublishEntryUseCase/abstractions.js.map +1 -0
  38. package/features/{ScheduleEntryAction/actionHandlers → UnpublishActionHandler}/UnpublishEntryActionHandler.d.ts +6 -5
  39. package/features/UnpublishActionHandler/UnpublishEntryActionHandler.js +69 -0
  40. package/features/UnpublishActionHandler/UnpublishEntryActionHandler.js.map +1 -0
  41. package/index.d.ts +2 -6
  42. package/index.js +4 -9
  43. package/index.js.map +1 -1
  44. package/package.json +24 -22
  45. package/types.d.ts +4 -0
  46. package/types.js +0 -0
  47. package/utils/namespace.d.ts +4 -0
  48. package/utils/namespace.js +9 -0
  49. package/utils/namespace.js.map +1 -0
  50. package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.d.ts +0 -15
  51. package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js +0 -25
  52. package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js.map +0 -1
  53. package/features/CancelScheduledEntryAction/abstractions.d.ts +0 -22
  54. package/features/CancelScheduledEntryAction/abstractions.js +0 -11
  55. package/features/CancelScheduledEntryAction/abstractions.js.map +0 -1
  56. package/features/CancelScheduledEntryAction/feature.d.ts +0 -6
  57. package/features/CancelScheduledEntryAction/feature.js +0 -16
  58. package/features/CancelScheduledEntryAction/feature.js.map +0 -1
  59. package/features/CancelScheduledEntryAction/index.d.ts +0 -1
  60. package/features/CancelScheduledEntryAction/index.js +0 -3
  61. package/features/CancelScheduledEntryAction/index.js.map +0 -1
  62. package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.d.ts +0 -27
  63. package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js +0 -83
  64. package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js.map +0 -1
  65. package/features/ScheduleEntryAction/abstractions.d.ts +0 -45
  66. package/features/ScheduleEntryAction/abstractions.js +0 -15
  67. package/features/ScheduleEntryAction/abstractions.js.map +0 -1
  68. package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.js +0 -109
  69. package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.js.map +0 -1
  70. package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.js +0 -92
  71. package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.js.map +0 -1
  72. package/features/ScheduleEntryAction/feature.d.ts +0 -7
  73. package/features/ScheduleEntryAction/feature.js +0 -21
  74. package/features/ScheduleEntryAction/feature.js.map +0 -1
  75. package/features/ScheduleEntryAction/index.d.ts +0 -1
  76. package/features/ScheduleEntryAction/index.js +0 -3
  77. package/features/ScheduleEntryAction/index.js.map +0 -1
  78. package/graphql/ActionMapper.d.ts +0 -15
  79. package/graphql/ActionMapper.js +0 -18
  80. package/graphql/ActionMapper.js.map +0 -1
  81. package/graphql/dates.d.ts +0 -6
  82. package/graphql/dates.js +0 -9
  83. package/graphql/dates.js.map +0 -1
  84. package/graphql/index.d.ts +0 -3
  85. package/graphql/index.js +0 -246
  86. package/graphql/index.js.map +0 -1
  87. package/graphql/schema.d.ts +0 -162
  88. package/graphql/schema.js +0 -83
  89. package/graphql/schema.js.map +0 -1
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-scheduler",
3
- "version": "0.0.0-unstable.6f45466a1d",
3
+ "version": "0.0.0-unstable.7be00a75a9",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "description": "Schedule for Webiny Headless CMS",
7
10
  "keywords": [
8
11
  "api-headless-cms-scheduler:base"
@@ -14,30 +17,29 @@
14
17
  },
15
18
  "license": "MIT",
16
19
  "dependencies": {
17
- "@webiny/api": "0.0.0-unstable.6f45466a1d",
18
- "@webiny/api-headless-cms": "0.0.0-unstable.6f45466a1d",
19
- "@webiny/api-scheduler": "0.0.0-unstable.6f45466a1d",
20
- "@webiny/feature": "0.0.0-unstable.6f45466a1d",
21
- "@webiny/handler-graphql": "0.0.0-unstable.6f45466a1d",
22
- "@webiny/utils": "0.0.0-unstable.6f45466a1d",
23
- "zod": "3.25.76"
20
+ "@webiny/api": "0.0.0-unstable.7be00a75a9",
21
+ "@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
22
+ "@webiny/api-scheduler": "0.0.0-unstable.7be00a75a9",
23
+ "@webiny/feature": "0.0.0-unstable.7be00a75a9",
24
+ "@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9"
24
25
  },
25
26
  "devDependencies": {
26
- "@webiny/api-core": "0.0.0-unstable.6f45466a1d",
27
- "@webiny/aws-sdk": "0.0.0-unstable.6f45466a1d",
28
- "@webiny/build-tools": "0.0.0-unstable.6f45466a1d",
29
- "@webiny/handler": "0.0.0-unstable.6f45466a1d",
30
- "@webiny/handler-aws": "0.0.0-unstable.6f45466a1d",
31
- "@webiny/plugins": "0.0.0-unstable.6f45466a1d",
32
- "@webiny/project-utils": "0.0.0-unstable.6f45466a1d",
33
- "@webiny/wcp": "0.0.0-unstable.6f45466a1d",
27
+ "@webiny/api-core": "0.0.0-unstable.7be00a75a9",
28
+ "@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
29
+ "@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
30
+ "@webiny/handler": "0.0.0-unstable.7be00a75a9",
31
+ "@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
32
+ "@webiny/plugins": "0.0.0-unstable.7be00a75a9",
33
+ "@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
34
+ "@webiny/wcp": "0.0.0-unstable.7be00a75a9",
34
35
  "aws-sdk-client-mock": "4.1.0",
35
- "typescript": "5.9.3",
36
- "vitest": "3.2.4"
36
+ "typescript": "6.0.3",
37
+ "vitest": "4.1.7"
37
38
  },
38
39
  "publishConfig": {
39
- "access": "public",
40
- "directory": "dist"
40
+ "access": "public"
41
41
  },
42
- "gitHead": "6f45466a1d9fb94f6156923501eb90ac303b81a5"
42
+ "webiny": {
43
+ "publishFrom": "dist"
44
+ }
43
45
  }
package/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { INamespaceHandlerResult } from "@webiny/api-scheduler/features/NamespaceHandler/abstractions.js";
2
+ export interface IScheduledActionPayload extends INamespaceHandlerResult {
3
+ modelId: string;
4
+ }
package/types.js ADDED
File without changes
@@ -0,0 +1,4 @@
1
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ export declare const CMS_NAMESPACE = "Cms/Entry/";
3
+ export declare const createNamespace: (model: Pick<CmsModel, "modelId">) => string;
4
+ export declare const extractModelIdFromNamespace: (namespace: string) => string | null;
@@ -0,0 +1,9 @@
1
+ const CMS_NAMESPACE = "Cms/Entry/";
2
+ const createNamespace = (model)=>`${CMS_NAMESPACE}${model.modelId}`;
3
+ const extractModelIdFromNamespace = (namespace)=>{
4
+ if (!namespace.startsWith(CMS_NAMESPACE)) return null;
5
+ return namespace.substring(CMS_NAMESPACE.length) || null;
6
+ };
7
+ export { CMS_NAMESPACE, createNamespace, extractModelIdFromNamespace };
8
+
9
+ //# sourceMappingURL=namespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/namespace.js","sources":["../../src/utils/namespace.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport const CMS_NAMESPACE = \"Cms/Entry/\";\n\nexport const createNamespace = (model: Pick<CmsModel, \"modelId\">) => {\n return `${CMS_NAMESPACE}${model.modelId}`;\n};\n\nexport const extractModelIdFromNamespace = (namespace: string): string | null => {\n if (!namespace.startsWith(CMS_NAMESPACE)) {\n return null;\n }\n return namespace.substring(CMS_NAMESPACE.length) || null;\n};\n"],"names":["CMS_NAMESPACE","createNamespace","model","extractModelIdFromNamespace","namespace"],"mappings":"AAEO,MAAMA,gBAAgB;AAEtB,MAAMC,kBAAkB,CAACC,QACrB,GAAGF,gBAAgBE,MAAM,OAAO,EAAE;AAGtC,MAAMC,8BAA8B,CAACC;IACxC,IAAI,CAACA,UAAU,UAAU,CAACJ,gBACtB,OAAO;IAEX,OAAOI,UAAU,SAAS,CAACJ,cAAc,MAAM,KAAK;AACxD"}
@@ -1,15 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { CancelScheduledActionUseCase } from "@webiny/api-scheduler/features/CancelScheduledAction";
3
- import { CancelScheduledEntryActionUseCase as UseCaseAbstraction } from "./abstractions.js";
4
- /**
5
- * Cancels a scheduled CMS entry action
6
- */
7
- declare class CancelScheduledEntryActionUseCaseImpl 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 CancelScheduledEntryActionUseCase: typeof CancelScheduledEntryActionUseCaseImpl & {
13
- __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICancelScheduledEntryActionUseCase>;
14
- };
15
- export {};
@@ -1,25 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { CancelScheduledActionUseCase } from "@webiny/api-scheduler/features/CancelScheduledAction";
3
- import { CancelScheduledEntryActionUseCase as UseCaseAbstraction } from "./abstractions.js";
4
-
5
- /**
6
- * Cancels a scheduled CMS entry action
7
- */
8
- class CancelScheduledEntryActionUseCaseImpl {
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 CancelScheduledEntryActionUseCase = UseCaseAbstraction.createImplementation({
21
- implementation: CancelScheduledEntryActionUseCaseImpl,
22
- dependencies: [CancelScheduledActionUseCase]
23
- });
24
-
25
- //# sourceMappingURL=CancelScheduledEntryActionUseCase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Result","CancelScheduledActionUseCase","CancelScheduledEntryActionUseCase","UseCaseAbstraction","CancelScheduledEntryActionUseCaseImpl","constructor","cancelScheduledAction","execute","scheduleId","cancelRes","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["CancelScheduledEntryActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CancelScheduledActionUseCase } from \"@webiny/api-scheduler/features/CancelScheduledAction\";\nimport { CancelScheduledEntryActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\n/**\n * Cancels a scheduled CMS entry action\n */\nclass CancelScheduledEntryActionUseCaseImpl 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 CancelScheduledEntryActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: CancelScheduledEntryActionUseCaseImpl,\n dependencies: [CancelScheduledActionUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,QAAQ,sDAAsD;AACnG,SAASC,iCAAiC,IAAIC,kBAAkB;;AAEhE;AACA;AACA;AACA,MAAMC,qCAAqC,CAAyC;EAChFC,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,iCAAiC,GAAGC,kBAAkB,CAACW,oBAAoB,CAAC;EACrFC,cAAc,EAAEX,qCAAqC;EACrDY,YAAY,EAAE,CAACf,4BAA4B;AAC/C,CAAC,CAAC","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, SchedulerServiceError } from "@webiny/api-scheduler/domain/errors.js";
3
- /**
4
- * CancelScheduledEntryActionUseCase - Cancel a scheduled CMS entry action
5
- *
6
- * This is a convenience use case for canceling scheduled CMS entry actions.
7
- */
8
- export interface ICancelScheduledEntryActionErrors {
9
- notFound: ScheduledActionNotFoundError;
10
- persistence: ScheduledActionPersistenceError;
11
- schedulerService: SchedulerServiceError;
12
- }
13
- type CancelScheduledEntryActionError = ICancelScheduledEntryActionErrors[keyof ICancelScheduledEntryActionErrors];
14
- export interface ICancelScheduledEntryActionUseCase {
15
- execute(scheduleId: string): Promise<Result<void, CancelScheduledEntryActionError>>;
16
- }
17
- export declare const CancelScheduledEntryActionUseCase: import("@webiny/di").Abstraction<ICancelScheduledEntryActionUseCase>;
18
- export declare namespace CancelScheduledEntryActionUseCase {
19
- type Interface = ICancelScheduledEntryActionUseCase;
20
- type Error = CancelScheduledEntryActionError;
21
- }
22
- export {};
@@ -1,11 +0,0 @@
1
- import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * CancelScheduledEntryActionUseCase - Cancel a scheduled CMS entry action
5
- *
6
- * This is a convenience use case for canceling scheduled CMS entry actions.
7
- */
8
-
9
- export const CancelScheduledEntryActionUseCase = createAbstraction("CancelScheduledEntryActionUseCase");
10
-
11
- //# sourceMappingURL=abstractions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createAbstraction","CancelScheduledEntryActionUseCase"],"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 * CancelScheduledEntryActionUseCase - Cancel a scheduled CMS entry action\n *\n * This is a convenience use case for canceling scheduled CMS entry actions.\n */\n\nexport interface ICancelScheduledEntryActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n schedulerService: SchedulerServiceError;\n}\n\ntype CancelScheduledEntryActionError =\n ICancelScheduledEntryActionErrors[keyof ICancelScheduledEntryActionErrors];\n\nexport interface ICancelScheduledEntryActionUseCase {\n execute(scheduleId: string): Promise<Result<void, CancelScheduledEntryActionError>>;\n}\n\nexport const CancelScheduledEntryActionUseCase =\n createAbstraction<ICancelScheduledEntryActionUseCase>(\"CancelScheduledEntryActionUseCase\");\n\nexport namespace CancelScheduledEntryActionUseCase {\n export type Interface = ICancelScheduledEntryActionUseCase;\n export type Error = CancelScheduledEntryActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAQvD;AACA;AACA;AACA;AACA;;AAeA,OAAO,MAAMC,iCAAiC,GAC1CD,iBAAiB,CAAqC,mCAAmC,CAAC","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- /**
2
- * CancelScheduledEntryAction Feature
3
- *
4
- * Provides the ability to cancel scheduled CMS entry actions (publish/unpublish).
5
- */
6
- export declare const CancelScheduledEntryActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -1,16 +0,0 @@
1
- import { createFeature } from "@webiny/feature/api";
2
- import { CancelScheduledEntryActionUseCase } from "./CancelScheduledEntryActionUseCase.js";
3
-
4
- /**
5
- * CancelScheduledEntryAction Feature
6
- *
7
- * Provides the ability to cancel scheduled CMS entry actions (publish/unpublish).
8
- */
9
- export const CancelScheduledEntryActionFeature = createFeature({
10
- name: "CancelScheduledEntryAction",
11
- register(container) {
12
- container.register(CancelScheduledEntryActionUseCase);
13
- }
14
- });
15
-
16
- //# sourceMappingURL=feature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createFeature","CancelScheduledEntryActionUseCase","CancelScheduledEntryActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CancelScheduledEntryActionUseCase } from \"./CancelScheduledEntryActionUseCase.js\";\n\n/**\n * CancelScheduledEntryAction Feature\n *\n * Provides the ability to cancel scheduled CMS entry actions (publish/unpublish).\n */\nexport const CancelScheduledEntryActionFeature = createFeature({\n name: \"CancelScheduledEntryAction\",\n register(container) {\n container.register(CancelScheduledEntryActionUseCase);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,iCAAiC;;AAE1C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,GAAGF,aAAa,CAAC;EAC3DG,IAAI,EAAE,4BAA4B;EAClCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,iCAAiC,CAAC;EACzD;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- export * from "./abstractions.js";
@@ -1,3 +0,0 @@
1
- export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1,27 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { type IScheduleActionPayload, ScheduleEntryActionUseCase 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 { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
7
- import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
8
- /**
9
- * Schedules a CMS entry action (publish or unpublish)
10
- *
11
- * Flow:
12
- * 1. If immediately=true, use RunAction for immediate execution
13
- * 2. Otherwise, fetch entry to get title metadata
14
- * 3. Use ScheduleAction with entry title in payload
15
- */
16
- declare class ScheduleEntryActionUseCaseImpl implements UseCaseAbstraction.Interface {
17
- private scheduleActionUseCase;
18
- private runActionUseCase;
19
- private getModelUseCase;
20
- private getEntryByIdUseCase;
21
- constructor(scheduleActionUseCase: ScheduleActionUseCase.Interface, runActionUseCase: RunActionUseCase.Interface, getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface);
22
- execute(input: UseCaseAbstraction.Input): Promise<Result<IScheduledAction<IScheduleActionPayload>, UseCaseAbstraction.Error>>;
23
- }
24
- export declare const ScheduleEntryActionUseCase: typeof ScheduleEntryActionUseCaseImpl & {
25
- __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IScheduleEntryActionUseCase>;
26
- };
27
- export {};
@@ -1,83 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { ScheduleEntryActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
- import { ScheduleActionUseCase } from "@webiny/api-scheduler";
4
- import { RunActionUseCase } from "@webiny/api-scheduler";
5
- import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
6
- import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
7
- /**
8
- * Schedules a CMS entry action (publish or unpublish)
9
- *
10
- * Flow:
11
- * 1. If immediately=true, use RunAction for immediate execution
12
- * 2. Otherwise, fetch entry to get title metadata
13
- * 3. Use ScheduleAction with entry title in payload
14
- */
15
- class ScheduleEntryActionUseCaseImpl {
16
- constructor(scheduleActionUseCase, runActionUseCase, getModelUseCase, getEntryByIdUseCase) {
17
- this.scheduleActionUseCase = scheduleActionUseCase;
18
- this.runActionUseCase = runActionUseCase;
19
- this.getModelUseCase = getModelUseCase;
20
- this.getEntryByIdUseCase = getEntryByIdUseCase;
21
- }
22
- async execute(input) {
23
- const namespace = `Cms/Entry/${input.modelId}`;
24
-
25
- // Handle immediate execution
26
- if (input.immediately) {
27
- const result = await this.runActionUseCase.execute({
28
- namespace,
29
- actionType: input.actionType,
30
- targetId: input.targetId,
31
- payload: {
32
- modelId: input.modelId
33
- }
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 the target model
47
- const modelResult = await this.getModelUseCase.execute(input.modelId);
48
- if (modelResult.isFail()) {
49
- return Result.fail(modelResult.error);
50
- }
51
- const model = modelResult.value;
52
-
53
- // Fetch entry to get title
54
- const entryResult = await this.getEntryByIdUseCase.execute(model, input.targetId);
55
- if (entryResult.isFail()) {
56
- return Result.fail(entryResult.error);
57
- }
58
- const entry = entryResult.value;
59
- const title = entry.values[model.titleFieldId] || "Unknown entry title";
60
-
61
- // Schedule with title metadata
62
- const scheduleResult = await this.scheduleActionUseCase.execute({
63
- namespace,
64
- actionType: input.actionType,
65
- targetId: input.targetId,
66
- title,
67
- scheduleFor: input.scheduleFor,
68
- payload: {
69
- modelId: input.modelId
70
- }
71
- });
72
- if (scheduleResult.isFail()) {
73
- return Result.fail(scheduleResult.error);
74
- }
75
- return Result.ok(scheduleResult.value);
76
- }
77
- }
78
- export const ScheduleEntryActionUseCase = UseCaseAbstraction.createImplementation({
79
- implementation: ScheduleEntryActionUseCaseImpl,
80
- dependencies: [ScheduleActionUseCase, RunActionUseCase, GetModelUseCase, GetEntryByIdUseCase]
81
- });
82
-
83
- //# sourceMappingURL=ScheduleEntryActionUseCase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Result","ScheduleEntryActionUseCase","UseCaseAbstraction","ScheduleActionUseCase","RunActionUseCase","GetModelUseCase","GetEntryByIdUseCase","ScheduleEntryActionUseCaseImpl","constructor","scheduleActionUseCase","runActionUseCase","getModelUseCase","getEntryByIdUseCase","execute","input","namespace","modelId","immediately","result","actionType","targetId","payload","isFail","fail","error","ok","value","scheduleFor","Error","modelResult","model","entryResult","entry","title","values","titleFieldId","scheduleResult","createImplementation","implementation","dependencies"],"sources":["ScheduleEntryActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type IScheduleActionPayload,\n ScheduleEntryActionUseCase 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 { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport type { ModelNotFoundError } from \"@webiny/api-headless-cms/domain/contentModel/errors.js\";\nimport type { EntryNotFoundError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\n\n/**\n * Schedules a CMS entry action (publish or unpublish)\n *\n * Flow:\n * 1. If immediately=true, use RunAction for immediate execution\n * 2. Otherwise, fetch entry to get title metadata\n * 3. Use ScheduleAction with entry title in payload\n */\nclass ScheduleEntryActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private scheduleActionUseCase: ScheduleActionUseCase.Interface,\n private runActionUseCase: RunActionUseCase.Interface,\n private getModelUseCase: GetModelUseCase.Interface,\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface\n ) {}\n\n async execute(\n input: UseCaseAbstraction.Input\n ): Promise<Result<IScheduledAction<IScheduleActionPayload>, UseCaseAbstraction.Error>> {\n const namespace = `Cms/Entry/${input.modelId}`;\n\n // Handle immediate execution\n if (input.immediately) {\n const result = await this.runActionUseCase.execute<IScheduleActionPayload>({\n namespace,\n actionType: input.actionType,\n targetId: input.targetId,\n payload: {\n modelId: input.modelId\n }\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 the target model\n const modelResult = await this.getModelUseCase.execute(input.modelId);\n if (modelResult.isFail()) {\n return Result.fail(modelResult.error as ModelNotFoundError);\n }\n\n const model = modelResult.value;\n\n // Fetch entry to get title\n const entryResult = await this.getEntryByIdUseCase.execute(model, input.targetId);\n if (entryResult.isFail()) {\n return Result.fail(entryResult.error as EntryNotFoundError);\n }\n\n const entry = entryResult.value;\n const title = entry.values[model.titleFieldId] || \"Unknown entry title\";\n\n // Schedule with title metadata\n const scheduleResult = await this.scheduleActionUseCase.execute<IScheduleActionPayload>({\n namespace,\n actionType: input.actionType,\n targetId: input.targetId,\n title,\n scheduleFor: input.scheduleFor,\n payload: {\n modelId: input.modelId\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 ScheduleEntryActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: ScheduleEntryActionUseCaseImpl,\n dependencies: [ScheduleActionUseCase, RunActionUseCase, GetModelUseCase, GetEntryByIdUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAEIC,0BAA0B,IAAIC,kBAAkB;AAGpD,SAASC,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,mBAAmB,QAAQ,sEAAsE;AAI1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,8BAA8B,CAAyC;EACzEC,WAAWA,CACCC,qBAAsD,EACtDC,gBAA4C,EAC5CC,eAA0C,EAC1CC,mBAAkD,EAC5D;IAAA,KAJUH,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,gBAA4C,GAA5CA,gBAA4C;IAAA,KAC5CC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,mBAAkD,GAAlDA,mBAAkD;EAC3D;EAEH,MAAMC,OAAOA,CACTC,KAA+B,EACoD;IACnF,MAAMC,SAAS,GAAG,aAAaD,KAAK,CAACE,OAAO,EAAE;;IAE9C;IACA,IAAIF,KAAK,CAACG,WAAW,EAAE;MACnB,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,gBAAgB,CAACG,OAAO,CAAyB;QACvEE,SAAS;QACTI,UAAU,EAAEL,KAAK,CAACK,UAAU;QAC5BC,QAAQ,EAAEN,KAAK,CAACM,QAAQ;QACxBC,OAAO,EAA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EAAE;QACLL,OAAO,EAAEF,KAAK,CAACE;MACnB;IACJ,CAAC,CAAC;IAEF,IAAIoB,cAAc,CAACd,MAAM,CAAC,CAAC,EAAE;MACzB,OAAOtB,MAAM,CAACuB,IAAI,CAACa,cAAc,CAACZ,KAAK,CAAC;IAC5C;IAEA,OAAOxB,MAAM,CAACyB,EAAE,CAACW,cAAc,CAACV,KAAK,CAAC;EAC1C;AACJ;AAEA,OAAO,MAAMzB,0BAA0B,GAAGC,kBAAkB,CAACmC,oBAAoB,CAAC;EAC9EC,cAAc,EAAE/B,8BAA8B;EAC9CgC,YAAY,EAAE,CAACpC,qBAAqB,EAAEC,gBAAgB,EAAEC,eAAe,EAAEC,mBAAmB;AAChG,CAAC,CAAC","ignoreList":[]}
@@ -1,45 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import type { IScheduledAction } from "@webiny/api-scheduler";
3
- import { InvalidScheduleDateError, ScheduledActionPersistenceError, SchedulerServiceError } from "@webiny/api-scheduler/domain/errors.js";
4
- import type { ModelNotFoundError } from "@webiny/api-headless-cms/domain/contentModel/errors.js";
5
- import type { EntryNotFoundError } from "@webiny/api-headless-cms/domain/contentEntry/errors.js";
6
- /**
7
- * ScheduleEntryActionUseCase - Schedule a CMS entry action (publish/unpublish)
8
- *
9
- * This is a convenience use case for scheduling CMS entry actions.
10
- * It handles:
11
- * - Immediate execution (via RunAction)
12
- * - Future scheduling (via ScheduleAction)
13
- * - Fetching entry title for schedule metadata
14
- */
15
- export type ScheduleEntryActionType = "Publish" | "Unpublish";
16
- export interface IScheduleActionPayload {
17
- modelId: string;
18
- }
19
- export interface IScheduleActionWithPayload extends IScheduledAction<IScheduleActionPayload> {
20
- }
21
- export interface IScheduleEntryActionInput {
22
- modelId: string;
23
- targetId: string;
24
- actionType: ScheduleEntryActionType;
25
- immediately?: boolean;
26
- scheduleFor?: string;
27
- }
28
- export interface IScheduleEntryActionErrors {
29
- persistence: ScheduledActionPersistenceError;
30
- invalidDate: InvalidScheduleDateError;
31
- schedulerService: SchedulerServiceError;
32
- modelNotFound: ModelNotFoundError;
33
- entryNotFound: EntryNotFoundError;
34
- }
35
- type ScheduleEntryActionError = IScheduleEntryActionErrors[keyof IScheduleEntryActionErrors];
36
- export interface IScheduleEntryActionUseCase {
37
- execute(input: IScheduleEntryActionInput): Promise<Result<IScheduledAction<IScheduleActionPayload>, ScheduleEntryActionError>>;
38
- }
39
- export declare const ScheduleEntryActionUseCase: import("@webiny/di").Abstraction<IScheduleEntryActionUseCase>;
40
- export declare namespace ScheduleEntryActionUseCase {
41
- type Interface = IScheduleEntryActionUseCase;
42
- type Input = IScheduleEntryActionInput;
43
- type Error = ScheduleEntryActionError;
44
- }
45
- export {};
@@ -1,15 +0,0 @@
1
- import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * ScheduleEntryActionUseCase - Schedule a CMS entry action (publish/unpublish)
5
- *
6
- * This is a convenience use case for scheduling CMS entry actions.
7
- * It handles:
8
- * - Immediate execution (via RunAction)
9
- * - Future scheduling (via ScheduleAction)
10
- * - Fetching entry title for schedule metadata
11
- */
12
-
13
- export const ScheduleEntryActionUseCase = createAbstraction("ScheduleEntryActionUseCase");
14
-
15
- //# sourceMappingURL=abstractions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createAbstraction","ScheduleEntryActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"@webiny/api-scheduler\";\nimport {\n InvalidScheduleDateError,\n ScheduledActionPersistenceError,\n SchedulerServiceError\n} from \"@webiny/api-scheduler/domain/errors.js\";\nimport type { ModelNotFoundError } from \"@webiny/api-headless-cms/domain/contentModel/errors.js\";\nimport type { EntryNotFoundError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\n\n/**\n * ScheduleEntryActionUseCase - Schedule a CMS entry action (publish/unpublish)\n *\n * This is a convenience use case for scheduling CMS entry actions.\n * It handles:\n * - Immediate execution (via RunAction)\n * - Future scheduling (via ScheduleAction)\n * - Fetching entry title for schedule metadata\n */\n\nexport type ScheduleEntryActionType = \"Publish\" | \"Unpublish\";\n\nexport interface IScheduleActionPayload {\n modelId: string;\n}\n\nexport interface IScheduleActionWithPayload extends IScheduledAction<IScheduleActionPayload> {}\n\nexport interface IScheduleEntryActionInput {\n modelId: string;\n targetId: string;\n actionType: ScheduleEntryActionType;\n immediately?: boolean;\n scheduleFor?: string;\n}\n\nexport interface IScheduleEntryActionErrors {\n persistence: ScheduledActionPersistenceError;\n invalidDate: InvalidScheduleDateError;\n schedulerService: SchedulerServiceError;\n modelNotFound: ModelNotFoundError;\n entryNotFound: EntryNotFoundError;\n}\n\ntype ScheduleEntryActionError = IScheduleEntryActionErrors[keyof IScheduleEntryActionErrors];\n\nexport interface IScheduleEntryActionUseCase {\n execute(\n input: IScheduleEntryActionInput\n ): Promise<Result<IScheduledAction<IScheduleActionPayload>, ScheduleEntryActionError>>;\n}\n\nexport const ScheduleEntryActionUseCase = createAbstraction<IScheduleEntryActionUseCase>(\n \"ScheduleEntryActionUseCase\"\n);\n\nexport namespace ScheduleEntryActionUseCase {\n export type Interface = IScheduleEntryActionUseCase;\n export type Input = IScheduleEntryActionInput;\n export type Error = ScheduleEntryActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;;AAU/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA,OAAO,MAAMC,0BAA0B,GAAGD,iBAAiB,CACvD,4BACJ,CAAC","ignoreList":[]}
@@ -1,109 +0,0 @@
1
- import { ScheduledActionHandler } from "@webiny/api-scheduler";
2
- import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
3
- import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
4
- import { GetPublishedEntriesByIdsUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds";
5
- import { PublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/PublishEntry";
6
- import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
7
- import { RepublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/RepublishEntry";
8
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
9
-
10
- /**
11
- * Handler for publishing CMS entries
12
- *
13
- * Handles the "Publish" action for CMS entries with namespace pattern: Cms/Entry/{modelId}
14
- *
15
- * Publishing logic:
16
- * 1. If entry is not published -> publish it
17
- * 2. If the same revision is already published -> republish it
18
- * 3. If a different revision is published -> unpublish old, publish new
19
- */
20
- class PublishEntryActionHandlerImpl {
21
- constructor(getModelUseCase, getEntryByIdUseCase, getPublishedEntriesByIdsUseCase, publishEntryUseCase, unpublishEntryUseCase, republishEntryUseCase, identityContext) {
22
- this.getModelUseCase = getModelUseCase;
23
- this.getEntryByIdUseCase = getEntryByIdUseCase;
24
- this.getPublishedEntriesByIdsUseCase = getPublishedEntriesByIdsUseCase;
25
- this.publishEntryUseCase = publishEntryUseCase;
26
- this.unpublishEntryUseCase = unpublishEntryUseCase;
27
- this.republishEntryUseCase = republishEntryUseCase;
28
- this.identityContext = identityContext;
29
- }
30
- canHandle(namespace, actionType) {
31
- return namespace.startsWith("Cms/Entry/") && actionType === "Publish";
32
- }
33
- async handle(action) {
34
- const {
35
- payload
36
- } = action;
37
- const modelId = payload.modelId;
38
-
39
- // Fetch the model
40
- const modelResult = await this.getModelUseCase.execute(modelId);
41
- if (modelResult.isFail()) {
42
- console.error(`Failed to get model "${modelId}" for scheduled publish action:`, modelResult.error, {
43
- identity: this.identityContext.getIdentity()
44
- });
45
- throw new Error(`Model not found: ${modelId}`);
46
- }
47
- const model = modelResult.value;
48
-
49
- // Fetch the target entry
50
- const targetEntryResult = await this.getEntryByIdUseCase.execute(model, action.targetId);
51
- if (targetEntryResult.isFail()) {
52
- console.error(`Failed to get entry "${action.targetId}" for scheduled publish action:`, targetEntryResult.error);
53
- throw new Error(`Entry not found: ${action.targetId}`);
54
- }
55
- const targetEntry = targetEntryResult.value;
56
-
57
- // Get published entries
58
- const publishedEntriesResult = await this.getPublishedEntriesByIdsUseCase.execute(model, [targetEntry.id]);
59
- if (publishedEntriesResult.isFail()) {
60
- console.error(`Failed to get published entries for "${targetEntry.id}":`, publishedEntriesResult.error);
61
- throw new Error(`Failed to check published entries`);
62
- }
63
- const [publishedTargetEntry] = publishedEntriesResult.value;
64
-
65
- /**
66
- * Scenario 1: Entry has no published revision -> publish it
67
- */
68
- if (!publishedTargetEntry) {
69
- const publishResult = await this.publishEntryUseCase.execute(model, targetEntry.id);
70
- if (publishResult.isFail()) {
71
- console.error(`Failed to publish entry "${action.targetId}":`, publishResult.error);
72
- throw new Error(`Failed to publish entry: ${action.targetId}`);
73
- }
74
- return;
75
- }
76
-
77
- /**
78
- * Scenario 2: Target entry is already published (same revision) -> republish it
79
- */
80
- if (publishedTargetEntry.id === targetEntry.id) {
81
- const republishResult = await this.republishEntryUseCase.execute(model, targetEntry.id);
82
- if (republishResult.isFail()) {
83
- console.error(`Failed to republish entry "${action.targetId}":`, republishResult.error);
84
- throw new Error(`Failed to republish entry: ${action.targetId}`);
85
- }
86
- return;
87
- }
88
-
89
- /**
90
- * Scenario 3: A different revision is published -> unpublish old, publish new
91
- */
92
- const unpublishResult = await this.unpublishEntryUseCase.execute(model, publishedTargetEntry.id);
93
- if (unpublishResult.isFail()) {
94
- console.error(`Failed to unpublish old revision "${publishedTargetEntry.id}":`, unpublishResult.error);
95
- throw new Error(`Failed to unpublish old revision: ${publishedTargetEntry.id}`);
96
- }
97
- const publishResult = await this.publishEntryUseCase.execute(model, targetEntry.id);
98
- if (publishResult.isFail()) {
99
- console.error(`Failed to publish entry "${action.targetId}":`, publishResult.error);
100
- throw new Error(`Failed to publish entry: ${action.targetId}`);
101
- }
102
- }
103
- }
104
- export const PublishEntryActionHandler = ScheduledActionHandler.createImplementation({
105
- implementation: PublishEntryActionHandlerImpl,
106
- dependencies: [GetModelUseCase, GetEntryByIdUseCase, GetPublishedEntriesByIdsUseCase, PublishEntryUseCase, UnpublishEntryUseCase, RepublishEntryUseCase, IdentityContext]
107
- });
108
-
109
- //# sourceMappingURL=PublishEntryActionHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ScheduledActionHandler","GetModelUseCase","GetEntryByIdUseCase","GetPublishedEntriesByIdsUseCase","PublishEntryUseCase","UnpublishEntryUseCase","RepublishEntryUseCase","IdentityContext","PublishEntryActionHandlerImpl","constructor","getModelUseCase","getEntryByIdUseCase","getPublishedEntriesByIdsUseCase","publishEntryUseCase","unpublishEntryUseCase","republishEntryUseCase","identityContext","canHandle","namespace","actionType","startsWith","handle","action","payload","modelId","modelResult","execute","isFail","console","error","identity","getIdentity","Error","model","value","targetEntryResult","targetId","targetEntry","publishedEntriesResult","id","publishedTargetEntry","publishResult","republishResult","unpublishResult","PublishEntryActionHandler","createImplementation","implementation","dependencies"],"sources":["PublishEntryActionHandler.ts"],"sourcesContent":["import { ScheduledActionHandler } from \"@webiny/api-scheduler\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { GetPublishedEntriesByIdsUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds\";\nimport { PublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry\";\nimport { RepublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RepublishEntry\";\nimport type { IScheduleActionWithPayload } from \"~/features/ScheduleEntryAction/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\n/**\n * Handler for publishing CMS entries\n *\n * Handles the \"Publish\" action for CMS entries with namespace pattern: Cms/Entry/{modelId}\n *\n * Publishing logic:\n * 1. If entry is not published -> publish it\n * 2. If the same revision is already published -> republish it\n * 3. If a different revision is published -> unpublish old, publish new\n */\nclass PublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {\n constructor(\n private getModelUseCase: GetModelUseCase.Interface,\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface,\n private publishEntryUseCase: PublishEntryUseCase.Interface,\n private unpublishEntryUseCase: UnpublishEntryUseCase.Interface,\n private republishEntryUseCase: RepublishEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n public canHandle(namespace: string, actionType: string): boolean {\n return namespace.startsWith(\"Cms/Entry/\") && actionType === \"Publish\";\n }\n\n public async handle(action: IScheduleActionWithPayload): Promise<void> {\n const { payload } = action;\n\n const modelId = payload.modelId as string;\n\n // Fetch the model\n const modelResult = await this.getModelUseCase.execute(modelId);\n if (modelResult.isFail()) {\n console.error(\n `Failed to get model \"${modelId}\" for scheduled publish action:`,\n modelResult.error,\n {\n identity: this.identityContext.getIdentity()\n }\n );\n throw new Error(`Model not found: ${modelId}`);\n }\n\n const model = modelResult.value;\n\n // Fetch the target entry\n const targetEntryResult =\n await this.getEntryByIdUseCase.execute<IScheduleActionWithPayload>(\n model,\n action.targetId\n );\n if (targetEntryResult.isFail()) {\n console.error(\n `Failed to get entry \"${action.targetId}\" for scheduled publish action:`,\n targetEntryResult.error\n );\n throw new Error(`Entry not found: ${action.targetId}`);\n }\n\n const targetEntry = targetEntryResult.value;\n\n // Get published entries\n const publishedEntriesResult =\n await this.getPublishedEntriesByIdsUseCase.execute<IScheduleActionWithPayload>(model, [\n targetEntry.id\n ]);\n\n if (publishedEntriesResult.isFail()) {\n console.error(\n `Failed to get published entries for \"${targetEntry.id}\":`,\n publishedEntriesResult.error\n );\n throw new Error(`Failed to check published entries`);\n }\n\n const [publishedTargetEntry] = publishedEntriesResult.value;\n\n /**\n * Scenario 1: Entry has no published revision -> publish it\n */\n if (!publishedTargetEntry) {\n const publishResult =\n await this.publishEntryUseCase.execute<IScheduleActionWithPayload>(\n model,\n targetEntry.id\n );\n if (publishResult.isFail()) {\n console.error(`Failed to publish entry \"${action.targetId}\":`, publishResult.error);\n throw new Error(`Failed to publish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * Scenario 2: Target entry is already published (same revision) -> republish it\n */\n if (publishedTargetEntry.id === targetEntry.id) {\n const republishResult = await this.republishEntryUseCase.execute(model, targetEntry.id);\n if (republishResult.isFail()) {\n console.error(\n `Failed to republish entry \"${action.targetId}\":`,\n republishResult.error\n );\n throw new Error(`Failed to republish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * Scenario 3: A different revision is published -> unpublish old, publish new\n */\n const unpublishResult =\n await this.unpublishEntryUseCase.execute<IScheduleActionWithPayload>(\n model,\n publishedTargetEntry.id\n );\n if (unpublishResult.isFail()) {\n console.error(\n `Failed to unpublish old revision \"${publishedTargetEntry.id}\":`,\n unpublishResult.error\n );\n throw new Error(`Failed to unpublish old revision: ${publishedTargetEntry.id}`);\n }\n\n const publishResult = await this.publishEntryUseCase.execute<IScheduleActionWithPayload>(\n model,\n targetEntry.id\n );\n if (publishResult.isFail()) {\n console.error(`Failed to publish entry \"${action.targetId}\":`, publishResult.error);\n throw new Error(`Failed to publish entry: ${action.targetId}`);\n }\n }\n}\n\nexport const PublishEntryActionHandler = ScheduledActionHandler.createImplementation({\n implementation: PublishEntryActionHandlerImpl,\n dependencies: [\n GetModelUseCase,\n GetEntryByIdUseCase,\n GetPublishedEntriesByIdsUseCase,\n PublishEntryUseCase,\n UnpublishEntryUseCase,\n RepublishEntryUseCase,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,uBAAuB;AAC9D,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,mBAAmB,QAAQ,6DAA6D;AACjG,SAASC,+BAA+B,QAAQ,yEAAyE;AACzH,SAASC,mBAAmB,QAAQ,6DA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