@webiny/api-scheduler 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants.d.ts +5 -0
- package/constants.js +11 -8
- package/constants.js.map +1 -1
- package/context.d.ts +1 -1
- package/context.js +32 -26
- package/context.js.map +1 -1
- package/createEventHandler.d.ts +1 -0
- package/createEventHandler.js +26 -39
- package/createEventHandler.js.map +1 -1
- package/createScheduler.d.ts +1 -1
- package/createScheduler.js +5 -7
- package/createScheduler.js.map +1 -1
- package/domain/SchedulePrivateModel.js +25 -22
- package/domain/SchedulePrivateModel.js.map +1 -1
- package/domain/ScheduledActionId.js +12 -4
- package/domain/ScheduledActionId.js.map +1 -1
- package/domain/ScheduledActionIdWithVersion.js +5 -6
- package/domain/ScheduledActionIdWithVersion.js.map +1 -1
- package/domain/ScheduledActionMapper.d.ts +16 -0
- package/domain/ScheduledActionMapper.js +36 -0
- package/domain/ScheduledActionMapper.js.map +1 -0
- package/domain/errors.d.ts +19 -1
- package/domain/errors.js +54 -56
- package/domain/errors.js.map +1 -1
- package/domain/isValidDate.d.ts +1 -1
- package/domain/isValidDate.js +4 -9
- package/domain/isValidDate.js.map +1 -1
- package/domain/permissionsSchema.d.ts +9 -0
- package/domain/permissionsSchema.js +18 -0
- package/domain/permissionsSchema.js.map +1 -0
- package/exports/api/scheduler.d.ts +10 -0
- package/exports/api/scheduler.js +8 -0
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +4 -2
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +45 -61
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
- package/features/CancelScheduledAction/abstractions.d.ts +9 -2
- package/features/CancelScheduledAction/abstractions.js +2 -10
- package/features/CancelScheduledAction/abstractions.js.map +1 -1
- package/features/CancelScheduledAction/feature.d.ts +4 -1
- package/features/CancelScheduledAction/feature.js +6 -12
- package/features/CancelScheduledAction/feature.js.map +1 -1
- package/features/CancelScheduledAction/index.js +0 -2
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +1 -1
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +65 -89
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
- package/features/ExecuteScheduledAction/abstractions.d.ts +9 -2
- package/features/ExecuteScheduledAction/abstractions.js +12 -36
- package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
- package/features/ExecuteScheduledAction/feature.d.ts +4 -1
- package/features/ExecuteScheduledAction/feature.js +7 -13
- package/features/ExecuteScheduledAction/feature.js.map +1 -1
- package/features/ExecuteScheduledAction/index.js +0 -2
- package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +6 -2
- package/features/GetScheduledAction/GetScheduledActionUseCase.js +38 -39
- package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
- package/features/GetScheduledAction/abstractions.d.ts +9 -2
- package/features/GetScheduledAction/abstractions.js +2 -11
- package/features/GetScheduledAction/abstractions.js.map +1 -1
- package/features/GetScheduledAction/feature.d.ts +4 -1
- package/features/GetScheduledAction/feature.js +6 -12
- package/features/GetScheduledAction/feature.js.map +1 -1
- package/features/GetScheduledAction/index.js +0 -2
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +32 -0
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +64 -0
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
- package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
- package/features/GetTargetScheduledAction/abstractions.js +5 -0
- package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
- package/features/GetTargetScheduledAction/feature.d.ts +10 -0
- package/features/GetTargetScheduledAction/feature.js +11 -0
- package/features/GetTargetScheduledAction/feature.js.map +1 -0
- package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -2
- package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -1
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js +53 -67
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
- package/features/ListScheduledActions/abstractions.d.ts +11 -3
- package/features/ListScheduledActions/abstractions.js +2 -12
- package/features/ListScheduledActions/abstractions.js.map +1 -1
- package/features/ListScheduledActions/feature.d.ts +4 -1
- package/features/ListScheduledActions/feature.js +6 -12
- package/features/ListScheduledActions/feature.js.map +1 -1
- package/features/ListScheduledActions/index.js +0 -2
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +26 -0
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
- package/features/NamespaceHandler/abstractions.d.ts +50 -0
- package/features/NamespaceHandler/abstractions.js +6 -0
- package/features/NamespaceHandler/abstractions.js.map +1 -0
- package/features/NamespaceHandler/index.d.ts +1 -0
- package/features/NamespaceHandler/index.js +1 -0
- package/features/ScheduleAction/ScheduleActionUseCase.d.ts +4 -4
- package/features/ScheduleAction/ScheduleActionUseCase.js +146 -143
- package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
- package/features/ScheduleAction/abstractions.d.ts +11 -11
- package/features/ScheduleAction/abstractions.js +2 -10
- package/features/ScheduleAction/abstractions.js.map +1 -1
- package/features/ScheduleAction/feature.d.ts +4 -1
- package/features/ScheduleAction/feature.js +6 -12
- package/features/ScheduleAction/feature.js.map +1 -1
- package/features/ScheduleAction/index.js +0 -2
- package/features/SchedulerFeature.d.ts +4 -1
- package/features/SchedulerFeature.js +12 -20
- package/features/SchedulerFeature.js.map +1 -1
- package/features/SchedulerService/EventBridgeSchedulerService.d.ts +1 -1
- package/features/SchedulerService/EventBridgeSchedulerService.js +86 -120
- package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
- package/features/SchedulerService/VoidSchedulerService.js +17 -24
- package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
- package/features/permissions/abstractions.d.ts +14 -0
- package/features/permissions/abstractions.js +6 -0
- package/features/permissions/abstractions.js.map +1 -0
- package/features/permissions/feature.d.ts +4 -0
- package/features/permissions/feature.js +7 -0
- package/features/permissions/feature.js.map +1 -0
- package/graphql/SchedulerGraphQLFactory.d.ts +8 -0
- package/graphql/SchedulerGraphQLFactory.js +219 -0
- package/graphql/SchedulerGraphQLFactory.js.map +1 -0
- package/graphql/index.d.ts +1 -0
- package/graphql/index.js +1 -0
- package/index.d.ts +0 -6
- package/index.js +1 -11
- package/manifest.js +26 -30
- package/manifest.js.map +1 -1
- package/package.json +29 -31
- package/shared/abstractions.d.ts +19 -6
- package/shared/abstractions.js +4 -29
- package/shared/abstractions.js.map +1 -1
- package/features/CancelScheduledAction/index.js.map +0 -1
- package/features/ExecuteScheduledAction/index.js.map +0 -1
- package/features/GetScheduledAction/index.js.map +0 -1
- package/features/ListScheduledActions/index.js.map +0 -1
- package/features/RunAction/RunActionUseCase.d.ts +0 -23
- package/features/RunAction/RunActionUseCase.js +0 -37
- package/features/RunAction/RunActionUseCase.js.map +0 -1
- package/features/RunAction/abstractions.d.ts +0 -35
- package/features/RunAction/abstractions.js +0 -15
- package/features/RunAction/abstractions.js.map +0 -1
- package/features/RunAction/feature.d.ts +0 -7
- package/features/RunAction/feature.js +0 -17
- package/features/RunAction/feature.js.map +0 -1
- package/features/RunAction/index.js.map +0 -1
- package/features/ScheduleAction/index.js.map +0 -1
- package/index.js.map +0 -1
- /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
package/constants.d.ts
CHANGED
|
@@ -6,3 +6,8 @@ export declare const SCHEDULE_ID_PREFIX = "wby-schedule-";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const SCHEDULE_MIN_FUTURE_SECONDS = 65;
|
|
8
8
|
export declare const SCHEDULED_ACTION_EVENT_IDENTIFIER = "WebinyScheduledAction";
|
|
9
|
+
/** Constant identifier for the publish scheduled action type. */
|
|
10
|
+
export declare const SCHEDULED_ACTION_PUBLISH: "publish";
|
|
11
|
+
/** Constant identifier for the unpublish scheduled action type. */
|
|
12
|
+
export declare const SCHEDULED_ACTION_UNPUBLISH: "unpublish";
|
|
13
|
+
export declare const SCHEDULED_ACTIONS: readonly ["publish", "unpublish"];
|
package/constants.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const SCHEDULE_MODEL_ID = "wbySchedule";
|
|
2
|
+
const SCHEDULE_ID_PREFIX = "wby-schedule-";
|
|
3
|
+
const SCHEDULE_MIN_FUTURE_SECONDS = 65;
|
|
4
|
+
const SCHEDULED_ACTION_EVENT_IDENTIFIER = "WebinyScheduledAction";
|
|
5
|
+
const SCHEDULED_ACTION_PUBLISH = "publish";
|
|
6
|
+
const SCHEDULED_ACTION_UNPUBLISH = "unpublish";
|
|
7
|
+
const SCHEDULED_ACTIONS = [
|
|
8
|
+
SCHEDULED_ACTION_PUBLISH,
|
|
9
|
+
SCHEDULED_ACTION_UNPUBLISH
|
|
10
|
+
];
|
|
11
|
+
export { SCHEDULED_ACTIONS, SCHEDULED_ACTION_EVENT_IDENTIFIER, SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH, SCHEDULE_ID_PREFIX, SCHEDULE_MIN_FUTURE_SECONDS, SCHEDULE_MODEL_ID };
|
|
9
12
|
|
|
10
13
|
//# sourceMappingURL=constants.js.map
|
package/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const SCHEDULE_MODEL_ID = \"wbySchedule\";\nexport const SCHEDULE_ID_PREFIX = \"wby-schedule-\";\n/**\n * Minimum number of seconds in the future that a schedule can be set.\n * Everything else will result in immediately running the action.\n */\nexport const SCHEDULE_MIN_FUTURE_SECONDS = 65;\n\nexport const SCHEDULED_ACTION_EVENT_IDENTIFIER = \"WebinyScheduledAction\";\n\n/** Constant identifier for the publish scheduled action type. */\nexport const SCHEDULED_ACTION_PUBLISH = \"publish\" as const;\n/** Constant identifier for the unpublish scheduled action type. */\nexport const SCHEDULED_ACTION_UNPUBLISH = \"unpublish\" as const;\n\nexport const SCHEDULED_ACTIONS = [SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH] as const;\n"],"names":["SCHEDULE_MODEL_ID","SCHEDULE_ID_PREFIX","SCHEDULE_MIN_FUTURE_SECONDS","SCHEDULED_ACTION_EVENT_IDENTIFIER","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH","SCHEDULED_ACTIONS"],"mappings":"AAAO,MAAMA,oBAAoB;AAC1B,MAAMC,qBAAqB;AAK3B,MAAMC,8BAA8B;AAEpC,MAAMC,oCAAoC;AAG1C,MAAMC,2BAA2B;AAEjC,MAAMC,6BAA6B;AAEnC,MAAMC,oBAAoB;IAACF;IAA0BC;CAA2B"}
|
package/context.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
|
|
|
4
4
|
export interface ICreateHeadlessCmsSchedulerContextParams {
|
|
5
5
|
getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
|
|
6
6
|
}
|
|
7
|
-
export declare const createSchedulerContext: (params: ICreateHeadlessCmsSchedulerContextParams) => ContextPlugin<CmsContext
|
|
7
|
+
export declare const createSchedulerContext: (params: ICreateHeadlessCmsSchedulerContextParams) => (ContextPlugin<CmsContext> | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[];
|
package/context.js
CHANGED
|
@@ -8,34 +8,40 @@ import { SchedulePrivateModel } from "./domain/SchedulePrivateModel.js";
|
|
|
8
8
|
import { SchedulerFeature } from "./features/SchedulerFeature.js";
|
|
9
9
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
10
10
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const manifest = await getManifest({
|
|
19
|
-
client: context.db.driver.getClient()
|
|
11
|
+
import { SchedulerGraphQLFactory } from "./graphql/index.js";
|
|
12
|
+
import { SchedulerPermissionsFeature } from "./features/permissions/feature.js";
|
|
13
|
+
import { NamespaceHandlerExecutioner } from "./features/NamespaceHandler/NamespaceHandlerExecutioner.js";
|
|
14
|
+
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
15
|
+
const createSchedulerContext = (params)=>{
|
|
16
|
+
const modelsPlugin = createRegisterExtensionPlugin((context)=>{
|
|
17
|
+
context.container.register(SchedulePrivateModel);
|
|
20
18
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const schedulerContextPlugin = new ContextPlugin(async (context)=>{
|
|
20
|
+
const tenantContext = context.container.resolve(TenantContext);
|
|
21
|
+
const getModel = context.container.resolve(GetModelUseCase);
|
|
22
|
+
if (!tenantContext.getTenant()) return;
|
|
23
|
+
const manifest = await getManifest({
|
|
24
|
+
client: context.db.driver.getClient()
|
|
25
|
+
});
|
|
26
|
+
if (manifest.error) context.container.registerInstance(SchedulerService, new VoidSchedulerService());
|
|
27
|
+
else context.container.registerInstance(SchedulerService, new EventBridgeSchedulerService(params.getClient, {
|
|
28
|
+
lambdaArn: manifest.data.lambdaArn,
|
|
29
|
+
roleArn: manifest.data.roleArn
|
|
30
|
+
}));
|
|
31
|
+
SchedulerPermissionsFeature.register(context.container);
|
|
32
|
+
context.container.register(SchedulerGraphQLFactory);
|
|
33
|
+
context.container.register(NamespaceHandlerExecutioner);
|
|
34
|
+
await context.security.withoutAuthorization(async ()=>{
|
|
35
|
+
const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
|
|
36
|
+
context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
|
|
37
|
+
});
|
|
38
|
+
SchedulerFeature.register(context.container);
|
|
34
39
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
return [
|
|
41
|
+
schedulerContextPlugin,
|
|
42
|
+
modelsPlugin
|
|
43
|
+
];
|
|
39
44
|
};
|
|
45
|
+
export { createSchedulerContext };
|
|
40
46
|
|
|
41
47
|
//# sourceMappingURL=context.js.map
|
package/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type {\n SchedulerClient,\n SchedulerClientConfig\n} from \"@webiny/aws-sdk/client-scheduler/index.js\";\nimport { getManifest } from \"~/manifest.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport { SCHEDULE_MODEL_ID } from \"./constants.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { ScheduledActionModel, SchedulerService } from \"~/shared/abstractions.js\";\nimport { EventBridgeSchedulerService } from \"~/features/SchedulerService/EventBridgeSchedulerService.js\";\nimport { VoidSchedulerService } from \"~/features/SchedulerService/VoidSchedulerService.js\";\nimport { SchedulePrivateModel } from \"~/domain/SchedulePrivateModel.js\";\nimport { SchedulerFeature } from \"./features/SchedulerFeature.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { SchedulerGraphQLFactory } from \"~/graphql/index.js\";\nimport { SchedulerPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { NamespaceHandlerExecutioner } from \"~/features/NamespaceHandler/NamespaceHandlerExecutioner.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\nexport interface ICreateHeadlessCmsSchedulerContextParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\n\nexport const createSchedulerContext = (params: ICreateHeadlessCmsSchedulerContextParams) => {\n const modelsPlugin = createRegisterExtensionPlugin(context => {\n context.container.register(SchedulePrivateModel);\n });\n\n const schedulerContextPlugin = new ContextPlugin<CmsContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const getModel = context.container.resolve(GetModelUseCase);\n\n if (!tenantContext.getTenant()) {\n return;\n }\n\n const manifest = await getManifest({\n client: context.db.driver.getClient() as DynamoDBDocument\n });\n\n if (manifest.error) {\n context.container.registerInstance(SchedulerService, new VoidSchedulerService());\n } else {\n // TODO: in the future, extract AWS specific implementation into a separate package\n context.container.registerInstance(\n SchedulerService,\n new EventBridgeSchedulerService(params.getClient, {\n lambdaArn: manifest.data.lambdaArn,\n roleArn: manifest.data.roleArn\n })\n );\n }\n\n SchedulerPermissionsFeature.register(context.container);\n context.container.register(SchedulerGraphQLFactory);\n context.container.register(NamespaceHandlerExecutioner);\n\n await context.security.withoutAuthorization(async () => {\n const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);\n context.container.registerInstance(ScheduledActionModel, schedulerModel.value);\n });\n\n // Register all features\n SchedulerFeature.register(context.container);\n });\n\n return [schedulerContextPlugin, modelsPlugin];\n};\n"],"names":["createSchedulerContext","params","modelsPlugin","createRegisterExtensionPlugin","context","SchedulePrivateModel","schedulerContextPlugin","ContextPlugin","tenantContext","TenantContext","getModel","GetModelUseCase","manifest","getManifest","SchedulerService","VoidSchedulerService","EventBridgeSchedulerService","SchedulerPermissionsFeature","SchedulerGraphQLFactory","NamespaceHandlerExecutioner","schedulerModel","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerFeature"],"mappings":";;;;;;;;;;;;;;AAyBO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,eAAeC,8BAA8BC,CAAAA;QAC/CA,QAAQ,SAAS,CAAC,QAAQ,CAACC;IAC/B;IAEA,MAAMC,yBAAyB,IAAIC,cAA0B,OAAMH;QAC/D,MAAMI,gBAAgBJ,QAAQ,SAAS,CAAC,OAAO,CAACK;QAChD,MAAMC,WAAWN,QAAQ,SAAS,CAAC,OAAO,CAACO;QAE3C,IAAI,CAACH,cAAc,SAAS,IACxB;QAGJ,MAAMI,WAAW,MAAMC,YAAY;YAC/B,QAAQT,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS;QACvC;QAEA,IAAIQ,SAAS,KAAK,EACdR,QAAQ,SAAS,CAAC,gBAAgB,CAACU,kBAAkB,IAAIC;aAGzDX,QAAQ,SAAS,CAAC,gBAAgB,CAC9BU,kBACA,IAAIE,4BAA4Bf,OAAO,SAAS,EAAE;YAC9C,WAAWW,SAAS,IAAI,CAAC,SAAS;YAClC,SAASA,SAAS,IAAI,CAAC,OAAO;QAClC;QAIRK,4BAA4B,QAAQ,CAACb,QAAQ,SAAS;QACtDA,QAAQ,SAAS,CAAC,QAAQ,CAACc;QAC3Bd,QAAQ,SAAS,CAAC,QAAQ,CAACe;QAE3B,MAAMf,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;YACxC,MAAMgB,iBAAiB,MAAMV,SAAS,OAAO,CAACW;YAC9CjB,QAAQ,SAAS,CAAC,gBAAgB,CAACkB,sBAAsBF,eAAe,KAAK;QACjF;QAGAG,iBAAiB,QAAQ,CAACnB,QAAQ,SAAS;IAC/C;IAEA,OAAO;QAACE;QAAwBJ;KAAa;AACjD"}
|
package/createEventHandler.d.ts
CHANGED
package/createEventHandler.js
CHANGED
|
@@ -3,48 +3,35 @@ import { createSourceHandler } from "@webiny/handler-aws/sourceHandler.js";
|
|
|
3
3
|
import { createEventHandler, createHandler } from "@webiny/handler-aws/raw/index.js";
|
|
4
4
|
import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
|
|
5
5
|
import { ExecuteScheduledActionUseCase } from "./features/ExecuteScheduledAction/index.js";
|
|
6
|
-
const canHandle = event
|
|
7
|
-
|
|
8
|
-
return false;
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];
|
|
13
|
-
return !!(value?.id && value?.scheduleFor);
|
|
6
|
+
const canHandle = (event)=>{
|
|
7
|
+
if ("function" != typeof event?.hasOwnProperty) return false;
|
|
8
|
+
if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) return false;
|
|
9
|
+
const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];
|
|
10
|
+
return !!(value?.id && value?.scheduleFor);
|
|
14
11
|
};
|
|
15
12
|
const handler = createSourceHandler({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
params,
|
|
20
|
-
event,
|
|
21
|
-
context
|
|
22
|
-
}) => {
|
|
23
|
-
return createHandler(params)(event, context);
|
|
24
|
-
}
|
|
13
|
+
name: "handler-aws-event-bridge-scheduled-cms-action-event",
|
|
14
|
+
canUse: canHandle,
|
|
15
|
+
handle: async ({ params, event, context })=>createHandler(params)(event, context)
|
|
25
16
|
});
|
|
26
17
|
registry.register(handler);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
};
|
|
18
|
+
const createScheduledActionEventHandler = ()=>createEventHandler({
|
|
19
|
+
canHandle: canHandle,
|
|
20
|
+
handle: async (params)=>{
|
|
21
|
+
const { payload, context } = params;
|
|
22
|
+
const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];
|
|
23
|
+
const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);
|
|
24
|
+
const result = await executeScheduledAction.execute(input);
|
|
25
|
+
if (result.isFail()) {
|
|
26
|
+
const error = result.error;
|
|
27
|
+
console.error(error.code, error.message);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
success: true
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export { createScheduledActionEventHandler };
|
|
49
36
|
|
|
50
37
|
//# sourceMappingURL=createEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createEventHandler.js","sources":["../src/createEventHandler.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_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport { ExecuteScheduledActionUseCase } from \"~/features/ExecuteScheduledAction/index.js\";\n\nexport interface IScheduledActionEventPayload {\n namespace: string;\n id: string;\n scheduleFor: string;\n}\n\nexport interface IScheduledActionEvent {\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;\n}\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst canHandle = (event: Partial<IScheduledActionEvent>): boolean => {\n if (typeof event?.hasOwnProperty !== \"function\") {\n return false;\n } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {\n return false;\n }\n\n const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n return !!(value?.id && value?.scheduleFor);\n};\n\nconst handler = createSourceHandler<IScheduledActionEvent, HandlerParams>({\n name: \"handler-aws-event-bridge-scheduled-cms-action-event\",\n canUse: canHandle,\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n\nexport const createScheduledActionEventHandler = () => {\n return createEventHandler<IScheduledActionEvent>({\n canHandle,\n handle: async params => {\n const { payload, context } = params;\n const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n\n const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);\n const result = await executeScheduledAction.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n console.error(error.code, error.message);\n throw error;\n }\n return {\n success: true\n };\n }\n });\n};\n"],"names":["canHandle","event","SCHEDULED_ACTION_EVENT_IDENTIFIER","value","handler","createSourceHandler","params","context","createHandler","registry","createScheduledActionEventHandler","createEventHandler","payload","input","executeScheduledAction","ExecuteScheduledActionUseCase","result","error","console"],"mappings":";;;;;AAqBA,MAAMA,YAAY,CAACC;IACf,IAAI,AAAiC,cAAjC,OAAOA,OAAO,gBACd,OAAO;IACJ,IAAI,CAACA,MAAM,cAAc,CAACC,oCAC7B,OAAO;IAGX,MAAMC,QAAQF,KAAK,CAACC,kCAAkC;IACtD,OAAO,CAAC,CAAEC,CAAAA,OAAO,MAAMA,OAAO,WAAU;AAC5C;AAEA,MAAMC,UAAUC,oBAA0D;IACtE,MAAM;IACN,QAAQL;IACR,QAAQ,OAAO,EAAEM,MAAM,EAAEL,KAAK,EAAEM,OAAO,EAAE,GAC9BC,cAAcF,QAAQL,OAAOM;AAE5C;AAEAE,SAAS,QAAQ,CAACL;AAEX,MAAMM,oCAAoC,IACtCC,mBAA0C;QAC7CX,WAAAA;QACA,QAAQ,OAAMM;YACV,MAAM,EAAEM,OAAO,EAAEL,OAAO,EAAE,GAAGD;YAC7B,MAAMO,QAAQD,OAAO,CAACV,kCAAkC;YAExD,MAAMY,yBAAyBP,QAAQ,SAAS,CAAC,OAAO,CAACQ;YACzD,MAAMC,SAAS,MAAMF,uBAAuB,OAAO,CAACD;YAEpD,IAAIG,OAAO,MAAM,IAAI;gBACjB,MAAMC,QAAQD,OAAO,KAAK;gBAC1BE,QAAQ,KAAK,CAACD,MAAM,IAAI,EAAEA,MAAM,OAAO;gBACvC,MAAMA;YACV;YACA,OAAO;gBACH,SAAS;YACb;QACJ;IACJ"}
|
package/createScheduler.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
|
-
import { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler";
|
|
2
|
+
import { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler/index.js";
|
|
3
3
|
export interface ICreateSchedulerParams {
|
|
4
4
|
getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
|
|
5
5
|
}
|
package/createScheduler.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createSchedulerContext } from "./context.js";
|
|
2
2
|
import { createScheduledActionEventHandler } from "./createEventHandler.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
createScheduledActionEventHandler(), createSchedulerContext(params)];
|
|
9
|
-
};
|
|
3
|
+
const createScheduler = (params)=>[
|
|
4
|
+
createScheduledActionEventHandler(),
|
|
5
|
+
...createSchedulerContext(params)
|
|
6
|
+
];
|
|
7
|
+
export { createScheduler };
|
|
10
8
|
|
|
11
9
|
//# sourceMappingURL=createScheduler.js.map
|
package/createScheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createScheduler.js","sources":["../src/createScheduler.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport { SchedulerClient, SchedulerClientConfig } from \"@webiny/aws-sdk/client-scheduler/index.js\";\nimport { createSchedulerContext } from \"~/context.js\";\nimport { createScheduledActionEventHandler } from \"~/createEventHandler.js\";\n\nexport interface ICreateSchedulerParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\nexport const createScheduler = (params: ICreateSchedulerParams): Plugin[] => {\n return [\n /**\n * Handler for the Scheduled Action Event.\n */\n createScheduledActionEventHandler(),\n ...createSchedulerContext(params)\n ];\n};\n"],"names":["createScheduler","params","createScheduledActionEventHandler","createSchedulerContext"],"mappings":";;AAQO,MAAMA,kBAAkB,CAACC,SACrB;QAIHC;WACGC,uBAAuBF;KAC7B"}
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { ModelFactory } from "@webiny/api-headless-cms/features/modelBuilder/index.js";
|
|
2
2
|
import { SCHEDULE_MODEL_ID } from "../constants.js";
|
|
3
3
|
class SchedulePrivateModelImpl {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
async execute(builder) {
|
|
5
|
+
return [
|
|
6
|
+
builder.private({
|
|
7
|
+
modelId: SCHEDULE_MODEL_ID,
|
|
8
|
+
name: "Webiny CMS Schedule"
|
|
9
|
+
}).fields((fields)=>({
|
|
10
|
+
namespace: fields.text().label("Namespace"),
|
|
11
|
+
actionType: fields.text().label("Action Type"),
|
|
12
|
+
targetId: fields.text().label("Target ID"),
|
|
13
|
+
scheduledBy: fields.object().label("Scheduled By").fields((fields)=>({
|
|
14
|
+
id: fields.text().label("Identity ID"),
|
|
15
|
+
displayName: fields.text().label("Display Name"),
|
|
16
|
+
type: fields.text().label("Type")
|
|
17
|
+
})),
|
|
18
|
+
scheduledFor: fields.datetime().label("Scheduled For"),
|
|
19
|
+
title: fields.text().label("Title"),
|
|
20
|
+
error: fields.text().label("Error"),
|
|
21
|
+
payload: fields.json().label("Payload")
|
|
22
|
+
}))
|
|
23
|
+
];
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const SchedulePrivateModel = ModelFactory.createImplementation({
|
|
27
|
+
implementation: SchedulePrivateModelImpl,
|
|
28
|
+
dependencies: []
|
|
27
29
|
});
|
|
30
|
+
export { SchedulePrivateModel };
|
|
28
31
|
|
|
29
32
|
//# sourceMappingURL=SchedulePrivateModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/SchedulePrivateModel.js","sources":["../../src/domain/SchedulePrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { SCHEDULE_MODEL_ID } from \"~/constants.js\";\n\nclass SchedulePrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: SCHEDULE_MODEL_ID,\n name: \"Webiny CMS Schedule\"\n })\n .fields(fields => ({\n namespace: fields.text().label(\"Namespace\"),\n actionType: fields.text().label(\"Action Type\"),\n targetId: fields.text().label(\"Target ID\"),\n scheduledBy: fields\n .object()\n .label(\"Scheduled By\")\n .fields(fields => ({\n id: fields.text().label(\"Identity ID\"),\n displayName: fields.text().label(\"Display Name\"),\n type: fields.text().label(\"Type\")\n })),\n scheduledFor: fields.datetime().label(\"Scheduled For\"),\n title: fields.text().label(\"Title\"),\n error: fields.text().label(\"Error\"),\n payload: fields.json().label(\"Payload\")\n }))\n ];\n }\n}\n\nexport const SchedulePrivateModel = ModelFactory.createImplementation({\n implementation: SchedulePrivateModelImpl,\n dependencies: []\n});\n"],"names":["SchedulePrivateModelImpl","builder","SCHEDULE_MODEL_ID","fields","SchedulePrivateModel","ModelFactory"],"mappings":";;AAGA,MAAMA;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASC;gBACT,MAAM;YACV,GACC,MAAM,CAACC,CAAAA,SAAW;oBACf,WAAWA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC/B,YAAYA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAChC,UAAUA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC9B,aAAaA,OACR,MAAM,GACN,KAAK,CAAC,gBACN,MAAM,CAACA,CAAAA,SAAW;4BACf,IAAIA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACxB,aAAaA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACjC,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC;wBAC9B;oBACJ,cAAcA,OAAO,QAAQ,GAAG,KAAK,CAAC;oBACtC,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC3B,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC3B,SAASA,OAAO,IAAI,GAAG,KAAK,CAAC;gBACjC;SACP;IACL;AACJ;AAEO,MAAMC,uBAAuBC,aAAa,oBAAoB,CAAC;IAClE,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { createCacheKey } from "@webiny/utils";
|
|
2
2
|
import { SCHEDULE_ID_PREFIX } from "../constants.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
class ScheduledActionId {
|
|
4
|
+
static from(params) {
|
|
5
|
+
return [
|
|
6
|
+
SCHEDULE_ID_PREFIX,
|
|
7
|
+
createCacheKey([
|
|
8
|
+
params.namespace,
|
|
9
|
+
params.actionType,
|
|
10
|
+
params.targetId
|
|
11
|
+
]).slice(-24)
|
|
12
|
+
].join("");
|
|
13
|
+
}
|
|
7
14
|
}
|
|
15
|
+
export { ScheduledActionId };
|
|
8
16
|
|
|
9
17
|
//# sourceMappingURL=ScheduledActionId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/ScheduledActionId.js","sources":["../../src/domain/ScheduledActionId.ts"],"sourcesContent":["import { createCacheKey } from \"@webiny/utils\";\nimport { SCHEDULE_ID_PREFIX } from \"~/constants.js\";\n\nexport interface IScheduledActionIdParams {\n namespace: string;\n actionType: string;\n targetId: string;\n}\n\nexport class ScheduledActionId {\n static from(params: IScheduledActionIdParams) {\n return [\n SCHEDULE_ID_PREFIX,\n createCacheKey([params.namespace, params.actionType, params.targetId]).slice(-24)\n ].join(\"\");\n }\n}\n"],"names":["ScheduledActionId","params","SCHEDULE_ID_PREFIX","createCacheKey"],"mappings":";;AASO,MAAMA;IACT,OAAO,KAAKC,MAAgC,EAAE;QAC1C,OAAO;YACHC;YACAC,eAAe;gBAACF,OAAO,SAAS;gBAAEA,OAAO,UAAU;gBAAEA,OAAO,QAAQ;aAAC,EAAE,KAAK,CAAC;SAChF,CAAC,IAAI,CAAC;IACX;AACJ"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
class ScheduledActionIdWithVersion {
|
|
2
|
+
static from(id) {
|
|
3
|
+
if (id.endsWith("#0001")) return id;
|
|
4
|
+
return `${id}#0001`;
|
|
5
5
|
}
|
|
6
|
-
return `${id}#0001`;
|
|
7
|
-
}
|
|
8
6
|
}
|
|
7
|
+
export { ScheduledActionIdWithVersion };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=ScheduledActionIdWithVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/ScheduledActionIdWithVersion.js","sources":["../../src/domain/ScheduledActionIdWithVersion.ts"],"sourcesContent":["export class ScheduledActionIdWithVersion {\n static from(id: string) {\n if (id.endsWith(\"#0001\")) {\n return id;\n }\n\n return `${id}#0001`;\n }\n}\n"],"names":["ScheduledActionIdWithVersion","id"],"mappings":"AAAO,MAAMA;IACT,OAAO,KAAKC,EAAU,EAAE;QACpB,IAAIA,GAAG,QAAQ,CAAC,UACZ,OAAOA;QAGX,OAAO,GAAGA,GAAG,KAAK,CAAC;IACvB;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IScheduledAction, IScheduledActionEntry } from "../shared/abstractions.js";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
export declare class ScheduledActionMapper {
|
|
4
|
+
static toAction<T extends GenericRecord = GenericRecord>(action: IScheduledActionEntry<T>): IScheduledAction<T>;
|
|
5
|
+
static toActions<T extends GenericRecord = GenericRecord>(actions: IScheduledActionEntry<T>[]): IScheduledAction<T>[];
|
|
6
|
+
static toGraphQL<T extends GenericRecord = GenericRecord>(action: IScheduledAction<T>): {
|
|
7
|
+
id: string;
|
|
8
|
+
targetId: string;
|
|
9
|
+
namespace: string;
|
|
10
|
+
scheduledBy: import("~/shared/abstractions.js").Identity;
|
|
11
|
+
publishOn: Date | null;
|
|
12
|
+
unpublishOn: Date | null;
|
|
13
|
+
actionType: import("~/shared/abstractions.js").ScheduledActionType;
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
2
|
+
import { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from "../constants.js";
|
|
3
|
+
class ScheduledActionMapper {
|
|
4
|
+
static toAction(action) {
|
|
5
|
+
const { id: scheduleId } = parseIdentifier(action.id);
|
|
6
|
+
return {
|
|
7
|
+
id: scheduleId,
|
|
8
|
+
targetId: action.values.targetId,
|
|
9
|
+
namespace: action.values.namespace,
|
|
10
|
+
scheduledBy: action.values.scheduledBy,
|
|
11
|
+
scheduledFor: new Date(action.values.scheduledFor),
|
|
12
|
+
actionType: action.values.actionType,
|
|
13
|
+
title: action.values.title,
|
|
14
|
+
payload: action.values.payload,
|
|
15
|
+
error: action.values.error
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
static toActions(actions) {
|
|
19
|
+
return actions.map(ScheduledActionMapper.toAction);
|
|
20
|
+
}
|
|
21
|
+
static toGraphQL(action) {
|
|
22
|
+
return {
|
|
23
|
+
id: action.id,
|
|
24
|
+
targetId: action.targetId,
|
|
25
|
+
namespace: action.namespace,
|
|
26
|
+
scheduledBy: action.scheduledBy,
|
|
27
|
+
publishOn: action.actionType === SCHEDULED_ACTION_PUBLISH ? action.scheduledFor : null,
|
|
28
|
+
unpublishOn: action.actionType === SCHEDULED_ACTION_UNPUBLISH ? action.scheduledFor : null,
|
|
29
|
+
actionType: action.actionType,
|
|
30
|
+
title: action.title
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export { ScheduledActionMapper };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=ScheduledActionMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain/ScheduledActionMapper.js","sources":["../../src/domain/ScheduledActionMapper.ts"],"sourcesContent":["import type { IScheduledAction, IScheduledActionEntry } from \"~/shared/abstractions.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\nexport class ScheduledActionMapper {\n static toAction<T extends GenericRecord = GenericRecord>(\n action: IScheduledActionEntry<T>\n ): IScheduledAction<T> {\n const { id: scheduleId } = parseIdentifier(action.id);\n return {\n id: scheduleId,\n targetId: action.values.targetId,\n namespace: action.values.namespace,\n scheduledBy: action.values.scheduledBy,\n scheduledFor: new Date(action.values.scheduledFor),\n actionType: action.values.actionType,\n title: action.values.title,\n payload: action.values.payload,\n error: action.values.error\n };\n }\n\n static toActions<T extends GenericRecord = GenericRecord>(\n actions: IScheduledActionEntry<T>[]\n ): IScheduledAction<T>[] {\n return actions.map(ScheduledActionMapper.toAction);\n }\n\n static toGraphQL<T extends GenericRecord = GenericRecord>(action: IScheduledAction<T>) {\n return {\n id: action.id,\n targetId: action.targetId,\n namespace: action.namespace,\n scheduledBy: action.scheduledBy,\n publishOn: action.actionType === SCHEDULED_ACTION_PUBLISH ? action.scheduledFor : null,\n unpublishOn:\n action.actionType === SCHEDULED_ACTION_UNPUBLISH ? action.scheduledFor : null,\n actionType: action.actionType,\n title: action.title\n };\n }\n}\n"],"names":["ScheduledActionMapper","action","scheduleId","parseIdentifier","Date","actions","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH"],"mappings":";;AAKO,MAAMA;IACT,OAAO,SACHC,MAAgC,EACb;QACnB,MAAM,EAAE,IAAIC,UAAU,EAAE,GAAGC,gBAAgBF,OAAO,EAAE;QACpD,OAAO;YACH,IAAIC;YACJ,UAAUD,OAAO,MAAM,CAAC,QAAQ;YAChC,WAAWA,OAAO,MAAM,CAAC,SAAS;YAClC,aAAaA,OAAO,MAAM,CAAC,WAAW;YACtC,cAAc,IAAIG,KAAKH,OAAO,MAAM,CAAC,YAAY;YACjD,YAAYA,OAAO,MAAM,CAAC,UAAU;YACpC,OAAOA,OAAO,MAAM,CAAC,KAAK;YAC1B,SAASA,OAAO,MAAM,CAAC,OAAO;YAC9B,OAAOA,OAAO,MAAM,CAAC,KAAK;QAC9B;IACJ;IAEA,OAAO,UACHI,OAAmC,EACd;QACrB,OAAOA,QAAQ,GAAG,CAACL,sBAAsB,QAAQ;IACrD;IAEA,OAAO,UAAmDC,MAA2B,EAAE;QACnF,OAAO;YACH,IAAIA,OAAO,EAAE;YACb,UAAUA,OAAO,QAAQ;YACzB,WAAWA,OAAO,SAAS;YAC3B,aAAaA,OAAO,WAAW;YAC/B,WAAWA,OAAO,UAAU,KAAKK,2BAA2BL,OAAO,YAAY,GAAG;YAClF,aACIA,OAAO,UAAU,KAAKM,6BAA6BN,OAAO,YAAY,GAAG;YAC7E,YAAYA,OAAO,UAAU;YAC7B,OAAOA,OAAO,KAAK;QACvB;IACJ;AACJ"}
|
package/domain/errors.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
/**
|
|
3
|
+
* Not authorized error when user lacks permissions to manage scheduled actions.
|
|
4
|
+
*/
|
|
5
|
+
export declare class NotAuthorizedError extends BaseError {
|
|
6
|
+
readonly code: "Scheduler/NotAuthorized";
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Scheduled action not found error
|
|
4
11
|
*/
|
|
@@ -24,7 +31,7 @@ export declare class InvalidScheduleDateError extends BaseError<{
|
|
|
24
31
|
scheduleFor: string;
|
|
25
32
|
}> {
|
|
26
33
|
readonly code: "Scheduler/ScheduledAction/InvalidDate";
|
|
27
|
-
constructor(scheduleFor:
|
|
34
|
+
constructor(scheduleFor: Date);
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
37
|
* Scheduler service error (EventBridge/cloud provider errors)
|
|
@@ -35,3 +42,14 @@ export declare class SchedulerServiceError extends BaseError<{
|
|
|
35
42
|
readonly code: "Scheduler/Service/Error";
|
|
36
43
|
constructor(error: Error);
|
|
37
44
|
}
|
|
45
|
+
interface INamespaceHandlerNotFoundErrorData {
|
|
46
|
+
namespace: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Namespace handler not found error.
|
|
50
|
+
*/
|
|
51
|
+
export declare class NamespaceHandlerNotFoundError extends BaseError<INamespaceHandlerNotFoundErrorData> {
|
|
52
|
+
readonly code: "Scheduler/NamespaceHandler/NotFound";
|
|
53
|
+
constructor(namespace: string);
|
|
54
|
+
}
|
|
55
|
+
export {};
|