@webiny/api-scheduler 6.3.0 → 6.4.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.
Files changed (101) hide show
  1. package/constants.js +11 -14
  2. package/constants.js.map +1 -1
  3. package/context.js +22 -31
  4. package/context.js.map +1 -1
  5. package/createEventHandler.js +26 -39
  6. package/createEventHandler.js.map +1 -1
  7. package/createScheduler.js +5 -7
  8. package/createScheduler.js.map +1 -1
  9. package/domain/SchedulePrivateModel.js +25 -22
  10. package/domain/SchedulePrivateModel.js.map +1 -1
  11. package/domain/ScheduledActionId.js +12 -4
  12. package/domain/ScheduledActionId.js.map +1 -1
  13. package/domain/ScheduledActionIdWithVersion.js +5 -6
  14. package/domain/ScheduledActionIdWithVersion.js.map +1 -1
  15. package/domain/ScheduledActionMapper.js +31 -32
  16. package/domain/ScheduledActionMapper.js.map +1 -1
  17. package/domain/errors.js +52 -80
  18. package/domain/errors.js.map +1 -1
  19. package/domain/isValidDate.js +4 -9
  20. package/domain/isValidDate.js.map +1 -1
  21. package/domain/permissionsSchema.js +14 -8
  22. package/domain/permissionsSchema.js.map +1 -1
  23. package/exports/api/scheduler.js +1 -3
  24. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +42 -67
  25. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  26. package/features/CancelScheduledAction/abstractions.js +2 -11
  27. package/features/CancelScheduledAction/abstractions.js.map +1 -1
  28. package/features/CancelScheduledAction/feature.js +6 -12
  29. package/features/CancelScheduledAction/feature.js.map +1 -1
  30. package/features/CancelScheduledAction/index.js +0 -2
  31. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +65 -92
  32. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  33. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
  34. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
  35. package/features/ExecuteScheduledAction/abstractions.js +12 -37
  36. package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
  37. package/features/ExecuteScheduledAction/feature.js +7 -13
  38. package/features/ExecuteScheduledAction/feature.js.map +1 -1
  39. package/features/ExecuteScheduledAction/index.js +0 -2
  40. package/features/GetScheduledAction/GetScheduledActionUseCase.js +33 -51
  41. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  42. package/features/GetScheduledAction/abstractions.js +2 -12
  43. package/features/GetScheduledAction/abstractions.js.map +1 -1
  44. package/features/GetScheduledAction/feature.js +6 -12
  45. package/features/GetScheduledAction/feature.js.map +1 -1
  46. package/features/GetScheduledAction/index.js +0 -2
  47. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +46 -68
  48. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -1
  49. package/features/GetTargetScheduledAction/abstractions.js +2 -1
  50. package/features/GetTargetScheduledAction/abstractions.js.map +1 -1
  51. package/features/GetTargetScheduledAction/feature.js +6 -12
  52. package/features/GetTargetScheduledAction/feature.js.map +1 -1
  53. package/features/GetTargetScheduledAction/index.js +0 -2
  54. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +48 -63
  55. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  56. package/features/ListScheduledActions/abstractions.js +2 -13
  57. package/features/ListScheduledActions/abstractions.js.map +1 -1
  58. package/features/ListScheduledActions/feature.js +6 -12
  59. package/features/ListScheduledActions/feature.js.map +1 -1
  60. package/features/ListScheduledActions/index.js +0 -2
  61. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +18 -17
  62. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -1
  63. package/features/NamespaceHandler/abstractions.js +3 -13
  64. package/features/NamespaceHandler/abstractions.js.map +1 -1
  65. package/features/NamespaceHandler/index.js +0 -2
  66. package/features/ScheduleAction/ScheduleActionUseCase.js +144 -200
  67. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  68. package/features/ScheduleAction/abstractions.js +2 -11
  69. package/features/ScheduleAction/abstractions.js.map +1 -1
  70. package/features/ScheduleAction/feature.js +6 -12
  71. package/features/ScheduleAction/feature.js.map +1 -1
  72. package/features/ScheduleAction/index.js +0 -2
  73. package/features/SchedulerFeature.js +11 -19
  74. package/features/SchedulerFeature.js.map +1 -1
  75. package/features/SchedulerService/EventBridgeSchedulerService.js +85 -121
  76. package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
  77. package/features/SchedulerService/VoidSchedulerService.js +17 -24
  78. package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
  79. package/features/permissions/abstractions.js +2 -1
  80. package/features/permissions/abstractions.js.map +1 -1
  81. package/features/permissions/feature.js +2 -1
  82. package/features/permissions/feature.js.map +1 -1
  83. package/graphql/SchedulerGraphQLFactory.js +84 -113
  84. package/graphql/SchedulerGraphQLFactory.js.map +1 -1
  85. package/graphql/index.js +0 -2
  86. package/index.js +1 -3
  87. package/manifest.js +26 -30
  88. package/manifest.js.map +1 -1
  89. package/package.json +20 -20
  90. package/shared/abstractions.js +4 -32
  91. package/shared/abstractions.js.map +1 -1
  92. package/exports/api/scheduler.js.map +0 -1
  93. package/features/CancelScheduledAction/index.js.map +0 -1
  94. package/features/ExecuteScheduledAction/index.js.map +0 -1
  95. package/features/GetScheduledAction/index.js.map +0 -1
  96. package/features/GetTargetScheduledAction/index.js.map +0 -1
  97. package/features/ListScheduledActions/index.js.map +0 -1
  98. package/features/NamespaceHandler/index.js.map +0 -1
  99. package/features/ScheduleAction/index.js.map +0 -1
  100. package/graphql/index.js.map +0 -1
  101. package/index.js.map +0 -1
package/constants.js CHANGED
@@ -1,16 +1,13 @@
1
- export const SCHEDULE_MODEL_ID = "wbySchedule";
2
- export const SCHEDULE_ID_PREFIX = "wby-schedule-";
3
- /**
4
- * Minimum number of seconds in the future that a schedule can be set.
5
- * Everything else will result in immediately running the action.
6
- */
7
- export const SCHEDULE_MIN_FUTURE_SECONDS = 65;
8
- export const SCHEDULED_ACTION_EVENT_IDENTIFIER = "WebinyScheduledAction";
9
-
10
- /** Constant identifier for the publish scheduled action type. */
11
- export const SCHEDULED_ACTION_PUBLISH = "publish";
12
- /** Constant identifier for the unpublish scheduled action type. */
13
- export const SCHEDULED_ACTION_UNPUBLISH = "unpublish";
14
- export const SCHEDULED_ACTIONS = [SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH];
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 };
15
12
 
16
13
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["SCHEDULE_MODEL_ID","SCHEDULE_ID_PREFIX","SCHEDULE_MIN_FUTURE_SECONDS","SCHEDULED_ACTION_EVENT_IDENTIFIER","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH","SCHEDULED_ACTIONS"],"sources":["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"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,GAAG,aAAa;AAC9C,OAAO,MAAMC,kBAAkB,GAAG,eAAe;AACjD;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,EAAE;AAE7C,OAAO,MAAMC,iCAAiC,GAAG,uBAAuB;;AAExE;AACA,OAAO,MAAMC,wBAAwB,GAAG,SAAkB;AAC1D;AACA,OAAO,MAAMC,0BAA0B,GAAG,WAAoB;AAE9D,OAAO,MAAMC,iBAAiB,GAAG,CAACF,wBAAwB,EAAEC,0BAA0B,CAAU","ignoreList":[]}
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.js CHANGED
@@ -11,37 +11,28 @@ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/
11
11
  import { SchedulerGraphQLFactory } from "./graphql/index.js";
12
12
  import { SchedulerPermissionsFeature } from "./features/permissions/feature.js";
13
13
  import { NamespaceHandlerExecutioner } from "./features/NamespaceHandler/NamespaceHandlerExecutioner.js";
14
- export const createSchedulerContext = params => {
15
- return new ContextPlugin(async context => {
16
- const tenantContext = context.container.resolve(TenantContext);
17
- const getModel = context.container.resolve(GetModelUseCase);
18
- if (!tenantContext.getTenant()) {
19
- return;
20
- }
21
- const manifest = await getManifest({
22
- client: context.db.driver.getClient()
14
+ const createSchedulerContext = (params)=>new ContextPlugin(async (context)=>{
15
+ const tenantContext = context.container.resolve(TenantContext);
16
+ const getModel = context.container.resolve(GetModelUseCase);
17
+ if (!tenantContext.getTenant()) return;
18
+ const manifest = await getManifest({
19
+ client: context.db.driver.getClient()
20
+ });
21
+ if (manifest.error) context.container.registerInstance(SchedulerService, new VoidSchedulerService());
22
+ else context.container.registerInstance(SchedulerService, new EventBridgeSchedulerService(params.getClient, {
23
+ lambdaArn: manifest.data.lambdaArn,
24
+ roleArn: manifest.data.roleArn
25
+ }));
26
+ SchedulerPermissionsFeature.register(context.container);
27
+ context.container.register(SchedulePrivateModel);
28
+ context.container.register(SchedulerGraphQLFactory);
29
+ context.container.register(NamespaceHandlerExecutioner);
30
+ await context.security.withoutAuthorization(async ()=>{
31
+ const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
32
+ context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
33
+ });
34
+ SchedulerFeature.register(context.container);
23
35
  });
24
- if (manifest.error) {
25
- context.container.registerInstance(SchedulerService, new VoidSchedulerService());
26
- } else {
27
- // TODO: in the future, extract AWS specific implementation into a separate package
28
- context.container.registerInstance(SchedulerService, new EventBridgeSchedulerService(params.getClient, {
29
- lambdaArn: manifest.data.lambdaArn,
30
- roleArn: manifest.data.roleArn
31
- }));
32
- }
33
- SchedulerPermissionsFeature.register(context.container);
34
- context.container.register(SchedulePrivateModel);
35
- context.container.register(SchedulerGraphQLFactory);
36
- context.container.register(NamespaceHandlerExecutioner);
37
- await context.security.withoutAuthorization(async () => {
38
- const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
39
- context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
40
- });
41
-
42
- // Register all features
43
- SchedulerFeature.register(context.container);
44
- });
45
- };
36
+ export { createSchedulerContext };
46
37
 
47
38
  //# sourceMappingURL=context.js.map
package/context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","getManifest","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerService","EventBridgeSchedulerService","VoidSchedulerService","SchedulePrivateModel","SchedulerFeature","TenantContext","GetModelUseCase","SchedulerGraphQLFactory","SchedulerPermissionsFeature","NamespaceHandlerExecutioner","createSchedulerContext","params","context","tenantContext","container","resolve","getModel","getTenant","manifest","client","db","driver","getClient","error","registerInstance","lambdaArn","data","roleArn","register","security","withoutAuthorization","schedulerModel","execute","value"],"sources":["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\";\n\nexport interface ICreateHeadlessCmsSchedulerContextParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\n\nexport const createSchedulerContext = (params: ICreateHeadlessCmsSchedulerContextParams) => {\n return 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(SchedulePrivateModel);\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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAK3C,SAASC,WAAW;AAEpB,SAASC,iBAAiB;AAE1B,SAASC,oBAAoB,EAAEC,gBAAgB;AAC/C,SAASC,2BAA2B;AACpC,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,uBAAuB;AAChC,SAASC,2BAA2B;AACpC,SAASC,2BAA2B;AAMpC,OAAO,MAAMC,sBAAsB,GAAIC,MAAgD,IAAK;EACxF,OAAO,IAAIf,aAAa,CAAa,MAAMgB,OAAO,IAAI;IAClD,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACV,aAAa,CAAC;IAC9D,MAAMW,QAAQ,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACT,eAAe,CAAC;IAE3D,IAAI,CAACO,aAAa,CAACI,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEA,MAAMC,QAAQ,GAAG,MAAMrB,WAAW,CAAC;MAC/BsB,MAAM,EAAEP,OAAO,CAACQ,EAAE,CAACC,MAAM,CAACC,SAAS,CAAC;IACxC,CAAC,CAAC;IAEF,IAAIJ,QAAQ,CAACK,KAAK,EAAE;MAChBX,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAACxB,gBAAgB,EAAE,IAAIE,oBAAoB,CAAC,CAAC,CAAC;IACpF,CAAC,MAAM;MACH;MACAU,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAC9BxB,gBAAgB,EAChB,IAAIC,2BAA2B,CAACU,MAAM,CAACW,SAAS,EAAE;QAC9CG,SAAS,EAAEP,QAAQ,CAACQ,IAAI,CAACD,SAAS;QAClCE,OAAO,EAAET,QAAQ,CAACQ,IAAI,CAACC;MAC3B,CAAC,CACL,CAAC;IACL;IAEAnB,2BAA2B,CAACoB,QAAQ,CAAChB,OAAO,CAACE,SAAS,CAAC;IACvDF,OAAO,CAACE,SAAS,CAACc,QAAQ,CAACzB,oBAAoB,CAAC;IAChDS,OAAO,CAACE,SAAS,CAACc,QAAQ,CAACrB,uBAAuB,CAAC;IACnDK,OAAO,CAACE,SAAS,CAACc,QAAQ,CAACnB,2BAA2B,CAAC;IAEvD,MAAMG,OAAO,CAACiB,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,cAAc,GAAG,MAAMf,QAAQ,CAACgB,OAAO,CAAClC,iBAAiB,CAAC;MAChEc,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAACzB,oBAAoB,EAAEgC,cAAc,CAACE,KAAK,CAAC;IAClF,CAAC,CAAC;;IAEF;IACA7B,gBAAgB,CAACwB,QAAQ,CAAChB,OAAO,CAACE,SAAS,CAAC;EAChD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
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\";\n\nexport interface ICreateHeadlessCmsSchedulerContextParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\n\nexport const createSchedulerContext = (params: ICreateHeadlessCmsSchedulerContextParams) => {\n return 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(SchedulePrivateModel);\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"],"names":["createSchedulerContext","params","ContextPlugin","context","tenantContext","TenantContext","getModel","GetModelUseCase","manifest","getManifest","SchedulerService","VoidSchedulerService","EventBridgeSchedulerService","SchedulerPermissionsFeature","SchedulePrivateModel","SchedulerGraphQLFactory","NamespaceHandlerExecutioner","schedulerModel","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerFeature"],"mappings":";;;;;;;;;;;;;AAwBO,MAAMA,yBAAyB,CAACC,SAC5B,IAAIC,cAA0B,OAAMC;QACvC,MAAMC,gBAAgBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAChD,MAAMC,WAAWH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAE3C,IAAI,CAACH,cAAc,SAAS,IACxB;QAGJ,MAAMI,WAAW,MAAMC,YAAY;YAC/B,QAAQN,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS;QACvC;QAEA,IAAIK,SAAS,KAAK,EACdL,QAAQ,SAAS,CAAC,gBAAgB,CAACO,kBAAkB,IAAIC;aAGzDR,QAAQ,SAAS,CAAC,gBAAgB,CAC9BO,kBACA,IAAIE,4BAA4BX,OAAO,SAAS,EAAE;YAC9C,WAAWO,SAAS,IAAI,CAAC,SAAS;YAClC,SAASA,SAAS,IAAI,CAAC,OAAO;QAClC;QAIRK,4BAA4B,QAAQ,CAACV,QAAQ,SAAS;QACtDA,QAAQ,SAAS,CAAC,QAAQ,CAACW;QAC3BX,QAAQ,SAAS,CAAC,QAAQ,CAACY;QAC3BZ,QAAQ,SAAS,CAAC,QAAQ,CAACa;QAE3B,MAAMb,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;YACxC,MAAMc,iBAAiB,MAAMX,SAAS,OAAO,CAACY;YAC9Cf,QAAQ,SAAS,CAAC,gBAAgB,CAACgB,sBAAsBF,eAAe,KAAK;QACjF;QAGAG,iBAAiB,QAAQ,CAACjB,QAAQ,SAAS;IAC/C"}
@@ -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
- if (typeof event?.hasOwnProperty !== "function") {
8
- return false;
9
- } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {
10
- return false;
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
- name: "handler-aws-event-bridge-scheduled-cms-action-event",
17
- canUse: canHandle,
18
- handle: async ({
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
- export const createScheduledActionEventHandler = () => {
28
- return createEventHandler({
29
- canHandle,
30
- handle: async params => {
31
- const {
32
- payload,
33
- context
34
- } = params;
35
- const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];
36
- const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);
37
- const result = await executeScheduledAction.execute(input);
38
- if (result.isFail()) {
39
- const error = result.error;
40
- console.error(error.code, error.message);
41
- throw error;
42
- }
43
- return {
44
- success: true
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,"names":["registry","createSourceHandler","createEventHandler","createHandler","SCHEDULED_ACTION_EVENT_IDENTIFIER","ExecuteScheduledActionUseCase","canHandle","event","hasOwnProperty","value","id","scheduleFor","handler","name","canUse","handle","params","context","register","createScheduledActionEventHandler","payload","input","executeScheduledAction","container","resolve","result","execute","isFail","error","console","code","message","success"],"sources":["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"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iCAAiC;AAE1D,SAASC,mBAAmB,QAAQ,sCAAsC;AAC1E,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,kCAAkC;AACpF,SAASC,iCAAiC;AAC1C,SAASC,6BAA6B;AAgBtC,MAAMC,SAAS,GAAIC,KAAqC,IAAc;EAClE,IAAI,OAAOA,KAAK,EAAEC,cAAc,KAAK,UAAU,EAAE;IAC7C,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACD,KAAK,CAACC,cAAc,CAACJ,iCAAiC,CAAC,EAAE;IACjE,OAAO,KAAK;EAChB;EAEA,MAAMK,KAAK,GAAGF,KAAK,CAACH,iCAAiC,CAAC;EACtD,OAAO,CAAC,EAAEK,KAAK,EAAEC,EAAE,IAAID,KAAK,EAAEE,WAAW,CAAC;AAC9C,CAAC;AAED,MAAMC,OAAO,GAAGX,mBAAmB,CAAuC;EACtEY,IAAI,EAAE,qDAAqD;EAC3DC,MAAM,EAAER,SAAS;EACjBS,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAET,KAAK;IAAEU;EAAQ,CAAC,KAAK;IAC1C,OAAOd,aAAa,CAACa,MAAM,CAAC,CAACT,KAAK,EAAEU,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFjB,QAAQ,CAACkB,QAAQ,CAACN,OAAO,CAAC;AAE1B,OAAO,MAAMO,iCAAiC,GAAGA,CAAA,KAAM;EACnD,OAAOjB,kBAAkB,CAAwB;IAC7CI,SAAS;IACTS,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAM;QAAEI,OAAO;QAAEH;MAAQ,CAAC,GAAGD,MAAM;MACnC,MAAMK,KAAK,GAAGD,OAAO,CAAChB,iCAAiC,CAAC;MAExD,MAAMkB,sBAAsB,GAAGL,OAAO,CAACM,SAAS,CAACC,OAAO,CAACnB,6BAA6B,CAAC;MACvF,MAAMoB,MAAM,GAAG,MAAMH,sBAAsB,CAACI,OAAO,CAACL,KAAK,CAAC;MAE1D,IAAII,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;QACjB,MAAMC,KAAK,GAAGH,MAAM,CAACG,KAAK;QAC1BC,OAAO,CAACD,KAAK,CAACA,KAAK,CAACE,IAAI,EAAEF,KAAK,CAACG,OAAO,CAAC;QACxC,MAAMH,KAAK;MACf;MACA,OAAO;QACHI,OAAO,EAAE;MACb,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
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"}
@@ -1,11 +1,9 @@
1
1
  import { createSchedulerContext } from "./context.js";
2
2
  import { createScheduledActionEventHandler } from "./createEventHandler.js";
3
- export const createScheduler = params => {
4
- return [
5
- /**
6
- * Handler for the Scheduled Action Event.
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
@@ -1 +1 @@
1
- {"version":3,"names":["createSchedulerContext","createScheduledActionEventHandler","createScheduler","params"],"sources":["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"],"mappings":"AAEA,SAASA,sBAAsB;AAC/B,SAASC,iCAAiC;AAK1C,OAAO,MAAMC,eAAe,GAAIC,MAA8B,IAAe;EACzE,OAAO;EACH;AACR;AACA;EACQF,iCAAiC,CAAC,CAAC,EACnCD,sBAAsB,CAACG,MAAM,CAAC,CACjC;AACL,CAAC","ignoreList":[]}
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;QACAC,uBAAuBF;KAC1B"}
@@ -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
- async execute(builder) {
5
- return [builder.private({
6
- modelId: SCHEDULE_MODEL_ID,
7
- name: "Webiny CMS Schedule"
8
- }).fields(fields => ({
9
- namespace: fields.text().label("Namespace"),
10
- actionType: fields.text().label("Action Type"),
11
- targetId: fields.text().label("Target ID"),
12
- scheduledBy: fields.object().label("Scheduled By").fields(fields => ({
13
- id: fields.text().label("Identity ID"),
14
- displayName: fields.text().label("Display Name"),
15
- type: fields.text().label("Type")
16
- })),
17
- scheduledFor: fields.datetime().label("Scheduled For"),
18
- title: fields.text().label("Title"),
19
- error: fields.text().label("Error"),
20
- payload: fields.json().label("Payload")
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
- export const SchedulePrivateModel = ModelFactory.createImplementation({
25
- implementation: SchedulePrivateModelImpl,
26
- dependencies: []
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,"names":["ModelFactory","SCHEDULE_MODEL_ID","SchedulePrivateModelImpl","execute","builder","private","modelId","name","fields","namespace","text","label","actionType","targetId","scheduledBy","object","id","displayName","type","scheduledFor","datetime","title","error","payload","json","SchedulePrivateModel","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,YAAY,QAAQ,yDAAyD;AACtF,SAASC,iBAAiB;AAE1B,MAAMC,wBAAwB,CAAmC;EAC7D,MAAaC,OAAOA,CAACC,OAA6B,EAAE;IAChD,OAAO,CACHA,OAAO,CACFC,OAAO,CAAC;MACLC,OAAO,EAAEL,iBAAiB;MAC1BM,IAAI,EAAE;IACV,CAAC,CAAC,CACDC,MAAM,CAACA,MAAM,KAAK;MACfC,SAAS,EAAED,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,WAAW,CAAC;MAC3CC,UAAU,EAAEJ,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,aAAa,CAAC;MAC9CE,QAAQ,EAAEL,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,WAAW,CAAC;MAC1CG,WAAW,EAAEN,MAAM,CACdO,MAAM,CAAC,CAAC,CACRJ,KAAK,CAAC,cAAc,CAAC,CACrBH,MAAM,CAACA,MAAM,KAAK;QACfQ,EAAE,EAAER,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,aAAa,CAAC;QACtCM,WAAW,EAAET,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,cAAc,CAAC;QAChDO,IAAI,EAAEV,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM;MACpC,CAAC,CAAC,CAAC;MACPQ,YAAY,EAAEX,MAAM,CAACY,QAAQ,CAAC,CAAC,CAACT,KAAK,CAAC,eAAe,CAAC;MACtDU,KAAK,EAAEb,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,OAAO,CAAC;MACnCW,KAAK,EAAEd,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,OAAO,CAAC;MACnCY,OAAO,EAAEf,MAAM,CAACgB,IAAI,CAAC,CAAC,CAACb,KAAK,CAAC,SAAS;IAC1C,CAAC,CAAC,CAAC,CACV;EACL;AACJ;AAEA,OAAO,MAAMc,oBAAoB,GAAGzB,YAAY,CAAC0B,oBAAoB,CAAC;EAClEC,cAAc,EAAEzB,wBAAwB;EACxC0B,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
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
- export class ScheduledActionId {
4
- static from(params) {
5
- return [SCHEDULE_ID_PREFIX, createCacheKey([params.namespace, params.actionType, params.targetId]).slice(-24)].join("");
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,"names":["createCacheKey","SCHEDULE_ID_PREFIX","ScheduledActionId","from","params","namespace","actionType","targetId","slice","join"],"sources":["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"],"mappings":"AAAA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,kBAAkB;AAQ3B,OAAO,MAAMC,iBAAiB,CAAC;EAC3B,OAAOC,IAAIA,CAACC,MAAgC,EAAE;IAC1C,OAAO,CACHH,kBAAkB,EAClBD,cAAc,CAAC,CAACI,MAAM,CAACC,SAAS,EAAED,MAAM,CAACE,UAAU,EAAEF,MAAM,CAACG,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CACpF,CAACC,IAAI,CAAC,EAAE,CAAC;EACd;AACJ","ignoreList":[]}
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
- export class ScheduledActionIdWithVersion {
2
- static from(id) {
3
- if (id.endsWith("#0001")) {
4
- return id;
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,"names":["ScheduledActionIdWithVersion","from","id","endsWith"],"sources":["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"],"mappings":"AAAA,OAAO,MAAMA,4BAA4B,CAAC;EACtC,OAAOC,IAAIA,CAACC,EAAU,EAAE;IACpB,IAAIA,EAAE,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;MACtB,OAAOD,EAAE;IACb;IAEA,OAAO,GAAGA,EAAE,OAAO;EACvB;AACJ","ignoreList":[]}
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"}
@@ -1,37 +1,36 @@
1
1
  import { parseIdentifier } from "@webiny/utils";
2
2
  import { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from "../constants.js";
3
- export class ScheduledActionMapper {
4
- static toAction(action) {
5
- const {
6
- id: scheduleId
7
- } = parseIdentifier(action.id);
8
- return {
9
- id: scheduleId,
10
- targetId: action.values.targetId,
11
- namespace: action.values.namespace,
12
- scheduledBy: action.values.scheduledBy,
13
- scheduledFor: new Date(action.values.scheduledFor),
14
- actionType: action.values.actionType,
15
- title: action.values.title,
16
- payload: action.values.payload,
17
- error: action.values.error
18
- };
19
- }
20
- static toActions(actions) {
21
- return actions.map(ScheduledActionMapper.toAction);
22
- }
23
- static toGraphQL(action) {
24
- return {
25
- id: action.id,
26
- targetId: action.targetId,
27
- namespace: action.namespace,
28
- scheduledBy: action.scheduledBy,
29
- publishOn: action.actionType === SCHEDULED_ACTION_PUBLISH ? action.scheduledFor : null,
30
- unpublishOn: action.actionType === SCHEDULED_ACTION_UNPUBLISH ? action.scheduledFor : null,
31
- actionType: action.actionType,
32
- title: action.title
33
- };
34
- }
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
+ }
35
33
  }
34
+ export { ScheduledActionMapper };
36
35
 
37
36
  //# sourceMappingURL=ScheduledActionMapper.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["parseIdentifier","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH","ScheduledActionMapper","toAction","action","id","scheduleId","targetId","values","namespace","scheduledBy","scheduledFor","Date","actionType","title","payload","error","toActions","actions","map","toGraphQL","publishOn","unpublishOn"],"sources":["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"],"mappings":"AAEA,SAASA,eAAe,QAAQ,eAAe;AAC/C,SAASC,wBAAwB,EAAEC,0BAA0B;AAE7D,OAAO,MAAMC,qBAAqB,CAAC;EAC/B,OAAOC,QAAQA,CACXC,MAAgC,EACb;IACnB,MAAM;MAAEC,EAAE,EAAEC;IAAW,CAAC,GAAGP,eAAe,CAACK,MAAM,CAACC,EAAE,CAAC;IACrD,OAAO;MACHA,EAAE,EAAEC,UAAU;MACdC,QAAQ,EAAEH,MAAM,CAACI,MAAM,CAACD,QAAQ;MAChCE,SAAS,EAAEL,MAAM,CAACI,MAAM,CAACC,SAAS;MAClCC,WAAW,EAAEN,MAAM,CAACI,MAAM,CAACE,WAAW;MACtCC,YAAY,EAAE,IAAIC,IAAI,CAACR,MAAM,CAACI,MAAM,CAACG,YAAY,CAAC;MAClDE,UAAU,EAAET,MAAM,CAACI,MAAM,CAACK,UAAU;MACpCC,KAAK,EAAEV,MAAM,CAACI,MAAM,CAACM,KAAK;MAC1BC,OAAO,EAAEX,MAAM,CAACI,MAAM,CAACO,OAAO;MAC9BC,KAAK,EAAEZ,MAAM,CAACI,MAAM,CAACQ;IACzB,CAAC;EACL;EAEA,OAAOC,SAASA,CACZC,OAAmC,EACd;IACrB,OAAOA,OAAO,CAACC,GAAG,CAACjB,qBAAqB,CAACC,QAAQ,CAAC;EACtD;EAEA,OAAOiB,SAASA,CAA0ChB,MAA2B,EAAE;IACnF,OAAO;MACHC,EAAE,EAAED,MAAM,CAACC,EAAE;MACbE,QAAQ,EAAEH,MAAM,CAACG,QAAQ;MACzBE,SAAS,EAAEL,MAAM,CAACK,SAAS;MAC3BC,WAAW,EAAEN,MAAM,CAACM,WAAW;MAC/BW,SAAS,EAAEjB,MAAM,CAACS,UAAU,KAAKb,wBAAwB,GAAGI,MAAM,CAACO,YAAY,GAAG,IAAI;MACtFW,WAAW,EACPlB,MAAM,CAACS,UAAU,KAAKZ,0BAA0B,GAAGG,MAAM,CAACO,YAAY,GAAG,IAAI;MACjFE,UAAU,EAAET,MAAM,CAACS,UAAU;MAC7BC,KAAK,EAAEV,MAAM,CAACU;IAClB,CAAC;EACL;AACJ","ignoreList":[]}
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"}