@webiny/api-headless-cms-scheduler 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea
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/CmsSchedulerFeature.d.ts +4 -0
- package/CmsSchedulerFeature.js +23 -0
- package/CmsSchedulerFeature.js.map +1 -0
- package/README.md +11 -15
- package/exports/api/cms/scheduler.d.ts +2 -0
- package/exports/api/cms/scheduler.js +2 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.d.ts +22 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js +49 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnEntryDeleteEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.d.ts +21 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js +41 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnPublishEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.d.ts +21 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js +40 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnRevisionDeleteEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.d.ts +21 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js +41 -0
- package/features/CancelScheduledActionOnEntryChange/CancelScheduledActionOnUnpublishEventHandler.js.map +1 -0
- package/features/CancelScheduledActionOnEntryChange/feature.d.ts +11 -0
- package/features/CancelScheduledActionOnEntryChange/feature.js +17 -0
- package/features/CancelScheduledActionOnEntryChange/feature.js.map +1 -0
- package/features/NamespaceHandler/NamespaceHandler.d.ts +15 -0
- package/features/NamespaceHandler/NamespaceHandler.js +44 -0
- package/features/NamespaceHandler/NamespaceHandler.js.map +1 -0
- package/features/PublishActionHandler/PublishEntryActionHandler.d.ts +35 -0
- package/features/PublishActionHandler/PublishEntryActionHandler.js +92 -0
- package/features/PublishActionHandler/PublishEntryActionHandler.js.map +1 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.d.ts +15 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js +47 -0
- package/features/SchedulePublishEntryUseCase/SchedulePublishEntryUseCase.js.map +1 -0
- package/features/SchedulePublishEntryUseCase/abstractions.d.ts +24 -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 +47 -0
- package/features/ScheduleUnpublishEntryUseCase/ScheduleUnpublishEntryUseCase.js.map +1 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.d.ts +24 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.js +5 -0
- package/features/ScheduleUnpublishEntryUseCase/abstractions.js.map +1 -0
- package/features/UnpublishActionHandler/UnpublishEntryActionHandler.d.ts +30 -0
- package/features/UnpublishActionHandler/UnpublishEntryActionHandler.js +69 -0
- package/features/UnpublishActionHandler/UnpublishEntryActionHandler.js.map +1 -0
- package/features/permissions/CmsSchedulerPermissions.d.ts +13 -0
- package/features/permissions/CmsSchedulerPermissions.js +31 -0
- package/features/permissions/CmsSchedulerPermissions.js.map +1 -0
- package/index.d.ts +1 -10
- package/index.js +1 -29
- package/package.json +21 -26
- package/types.d.ts +3 -10
- package/types.js +0 -7
- package/utils/namespace.d.ts +4 -0
- package/utils/namespace.js +9 -0
- package/utils/namespace.js.map +1 -0
- package/constants.d.ts +0 -11
- package/constants.js +0 -19
- package/constants.js.map +0 -1
- package/context.d.ts +0 -7
- package/context.js +0 -63
- package/context.js.map +0 -1
- package/graphql/index.d.ts +0 -3
- package/graphql/index.js +0 -204
- package/graphql/index.js.map +0 -1
- package/graphql/schema.d.ts +0 -217
- package/graphql/schema.js +0 -87
- package/graphql/schema.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/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 -33
- package/scheduler/ScheduleRecord.js +0 -56
- 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 -209
- package/scheduler/actions/PublishScheduleAction.js.map +0 -1
- package/scheduler/actions/UnpublishScheduleAction.d.ts +0 -26
- package/scheduler/actions/UnpublishScheduleAction.js +0 -199
- 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 -59
- package/scheduler/createScheduler.js.map +0 -1
- package/scheduler/dates.d.ts +0 -7
- 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 -92
- 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.js.map +0 -1
- package/utils/dateInTheFuture.d.ts +0 -6
- package/utils/dateInTheFuture.js +0 -19
- package/utils/dateInTheFuture.js.map +0 -1
package/handler/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createScheduledCmsActionEventHandler = void 0;
|
|
7
|
-
var _registry = require("@webiny/handler-aws/registry.js");
|
|
8
|
-
var _sourceHandler = require("@webiny/handler-aws/sourceHandler.js");
|
|
9
|
-
var _index = require("@webiny/handler-aws/raw/index.js");
|
|
10
|
-
var _constants = require("../constants.js");
|
|
11
|
-
var _Handler = require("./Handler.js");
|
|
12
|
-
var _PublishHandlerAction = require("./actions/PublishHandlerAction.js");
|
|
13
|
-
var _UnpublishHandlerAction = require("./actions/UnpublishHandlerAction.js");
|
|
14
|
-
const canHandle = event => {
|
|
15
|
-
if (typeof event?.hasOwnProperty !== "function") {
|
|
16
|
-
return false;
|
|
17
|
-
} else if (!event.hasOwnProperty(_constants.SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
const value = event[_constants.SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER];
|
|
21
|
-
return !!(value?.id && value?.scheduleOn);
|
|
22
|
-
};
|
|
23
|
-
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
24
|
-
name: "handler-aws-event-bridge-scheduled-cms-action-event",
|
|
25
|
-
canUse: event => {
|
|
26
|
-
return canHandle(event);
|
|
27
|
-
},
|
|
28
|
-
handle: async ({
|
|
29
|
-
params,
|
|
30
|
-
event,
|
|
31
|
-
context
|
|
32
|
-
}) => {
|
|
33
|
-
return (0, _index.createHandler)(params)(event, context);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
_registry.registry.register(handler);
|
|
37
|
-
const createScheduledCmsActionEventHandler = () => {
|
|
38
|
-
return (0, _index.createEventHandler)({
|
|
39
|
-
canHandle: event => {
|
|
40
|
-
return canHandle(event);
|
|
41
|
-
},
|
|
42
|
-
handle: async params => {
|
|
43
|
-
const {
|
|
44
|
-
payload,
|
|
45
|
-
context
|
|
46
|
-
} = params;
|
|
47
|
-
const handler = new _Handler.Handler({
|
|
48
|
-
actions: [new _PublishHandlerAction.PublishHandlerAction({
|
|
49
|
-
cms: context.cms
|
|
50
|
-
}), new _UnpublishHandlerAction.UnpublishHandlerAction({
|
|
51
|
-
cms: context.cms
|
|
52
|
-
})]
|
|
53
|
-
});
|
|
54
|
-
return handler.handle({
|
|
55
|
-
payload,
|
|
56
|
-
cms: context.cms,
|
|
57
|
-
security: context.security
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
exports.createScheduledCmsActionEventHandler = createScheduledCmsActionEventHandler;
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
package/handler/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_registry","require","_sourceHandler","_index","_constants","_Handler","_PublishHandlerAction","_UnpublishHandlerAction","canHandle","event","hasOwnProperty","SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER","value","id","scheduleOn","handler","createSourceHandler","name","canUse","handle","params","context","createHandler","registry","register","createScheduledCmsActionEventHandler","createEventHandler","payload","Handler","actions","PublishHandlerAction","cms","UnpublishHandlerAction","security","exports"],"sources":["index.ts"],"sourcesContent":["import { registry } from \"@webiny/handler-aws/registry.js\";\nimport type { HandlerFactoryParams } from \"@webiny/handler-aws/types.js\";\nimport { createSourceHandler } from \"@webiny/handler-aws/sourceHandler.js\";\nimport { createEventHandler, createHandler } from \"@webiny/handler-aws/raw/index.js\";\nimport { SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport type { IWebinyScheduledCmsActionEvent } from \"./Handler.js\";\nimport { Handler } from \"./Handler.js\";\nimport type { ScheduleContext } from \"~/types.js\";\nimport { PublishHandlerAction } from \"./actions/PublishHandlerAction.js\";\nimport { UnpublishHandlerAction } from \"./actions/UnpublishHandlerAction.js\";\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst canHandle = (event: Partial<IWebinyScheduledCmsActionEvent>): boolean => {\n if (typeof event?.hasOwnProperty !== \"function\") {\n return false;\n } else if (!event.hasOwnProperty(SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER)) {\n return false;\n }\n\n const value = event[SCHEDULED_CMS_ACTION_EVENT_IDENTIFIER];\n return !!(value?.id && value?.scheduleOn);\n};\n\nconst handler = createSourceHandler<IWebinyScheduledCmsActionEvent, HandlerParams>({\n name: \"handler-aws-event-bridge-scheduled-cms-action-event\",\n canUse: event => {\n return canHandle(event);\n },\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n\nexport const createScheduledCmsActionEventHandler = () => {\n return createEventHandler<IWebinyScheduledCmsActionEvent, ScheduleContext>({\n canHandle: event => {\n return canHandle(event);\n },\n handle: async params => {\n const { payload, context } = params;\n\n const handler = new Handler({\n actions: [\n new PublishHandlerAction({\n cms: context.cms\n }),\n new UnpublishHandlerAction({\n cms: context.cms\n })\n ]\n });\n\n return handler.handle({\n payload,\n cms: context.cms,\n security: context.security\n });\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,uBAAA,GAAAN,OAAA;AAMA,MAAMO,SAAS,GAAIC,KAA8C,IAAc;EAC3E,IAAI,OAAOA,KAAK,EAAEC,cAAc,KAAK,UAAU,EAAE;IAC7C,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACD,KAAK,CAACC,cAAc,CAACC,gDAAqC,CAAC,EAAE;IACrE,OAAO,KAAK;EAChB;EAEA,MAAMC,KAAK,GAAGH,KAAK,CAACE,gDAAqC,CAAC;EAC1D,OAAO,CAAC,EAAEC,KAAK,EAAEC,EAAE,IAAID,KAAK,EAAEE,UAAU,CAAC;AAC7C,CAAC;AAED,MAAMC,OAAO,GAAG,IAAAC,kCAAmB,EAAgD;EAC/EC,IAAI,EAAE,qDAAqD;EAC3DC,MAAM,EAAET,KAAK,IAAI;IACb,OAAOD,SAAS,CAACC,KAAK,CAAC;EAC3B,CAAC;EACDU,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAEX,KAAK;IAAEY;EAAQ,CAAC,KAAK;IAC1C,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACX,KAAK,EAAEY,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAACT,OAAO,CAAC;AAEnB,MAAMU,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAAC,yBAAkB,EAAkD;IACvElB,SAAS,EAAEC,KAAK,IAAI;MAChB,OAAOD,SAAS,CAACC,KAAK,CAAC;IAC3B,CAAC;IACDU,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAM;QAAEO,OAAO;QAAEN;MAAQ,CAAC,GAAGD,MAAM;MAEnC,MAAML,OAAO,GAAG,IAAIa,gBAAO,CAAC;QACxBC,OAAO,EAAE,CACL,IAAIC,0CAAoB,CAAC;UACrBC,GAAG,EAAEV,OAAO,CAACU;QACjB,CAAC,CAAC,EACF,IAAIC,8CAAsB,CAAC;UACvBD,GAAG,EAAEV,OAAO,CAACU;QACjB,CAAC,CAAC;MAEV,CAAC,CAAC;MAEF,OAAOhB,OAAO,CAACI,MAAM,CAAC;QAClBQ,OAAO;QACPI,GAAG,EAAEV,OAAO,CAACU,GAAG;QAChBE,QAAQ,EAAEZ,OAAO,CAACY;MACtB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAT,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
package/handler/types.d.ts
DELETED
package/handler/types.js
DELETED
package/handler/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IScheduleRecord } from \"~/scheduler/types.js\";\n\nexport interface IHandlerAction {\n canHandle(record: IScheduleRecord): boolean;\n handle(record: IScheduleRecord): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_context","require","_model","_index","_index2","createHeadlessCmsSchedule","params","createScheduledCmsActionEventHandler","createSchedulerModel","createHeadlessCmsScheduleContext","createSchedulerGraphQL","exports"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { ICreateHeadlessCmsSchedulerContextParams } from \"~/context.js\";\nimport { createHeadlessCmsScheduleContext } from \"~/context.js\";\nimport { createSchedulerModel } from \"~/scheduler/model.js\";\nimport { createSchedulerGraphQL } from \"~/graphql/index.js\";\nimport { createScheduledCmsActionEventHandler } from \"~/handler/index.js\";\n\nexport interface ICreateHeadlessCmsScheduleParams extends ICreateHeadlessCmsSchedulerContextParams {\n //\n}\n\n/**\n * This will register both API and Handler plugins for the Headless CMS Scheduler.\n * * Handler plugin will handle the scheduled CMS action event - a lambda call from the EventBridge Scheduler.\n * * API plugin will provide the GraphQL API and code for managing the scheduled CMS actions.\n */\nexport const createHeadlessCmsSchedule = (params: ICreateHeadlessCmsScheduleParams): Plugin[] => {\n return [\n /**\n * Handler for the Scheduled CMS Action Event.\n */\n createScheduledCmsActionEventHandler(),\n /**\n * API side of the scheduler.\n */\n createSchedulerModel(),\n createHeadlessCmsScheduleContext(params),\n createSchedulerGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAMA;AACA;AACA;AACA;AACA;AACO,MAAMI,yBAAyB,GAAIC,MAAwC,IAAe;EAC7F,OAAO;EACH;AACR;AACA;EACQ,IAAAC,4CAAoC,EAAC,CAAC;EACtC;AACR;AACA;EACQ,IAAAC,2BAAoB,EAAC,CAAC,EACtB,IAAAC,yCAAgC,EAACH,MAAM,CAAC,EACxC,IAAAI,6BAAsB,EAAC,CAAC,CAC3B;AACL,CAAC;AAACC,OAAA,CAAAN,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/manifest.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
-
export interface IGetManifestErrorResult {
|
|
3
|
-
error: Error;
|
|
4
|
-
data?: never;
|
|
5
|
-
}
|
|
6
|
-
export interface IGetManifestSuccessResult {
|
|
7
|
-
data: {
|
|
8
|
-
lambdaArn: string;
|
|
9
|
-
roleArn: string;
|
|
10
|
-
};
|
|
11
|
-
error?: never;
|
|
12
|
-
}
|
|
13
|
-
export type IGetManifestResult = IGetManifestSuccessResult | IGetManifestErrorResult;
|
|
14
|
-
export interface IGetManifestParams {
|
|
15
|
-
client: DynamoDBDocument;
|
|
16
|
-
}
|
|
17
|
-
export declare const getManifest: (params: IGetManifestParams) => Promise<IGetManifestResult>;
|
package/manifest.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getManifest = void 0;
|
|
8
|
-
var _api = require("@webiny/api");
|
|
9
|
-
var _utils = require("@webiny/utils");
|
|
10
|
-
var _zod = _interopRequireDefault(require("zod"));
|
|
11
|
-
const schema = _zod.default.object({
|
|
12
|
-
scheduler: _zod.default.object({
|
|
13
|
-
lambdaArn: _zod.default.string(),
|
|
14
|
-
roleArn: _zod.default.string()
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
const getManifest = async params => {
|
|
18
|
-
try {
|
|
19
|
-
_api.ServiceDiscovery.setDocumentClient(params.client);
|
|
20
|
-
const manifest = await _api.ServiceDiscovery.load();
|
|
21
|
-
if (!manifest) {
|
|
22
|
-
return {
|
|
23
|
-
error: new Error("Manifest could not be loaded.")
|
|
24
|
-
};
|
|
25
|
-
} else if (!manifest.scheduler) {
|
|
26
|
-
return {
|
|
27
|
-
error: new Error("Scheduler not found in the Manifest.")
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const result = await schema.safeParseAsync(manifest);
|
|
31
|
-
if (!result.success) {
|
|
32
|
-
return {
|
|
33
|
-
error: (0, _utils.createZodError)(result.error)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
data: result.data.scheduler
|
|
38
|
-
};
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
return {
|
|
41
|
-
error: ex
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
exports.getManifest = getManifest;
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=manifest.js.map
|
package/manifest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_api","require","_utils","_zod","_interopRequireDefault","schema","zod","object","scheduler","lambdaArn","string","roleArn","getManifest","params","ServiceDiscovery","setDocumentClient","client","manifest","load","error","Error","result","safeParseAsync","success","createZodError","data","ex","exports"],"sources":["manifest.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { createZodError } from \"@webiny/utils\";\nimport zod from \"zod\";\n\nconst schema = zod.object({\n scheduler: zod.object({\n lambdaArn: zod.string(),\n roleArn: zod.string()\n })\n});\n\nexport interface IGetManifestErrorResult {\n error: Error;\n data?: never;\n}\n\nexport interface IGetManifestSuccessResult {\n data: {\n lambdaArn: string;\n roleArn: string;\n };\n error?: never;\n}\n\nexport type IGetManifestResult = IGetManifestSuccessResult | IGetManifestErrorResult;\n\nexport interface IGetManifestParams {\n client: DynamoDBDocument;\n}\n\nexport const getManifest = async (params: IGetManifestParams): Promise<IGetManifestResult> => {\n try {\n ServiceDiscovery.setDocumentClient(params.client);\n const manifest = await ServiceDiscovery.load();\n if (!manifest) {\n return {\n error: new Error(\"Manifest could not be loaded.\")\n };\n } else if (!manifest.scheduler) {\n return {\n error: new Error(\"Scheduler not found in the Manifest.\")\n };\n }\n\n const result = await schema.safeParseAsync(manifest);\n if (!result.success) {\n return {\n error: createZodError(result.error)\n };\n }\n\n return {\n data: result.data.scheduler\n };\n } catch (ex) {\n return {\n error: ex\n };\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,MAAM,GAAGC,YAAG,CAACC,MAAM,CAAC;EACtBC,SAAS,EAAEF,YAAG,CAACC,MAAM,CAAC;IAClBE,SAAS,EAAEH,YAAG,CAACI,MAAM,CAAC,CAAC;IACvBC,OAAO,EAAEL,YAAG,CAACI,MAAM,CAAC;EACxB,CAAC;AACL,CAAC,CAAC;AAqBK,MAAME,WAAW,GAAG,MAAOC,MAA0B,IAAkC;EAC1F,IAAI;IACAC,qBAAgB,CAACC,iBAAiB,CAACF,MAAM,CAACG,MAAM,CAAC;IACjD,MAAMC,QAAQ,GAAG,MAAMH,qBAAgB,CAACI,IAAI,CAAC,CAAC;IAC9C,IAAI,CAACD,QAAQ,EAAE;MACX,OAAO;QACHE,KAAK,EAAE,IAAIC,KAAK,CAAC,+BAA+B;MACpD,CAAC;IACL,CAAC,MAAM,IAAI,CAACH,QAAQ,CAACT,SAAS,EAAE;MAC5B,OAAO;QACHW,KAAK,EAAE,IAAIC,KAAK,CAAC,sCAAsC;MAC3D,CAAC;IACL;IAEA,MAAMC,MAAM,GAAG,MAAMhB,MAAM,CAACiB,cAAc,CAACL,QAAQ,CAAC;IACpD,IAAI,CAACI,MAAM,CAACE,OAAO,EAAE;MACjB,OAAO;QACHJ,KAAK,EAAE,IAAAK,qBAAc,EAACH,MAAM,CAACF,KAAK;MACtC,CAAC;IACL;IAEA,OAAO;MACHM,IAAI,EAAEJ,MAAM,CAACI,IAAI,CAACjB;IACtB,CAAC;EACL,CAAC,CAAC,OAAOkB,EAAE,EAAE;IACT,OAAO;MACHP,KAAK,EAAEO;IACX,CAAC;EACL;AACJ,CAAC;AAACC,OAAA,CAAAf,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type IScheduleAction, type IScheduleExecutor, type IScheduleFetcher, type IScheduleRecord, type ISchedulerInput } from "./types.js";
|
|
2
|
-
import type { PublishScheduleActionCms } from "./actions/PublishScheduleAction.js";
|
|
3
|
-
import type { UnpublishScheduleActionCms } from "./actions/UnpublishScheduleAction.js";
|
|
4
|
-
export type ScheduleExecutorCms = UnpublishScheduleActionCms & PublishScheduleActionCms;
|
|
5
|
-
export interface IScheduleExecutorParams {
|
|
6
|
-
actions: IScheduleAction[];
|
|
7
|
-
fetcher: IScheduleFetcher;
|
|
8
|
-
}
|
|
9
|
-
export declare class ScheduleExecutor implements IScheduleExecutor {
|
|
10
|
-
private readonly actions;
|
|
11
|
-
private readonly fetcher;
|
|
12
|
-
constructor(params: IScheduleExecutorParams);
|
|
13
|
-
schedule(targetId: string, input: ISchedulerInput): Promise<IScheduleRecord>;
|
|
14
|
-
cancel(initialId: string): Promise<IScheduleRecord>;
|
|
15
|
-
private getAction;
|
|
16
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ScheduleExecutor = void 0;
|
|
7
|
-
var _createScheduleRecordId = require("./createScheduleRecordId.js");
|
|
8
|
-
var _error = require("@webiny/error");
|
|
9
|
-
class ScheduleExecutor {
|
|
10
|
-
constructor(params) {
|
|
11
|
-
this.actions = params.actions;
|
|
12
|
-
this.fetcher = params.fetcher;
|
|
13
|
-
}
|
|
14
|
-
async schedule(targetId, input) {
|
|
15
|
-
const scheduleRecordId = (0, _createScheduleRecordId.createScheduleRecordIdWithVersion)(targetId);
|
|
16
|
-
const original = await this.fetcher.getScheduled(targetId);
|
|
17
|
-
const action = this.getAction(input.type);
|
|
18
|
-
if (original) {
|
|
19
|
-
return action.reschedule(original, input);
|
|
20
|
-
}
|
|
21
|
-
return await action.schedule({
|
|
22
|
-
scheduleRecordId,
|
|
23
|
-
targetId,
|
|
24
|
-
input
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async cancel(initialId) {
|
|
28
|
-
const id = (0, _createScheduleRecordId.createScheduleRecordIdWithVersion)(initialId);
|
|
29
|
-
const original = await this.fetcher.getScheduled(id);
|
|
30
|
-
if (!original) {
|
|
31
|
-
throw new _error.WebinyError(`No scheduled record found for ID "${id}".`, "SCHEDULED_RECORD_NOT_FOUND", {
|
|
32
|
-
id
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const action = this.getAction(original.type);
|
|
36
|
-
await action.cancel(original.id);
|
|
37
|
-
return original;
|
|
38
|
-
}
|
|
39
|
-
getAction(type) {
|
|
40
|
-
const action = this.actions.find(action => {
|
|
41
|
-
return action.canHandle({
|
|
42
|
-
type
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
if (action) {
|
|
46
|
-
return action;
|
|
47
|
-
}
|
|
48
|
-
throw new _error.WebinyError(`No action found for input type "${type}".`, "NO_ACTION_FOUND", {
|
|
49
|
-
type
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.ScheduleExecutor = ScheduleExecutor;
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=ScheduleExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_createScheduleRecordId","require","_error","ScheduleExecutor","constructor","params","actions","fetcher","schedule","targetId","input","scheduleRecordId","createScheduleRecordIdWithVersion","original","getScheduled","action","getAction","type","reschedule","cancel","initialId","id","WebinyError","find","canHandle","exports"],"sources":["ScheduleExecutor.ts"],"sourcesContent":["import type { ScheduleType } from \"~/scheduler/types.js\";\nimport {\n type IScheduleAction,\n type IScheduleExecutor,\n type IScheduleFetcher,\n type IScheduleRecord,\n type ISchedulerInput\n} from \"~/scheduler/types.js\";\nimport { createScheduleRecordIdWithVersion } from \"~/scheduler/createScheduleRecordId.js\";\nimport type { PublishScheduleActionCms } from \"~/scheduler/actions/PublishScheduleAction.js\";\nimport type { UnpublishScheduleActionCms } from \"~/scheduler/actions/UnpublishScheduleAction.js\";\nimport { WebinyError } from \"@webiny/error\";\n\nexport type ScheduleExecutorCms = UnpublishScheduleActionCms & PublishScheduleActionCms;\n\nexport interface IScheduleExecutorParams {\n actions: IScheduleAction[];\n fetcher: IScheduleFetcher;\n}\n\nexport class ScheduleExecutor implements IScheduleExecutor {\n private readonly actions: IScheduleAction[];\n private readonly fetcher: Pick<IScheduleFetcher, \"getScheduled\">;\n\n constructor(params: IScheduleExecutorParams) {\n this.actions = params.actions;\n this.fetcher = params.fetcher;\n }\n\n public async schedule(targetId: string, input: ISchedulerInput): Promise<IScheduleRecord> {\n const scheduleRecordId = createScheduleRecordIdWithVersion(targetId);\n const original = await this.fetcher.getScheduled(targetId);\n\n const action = this.getAction(input.type);\n\n if (original) {\n return action.reschedule(original, input);\n }\n\n return await action.schedule({\n scheduleRecordId,\n targetId,\n input\n });\n }\n\n public async cancel(initialId: string): Promise<IScheduleRecord> {\n const id = createScheduleRecordIdWithVersion(initialId);\n const original = await this.fetcher.getScheduled(id);\n if (!original) {\n throw new WebinyError(\n `No scheduled record found for ID \"${id}\".`,\n \"SCHEDULED_RECORD_NOT_FOUND\",\n {\n id\n }\n );\n }\n\n const action = this.getAction(original.type);\n await action.cancel(original.id);\n return original;\n }\n\n private getAction(type: ScheduleType): IScheduleAction {\n const action = this.actions.find(action => {\n return action.canHandle({\n type\n });\n });\n if (action) {\n return action;\n }\n throw new WebinyError(`No action found for input type \"${type}\".`, \"NO_ACTION_FOUND\", {\n type\n });\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,uBAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,gBAAgB,CAA8B;EAIvDC,WAAWA,CAACC,MAA+B,EAAE;IACzC,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;EAEA,MAAaC,QAAQA,CAACC,QAAgB,EAAEC,KAAsB,EA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,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAAtB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type { IScheduleFetcher, IScheduleRecord, ISchedulerListParams, ISchedulerListResponse } from "./types.js";
|
|
3
|
-
export type ScheduleFetcherCms = Pick<HeadlessCms, "getEntryById" | "listLatestEntries">;
|
|
4
|
-
export interface IScheduleFetcherParams {
|
|
5
|
-
cms: ScheduleFetcherCms;
|
|
6
|
-
targetModel: CmsModel;
|
|
7
|
-
scheduleModel: CmsModel;
|
|
8
|
-
}
|
|
9
|
-
export declare class ScheduleFetcher implements IScheduleFetcher {
|
|
10
|
-
private readonly cms;
|
|
11
|
-
private readonly targetModel;
|
|
12
|
-
private readonly scheduleModel;
|
|
13
|
-
constructor(params: IScheduleFetcherParams);
|
|
14
|
-
getScheduled(targetId: string): Promise<IScheduleRecord | null>;
|
|
15
|
-
listScheduled(params: ISchedulerListParams): Promise<ISchedulerListResponse>;
|
|
16
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ScheduleFetcher = void 0;
|
|
7
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
-
var _createScheduleRecordId = require("./createScheduleRecordId.js");
|
|
9
|
-
var _ScheduleRecord = require("./ScheduleRecord.js");
|
|
10
|
-
var _utils = require("@webiny/utils");
|
|
11
|
-
class ScheduleFetcher {
|
|
12
|
-
constructor(params) {
|
|
13
|
-
this.cms = params.cms;
|
|
14
|
-
this.scheduleModel = params.scheduleModel;
|
|
15
|
-
this.targetModel = params.targetModel;
|
|
16
|
-
}
|
|
17
|
-
async getScheduled(targetId) {
|
|
18
|
-
const scheduleRecordId = (0, _createScheduleRecordId.createScheduleRecordIdWithVersion)(targetId);
|
|
19
|
-
try {
|
|
20
|
-
const entry = await this.cms.getEntryById(this.scheduleModel, scheduleRecordId);
|
|
21
|
-
return (0, _ScheduleRecord.transformScheduleEntry)(this.targetModel, entry);
|
|
22
|
-
} catch (ex) {
|
|
23
|
-
if (ex.code === "NOT_FOUND" || ex instanceof _handlerGraphql.NotFoundError) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
console.error(`Error while fetching scheduled record: ${targetId}.`);
|
|
27
|
-
console.log((0, _utils.convertException)(ex));
|
|
28
|
-
throw ex;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async listScheduled(params) {
|
|
32
|
-
const [data, meta] = await this.cms.listLatestEntries(this.scheduleModel, {
|
|
33
|
-
sort: params.sort,
|
|
34
|
-
limit: params.limit,
|
|
35
|
-
/**
|
|
36
|
-
* When params
|
|
37
|
-
*/
|
|
38
|
-
where: {
|
|
39
|
-
...params.where
|
|
40
|
-
},
|
|
41
|
-
after: params.after
|
|
42
|
-
});
|
|
43
|
-
return {
|
|
44
|
-
data: data.map(item => (0, _ScheduleRecord.transformScheduleEntry)(this.targetModel, item)),
|
|
45
|
-
meta
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ScheduleFetcher = ScheduleFetcher;
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=ScheduleFetcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_createScheduleRecordId","_ScheduleRecord","_utils","ScheduleFetcher","constructor","params","cms","scheduleModel","targetModel","getScheduled","targetId","scheduleRecordId","createScheduleRecordIdWithVersion","entry","getEntryById","transformScheduleEntry","ex","code","NotFoundError","console","error","log","convertException","listScheduled","data","meta","listLatestEntries","sort","limit","where","after","map","item","exports"],"sources":["ScheduleFetcher.ts"],"sourcesContent":["import type { CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport type {\n IScheduleEntryValues,\n IScheduleFetcher,\n IScheduleRecord,\n ISchedulerListParams,\n ISchedulerListResponse\n} from \"~/scheduler/types.js\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createScheduleRecordIdWithVersion } from \"~/scheduler/createScheduleRecordId.js\";\nimport { transformScheduleEntry } from \"~/scheduler/ScheduleRecord.js\";\nimport { convertException } from \"@webiny/utils\";\n\nexport type ScheduleFetcherCms = Pick<HeadlessCms, \"getEntryById\" | \"listLatestEntries\">;\n\nexport interface IScheduleFetcherParams {\n cms: ScheduleFetcherCms;\n targetModel: CmsModel;\n scheduleModel: CmsModel;\n}\n\nexport class ScheduleFetcher implements IScheduleFetcher {\n private readonly cms: ScheduleFetcherCms;\n private readonly targetModel: CmsModel;\n private readonly scheduleModel: CmsModel;\n\n constructor(params: IScheduleFetcherParams) {\n this.cms = params.cms;\n this.scheduleModel = params.scheduleModel;\n this.targetModel = params.targetModel;\n }\n\n public async getScheduled(targetId: string): Promise<IScheduleRecord | null> {\n const scheduleRecordId = createScheduleRecordIdWithVersion(targetId);\n try {\n const entry = await this.cms.getEntryById<IScheduleEntryValues>(\n this.scheduleModel,\n scheduleRecordId\n );\n return transformScheduleEntry(this.targetModel, entry);\n } catch (ex) {\n if (ex.code === \"NOT_FOUND\" || ex instanceof NotFoundError) {\n return null;\n }\n console.error(`Error while fetching scheduled record: ${targetId}.`);\n console.log(convertException(ex));\n throw ex;\n }\n }\n\n public async listScheduled(params: ISchedulerListParams): Promise<ISchedulerListResponse> {\n const [data, meta] = await this.cms.listLatestEntries<IScheduleEntryValues>(\n this.scheduleModel,\n {\n sort: params.sort,\n limit: params.limit,\n /**\n * When params\n */\n where: {\n ...params.where\n },\n after: params.after\n }\n );\n\n return {\n data: data.map(item => transformScheduleEntry(this.targetModel, item)),\n meta\n };\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IA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ED,OAAO;MACHN,IAAI,EAAEA,IAAI,CAACO,GAAG,CAACC,IAAI,IAAI,IAAAjB,sCAAsB,EAAC,IAAI,CAACP,WAAW,EAAEwB,IAAI,CAAC,CAAC;MACtEP;IACJ,CAAC;EACL;AACJ;AAACQ,OAAA,CAAA9B,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type DateOnType, type IScheduleEntryValues, type IScheduleRecord, type ScheduledOnType, ScheduleType } from "./types.js";
|
|
2
|
-
import type { CmsEntry, CmsIdentity, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
export interface IScheduleRecordParams {
|
|
4
|
-
id: string;
|
|
5
|
-
targetId: string;
|
|
6
|
-
model: CmsModel;
|
|
7
|
-
scheduledBy: CmsIdentity;
|
|
8
|
-
/**
|
|
9
|
-
* The date when the schedule is to be executed.
|
|
10
|
-
*/
|
|
11
|
-
scheduledOn: ScheduledOnType;
|
|
12
|
-
/**
|
|
13
|
-
* The date when the action is to be set as done.
|
|
14
|
-
* User can set publishedOn (and other relevant dates) with this parameter.
|
|
15
|
-
*/
|
|
16
|
-
dateOn: DateOnType | undefined;
|
|
17
|
-
type: ScheduleType;
|
|
18
|
-
title: string;
|
|
19
|
-
}
|
|
20
|
-
export declare class ScheduleRecord implements IScheduleRecord {
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly targetId: string;
|
|
23
|
-
readonly model: CmsModel;
|
|
24
|
-
readonly scheduledBy: CmsIdentity;
|
|
25
|
-
readonly publishOn: ScheduledOnType | undefined;
|
|
26
|
-
readonly unpublishOn: ScheduledOnType | undefined;
|
|
27
|
-
readonly dateOn: DateOnType | undefined;
|
|
28
|
-
readonly type: ScheduleType;
|
|
29
|
-
readonly title: string;
|
|
30
|
-
constructor(record: IScheduleRecordParams);
|
|
31
|
-
}
|
|
32
|
-
export declare const createScheduleRecord: (record: IScheduleRecordParams) => IScheduleRecord;
|
|
33
|
-
export declare const transformScheduleEntry: (targetModel: CmsModel, entry: CmsEntry<IScheduleEntryValues>) => IScheduleRecord;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.transformScheduleEntry = exports.createScheduleRecord = exports.ScheduleRecord = void 0;
|
|
7
|
-
var _types = require("./types.js");
|
|
8
|
-
var _error = require("@webiny/error");
|
|
9
|
-
var _dates = require("./dates.js");
|
|
10
|
-
class ScheduleRecord {
|
|
11
|
-
constructor(record) {
|
|
12
|
-
this.id = record.id;
|
|
13
|
-
this.targetId = record.targetId;
|
|
14
|
-
this.model = record.model;
|
|
15
|
-
this.scheduledBy = record.scheduledBy;
|
|
16
|
-
this.dateOn = record.dateOn;
|
|
17
|
-
this.publishOn = record.type === _types.ScheduleType.publish ? record.scheduledOn : undefined;
|
|
18
|
-
this.unpublishOn = record.type === _types.ScheduleType.unpublish ? record.scheduledOn : undefined;
|
|
19
|
-
this.type = record.type;
|
|
20
|
-
this.title = record.title;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.ScheduleRecord = ScheduleRecord;
|
|
24
|
-
const createScheduleRecord = record => {
|
|
25
|
-
return new ScheduleRecord(record);
|
|
26
|
-
};
|
|
27
|
-
exports.createScheduleRecord = createScheduleRecord;
|
|
28
|
-
const transformScheduleEntry = (targetModel, entry) => {
|
|
29
|
-
let type;
|
|
30
|
-
switch (entry.values.type) {
|
|
31
|
-
case _types.ScheduleType.publish:
|
|
32
|
-
type = _types.ScheduleType.publish;
|
|
33
|
-
break;
|
|
34
|
-
case _types.ScheduleType.unpublish:
|
|
35
|
-
type = _types.ScheduleType.unpublish;
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
throw new _error.WebinyError(`Unsupported schedule type "${entry.values.type}".`, "UNSUPPORTED_SCHEDULE_TYPE", {
|
|
39
|
-
type: entry.values.type,
|
|
40
|
-
entry
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return createScheduleRecord({
|
|
44
|
-
id: entry.id,
|
|
45
|
-
type,
|
|
46
|
-
title: entry.values.title,
|
|
47
|
-
targetId: entry.values.targetId,
|
|
48
|
-
scheduledOn: new Date(entry.values.scheduledOn),
|
|
49
|
-
dateOn: (0, _dates.isoStringToDate)(entry.values.dateOn),
|
|
50
|
-
scheduledBy: entry.savedBy,
|
|
51
|
-
model: targetModel
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
exports.transformScheduleEntry = transformScheduleEntry;
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=ScheduleRecord.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_error","_dates","ScheduleRecord","constructor","record","id","targetId","model","scheduledBy","dateOn","publishOn","type","ScheduleType","publish","scheduledOn","undefined","unpublishOn","unpublish","title","exports","createScheduleRecord","transformScheduleEntry","targetModel","entry","values","WebinyError","Date","isoStringToDate","savedBy"],"sources":["ScheduleRecord.ts"],"sourcesContent":["import {\n type DateOnType,\n type IScheduleEntryValues,\n type IScheduleRecord,\n type ScheduledOnType,\n ScheduleType\n} from \"~/scheduler/types.js\";\nimport type { CmsEntry, CmsIdentity, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { isoStringToDate } from \"~/scheduler/dates.js\";\n\nexport interface IScheduleRecordParams {\n id: string;\n targetId: string;\n model: CmsModel;\n scheduledBy: CmsIdentity;\n /**\n * The date when the schedule is to be executed.\n */\n scheduledOn: ScheduledOnType;\n /**\n * The date when the action is to be set as done.\n * User can set publishedOn (and other relevant dates) with this parameter.\n */\n dateOn: DateOnType | undefined;\n type: ScheduleType;\n title: string;\n}\n\nexport class ScheduleRecord implements IScheduleRecord {\n public readonly id: string;\n public readonly targetId: string;\n public readonly model: CmsModel;\n public readonly scheduledBy: CmsIdentity;\n public readonly publishOn: ScheduledOnType | undefined;\n public readonly unpublishOn: ScheduledOnType | undefined;\n public readonly dateOn: DateOnType | undefined;\n public readonly type: ScheduleType;\n public readonly title: string;\n\n public constructor(record: IScheduleRecordParams) {\n this.id = record.id;\n this.targetId = record.targetId;\n this.model = record.model;\n this.scheduledBy = record.scheduledBy;\n this.dateOn = record.dateOn;\n this.publishOn = record.type === ScheduleType.publish ? record.scheduledOn : undefined;\n this.unpublishOn = record.type === ScheduleType.unpublish ? record.scheduledOn : undefined;\n this.type = record.type;\n this.title = record.title;\n }\n}\n\nexport const createScheduleRecord = (record: IScheduleRecordParams): IScheduleRecord => {\n return new ScheduleRecord(record);\n};\n\nexport const transformScheduleEntry = (\n targetModel: CmsModel,\n entry: CmsEntry<IScheduleEntryValues>\n): IScheduleRecord => {\n let type: ScheduleType;\n switch (entry.values.type) {\n case ScheduleType.publish:\n type = ScheduleType.publish;\n break;\n case ScheduleType.unpublish:\n type = ScheduleType.unpublish;\n break;\n default:\n throw new WebinyError(\n `Unsupported schedule type \"${entry.values.type}\".`,\n \"UNSUPPORTED_SCHEDULE_TYPE\",\n {\n type: entry.values.type,\n entry\n }\n );\n }\n return createScheduleRecord({\n id: entry.id,\n type,\n title: entry.values.title,\n targetId: entry.values.targetId,\n scheduledOn: new Date(entry.values.scheduledOn),\n dateOn: isoStringToDate(entry.values.dateOn),\n scheduledBy: entry.savedBy,\n model: targetModel\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAoBO,MAAMG,cAAc,CAA4B;EAW5CC,WAAWA,CAACC,MAA6B,EAAE;IAC9C,IAAI,CAACC,EAAE,GAAGD,MAAM,CAACC,EAAE;IACnB,IAAI,CAACC,QAAQ,GAAGF,MAAM,CAACE,QAAQ;IAC/B,IAAI,CAACC,KAAK,GAAGH,MAAM,CAACG,KAAK;IACzB,IAAI,CAACC,WAAW,GAAGJ,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MAAM,CAAClB,QAAQ;IAC/BQ,WAAW,EAAE,IAAIY,IAAI,CAACH,KAAK,CAACC,MAAM,CAACV,WAAW,CAAC;IAC/CL,MAAM,EAAE,IAAAkB,sBAAe,EAACJ,KAAK,CAACC,MAAM,CAACf,MAAM,CAAC;IAC5CD,WAAW,EAAEe,KAAK,CAACK,OAAO;IAC1BrB,KAAK,EAAEe;EACX,CAAC,CAAC;AACN,CAAC;AAACH,OAAA,CAAAE,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
package/scheduler/Scheduler.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IScheduleExecutor, IScheduleFetcher, IScheduler, IScheduleRecord, ISchedulerInput, ISchedulerListParams, ISchedulerListResponse } from "./types.js";
|
|
2
|
-
export interface ISchedulerParams {
|
|
3
|
-
fetcher: IScheduleFetcher;
|
|
4
|
-
executor: IScheduleExecutor;
|
|
5
|
-
}
|
|
6
|
-
export declare class Scheduler implements IScheduler {
|
|
7
|
-
private readonly fetcher;
|
|
8
|
-
private readonly executor;
|
|
9
|
-
constructor(params: ISchedulerParams);
|
|
10
|
-
getScheduled(targetId: string): Promise<IScheduleRecord | null>;
|
|
11
|
-
listScheduled(params: ISchedulerListParams): Promise<ISchedulerListResponse>;
|
|
12
|
-
schedule(targetId: string, input: ISchedulerInput): Promise<IScheduleRecord>;
|
|
13
|
-
cancel(id: string): Promise<IScheduleRecord>;
|
|
14
|
-
}
|
package/scheduler/Scheduler.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Scheduler = void 0;
|
|
7
|
-
class Scheduler {
|
|
8
|
-
constructor(params) {
|
|
9
|
-
this.fetcher = params.fetcher;
|
|
10
|
-
this.executor = params.executor;
|
|
11
|
-
}
|
|
12
|
-
async getScheduled(targetId) {
|
|
13
|
-
return this.fetcher.getScheduled(targetId);
|
|
14
|
-
}
|
|
15
|
-
async listScheduled(params) {
|
|
16
|
-
return this.fetcher.listScheduled(params);
|
|
17
|
-
}
|
|
18
|
-
async schedule(targetId, input) {
|
|
19
|
-
return this.executor.schedule(targetId, input);
|
|
20
|
-
}
|
|
21
|
-
async cancel(id) {
|
|
22
|
-
return this.executor.cancel(id);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.Scheduler = Scheduler;
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=Scheduler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Scheduler","constructor","params","fetcher","executor","getScheduled","targetId","listScheduled","schedule","input","cancel","id","exports"],"sources":["Scheduler.ts"],"sourcesContent":["import type {\n IScheduleExecutor,\n IScheduleFetcher,\n IScheduler,\n IScheduleRecord,\n ISchedulerInput,\n ISchedulerListParams,\n ISchedulerListResponse\n} from \"~/scheduler/types.js\";\n\nexport interface ISchedulerParams {\n fetcher: IScheduleFetcher;\n executor: IScheduleExecutor;\n}\n\nexport class Scheduler implements IScheduler {\n private readonly fetcher: IScheduleFetcher;\n private readonly executor: IScheduleExecutor;\n\n constructor(params: ISchedulerParams) {\n this.fetcher = params.fetcher;\n this.executor = params.executor;\n }\n\n public async getScheduled(targetId: string): Promise<IScheduleRecord | null> {\n return this.fetcher.getScheduled(targetId);\n }\n\n public async listScheduled(params: ISchedulerListParams): Promise<ISchedulerListResponse> {\n return this.fetcher.listScheduled(params);\n }\n\n public async schedule(targetId: string, input: ISchedulerInput): Promise<IScheduleRecord> {\n return this.executor.schedule(targetId, input);\n }\n\n public async cancel(id: string): Promise<IScheduleRecord> {\n return this.executor.cancel(id);\n }\n}\n"],"mappings":";;;;;;AAeO,MAAMA,SAAS,CAAuB;EAIzCC,WAAWA,CAACC,MAAwB,EAAE;IAClC,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,QAAQ,GAAGF,MAAM,CAACE,QAAQ;EACnC;EAEA,MAAaC,YAAYA,CAACC,QAAgB,EAAmC;IACzE,OAAO,IAAI,CAACH,OAAO,CAACE,YAAY,CAACC,QAAQ,CAAC;EAC9C;EAEA,MAAaC,aAAaA,CAACL,MAA4B,EAAmC;IACtF,OAAO,IAAI,CAACC,OAAO,CAACI,aAAa,CAACL,MAAM,CAAC;EAC7C;EAEA,MAAaM,QAAQA,CAACF,QAAgB,EAAEG,KAAsB,EAA4B;IACtF,OAAO,IAAI,CAACL,QAAQ,CAACI,QAAQ,CAACF,QAAQ,EAAEG,KAAK,CAAC;EAClD;EAEA,MAAaC,MAAMA,CAACC,EAAU,EAA4B;IACtD,OAAO,IAAI,CAACP,QAAQ,CAACM,MAAM,CAACC,EAAE,CAAC;EACnC;AACJ;AAACC,OAAA,CAAAZ,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { IScheduleAction, IScheduleActionScheduleParams, IScheduleFetcher, IScheduleRecord, ISchedulerInput } from "../types.js";
|
|
2
|
-
import type { CmsIdentity, CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import type { ISchedulerService } from "../../service/types.js";
|
|
4
|
-
export type PublishScheduleActionCms = Pick<HeadlessCms, "getEntryById" | "publishEntry" | "createEntry" | "updateEntry" | "deleteEntry">;
|
|
5
|
-
export interface IPublishScheduleActionParams {
|
|
6
|
-
service: ISchedulerService;
|
|
7
|
-
cms: PublishScheduleActionCms;
|
|
8
|
-
targetModel: CmsModel;
|
|
9
|
-
scheduleModel: CmsModel;
|
|
10
|
-
getIdentity: () => CmsIdentity;
|
|
11
|
-
fetcher: IScheduleFetcher;
|
|
12
|
-
}
|
|
13
|
-
export declare class PublishScheduleAction implements IScheduleAction {
|
|
14
|
-
private readonly service;
|
|
15
|
-
private readonly cms;
|
|
16
|
-
private readonly targetModel;
|
|
17
|
-
private readonly scheduleModel;
|
|
18
|
-
private readonly getIdentity;
|
|
19
|
-
private readonly fetcher;
|
|
20
|
-
constructor(params: IPublishScheduleActionParams);
|
|
21
|
-
canHandle(input: ISchedulerInput): boolean;
|
|
22
|
-
schedule(params: IScheduleActionScheduleParams): Promise<IScheduleRecord>;
|
|
23
|
-
reschedule(original: IScheduleRecord, input: ISchedulerInput): Promise<IScheduleRecord>;
|
|
24
|
-
cancel(id: string): Promise<void>;
|
|
25
|
-
private getUpdateableTargetEntry;
|
|
26
|
-
}
|