@webiny/api-headless-cms-scheduler 6.0.0 → 6.1.0-beta.0
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/context.js +10 -4
- package/context.js.map +1 -1
- package/exports/api/cms/scheduler.d.ts +2 -0
- package/exports/api/cms/scheduler.js +4 -0
- package/exports/api/cms/scheduler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.d.ts +3 -3
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js +8 -5
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js.map +1 -1
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.d.ts +3 -3
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js +7 -6
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js.map +1 -1
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.d.ts +3 -3
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js +6 -5
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js.map +1 -1
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.d.ts +3 -3
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js +7 -6
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js.map +1 -1
- package/features/NamespaceHandler/NamespaceHandler.d.ts +15 -0
- package/features/NamespaceHandler/NamespaceHandler.js +50 -0
- package/features/NamespaceHandler/NamespaceHandler.js.map +1 -0
- package/features/{ScheduleEntryAction/actionHandlers → PublishActionHandler}/PublishEntryActionHandler.d.ts +4 -4
- package/features/{ScheduleEntryAction/actionHandlers → PublishActionHandler}/PublishEntryActionHandler.js +7 -2
- package/features/PublishActionHandler/PublishEntryActionHandler.js.map +1 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.d.ts +15 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js +51 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js.map +1 -0
- package/features/SchedulePublishEntryUseCase/abstractions.d.ts +23 -0
- package/features/SchedulePublishEntryUseCase/abstractions.js +5 -0
- package/features/SchedulePublishEntryUseCase/abstractions.js.map +1 -0
- package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.d.ts +15 -0
- package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.js +51 -0
- package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.js.map +1 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.d.ts +23 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.js +5 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.js.map +1 -0
- package/features/{ScheduleEntryAction/actionHandlers → UnpublishActionHandler}/UnpublishEntryActionHandler.d.ts +6 -5
- package/features/{ScheduleEntryAction/actionHandlers → UnpublishActionHandler}/UnpublishEntryActionHandler.js +7 -2
- package/features/UnpublishActionHandler/UnpublishEntryActionHandler.js.map +1 -0
- package/index.d.ts +2 -6
- package/index.js +1 -7
- package/index.js.map +1 -1
- package/package.json +16 -18
- package/types.d.ts +4 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/utils/namespace.d.ts +4 -0
- package/utils/namespace.js +12 -0
- package/utils/namespace.js.map +1 -0
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.d.ts +0 -15
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js +0 -25
- package/features/CancelScheduledEntryAction/CancelScheduledEntryActionUseCase.js.map +0 -1
- package/features/CancelScheduledEntryAction/abstractions.d.ts +0 -22
- package/features/CancelScheduledEntryAction/abstractions.js +0 -11
- package/features/CancelScheduledEntryAction/abstractions.js.map +0 -1
- package/features/CancelScheduledEntryAction/feature.d.ts +0 -6
- package/features/CancelScheduledEntryAction/feature.js +0 -16
- package/features/CancelScheduledEntryAction/feature.js.map +0 -1
- package/features/CancelScheduledEntryAction/index.d.ts +0 -1
- package/features/CancelScheduledEntryAction/index.js +0 -3
- package/features/CancelScheduledEntryAction/index.js.map +0 -1
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.d.ts +0 -27
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js +0 -83
- package/features/ScheduleEntryAction/ScheduleEntryActionUseCase.js.map +0 -1
- package/features/ScheduleEntryAction/abstractions.d.ts +0 -45
- package/features/ScheduleEntryAction/abstractions.js +0 -15
- package/features/ScheduleEntryAction/abstractions.js.map +0 -1
- package/features/ScheduleEntryAction/actionHandlers/PublishEntryActionHandler.js.map +0 -1
- package/features/ScheduleEntryAction/actionHandlers/UnpublishEntryActionHandler.js.map +0 -1
- package/features/ScheduleEntryAction/feature.d.ts +0 -7
- package/features/ScheduleEntryAction/feature.js +0 -21
- package/features/ScheduleEntryAction/feature.js.map +0 -1
- package/features/ScheduleEntryAction/index.d.ts +0 -1
- package/features/ScheduleEntryAction/index.js +0 -3
- package/features/ScheduleEntryAction/index.js.map +0 -1
- package/graphql/ActionMapper.d.ts +0 -15
- package/graphql/ActionMapper.js +0 -18
- package/graphql/ActionMapper.js.map +0 -1
- package/graphql/dates.d.ts +0 -6
- package/graphql/dates.js +0 -9
- package/graphql/dates.js.map +0 -1
- package/graphql/index.d.ts +0 -3
- package/graphql/index.js +0 -246
- package/graphql/index.js.map +0 -1
- package/graphql/schema.d.ts +0 -162
- package/graphql/schema.js +0 -83
- package/graphql/schema.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SchedulePublishEntryUseCase","UseCaseAbstraction","ScheduleActionUseCase","ScheduledActionTypePublish","createNamespace","Result","EntryNotAuthorizedError","AccessControl","GetModelUseCase","SchedulePublishEntryUseCaseImpl","constructor","scheduleAction","accessControl","getModelUseCase","execute","params","model","initialModel","scheduleFor","id","modelResult","modelId","isFail","fail","error","value","canAccess","canAccessEntry","pw","fromModel","scheduleResult","namespace","actionType","targetId","ok","scheduledAction","createImplementation","implementation","dependencies"],"sources":["SchedulePublishEntryUseCase.ts"],"sourcesContent":["import { SchedulePublishEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport {\n ScheduleActionUseCase,\n ScheduledActionTypePublish\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport { createNamespace } from \"~/utils/namespace.js\";\nimport { Result } from \"@webiny/feature/exports/api.js\";\nimport { EntryNotAuthorizedError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\nimport { AccessControl } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\nclass SchedulePublishEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private scheduleAction: ScheduleActionUseCase.Interface,\n private accessControl: AccessControl.Interface,\n private getModelUseCase: GetModelUseCase.Interface\n ) {}\n\n public async execute(params: UseCaseAbstraction.Params): UseCaseAbstraction.Result {\n const { model: initialModel, scheduleFor, id } = params;\n\n const modelResult = await this.getModelUseCase.execute(initialModel.modelId);\n if (modelResult.isFail()) {\n return Result.fail(modelResult.error as any);\n }\n const model = modelResult.value;\n\n const canAccess = await this.accessControl.canAccessEntry({ model, pw: \"p\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model) as any);\n }\n\n const scheduleResult = await this.scheduleAction.execute({\n namespace: createNamespace(model),\n actionType: ScheduledActionTypePublish,\n scheduleFor,\n targetId: id\n });\n if (scheduleResult.isFail()) {\n return Result.fail(scheduleResult.error);\n }\n return Result.ok({\n scheduledAction: scheduleResult.value\n });\n }\n}\n\nexport const SchedulePublishEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: SchedulePublishEntryUseCaseImpl,\n dependencies: [ScheduleActionUseCase, AccessControl, GetModelUseCase]\n});\n"],"mappings":"AAAA,SAASA,2BAA2B,IAAIC,kBAAkB;AAC1D,SACIC,qBAAqB,EACrBC,0BAA0B,QACvB,gDAAgD;AACvD,SAASC,eAAe;AACxB,SAASC,MAAM,QAAQ,gCAAgC;AACvD,SAASC,uBAAuB,QAAQ,wDAAwD;AAChG,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,eAAe,QAAQ,kEAAkE;AAElG,MAAMC,+BAA+B,CAAyC;EACnEC,WAAWA,CACNC,cAA+C,EAC/CC,aAAsC,EACtCC,eAA0C,EACpD;IAAA,KAHUF,cAA+C,GAA/CA,cAA+C;IAAA,KAC/CC,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAaC,OAAOA,CAACC,MAAiC,EAA6B;IAC/E,MAAM;MAAEC,KAAK,EAAEC,YAAY;MAAEC,WAAW;MAAEC;IAAG,CAAC,GAAGJ,MAAM;IAEvD,MAAMK,WAAW,GAAG,MAAM,IAAI,CAACP,eAAe,CAACC,OAAO,CAACG,YAAY,CAACI,OAAO,CAAC;IAC5E,IAAID,WAAW,CAACE,MAAM,CAAC,CAAC,EAAE;MACtB,OAAOjB,MAAM,CAACkB,IAAI,CAACH,WAAW,CAACI,KAAY,CAAC;IAChD;IACA,MAAMR,KAAK,GAAGI,WAAW,CAACK,KAAK;IAE/B,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACd,aAAa,CAACe,cAAc,CAAC;MAAEX,KAAK;MAAEY,EAAE,EAAE;IAAI,CAAC,CAAC;IAC7E,IAAI,CAACF,SAAS,EAAE;MACZ,OAAOrB,MAAM,CAACkB,IAAI,CAACjB,uBAAuB,CAACuB,SAAS,CAACb,KAAK,CAAQ,CAAC;IACvE;IAEA,MAAMc,cAAc,GAAG,MAAM,IAAI,CAACnB,cAAc,CAACG,OAAO,CAAC;MACrDiB,SAAS,EAAE3B,eAAe,CAACY,KAAK,CAAC;MACjCgB,UAAU,EAAE7B,0BAA0B;MACtCe,WAAW;MACXe,QAAQ,EAAEd;IACd,CAAC,CAAC;IACF,IAAIW,cAAc,CAACR,MAAM,CAAC,CAAC,EAAE;MACzB,OAAOjB,MAAM,CAACkB,IAAI,CAACO,cAAc,CAACN,KAAK,CAAC;IAC5C;IACA,OAAOnB,MAAM,CAAC6B,EAAE,CAAC;MACbC,eAAe,EAAEL,cAAc,CAACL;IACpC,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMzB,2BAA2B,GAAGC,kBAAkB,CAACmC,oBAAoB,CAAC;EAC/EC,cAAc,EAAE5B,+BAA+B;EAC/C6B,YAAY,EAAE,CAACpC,qBAAqB,EAAEK,aAAa,EAAEC,eAAe;AACxE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { IScheduledAction, ScheduleActionError } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
+
export interface ISchedulePublishEntryUseCaseParams {
|
|
5
|
+
id: string;
|
|
6
|
+
model: Pick<CmsModel, "modelId">;
|
|
7
|
+
scheduleFor: Date;
|
|
8
|
+
}
|
|
9
|
+
export interface ISchedulePublishEntryUseCaseResult {
|
|
10
|
+
scheduledAction: IScheduledAction;
|
|
11
|
+
}
|
|
12
|
+
export type ISchedulePublishEntryUseCaseResponse = Promise<Result<ISchedulePublishEntryUseCaseResult, ScheduleActionError>>;
|
|
13
|
+
export interface ISchedulePublishEntryUseCase {
|
|
14
|
+
execute(params: ISchedulePublishEntryUseCaseParams): ISchedulePublishEntryUseCaseResponse;
|
|
15
|
+
}
|
|
16
|
+
/** Schedule an entry for future publishing. */
|
|
17
|
+
export declare const SchedulePublishEntryUseCase: import("@webiny/di").Abstraction<ISchedulePublishEntryUseCase>;
|
|
18
|
+
export declare namespace SchedulePublishEntryUseCase {
|
|
19
|
+
type Interface = ISchedulePublishEntryUseCase;
|
|
20
|
+
type Error = ScheduleActionError;
|
|
21
|
+
type Params = ISchedulePublishEntryUseCaseParams;
|
|
22
|
+
type Result = ISchedulePublishEntryUseCaseResponse;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","Result","SchedulePublishEntryUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type {\n IScheduledAction,\n ScheduleActionError\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ISchedulePublishEntryUseCaseParams {\n id: string;\n model: Pick<CmsModel, \"modelId\">;\n scheduleFor: Date;\n}\n\nexport interface ISchedulePublishEntryUseCaseResult {\n scheduledAction: IScheduledAction;\n}\n\nexport type ISchedulePublishEntryUseCaseResponse = Promise<\n Result<ISchedulePublishEntryUseCaseResult, ScheduleActionError>\n>;\n\nexport interface ISchedulePublishEntryUseCase {\n execute(params: ISchedulePublishEntryUseCaseParams): ISchedulePublishEntryUseCaseResponse;\n}\n\n/** Schedule an entry for future publishing. */\nexport const SchedulePublishEntryUseCase = createAbstraction<ISchedulePublishEntryUseCase>(\n \"CmsScheduler/SchedulePublishEntryUseCase\"\n);\n\nexport namespace SchedulePublishEntryUseCase {\n export type Interface = ISchedulePublishEntryUseCase;\n export type Error = ScheduleActionError;\n export type Params = ISchedulePublishEntryUseCaseParams;\n export type Result = ISchedulePublishEntryUseCaseResponse;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,MAAM,QAAQ,qBAAqB;AAyB/D;AACA,OAAO,MAAMC,2BAA2B,GAAGF,iBAAiB,CACxD,0CACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScheduleUnpublishEntryUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
|
+
import { ScheduleActionUseCase } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
3
|
+
import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
5
|
+
declare class ScheduleUnpublishEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
+
private scheduleAction;
|
|
7
|
+
private accessControl;
|
|
8
|
+
private getModelUseCase;
|
|
9
|
+
constructor(scheduleAction: ScheduleActionUseCase.Interface, accessControl: AccessControl.Interface, getModelUseCase: GetModelUseCase.Interface);
|
|
10
|
+
execute(params: UseCaseAbstraction.Params): UseCaseAbstraction.Result;
|
|
11
|
+
}
|
|
12
|
+
export declare const ScheduleUnpublishEntryUseCase: typeof ScheduleUnpublishEntryUseCaseImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IScheduleUnpublishEntryUseCase>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ScheduleUnpublishEntryUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
|
+
import { ScheduleActionUseCase, ScheduledActionTypeUnpublish } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
3
|
+
import { createNamespace } from "../../utils/namespace.js";
|
|
4
|
+
import { Result } from "@webiny/feature/exports/api.js";
|
|
5
|
+
import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
7
|
+
import { EntryNotAuthorizedError } from "@webiny/api-headless-cms/domain/contentEntry/errors.js";
|
|
8
|
+
class ScheduleUnpublishEntryUseCaseImpl {
|
|
9
|
+
constructor(scheduleAction, accessControl, getModelUseCase) {
|
|
10
|
+
this.scheduleAction = scheduleAction;
|
|
11
|
+
this.accessControl = accessControl;
|
|
12
|
+
this.getModelUseCase = getModelUseCase;
|
|
13
|
+
}
|
|
14
|
+
async execute(params) {
|
|
15
|
+
const {
|
|
16
|
+
model: initialModel,
|
|
17
|
+
scheduleFor,
|
|
18
|
+
id
|
|
19
|
+
} = params;
|
|
20
|
+
const modelResult = await this.getModelUseCase.execute(initialModel.modelId);
|
|
21
|
+
if (modelResult.isFail()) {
|
|
22
|
+
return Result.fail(modelResult.error);
|
|
23
|
+
}
|
|
24
|
+
const model = modelResult.value;
|
|
25
|
+
const canAccess = await this.accessControl.canAccessEntry({
|
|
26
|
+
model,
|
|
27
|
+
pw: "u"
|
|
28
|
+
});
|
|
29
|
+
if (!canAccess) {
|
|
30
|
+
return Result.fail(EntryNotAuthorizedError.fromModel(model));
|
|
31
|
+
}
|
|
32
|
+
const scheduleResult = await this.scheduleAction.execute({
|
|
33
|
+
namespace: createNamespace(model),
|
|
34
|
+
actionType: ScheduledActionTypeUnpublish,
|
|
35
|
+
scheduleFor,
|
|
36
|
+
targetId: id
|
|
37
|
+
});
|
|
38
|
+
if (scheduleResult.isFail()) {
|
|
39
|
+
return Result.fail(scheduleResult.error);
|
|
40
|
+
}
|
|
41
|
+
return Result.ok({
|
|
42
|
+
scheduledAction: scheduleResult.value
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const ScheduleUnpublishEntryUseCase = UseCaseAbstraction.createImplementation({
|
|
47
|
+
implementation: ScheduleUnpublishEntryUseCaseImpl,
|
|
48
|
+
dependencies: [ScheduleActionUseCase, AccessControl, GetModelUseCase]
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=ScheduleUnpublishEntryUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ScheduleUnpublishEntryUseCase","UseCaseAbstraction","ScheduleActionUseCase","ScheduledActionTypeUnpublish","createNamespace","Result","AccessControl","GetModelUseCase","EntryNotAuthorizedError","ScheduleUnpublishEntryUseCaseImpl","constructor","scheduleAction","accessControl","getModelUseCase","execute","params","model","initialModel","scheduleFor","id","modelResult","modelId","isFail","fail","error","value","canAccess","canAccessEntry","pw","fromModel","scheduleResult","namespace","actionType","targetId","ok","scheduledAction","createImplementation","implementation","dependencies"],"sources":["ScheduleUnpublishEntryUseCase.ts"],"sourcesContent":["import { ScheduleUnpublishEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport {\n ScheduleActionUseCase,\n ScheduledActionTypeUnpublish\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport { createNamespace } from \"~/utils/namespace.js\";\nimport { Result } from \"@webiny/feature/exports/api.js\";\nimport { AccessControl } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { EntryNotAuthorizedError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\n\nclass ScheduleUnpublishEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private scheduleAction: ScheduleActionUseCase.Interface,\n private accessControl: AccessControl.Interface,\n private getModelUseCase: GetModelUseCase.Interface\n ) {}\n\n public async execute(params: UseCaseAbstraction.Params): UseCaseAbstraction.Result {\n const { model: initialModel, scheduleFor, id } = params;\n\n const modelResult = await this.getModelUseCase.execute(initialModel.modelId);\n if (modelResult.isFail()) {\n return Result.fail(modelResult.error as any);\n }\n const model = modelResult.value;\n\n const canAccess = await this.accessControl.canAccessEntry({ model, pw: \"u\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model) as any);\n }\n\n const scheduleResult = await this.scheduleAction.execute({\n namespace: createNamespace(model),\n actionType: ScheduledActionTypeUnpublish,\n scheduleFor,\n targetId: id\n });\n if (scheduleResult.isFail()) {\n return Result.fail(scheduleResult.error);\n }\n return Result.ok({\n scheduledAction: scheduleResult.value\n });\n }\n}\n\nexport const ScheduleUnpublishEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: ScheduleUnpublishEntryUseCaseImpl,\n dependencies: [ScheduleActionUseCase, AccessControl, GetModelUseCase]\n});\n"],"mappings":"AAAA,SAASA,6BAA6B,IAAIC,kBAAkB;AAC5D,SACIC,qBAAqB,EACrBC,4BAA4B,QACzB,gDAAgD;AACvD,SAASC,eAAe;AACxB,SAASC,MAAM,QAAQ,gCAAgC;AACvD,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,uBAAuB,QAAQ,wDAAwD;AAEhG,MAAMC,iCAAiC,CAAyC;EACrEC,WAAWA,CACNC,cAA+C,EAC/CC,aAAsC,EACtCC,eAA0C,EACpD;IAAA,KAHUF,cAA+C,GAA/CA,cAA+C;IAAA,KAC/CC,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAaC,OAAOA,CAACC,MAAiC,EAA6B;IAC/E,MAAM;MAAEC,KAAK,EAAEC,YAAY;MAAEC,WAAW;MAAEC;IAAG,CAAC,GAAGJ,MAAM;IAEvD,MAAMK,WAAW,GAAG,MAAM,IAAI,CAACP,eAAe,CAACC,OAAO,CAACG,YAAY,CAACI,OAAO,CAAC;IAC5E,IAAID,WAAW,CAACE,MAAM,CAAC,CAAC,EAAE;MACtB,OAAOjB,MAAM,CAACkB,IAAI,CAACH,WAAW,CAACI,KAAY,CAAC;IAChD;IACA,MAAMR,KAAK,GAAGI,WAAW,CAACK,KAAK;IAE/B,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACd,aAAa,CAACe,cAAc,CAAC;MAAEX,KAAK;MAAEY,EAAE,EAAE;IAAI,CAAC,CAAC;IAC7E,IAAI,CAACF,SAAS,EAAE;MACZ,OAAOrB,MAAM,CAACkB,IAAI,CAACf,uBAAuB,CAACqB,SAAS,CAACb,KAAK,CAAQ,CAAC;IACvE;IAEA,MAAMc,cAAc,GAAG,MAAM,IAAI,CAACnB,cAAc,CAACG,OAAO,CAAC;MACrDiB,SAAS,EAAE3B,eAAe,CAACY,KAAK,CAAC;MACjCgB,UAAU,EAAE7B,4BAA4B;MACxCe,WAAW;MACXe,QAAQ,EAAEd;IACd,CAAC,CAAC;IACF,IAAIW,cAAc,CAACR,MAAM,CAAC,CAAC,EAAE;MACzB,OAAOjB,MAAM,CAACkB,IAAI,CAACO,cAAc,CAACN,KAAK,CAAC;IAC5C;IACA,OAAOnB,MAAM,CAAC6B,EAAE,CAAC;MACbC,eAAe,EAAEL,cAAc,CAACL;IACpC,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMzB,6BAA6B,GAAGC,kBAAkB,CAACmC,oBAAoB,CAAC;EACjFC,cAAc,EAAE5B,iCAAiC;EACjD6B,YAAY,EAAE,CAACpC,qBAAqB,EAAEI,aAAa,EAAEC,eAAe;AACxE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { IScheduledAction, ScheduleActionError } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
+
export interface IScheduleUnpublishEntryUseCaseParams {
|
|
5
|
+
id: string;
|
|
6
|
+
model: Pick<CmsModel, "modelId">;
|
|
7
|
+
scheduleFor: Date;
|
|
8
|
+
}
|
|
9
|
+
export interface IScheduleUnpublishEntryUseCaseResult {
|
|
10
|
+
scheduledAction: IScheduledAction;
|
|
11
|
+
}
|
|
12
|
+
export type IScheduleUnpublishEntryUseCaseResponse = Promise<Result<IScheduleUnpublishEntryUseCaseResult, ScheduleActionError>>;
|
|
13
|
+
export interface IScheduleUnpublishEntryUseCase {
|
|
14
|
+
execute(params: IScheduleUnpublishEntryUseCaseParams): IScheduleUnpublishEntryUseCaseResponse;
|
|
15
|
+
}
|
|
16
|
+
/** Schedule an entry for future unpublishing. */
|
|
17
|
+
export declare const ScheduleUnpublishEntryUseCase: import("@webiny/di").Abstraction<IScheduleUnpublishEntryUseCase>;
|
|
18
|
+
export declare namespace ScheduleUnpublishEntryUseCase {
|
|
19
|
+
type Interface = IScheduleUnpublishEntryUseCase;
|
|
20
|
+
type Error = ScheduleActionError;
|
|
21
|
+
type Params = IScheduleUnpublishEntryUseCaseParams;
|
|
22
|
+
type Result = IScheduleUnpublishEntryUseCaseResponse;
|
|
23
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createAbstraction, Result } from "@webiny/feature/api";
|
|
2
|
+
/** Schedule an entry for future unpublishing. */
|
|
3
|
+
export const ScheduleUnpublishEntryUseCase = createAbstraction("CmsScheduler/ScheduleUnpublishEntryUseCase");
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","Result","ScheduleUnpublishEntryUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type {\n IScheduledAction,\n ScheduleActionError\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IScheduleUnpublishEntryUseCaseParams {\n id: string;\n model: Pick<CmsModel, \"modelId\">;\n scheduleFor: Date;\n}\n\nexport interface IScheduleUnpublishEntryUseCaseResult {\n scheduledAction: IScheduledAction;\n}\n\nexport type IScheduleUnpublishEntryUseCaseResponse = Promise<\n Result<IScheduleUnpublishEntryUseCaseResult, ScheduleActionError>\n>;\n\nexport interface IScheduleUnpublishEntryUseCase {\n execute(params: IScheduleUnpublishEntryUseCaseParams): IScheduleUnpublishEntryUseCaseResponse;\n}\n\n/** Schedule an entry for future unpublishing. */\nexport const ScheduleUnpublishEntryUseCase = createAbstraction<IScheduleUnpublishEntryUseCase>(\n \"CmsScheduler/ScheduleUnpublishEntryUseCase\"\n);\n\nexport namespace ScheduleUnpublishEntryUseCase {\n export type Interface = IScheduleUnpublishEntryUseCase;\n export type Error = ScheduleActionError;\n export type Params = IScheduleUnpublishEntryUseCaseParams;\n export type Result = IScheduleUnpublishEntryUseCaseResponse;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,MAAM,QAAQ,qBAAqB;AAyB/D;AACA,OAAO,MAAMC,6BAA6B,GAAGF,iBAAiB,CAC1D,4CACJ,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ScheduledActionHandler } from "@webiny/api-scheduler";
|
|
1
|
+
import { type IScheduledAction, ScheduledActionHandler } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
2
2
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { GetPublishedEntriesByIdsUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds";
|
|
5
5
|
import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
6
|
-
import type {
|
|
6
|
+
import type { IScheduledActionPayload } from "../../types.js";
|
|
7
|
+
import type { ScheduledActionType } from "@webiny/api-scheduler/shared/abstractions.js";
|
|
7
8
|
/**
|
|
8
9
|
* Handler for unpublishing CMS entries
|
|
9
10
|
*
|
|
@@ -20,10 +21,10 @@ declare class UnpublishEntryActionHandlerImpl implements ScheduledActionHandler.
|
|
|
20
21
|
private getPublishedEntriesByIdsUseCase;
|
|
21
22
|
private unpublishEntryUseCase;
|
|
22
23
|
constructor(getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface, getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface, unpublishEntryUseCase: UnpublishEntryUseCase.Interface);
|
|
23
|
-
canHandle(namespace: string, actionType:
|
|
24
|
-
handle(action:
|
|
24
|
+
canHandle(namespace: string, actionType: ScheduledActionType): boolean;
|
|
25
|
+
handle(action: IScheduledAction<IScheduledActionPayload>): Promise<void>;
|
|
25
26
|
}
|
|
26
27
|
export declare const UnpublishEntryActionHandler: typeof UnpublishEntryActionHandlerImpl & {
|
|
27
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-scheduler/shared/abstractions").IScheduledActionHandler>;
|
|
28
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-scheduler/shared/abstractions.js").IScheduledActionHandler>;
|
|
28
29
|
};
|
|
29
30
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ScheduledActionHandler } from "@webiny/api-scheduler";
|
|
1
|
+
import { ScheduledActionHandler, ScheduledActionTypeUnpublish } from "@webiny/api-scheduler/exports/api/scheduler.js";
|
|
2
2
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { GetPublishedEntriesByIdsUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds";
|
|
5
5
|
import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
6
|
+
import { extractModelIdFromNamespace } from "../../utils/namespace.js";
|
|
6
7
|
/**
|
|
7
8
|
* Handler for unpublishing CMS entries
|
|
8
9
|
*
|
|
@@ -21,7 +22,11 @@ class UnpublishEntryActionHandlerImpl {
|
|
|
21
22
|
this.unpublishEntryUseCase = unpublishEntryUseCase;
|
|
22
23
|
}
|
|
23
24
|
canHandle(namespace, actionType) {
|
|
24
|
-
|
|
25
|
+
const modelId = extractModelIdFromNamespace(namespace);
|
|
26
|
+
if (!modelId) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return actionType === ScheduledActionTypeUnpublish;
|
|
25
30
|
}
|
|
26
31
|
async handle(action) {
|
|
27
32
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ScheduledActionHandler","ScheduledActionTypeUnpublish","GetModelUseCase","GetEntryByIdUseCase","GetPublishedEntriesByIdsUseCase","UnpublishEntryUseCase","extractModelIdFromNamespace","UnpublishEntryActionHandlerImpl","constructor","getModelUseCase","getEntryByIdUseCase","getPublishedEntriesByIdsUseCase","unpublishEntryUseCase","canHandle","namespace","actionType","modelId","handle","action","payload","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 {\n type IScheduledAction,\n ScheduledActionHandler,\n ScheduledActionTypeUnpublish\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\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 { IScheduledActionPayload } from \"~/types.js\";\nimport { extractModelIdFromNamespace } from \"~/utils/namespace.js\";\nimport type { ScheduledActionType } from \"@webiny/api-scheduler/shared/abstractions.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: ScheduledActionType): boolean {\n const modelId = extractModelIdFromNamespace(namespace);\n if (!modelId) {\n return false;\n }\n return actionType === ScheduledActionTypeUnpublish;\n }\n\n async handle(action: IScheduledAction<IScheduledActionPayload>): 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 = await this.getEntryByIdUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, action.targetId);\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 = await this.getPublishedEntriesByIdsUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, [targetEntry.id]);\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 = await this.unpublishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, action.targetId);\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 = await this.unpublishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, publishedTargetEntry.id);\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":"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","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
* This will register both API and Handler plugins for the Headless CMS Scheduler.
|
|
4
|
-
* API plugin will provide the GraphQL API and code for managing the scheduled CMS actions.
|
|
5
|
-
*/
|
|
6
|
-
export declare const createHeadlessCmsScheduler: () => PluginCollection;
|
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
export declare const createHeadlessCmsScheduler: () => ContextPlugin[];
|
package/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { createHeadlessCmsScheduleContext } from "./context.js";
|
|
2
|
-
import { createSchedulerGraphQL } from "./graphql/index.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This will register both API and Handler plugins for the Headless CMS Scheduler.
|
|
6
|
-
* API plugin will provide the GraphQL API and code for managing the scheduled CMS actions.
|
|
7
|
-
*/
|
|
8
2
|
export const createHeadlessCmsScheduler = () => {
|
|
9
|
-
return [createHeadlessCmsScheduleContext()
|
|
3
|
+
return [createHeadlessCmsScheduleContext()];
|
|
10
4
|
};
|
|
11
5
|
|
|
12
6
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createHeadlessCmsScheduleContext","
|
|
1
|
+
{"version":3,"names":["createHeadlessCmsScheduleContext","createHeadlessCmsScheduler"],"sources":["index.ts"],"sourcesContent":["import { createHeadlessCmsScheduleContext } from \"~/context.js\";\nimport { ContextPlugin } from \"@webiny/api\";\n\nexport const createHeadlessCmsScheduler = (): ContextPlugin[] => {\n return [createHeadlessCmsScheduleContext()];\n};\n"],"mappings":"AAAA,SAASA,gCAAgC;AAGzC,OAAO,MAAMC,0BAA0B,GAAGA,CAAA,KAAuB;EAC7D,OAAO,CAACD,gCAAgC,CAAC,CAAC,CAAC;AAC/C,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-scheduler",
|
|
3
|
-
"version": "6.0.0",
|
|
3
|
+
"version": "6.1.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"description": "Schedule for Webiny Headless CMS",
|
|
@@ -14,30 +14,28 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@webiny/api": "6.0.0",
|
|
18
|
-
"@webiny/api-headless-cms": "6.0.0",
|
|
19
|
-
"@webiny/api-scheduler": "6.0.0",
|
|
20
|
-
"@webiny/feature": "6.0.0",
|
|
21
|
-
"@webiny/handler-graphql": "6.0.0"
|
|
22
|
-
"@webiny/utils": "6.0.0",
|
|
23
|
-
"zod": "3.25.76"
|
|
17
|
+
"@webiny/api": "6.1.0-beta.0",
|
|
18
|
+
"@webiny/api-headless-cms": "6.1.0-beta.0",
|
|
19
|
+
"@webiny/api-scheduler": "6.1.0-beta.0",
|
|
20
|
+
"@webiny/feature": "6.1.0-beta.0",
|
|
21
|
+
"@webiny/handler-graphql": "6.1.0-beta.0"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
26
|
-
"@webiny/api-core": "6.0.0",
|
|
27
|
-
"@webiny/aws-sdk": "6.0.0",
|
|
28
|
-
"@webiny/build-tools": "6.0.0",
|
|
29
|
-
"@webiny/handler": "6.0.0",
|
|
30
|
-
"@webiny/handler-aws": "6.0.0",
|
|
31
|
-
"@webiny/plugins": "6.0.0",
|
|
32
|
-
"@webiny/project-utils": "6.0.0",
|
|
33
|
-
"@webiny/wcp": "6.0.0",
|
|
24
|
+
"@webiny/api-core": "6.1.0-beta.0",
|
|
25
|
+
"@webiny/aws-sdk": "6.1.0-beta.0",
|
|
26
|
+
"@webiny/build-tools": "6.1.0-beta.0",
|
|
27
|
+
"@webiny/handler": "6.1.0-beta.0",
|
|
28
|
+
"@webiny/handler-aws": "6.1.0-beta.0",
|
|
29
|
+
"@webiny/plugins": "6.1.0-beta.0",
|
|
30
|
+
"@webiny/project-utils": "6.1.0-beta.0",
|
|
31
|
+
"@webiny/wcp": "6.1.0-beta.0",
|
|
34
32
|
"aws-sdk-client-mock": "4.1.0",
|
|
35
33
|
"typescript": "5.9.3",
|
|
36
|
-
"vitest": "4.
|
|
34
|
+
"vitest": "4.1.2"
|
|
37
35
|
},
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public",
|
|
40
38
|
"directory": "dist"
|
|
41
39
|
},
|
|
42
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a3bd3695c66c79238e380d7360d9731b5fcf9c87"
|
|
43
41
|
}
|
package/types.d.ts
ADDED
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { INamespaceHandlerResult } from \"@webiny/api-scheduler/features/NamespaceHandler/abstractions.js\";\n\nexport interface IScheduledActionPayload extends INamespaceHandlerResult {\n modelId: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -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,12 @@
|
|
|
1
|
+
export const CMS_NAMESPACE = "Cms/Entry/";
|
|
2
|
+
export const createNamespace = model => {
|
|
3
|
+
return `${CMS_NAMESPACE}${model.modelId}`;
|
|
4
|
+
};
|
|
5
|
+
export const extractModelIdFromNamespace = namespace => {
|
|
6
|
+
if (!namespace.startsWith(CMS_NAMESPACE)) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return namespace.substring(CMS_NAMESPACE.length) || null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CMS_NAMESPACE","createNamespace","model","modelId","extractModelIdFromNamespace","namespace","startsWith","substring","length"],"sources":["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"],"mappings":"AAEA,OAAO,MAAMA,aAAa,GAAG,YAAY;AAEzC,OAAO,MAAMC,eAAe,GAAIC,KAAgC,IAAK;EACjE,OAAO,GAAGF,aAAa,GAAGE,KAAK,CAACC,OAAO,EAAE;AAC7C,CAAC;AAED,OAAO,MAAMC,2BAA2B,GAAIC,SAAiB,IAAoB;EAC7E,IAAI,CAACA,SAAS,CAACC,UAAU,CAACN,aAAa,CAAC,EAAE;IACtC,OAAO,IAAI;EACf;EACA,OAAOK,SAAS,CAACE,SAAS,CAACP,aAAa,CAACQ,MAAM,CAAC,IAAI,IAAI;AAC5D,CAAC","ignoreList":[]}
|
|
@@ -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,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 +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 {};
|