@webiny/api-headless-cms-scheduler 6.0.0-alpha.5 → 6.0.0-rc.1
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.
- package/README.md +11 -15
- package/context.d.ts +2 -7
- package/context.js +9 -64
- package/context.js.map +1 -1
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.d.ts +20 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js +51 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.d.ts +19 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js +48 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.d.ts +19 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js +47 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.d.ts +19 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js +48 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/feature.d.ts +8 -0
- package/features/CancelScheduledActionOnEntryChange/feature.js +24 -0
- package/features/CancelScheduledActionOnEntryChange/feature.js.map +1 -0
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.d.ts +15 -0
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js +25 -0
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js.map +1 -0
- package/features/CancelScheduledEntryAction/abstractions.d.ts +22 -0
- package/features/CancelScheduledEntryAction/abstractions.js +11 -0
- package/features/CancelScheduledEntryAction/abstractions.js.map +1 -0
- package/features/CancelScheduledEntryAction/feature.d.ts +6 -0
- package/features/CancelScheduledEntryAction/feature.js +16 -0
- package/features/CancelScheduledEntryAction/feature.js.map +1 -0
- package/features/CancelScheduledEntryAction/index.d.ts +1 -0
- package/features/CancelScheduledEntryAction/index.js +3 -0
- package/features/CancelScheduledEntryAction/index.js.map +1 -0
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.d.ts +27 -0
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js +83 -0
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js.map +1 -0
- package/features/ScheduleEntryAction/abstractions.d.ts +45 -0
- package/features/ScheduleEntryAction/abstractions.js +15 -0
- package/features/ScheduleEntryAction/abstractions.js.map +1 -0
- package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.d.ts +35 -0
- package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.js +109 -0
- package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.js.map +1 -0
- package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.d.ts +29 -0
- package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.js +92 -0
- package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.js.map +1 -0
- package/features/ScheduleEntryAction/feature.d.ts +7 -0
- package/features/ScheduleEntryAction/feature.js +21 -0
- package/features/ScheduleEntryAction/feature.js.map +1 -0
- package/features/ScheduleEntryAction/index.d.ts +1 -0
- package/features/ScheduleEntryAction/index.js +3 -0
- package/features/ScheduleEntryAction/index.js.map +1 -0
- package/graphql/ActionMapper.d.ts +15 -0
- package/graphql/ActionMapper.js +18 -0
- package/graphql/ActionMapper.js.map +1 -0
- package/{scheduler → graphql}/dates.d.ts +1 -2
- package/graphql/dates.js +9 -0
- package/graphql/dates.js.map +1 -0
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +113 -71
- package/graphql/index.js.map +1 -1
- package/graphql/schema.d.ts +93 -148
- package/graphql/schema.js +51 -55
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +3 -7
- package/index.js +5 -22
- package/index.js.map +1 -1
- package/package.json +20 -22
- package/constants.d.ts +0 -11
- package/constants.js +0 -19
- package/constants.js.map +0 -1
- package/handler/Handler.d.ts +0 -23
- package/handler/Handler.js +0 -74
- package/handler/Handler.js.map +0 -1
- package/handler/actions/PublishHandlerAction.d.ts +0 -13
- package/handler/actions/PublishHandlerAction.js +0 -64
- package/handler/actions/PublishHandlerAction.js.map +0 -1
- package/handler/actions/UnpublishHandlerAction.d.ts +0 -13
- package/handler/actions/UnpublishHandlerAction.js +0 -53
- package/handler/actions/UnpublishHandlerAction.js.map +0 -1
- package/handler/index.d.ts +0 -7
- package/handler/index.js +0 -64
- package/handler/index.js.map +0 -1
- package/handler/types.d.ts +0 -5
- package/handler/types.js +0 -7
- package/handler/types.js.map +0 -1
- package/hooks/index.d.ts +0 -7
- package/hooks/index.js +0 -58
- package/hooks/index.js.map +0 -1
- package/manifest.d.ts +0 -17
- package/manifest.js +0 -47
- package/manifest.js.map +0 -1
- package/scheduler/ScheduleExecutor.d.ts +0 -16
- package/scheduler/ScheduleExecutor.js +0 -55
- package/scheduler/ScheduleExecutor.js.map +0 -1
- package/scheduler/ScheduleFetcher.d.ts +0 -16
- package/scheduler/ScheduleFetcher.js +0 -51
- package/scheduler/ScheduleFetcher.js.map +0 -1
- package/scheduler/ScheduleRecord.d.ts +0 -31
- package/scheduler/ScheduleRecord.js +0 -57
- package/scheduler/ScheduleRecord.js.map +0 -1
- package/scheduler/Scheduler.d.ts +0 -14
- package/scheduler/Scheduler.js +0 -27
- package/scheduler/Scheduler.js.map +0 -1
- package/scheduler/actions/PublishScheduleAction.d.ts +0 -26
- package/scheduler/actions/PublishScheduleAction.js +0 -196
- package/scheduler/actions/PublishScheduleAction.js.map +0 -1
- package/scheduler/actions/UnpublishScheduleAction.d.ts +0 -26
- package/scheduler/actions/UnpublishScheduleAction.js +0 -194
- package/scheduler/actions/UnpublishScheduleAction.js.map +0 -1
- package/scheduler/createScheduleRecordId.d.ts +0 -2
- package/scheduler/createScheduleRecordId.js +0 -33
- package/scheduler/createScheduleRecordId.js.map +0 -1
- package/scheduler/createScheduler.d.ts +0 -12
- package/scheduler/createScheduler.js +0 -65
- package/scheduler/createScheduler.js.map +0 -1
- package/scheduler/dates.js +0 -27
- package/scheduler/dates.js.map +0 -1
- package/scheduler/model.d.ts +0 -1
- package/scheduler/model.js +0 -88
- package/scheduler/model.js.map +0 -1
- package/scheduler/types.d.ts +0 -88
- package/scheduler/types.js +0 -19
- package/scheduler/types.js.map +0 -1
- package/service/SchedulerService.d.ts +0 -23
- package/service/SchedulerService.js +0 -151
- package/service/SchedulerService.js.map +0 -1
- package/service/types.d.ts +0 -19
- package/service/types.js +0 -7
- package/service/types.js.map +0 -1
- package/types.d.ts +0 -11
- package/types.js +0 -7
- package/types.js.map +0 -1
- package/utils/dateInTheFuture.d.ts +0 -6
- package/utils/dateInTheFuture.js +0 -19
- package/utils/dateInTheFuture.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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, RunActionUse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,cAAc,EAAE/B,8BAA8B;EAC9CgC,YAAY,EAAE,CAACpC,qBAAqB,EAAEC,gBAAgB,EAAEC,eAAe,EAAEC,mBAAmB;AAChG,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 type { IScheduleActionWithPayload } from "../../../features/ScheduleEntryAction/index.js";
|
|
9
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
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
|
+
declare class PublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {
|
|
21
|
+
private getModelUseCase;
|
|
22
|
+
private getEntryByIdUseCase;
|
|
23
|
+
private getPublishedEntriesByIdsUseCase;
|
|
24
|
+
private publishEntryUseCase;
|
|
25
|
+
private unpublishEntryUseCase;
|
|
26
|
+
private republishEntryUseCase;
|
|
27
|
+
private identityContext;
|
|
28
|
+
constructor(getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface, getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface, publishEntryUseCase: PublishEntryUseCase.Interface, unpublishEntryUseCase: UnpublishEntryUseCase.Interface, republishEntryUseCase: RepublishEntryUseCase.Interface, identityContext: IdentityContext.Interface);
|
|
29
|
+
canHandle(namespace: string, actionType: string): boolean;
|
|
30
|
+
handle(action: IScheduleActionWithPayload): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare const PublishEntryActionHandler: typeof PublishEntryActionHandlerImpl & {
|
|
33
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-scheduler/shared/abstractions").IScheduledActionHandler>;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,6DAA6D;AACjG,SAASC,qBAAqB,QAAQ,+DAA+D;AACrG,SAASC,qBAAqB,QAAQ,+DAA+D;AAErG,SAASC,eAAe,QAAQ,6DAA6D;;AAE7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,6BAA6B,CAA6C;EAC5EC,WAAWA,CACCC,eAA0C,EAC1CC,mBAAkD,EAClDC,+BAA0E,EAC1EC,mBAAkD,EAClDC,qBAAsD,EACtDC,qBAAsD,EACtDC,eAA0C,EACpD;IAAA,KAPUN,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,+BAA0E,GAA1EA,+BAA0E;IAAA,KAC1EC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,eAA0C,GAA1CA,eAA0C;EACnD;EAEIC,SAASA,CAACC,SAAiB,EAAEC,UAAkB,EAAW;IAC7D,OAAOD,SAAS,CAACE,UAAU,CAAC,YAAY,CAAC,IAAID,UAAU,KAAK,SAAS;EACzE;EAEA,MAAaE,MAAMA,CAACC,MAAkC,EAAiB;IACnE,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM;IAE1B,MAAME,OAAO,GAAGD,OAAO,CAACC,OAAiB;;IAEzC;IACA,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACf,eAAe,CAACgB,OAAO,CAACF,OAAO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ACC,KAAK,CAAC,4BAA4BP,MAAM,CAACc,QAAQ,IAAI,EAAEK,aAAa,CAACZ,KAAK,CAAC;MACnF,MAAM,IAAIG,KAAK,CAAC,4BAA4BV,MAAM,CAACc,QAAQ,EAAE,CAAC;IAClE;EACJ;AACJ;AAEA,OAAO,MAAMQ,yBAAyB,GAAG5C,sBAAsB,CAAC6C,oBAAoB,CAAC;EACjFC,cAAc,EAAEtC,6BAA6B;EAC7CuC,YAAY,EAAE,CACV9C,eAAe,EACfC,mBAAmB,EACnBC,+BAA+B,EAC/BC,mBAAmB,EACnBC,qBAAqB,EACrBC,qBAAqB,EACrBC,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
6
|
+
import type { IScheduleActionWithPayload } from "../../../features/ScheduleEntryAction/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Handler for unpublishing CMS entries
|
|
9
|
+
*
|
|
10
|
+
* Handles the "Unpublish" action for CMS entries with namespace pattern: Cms/Entry/{modelId}
|
|
11
|
+
*
|
|
12
|
+
* Unpublishing logic:
|
|
13
|
+
* 1. If entry is not published -> nothing to do (warn)
|
|
14
|
+
* 2. If target entry is published (same revision) -> unpublish it
|
|
15
|
+
* 3. If a different revision is published -> unpublish it anyway
|
|
16
|
+
*/
|
|
17
|
+
declare class UnpublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {
|
|
18
|
+
private getModelUseCase;
|
|
19
|
+
private getEntryByIdUseCase;
|
|
20
|
+
private getPublishedEntriesByIdsUseCase;
|
|
21
|
+
private unpublishEntryUseCase;
|
|
22
|
+
constructor(getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface, getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface, unpublishEntryUseCase: UnpublishEntryUseCase.Interface);
|
|
23
|
+
canHandle(namespace: string, actionType: string): boolean;
|
|
24
|
+
handle(action: IScheduleActionWithPayload): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare const UnpublishEntryActionHandler: typeof UnpublishEntryActionHandlerImpl & {
|
|
27
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-scheduler/shared/abstractions").IScheduledActionHandler>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
6
|
+
/**
|
|
7
|
+
* Handler for unpublishing CMS entries
|
|
8
|
+
*
|
|
9
|
+
* Handles the "Unpublish" action for CMS entries with namespace pattern: Cms/Entry/{modelId}
|
|
10
|
+
*
|
|
11
|
+
* Unpublishing logic:
|
|
12
|
+
* 1. If entry is not published -> nothing to do (warn)
|
|
13
|
+
* 2. If target entry is published (same revision) -> unpublish it
|
|
14
|
+
* 3. If a different revision is published -> unpublish it anyway
|
|
15
|
+
*/
|
|
16
|
+
class UnpublishEntryActionHandlerImpl {
|
|
17
|
+
constructor(getModelUseCase, getEntryByIdUseCase, getPublishedEntriesByIdsUseCase, unpublishEntryUseCase) {
|
|
18
|
+
this.getModelUseCase = getModelUseCase;
|
|
19
|
+
this.getEntryByIdUseCase = getEntryByIdUseCase;
|
|
20
|
+
this.getPublishedEntriesByIdsUseCase = getPublishedEntriesByIdsUseCase;
|
|
21
|
+
this.unpublishEntryUseCase = unpublishEntryUseCase;
|
|
22
|
+
}
|
|
23
|
+
canHandle(namespace, actionType) {
|
|
24
|
+
return namespace.startsWith("Cms/Entry/") && actionType === "Unpublish";
|
|
25
|
+
}
|
|
26
|
+
async handle(action) {
|
|
27
|
+
const {
|
|
28
|
+
payload
|
|
29
|
+
} = action;
|
|
30
|
+
const modelId = payload.modelId;
|
|
31
|
+
|
|
32
|
+
// Fetch the model
|
|
33
|
+
const modelResult = await this.getModelUseCase.execute(modelId);
|
|
34
|
+
if (modelResult.isFail()) {
|
|
35
|
+
console.error(`Failed to get model "${modelId}" for scheduled unpublish action:`, modelResult.error);
|
|
36
|
+
throw new Error(`Model not found: ${modelId}`);
|
|
37
|
+
}
|
|
38
|
+
const model = modelResult.value;
|
|
39
|
+
|
|
40
|
+
// Fetch the target entry
|
|
41
|
+
const targetEntryResult = await this.getEntryByIdUseCase.execute(model, action.targetId);
|
|
42
|
+
if (targetEntryResult.isFail()) {
|
|
43
|
+
console.error(`Failed to get entry "${action.targetId}" for scheduled unpublish action:`, targetEntryResult.error);
|
|
44
|
+
throw new Error(`Entry not found: ${action.targetId}`);
|
|
45
|
+
}
|
|
46
|
+
const targetEntry = targetEntryResult.value;
|
|
47
|
+
|
|
48
|
+
// Get published entries
|
|
49
|
+
const publishedEntriesResult = await this.getPublishedEntriesByIdsUseCase.execute(model, [targetEntry.id]);
|
|
50
|
+
if (publishedEntriesResult.isFail()) {
|
|
51
|
+
console.error(`Failed to get published entries for "${targetEntry.id}":`, publishedEntriesResult.error);
|
|
52
|
+
throw new Error(`Failed to check published entries`);
|
|
53
|
+
}
|
|
54
|
+
const [publishedTargetEntry] = publishedEntriesResult.value;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Scenario 1: Entry is not published -> nothing to do
|
|
58
|
+
*/
|
|
59
|
+
if (!publishedTargetEntry) {
|
|
60
|
+
console.warn(`Entry "${action.targetId}" is not published, nothing to unpublish.`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Scenario 2: Target entry is published (same revision) -> unpublish it
|
|
66
|
+
*/
|
|
67
|
+
if (publishedTargetEntry.id === action.targetId) {
|
|
68
|
+
const unpublishResult = await this.unpublishEntryUseCase.execute(model, action.targetId);
|
|
69
|
+
if (unpublishResult.isFail()) {
|
|
70
|
+
console.error(`Failed to unpublish entry "${action.targetId}":`, unpublishResult.error);
|
|
71
|
+
throw new Error(`Failed to unpublish entry: ${action.targetId}`);
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Scenario 3: A different revision is published -> unpublish it anyway
|
|
78
|
+
* TODO: Determine if we really want to unpublish an entry which does not match the target ID
|
|
79
|
+
*/
|
|
80
|
+
const unpublishResult = await this.unpublishEntryUseCase.execute(model, publishedTargetEntry.id);
|
|
81
|
+
if (unpublishResult.isFail()) {
|
|
82
|
+
console.error(`Failed to unpublish published revision "${publishedTargetEntry.id}":`, unpublishResult.error);
|
|
83
|
+
throw new Error(`Failed to unpublish entry: ${publishedTargetEntry.id}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export const UnpublishEntryActionHandler = ScheduledActionHandler.createImplementation({
|
|
88
|
+
implementation: UnpublishEntryActionHandlerImpl,
|
|
89
|
+
dependencies: [GetModelUseCase, GetEntryByIdUseCase, GetPublishedEntriesByIdsUseCase, UnpublishEntryUseCase]
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=UnpublishEntryActionHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ScheduledActionHandler","GetModelUseCase","GetEntryByIdUseCase","GetPublishedEntriesByIdsUseCase","UnpublishEntryUseCase","UnpublishEntryActionHandlerImpl","constructor","getModelUseCase","getEntryByIdUseCase","getPublishedEntriesByIdsUseCase","unpublishEntryUseCase","canHandle","namespace","actionType","startsWith","handle","action","payload","modelId","modelResult","execute","isFail","console","error","Error","model","value","targetEntryResult","targetId","targetEntry","publishedEntriesResult","id","publishedTargetEntry","warn","unpublishResult","UnpublishEntryActionHandler","createImplementation","implementation","dependencies"],"sources":["UnpublishEntryActionHandler.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 { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry\";\nimport type { IScheduleActionWithPayload } from \"~/features/ScheduleEntryAction/index.js\";\n\n/**\n * Handler for unpublishing CMS entries\n *\n * Handles the \"Unpublish\" action for CMS entries with namespace pattern: Cms/Entry/{modelId}\n *\n * Unpublishing logic:\n * 1. If entry is not published -> nothing to do (warn)\n * 2. If target entry is published (same revision) -> unpublish it\n * 3. If a different revision is published -> unpublish it anyway\n */\nclass UnpublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {\n constructor(\n private getModelUseCase: GetModelUseCase.Interface,\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface,\n private unpublishEntryUseCase: UnpublishEntryUseCase.Interface\n ) {}\n\n canHandle(namespace: string, actionType: string): boolean {\n return namespace.startsWith(\"Cms/Entry/\") && actionType === \"Unpublish\";\n }\n\n 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 unpublish action:`,\n modelResult.error\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 unpublish 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 is not published -> nothing to do\n */\n if (!publishedTargetEntry) {\n console.warn(`Entry \"${action.targetId}\" is not published, nothing to unpublish.`);\n return;\n }\n\n /**\n * Scenario 2: Target entry is published (same revision) -> unpublish it\n */\n if (publishedTargetEntry.id === action.targetId) {\n const unpublishResult =\n await this.unpublishEntryUseCase.execute<IScheduleActionWithPayload>(\n model,\n action.targetId\n );\n if (unpublishResult.isFail()) {\n console.error(\n `Failed to unpublish entry \"${action.targetId}\":`,\n unpublishResult.error\n );\n throw new Error(`Failed to unpublish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * Scenario 3: A different revision is published -> unpublish it anyway\n * TODO: Determine if we really want to unpublish an entry which does not match the target ID\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 published revision \"${publishedTargetEntry.id}\":`,\n unpublishResult.error\n );\n throw new Error(`Failed to unpublish entry: ${publishedTargetEntry.id}`);\n }\n }\n}\n\nexport const UnpublishEntryActionHandler = ScheduledActionHandler.createImplementation({\n implementation: UnpublishEntryActionHandlerImpl,\n dependencies: [\n GetModelUseCase,\n GetEntryByIdUseCase,\n GetPublishedEntriesByIdsUseCase,\n UnpublishEntryUseCase\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,qBAAqB,QAAQ,+DAA+D;AAGrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,+BAA+B,CAA6C;EAC9EC,WAAWA,CACCC,eAA0C,EAC1CC,mBAAkD,EAClDC,+BAA0E,EAC1EC,qBAAsD,EAChE;IAAA,KAJUH,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,+BAA0E,GAA1EA,+BAA0E;IAAA,KAC1EC,qBAAsD,GAAtDA,qBAAsD;EAC/D;EAEHC,SAASA,CAACC,SAAiB,EAAEC,UAAkB,EAAW;IACtD,OAAOD,SAAS,CAACE,UAAU,CAAC,YAAY,CAAC,IAAID,UAAU,KAAK,WAAW;EAC3E;EAEA,MAAME,MAAMA,CAACC,MAAkC,EAAiB;IAC5D,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM;IAE1B,MAAME,OAAO,GAAGD,OAAO,CAACC,OAAiB;;IAEzC;IACA,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACZ,eAAe,CAACa,OAAO,CAACF,OAAO,CAAC;IAC/D,IAAIC,WAAW,CAACE,MAAM,CAAC,CAAC,EAAE;MACtBC,OAAO,CAACC,KAAK,CACT,wBAAwB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CACpCK,KAAK,EACLT,MAAM,CAACY,QACX,CAAC;MACL,IAAIM,eAAe,CAACb,MAAM,CAAC,CAAC,EAAE;QAC1BC,OAAO,CAACC,KAAK,CACT,8BAA8BP,MAAM,CAACY,QAAQ,IAAI,EACjDM,eAAe,CAACX,KACpB,CAAC;QACD,MAAM,IAAIC,KAAK,CAAC,8BAA8BR,MAAM,CAACY,QAAQ,EAAE,CAAC;MACpE;MACA;IACJ;;IAEA;AACR;AACA;AACA;IACQ,MAAMM,eAAe,GACjB,MAAM,IAAI,CAACxB,qBAAqB,CAACU,OAAO,CACpCK,KAAK,EACLO,oBAAoB,CAACD,EACzB,CAAC;IACL,IAAIG,eAAe,CAACb,MAAM,CAAC,CAAC,EAAE;MAC1BC,OAAO,CAACC,KAAK,CACT,2CAA2CS,oBAAoB,CAACD,EAAE,IAAI,EACtEG,eAAe,CAACX,KACpB,CAAC;MACD,MAAM,IAAIC,KAAK,CAAC,8BAA8BQ,oBAAoB,CAACD,EAAE,EAAE,CAAC;IAC5E;EACJ;AACJ;AAEA,OAAO,MAAMI,2BAA2B,GAAGnC,sBAAsB,CAACoC,oBAAoB,CAAC;EACnFC,cAAc,EAAEhC,+BAA+B;EAC/CiC,YAAY,EAAE,CACVrC,eAAe,EACfC,mBAAmB,EACnBC,+BAA+B,EAC/BC,qBAAqB;AAE7B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScheduleEntryAction Feature
|
|
3
|
+
*
|
|
4
|
+
* Provides the ability to schedule CMS entry actions (publish/unpublish).
|
|
5
|
+
* Handles both immediate execution and future scheduling.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ScheduleEntryActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ScheduleEntryActionUseCase } from "./ScheduleEntryActionUseCase.js";
|
|
3
|
+
import { PublishEntryActionHandler } from "./actionHandlers/PublishEntryActionHandler.js";
|
|
4
|
+
import { UnpublishEntryActionHandler } from "./actionHandlers/UnpublishEntryActionHandler.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ScheduleEntryAction Feature
|
|
8
|
+
*
|
|
9
|
+
* Provides the ability to schedule CMS entry actions (publish/unpublish).
|
|
10
|
+
* Handles both immediate execution and future scheduling.
|
|
11
|
+
*/
|
|
12
|
+
export const ScheduleEntryActionFeature = createFeature({
|
|
13
|
+
name: "ScheduleEntryAction",
|
|
14
|
+
register(container) {
|
|
15
|
+
container.register(ScheduleEntryActionUseCase);
|
|
16
|
+
container.register(PublishEntryActionHandler);
|
|
17
|
+
container.register(UnpublishEntryActionHandler);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","ScheduleEntryActionUseCase","PublishEntryActionHandler","UnpublishEntryActionHandler","ScheduleEntryActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ScheduleEntryActionUseCase } from \"./ScheduleEntryActionUseCase.js\";\nimport { PublishEntryActionHandler } from \"./actionHandlers/PublishEntryActionHandler.js\";\nimport { UnpublishEntryActionHandler } from \"./actionHandlers/UnpublishEntryActionHandler.js\";\n\n/**\n * ScheduleEntryAction Feature\n *\n * Provides the ability to schedule CMS entry actions (publish/unpublish).\n * Handles both immediate execution and future scheduling.\n */\nexport const ScheduleEntryActionFeature = createFeature({\n name: \"ScheduleEntryAction\",\n register(container) {\n container.register(ScheduleEntryActionUseCase);\n container.register(PublishEntryActionHandler);\n container.register(UnpublishEntryActionHandler);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,0BAA0B;AACnC,SAASC,yBAAyB;AAClC,SAASC,2BAA2B;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAGJ,aAAa,CAAC;EACpDK,IAAI,EAAE,qBAAqB;EAC3BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,0BAA0B,CAAC;IAC9CM,SAAS,CAACD,QAAQ,CAACJ,yBAAyB,CAAC;IAC7CK,SAAS,CAACD,QAAQ,CAACH,2BAA2B,CAAC;EACnD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IScheduleActionWithPayload } from "../features/ScheduleEntryAction/index.js";
|
|
2
|
+
export declare class ActionMapper {
|
|
3
|
+
static fromScheduledAction(action: IScheduleActionWithPayload): {
|
|
4
|
+
id: string;
|
|
5
|
+
targetId: string;
|
|
6
|
+
model: {
|
|
7
|
+
modelId: string;
|
|
8
|
+
};
|
|
9
|
+
scheduledBy: import("@webiny/api-scheduler/shared/abstractions").Identity;
|
|
10
|
+
publishOn: string | null;
|
|
11
|
+
unpublishOn: string | null;
|
|
12
|
+
type: string;
|
|
13
|
+
title: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class ActionMapper {
|
|
2
|
+
static fromScheduledAction(action) {
|
|
3
|
+
return {
|
|
4
|
+
id: action.id,
|
|
5
|
+
targetId: action.targetId,
|
|
6
|
+
model: {
|
|
7
|
+
modelId: action.payload?.modelId
|
|
8
|
+
},
|
|
9
|
+
scheduledBy: action.scheduledBy,
|
|
10
|
+
publishOn: action.actionType === "Publish" ? action.scheduledFor : null,
|
|
11
|
+
unpublishOn: action.actionType === "Unpublish" ? action.scheduledFor : null,
|
|
12
|
+
type: action.actionType.toLowerCase(),
|
|
13
|
+
title: action.title
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=ActionMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ActionMapper","fromScheduledAction","action","id","targetId","model","modelId","payload","scheduledBy","publishOn","actionType","scheduledFor","unpublishOn","type","toLowerCase","title"],"sources":["ActionMapper.ts"],"sourcesContent":["import type { IScheduleActionWithPayload } from \"~/features/ScheduleEntryAction/index.js\";\n\nexport class ActionMapper {\n static fromScheduledAction(action: IScheduleActionWithPayload) {\n return {\n id: action.id,\n targetId: action.targetId,\n model: {\n modelId: action.payload?.modelId\n },\n scheduledBy: action.scheduledBy,\n publishOn: action.actionType === \"Publish\" ? action.scheduledFor : null,\n unpublishOn: action.actionType === \"Unpublish\" ? action.scheduledFor : null,\n type: action.actionType.toLowerCase(),\n title: action.title\n };\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,YAAY,CAAC;EACtB,OAAOC,mBAAmBA,CAACC,MAAkC,EAAE;IAC3D,OAAO;MACHC,EAAE,EAAED,MAAM,CAACC,EAAE;MACbC,QAAQ,EAAEF,MAAM,CAACE,QAAQ;MACzBC,KAAK,EAAE;QACHC,OAAO,EAAEJ,MAAM,CAACK,OAAO,EAAED;MAC7B,CAAC;MACDE,WAAW,EAAEN,MAAM,CAACM,WAAW;MAC/BC,SAAS,EAAEP,MAAM,CAACQ,UAAU,KAAK,SAAS,GAAGR,MAAM,CAACS,YAAY,GAAG,IAAI;MACvEC,WAAW,EAAEV,MAAM,CAACQ,UAAU,KAAK,WAAW,GAAGR,MAAM,CAACS,YAAY,GAAG,IAAI;MAC3EE,IAAI,EAAEX,MAAM,CAACQ,UAAU,CAACI,WAAW,CAAC,CAAC;MACrCC,KAAK,EAAEb,MAAM,CAACa;IAClB,CAAC;EACL;AACJ","ignoreList":[]}
|