@webiny/api-scheduler 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (59) hide show
  1. package/ScheduledActionLambdaHandler.d.ts +4 -4
  2. package/ScheduledActionLambdaHandler.js +1 -1
  3. package/ScheduledActionLambdaHandler.js.map +1 -1
  4. package/SchedulerFeature.d.ts +0 -1
  5. package/SchedulerFeature.js +4 -4
  6. package/SchedulerFeature.js.map +1 -1
  7. package/domain/SchedulePrivateModel.js +2 -1
  8. package/domain/SchedulePrivateModel.js.map +1 -1
  9. package/domain/ScheduledActionMapper.js +6 -1
  10. package/domain/ScheduledActionMapper.js.map +1 -1
  11. package/exports/api/scheduler.d.ts +1 -1
  12. package/exports/api/scheduler.js +1 -1
  13. package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +5 -5
  14. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +12 -11
  15. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  16. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +3 -3
  17. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +16 -7
  18. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  19. package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +5 -5
  20. package/features/GetScheduledAction/GetScheduledActionUseCase.js +12 -11
  21. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  22. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +5 -5
  23. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +13 -12
  24. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -1
  25. package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -5
  26. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +15 -13
  27. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  28. package/features/ScheduleAction/ScheduleActionUseCase.d.ts +3 -3
  29. package/features/ScheduleAction/ScheduleActionUseCase.js +13 -9
  30. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  31. package/features/ScheduledActionModelProvider.d.ts +26 -0
  32. package/features/ScheduledActionModelProvider.js +22 -0
  33. package/features/ScheduledActionModelProvider.js.map +1 -0
  34. package/features/permissions/SchedulerPermissionsResolver.d.ts +12 -0
  35. package/features/permissions/SchedulerPermissionsResolver.js +42 -0
  36. package/features/permissions/SchedulerPermissionsResolver.js.map +1 -0
  37. package/features/permissions/abstractions.d.ts +18 -12
  38. package/features/permissions/abstractions.js +4 -4
  39. package/features/permissions/abstractions.js.map +1 -1
  40. package/graphql/SchedulerGraphQLFactory.d.ts +1 -0
  41. package/graphql/SchedulerGraphQLFactory.js +4 -0
  42. package/graphql/SchedulerGraphQLFactory.js.map +1 -1
  43. package/index.d.ts +1 -2
  44. package/index.js +1 -1
  45. package/package.json +10 -14
  46. package/shared/abstractions.d.ts +11 -5
  47. package/shared/abstractions.js +2 -2
  48. package/shared/abstractions.js.map +1 -1
  49. package/SchedulerFeature.types.d.ts +0 -5
  50. package/SchedulerFeature.types.js +0 -0
  51. package/SchedulerModelContextualSchema.d.ts +0 -13
  52. package/SchedulerModelContextualSchema.js +0 -32
  53. package/SchedulerModelContextualSchema.js.map +0 -1
  54. package/domain/permissionsSchema.d.ts +0 -9
  55. package/domain/permissionsSchema.js +0 -18
  56. package/domain/permissionsSchema.js.map +0 -1
  57. package/features/permissions/feature.d.ts +0 -4
  58. package/features/permissions/feature.js +0 -7
  59. package/features/permissions/feature.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { GraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions";
2
2
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.core.js";
3
3
  export declare class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
4
5
  execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
5
6
  }
6
7
  export declare const SchedulerGraphQLFactory: typeof SchedulerGraphQL & {
@@ -1,3 +1,4 @@
1
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
1
2
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.core.js";
2
3
  import { GetScheduledActionUseCase } from "../features/GetScheduledAction/index.js";
3
4
  import { ErrorResponse, ListResponse, Response } from "@webiny/api-graphql/responses.js";
@@ -209,6 +210,9 @@ class SchedulerGraphQL {
209
210
  });
210
211
  return builder;
211
212
  }
213
+ constructor(){
214
+ this.getSchemaKey = staticSchemaKey("api-scheduler/SchedulerGraphQL");
215
+ }
212
216
  }
213
217
  const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({
214
218
  dependencies: [],
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/SchedulerGraphQLFactory.js","sources":["../../src/graphql/SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"names":["SchedulerGraphQL","builder","GetScheduledActionUseCase","useCase","args","result","ScheduledActionNotFoundError","Response","ErrorResponse","ScheduledActionMapper","GetTargetScheduledActionUseCase","ListScheduledActionsUseCase","ListResponse","item","ScheduleActionUseCase","CancelScheduledActionUseCase","SchedulerGraphQLFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;;AA2BO,MAAMA;IACT,MAAa,QACTC,OAAuC,EACA;QACvCA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0HrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QACAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QAEAA,QAAQ,WAAW,CAAmC;YAClD,MAAM;YACN,cAAc;gBAACC;aAA0B;YACzC,UAAU,CAACC,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IAAI;wBACjB,IAAIA,OAAO,KAAK,YAAYC,8BACxB,OAAO,IAAIC,SAAS;wBAExB,OAAO,IAAIC,cAAcH,OAAO,KAAK;oBACzC;oBAEA,OAAO,IAAIE,SACPE,sBAAsB,SAAS,CAACJ,OAAO,KAAK;gBAEpD;QAER;QAEAJ,QAAQ,WAAW,CAAyC;YACxD,MAAM;YACN,cAAc;gBAACS;aAAgC;YAC/C,UAAU,CAACP,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IAAI;wBACjB,IAAIA,OAAO,KAAK,YAAYC,8BACxB,OAAO,IAAIC,SAAS;wBAExB,OAAO,IAAIC,cAAcH,OAAO,KAAK;oBACzC;oBAEA,OAAO,IAAIE,SACPE,sBAAsB,SAAS,CAACJ,OAAO,KAAK;gBAEpD;QAER;QAEAJ,QAAQ,WAAW,CAA4B;YAC3C,MAAM;YACN,cAAc;gBAACU;aAA4B;YAC3C,UAAU,CAACR,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAAC;wBACjC,GAAGC,IAAI;wBACP,OAAO;4BACH,GAAGA,KAAK,KAAK;4BACb,WAAWA,KAAK,SAAS;wBAC7B;oBACJ;oBAEA,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIO,aACPP,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACQ,CAAAA,OACZJ,sBAAsB,SAAS,CAACI,QAE3CR,OAAO,KAAK,CAAC,IAAI;gBAEzB;QAER;QAEAJ,QAAQ,WAAW,CAA+B;YAC9C,MAAM;YACN,cAAc;gBAACa;aAAsB;YACrC,UAAU,CAACX,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SACPE,sBAAsB,SAAS,CAACJ,OAAO,KAAK;gBAEpD;QAER;QAEAJ,QAAQ,WAAW,CAAsC;YACrD,MAAM;YACN,cAAc;gBAACc;aAA6B;YAC5C,UAAU,CAACZ,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SAAkBF,OAAO,KAAK;gBAC7C;QAER;QAEA,OAAOJ;IACX;AACJ;AAEO,MAAMe,0BAA0BC,yBAAyB,oBAAoB,CAAC;IACjF,cAAc,EAAE;IAChB,gBAAgBjB;AACpB"}
1
+ {"version":3,"file":"graphql/SchedulerGraphQLFactory.js","sources":["../../src/graphql/SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-scheduler/SchedulerGraphQL\");\n\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"names":["SchedulerGraphQL","builder","GetScheduledActionUseCase","useCase","args","result","ScheduledActionNotFoundError","Response","ErrorResponse","ScheduledActionMapper","GetTargetScheduledActionUseCase","ListScheduledActionsUseCase","ListResponse","item","ScheduleActionUseCase","CancelScheduledActionUseCase","staticSchemaKey","SchedulerGraphQLFactory","CoreGraphQLSchemaFactory"],"mappings":"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"}
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "./shared/abstractions.js";
1
+ export { SchedulerService, ScheduledActionHandler } from "./shared/abstractions.js";
2
2
  export type { IScheduledAction } from "./shared/abstractions.js";
3
3
  export { ScheduledActionId } from "./domain/ScheduledActionId.js";
4
4
  export { SchedulerFeature } from "./SchedulerFeature.js";
5
- export type { ISchedulerFeatureConfig } from "./SchedulerFeature.js";
6
5
  export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { ScheduledActionHandler, ScheduledActionModel, SchedulerService } from "./shared/abstractions.js";
1
+ export { ScheduledActionHandler, SchedulerService } from "./shared/abstractions.js";
2
2
  export { ScheduledActionId } from "./domain/ScheduledActionId.js";
3
3
  export { SchedulerFeature } from "./SchedulerFeature.js";
4
4
  export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-scheduler",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,24 +18,20 @@
18
18
  "description": "A generic action scheduler.",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@webiny/api": "6.6.0-alpha.0",
22
- "@webiny/api-core": "6.6.0-alpha.0",
23
- "@webiny/api-graphql": "6.6.0-alpha.0",
24
- "@webiny/api-headless-cms": "6.6.0-alpha.0",
25
- "@webiny/aws-sdk": "6.6.0-alpha.0",
26
- "@webiny/di": "1.0.2",
27
- "@webiny/event-handler-aws": "6.6.0-alpha.0",
28
- "@webiny/event-handler-core": "6.6.0-alpha.0",
29
- "@webiny/feature": "6.6.0-alpha.0",
30
- "@webiny/utils": "6.6.0-alpha.0",
21
+ "@webiny/api": "6.6.0-alpha.10",
22
+ "@webiny/api-core": "6.6.0-alpha.10",
23
+ "@webiny/api-graphql": "6.6.0-alpha.10",
24
+ "@webiny/api-headless-cms": "6.6.0-alpha.10",
25
+ "@webiny/event-handler-core": "6.6.0-alpha.10",
26
+ "@webiny/feature": "6.6.0-alpha.10",
27
+ "@webiny/utils": "6.6.0-alpha.10",
31
28
  "graphql": "16.14.2"
32
29
  },
33
30
  "devDependencies": {
34
- "@webiny/build-tools": "6.6.0-alpha.0",
35
- "@webiny/project-utils": "6.6.0-alpha.0",
31
+ "@webiny/build-tools": "6.6.0-alpha.10",
36
32
  "rimraf": "6.1.3",
37
33
  "typescript": "7.0.2",
38
- "vitest": "4.1.10"
34
+ "vitest": "5.0.5"
39
35
  },
40
36
  "publishConfig": {
41
37
  "access": "public"
@@ -98,10 +98,16 @@ export declare namespace SchedulerService {
98
98
  type ExistsParams = ISchedulerServiceExistsParams;
99
99
  }
100
100
  /**
101
- * ScheduledActionModel - A CMS model used by the scheduler for persistence.
101
+ * Provides the scheduler's CMS model for the current request's tenant.
102
+ *
103
+ * A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,
104
+ * and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a
105
+ * per-request hook running before every consumer. Consumers `await get()` at the point of use.
102
106
  */
103
- /** Content model definition for scheduled actions. */
104
- export declare const ScheduledActionModel: import("@webiny/di").Abstraction<CmsModel>;
105
- export declare namespace ScheduledActionModel {
106
- type Interface = CmsModel;
107
+ export interface IScheduledActionModelProvider {
108
+ get(): Promise<CmsModel>;
109
+ }
110
+ export declare const ScheduledActionModelProvider: import("@webiny/di").Abstraction<IScheduledActionModelProvider>;
111
+ export declare namespace ScheduledActionModelProvider {
112
+ type Interface = IScheduledActionModelProvider;
107
113
  }
@@ -1,7 +1,7 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
2
  const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
3
3
  const SchedulerService = createAbstraction("SchedulerService");
4
- const ScheduledActionModel = createAbstraction("ScheduledActionModel");
5
- export { ScheduledActionHandler, ScheduledActionModel, SchedulerService };
4
+ const ScheduledActionModelProvider = createAbstraction("ScheduledActionModelProvider");
5
+ export { ScheduledActionHandler, ScheduledActionModelProvider, SchedulerService };
6
6
 
7
7
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared/abstractions.js","sources":["../../src/shared/abstractions.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\n/**\n * Identity type - represents who scheduled an action\n */\nexport interface Identity {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport type ScheduledActionType =\n | typeof SCHEDULED_ACTION_PUBLISH\n | typeof SCHEDULED_ACTION_UNPUBLISH;\n/**\n * Scheduled Action Record - The data stored for a scheduled action\n */\n\nexport interface IScheduledActionEntryValues<T> {\n namespace: string; // Resource scope: \"Cms/Entry/Article\", \"Mailer/Email\"\n actionType: ScheduledActionType;\n targetId: string; // Resource identifier (entry ID, email ID, etc.)\n scheduledBy: Identity;\n scheduledFor: string;\n title: string;\n payload: T; // Action-specific data\n error: string | undefined; // Error if execution failed\n}\n\nexport interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<\n IScheduledActionEntryValues<T>\n> {}\n\nexport interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<\n IScheduledActionEntryValues<T>,\n \"scheduledFor\"\n> {\n id: string;\n tenant: string;\n scheduledFor: Date;\n}\n\n/**\n * ScheduledActionHandler - Similar to EventHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: ScheduledActionType): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\n/** Handle execution of a scheduled action. */\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\n\nexport interface ISchedulerServiceDeleteParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerServiceExistsParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerService {\n create(params: ISchedulerServiceCreateParams): Promise<void>;\n update(params: ISchedulerServiceUpdateParams): Promise<void>;\n delete(params: ISchedulerServiceDeleteParams): Promise<void>;\n exists(params: ISchedulerServiceExistsParams): Promise<boolean>;\n}\n\n/** Core service for managing scheduled actions. */\nexport const SchedulerService = createAbstraction<ISchedulerService>(\"SchedulerService\");\n\nexport namespace SchedulerService {\n export type Interface = ISchedulerService;\n export type CreateParams = ISchedulerServiceCreateParams;\n export type UpdateParams = ISchedulerServiceUpdateParams;\n export type DeleteParams = ISchedulerServiceDeleteParams;\n export type ExistsParams = ISchedulerServiceExistsParams;\n}\n\n/**\n * ScheduledActionModel - A CMS model used by the scheduler for persistence.\n */\n/** Content model definition for scheduled actions. */\nexport const ScheduledActionModel = createAbstraction<CmsModel>(\"ScheduledActionModel\");\n\nexport namespace ScheduledActionModel {\n export type Interface = CmsModel;\n}\n"],"names":["ScheduledActionHandler","createAbstraction","SchedulerService","ScheduledActionModel"],"mappings":";AAoEO,MAAMA,yBACTC,kBAA2C;AA6CxC,MAAMC,mBAAmBD,kBAAqC;AAc9D,MAAME,uBAAuBF,kBAA4B"}
1
+ {"version":3,"file":"shared/abstractions.js","sources":["../../src/shared/abstractions.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\n/**\n * Identity type - represents who scheduled an action\n */\nexport interface Identity {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport type ScheduledActionType =\n | typeof SCHEDULED_ACTION_PUBLISH\n | typeof SCHEDULED_ACTION_UNPUBLISH;\n/**\n * Scheduled Action Record - The data stored for a scheduled action\n */\n\nexport interface IScheduledActionEntryValues<T> {\n namespace: string; // Resource scope: \"Cms/Entry/Article\", \"Mailer/Email\"\n actionType: ScheduledActionType;\n targetId: string; // Resource identifier (entry ID, email ID, etc.)\n scheduledBy: Identity;\n scheduledFor: string;\n title: string;\n payload: T; // Action-specific data\n error: string | undefined; // Error if execution failed\n}\n\nexport interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<\n IScheduledActionEntryValues<T>\n> {}\n\nexport interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<\n IScheduledActionEntryValues<T>,\n \"scheduledFor\"\n> {\n id: string;\n tenant: string;\n scheduledFor: Date;\n}\n\n/**\n * ScheduledActionHandler - Similar to EventHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: ScheduledActionType): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\n/** Handle execution of a scheduled action. */\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\n\nexport interface ISchedulerServiceDeleteParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerServiceExistsParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerService {\n create(params: ISchedulerServiceCreateParams): Promise<void>;\n update(params: ISchedulerServiceUpdateParams): Promise<void>;\n delete(params: ISchedulerServiceDeleteParams): Promise<void>;\n exists(params: ISchedulerServiceExistsParams): Promise<boolean>;\n}\n\n/** Core service for managing scheduled actions. */\nexport const SchedulerService = createAbstraction<ISchedulerService>(\"SchedulerService\");\n\nexport namespace SchedulerService {\n export type Interface = ISchedulerService;\n export type CreateParams = ISchedulerServiceCreateParams;\n export type UpdateParams = ISchedulerServiceUpdateParams;\n export type DeleteParams = ISchedulerServiceDeleteParams;\n export type ExistsParams = ISchedulerServiceExistsParams;\n}\n\n/**\n * Provides the scheduler's CMS model for the current request's tenant.\n *\n * A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,\n * and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a\n * per-request hook running before every consumer. Consumers `await get()` at the point of use.\n */\nexport interface IScheduledActionModelProvider {\n get(): Promise<CmsModel>;\n}\n\nexport const ScheduledActionModelProvider = createAbstraction<IScheduledActionModelProvider>(\n \"ScheduledActionModelProvider\"\n);\n\nexport namespace ScheduledActionModelProvider {\n export type Interface = IScheduledActionModelProvider;\n}\n"],"names":["ScheduledActionHandler","createAbstraction","SchedulerService","ScheduledActionModelProvider"],"mappings":";AAoEO,MAAMA,yBACTC,kBAA2C;AA6CxC,MAAMC,mBAAmBD,kBAAqC;AAqB9D,MAAME,+BAA+BF,kBACxC"}
@@ -1,5 +0,0 @@
1
- import type { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler/index.js";
2
- /** @deprecated getClient is now passed to registerSchedulerAwsExtension in @webiny/api-scheduler-aws */
3
- export interface ISchedulerFeatureConfig {
4
- getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
5
- }
File without changes
@@ -1,13 +0,0 @@
1
- import type { IRequestContextInitializer } from "@webiny/event-handler-core";
2
- import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
4
- declare class SchedulerModelContextualSchemaImpl implements IRequestContextInitializer {
5
- private tenantCtx;
6
- private identityCtx;
7
- constructor(tenantCtx: TenantContext.Interface, identityCtx: IdentityContext.Interface);
8
- init(ctx: Record<string, any>): Promise<void>;
9
- }
10
- export declare const SchedulerModelContextualSchema: typeof SchedulerModelContextualSchemaImpl & {
11
- __abstraction: import("@webiny/di").Abstraction<IRequestContextInitializer>;
12
- };
13
- export {};
@@ -1,32 +0,0 @@
1
- import { RequestContextInitializer } from "@webiny/event-handler-core";
2
- import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
4
- import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
5
- import { ScheduledActionModel } from "./shared/abstractions.js";
6
- import { SCHEDULE_MODEL_ID } from "./constants.js";
7
- class SchedulerModelContextualSchemaImpl {
8
- constructor(tenantCtx, identityCtx){
9
- this.tenantCtx = tenantCtx;
10
- this.identityCtx = identityCtx;
11
- }
12
- async init(ctx) {
13
- if (!this.tenantCtx.getTenant()) return;
14
- const container = ctx.container;
15
- const getModel = container.resolve(GetModelUseCase);
16
- await this.identityCtx.withoutAuthorization(async ()=>{
17
- const result = await getModel.execute(SCHEDULE_MODEL_ID);
18
- if (result.isFail()) throw result.error;
19
- container.registerInstance(ScheduledActionModel, result.value);
20
- });
21
- }
22
- }
23
- const SchedulerModelContextualSchema = RequestContextInitializer.createImplementation({
24
- implementation: SchedulerModelContextualSchemaImpl,
25
- dependencies: [
26
- TenantContext,
27
- IdentityContext
28
- ]
29
- });
30
- export { SchedulerModelContextualSchema };
31
-
32
- //# sourceMappingURL=SchedulerModelContextualSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchedulerModelContextualSchema.js","sources":["../src/SchedulerModelContextualSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { RequestContextInitializer } from \"@webiny/event-handler-core\";\nimport type { IRequestContextInitializer } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport { SCHEDULE_MODEL_ID } from \"~/constants.js\";\n\nclass SchedulerModelContextualSchemaImpl implements IRequestContextInitializer {\n constructor(\n private tenantCtx: TenantContext.Interface,\n private identityCtx: IdentityContext.Interface\n ) {}\n\n async init(ctx: Record<string, any>): Promise<void> {\n if (!this.tenantCtx.getTenant()) {\n return;\n }\n\n const container = ctx.container as Container;\n // Resolved lazily here (build/request time), not as a constructor dep: GetModelUseCase\n // depends on AccessControl, which the CMS initializer only registers during its own init().\n const getModel = container.resolve(GetModelUseCase);\n\n await this.identityCtx.withoutAuthorization(async () => {\n const result = await getModel.execute(SCHEDULE_MODEL_ID);\n if (result.isFail()) {\n throw result.error;\n }\n container.registerInstance(ScheduledActionModel, result.value);\n });\n }\n}\n\nexport const SchedulerModelContextualSchema = RequestContextInitializer.createImplementation({\n implementation: SchedulerModelContextualSchemaImpl,\n dependencies: [TenantContext, IdentityContext]\n});\n"],"names":["SchedulerModelContextualSchemaImpl","tenantCtx","identityCtx","ctx","container","getModel","GetModelUseCase","result","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerModelContextualSchema","RequestContextInitializer","TenantContext","IdentityContext"],"mappings":";;;;;;AASA,MAAMA;IACF,YACYC,SAAkC,EAClCC,WAAsC,CAChD;aAFUD,SAAS,GAATA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,KAAKC,GAAwB,EAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,IACzB;QAGJ,MAAMC,YAAYD,IAAI,SAAS;QAG/B,MAAME,WAAWD,UAAU,OAAO,CAACE;QAEnC,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YACxC,MAAMC,SAAS,MAAMF,SAAS,OAAO,CAACG;YACtC,IAAID,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtBH,UAAU,gBAAgB,CAACK,sBAAsBF,OAAO,KAAK;QACjE;IACJ;AACJ;AAEO,MAAMG,iCAAiCC,0BAA0B,oBAAoB,CAAC;IACzF,gBAAgBX;IAChB,cAAc;QAACY;QAAeC;KAAgB;AAClD"}
@@ -1,9 +0,0 @@
1
- export declare const SCHEDULER_PERMISSIONS_SCHEMA: {
2
- readonly prefix: "scheduler";
3
- readonly fullAccess: true;
4
- readonly entities: readonly [{
5
- readonly id: "action";
6
- readonly permission: "scheduler.action";
7
- readonly scopes: readonly ["full", "own"];
8
- }];
9
- };
@@ -1,18 +0,0 @@
1
- import { createPermissionSchema } from "@webiny/api-core/exports/api/security.js";
2
- const SCHEDULER_PERMISSIONS_SCHEMA = createPermissionSchema({
3
- prefix: "scheduler",
4
- fullAccess: true,
5
- entities: [
6
- {
7
- id: "action",
8
- permission: "scheduler.action",
9
- scopes: [
10
- "full",
11
- "own"
12
- ]
13
- }
14
- ]
15
- });
16
- export { SCHEDULER_PERMISSIONS_SCHEMA };
17
-
18
- //# sourceMappingURL=permissionsSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domain/permissionsSchema.js","sources":["../../src/domain/permissionsSchema.ts"],"sourcesContent":["import { createPermissionSchema } from \"@webiny/api-core/exports/api/security.js\";\n\nexport const SCHEDULER_PERMISSIONS_SCHEMA = createPermissionSchema({\n prefix: \"scheduler\",\n fullAccess: true,\n entities: [\n {\n id: \"action\",\n permission: \"scheduler.action\",\n scopes: [\"full\", \"own\"]\n }\n ]\n});\n"],"names":["SCHEDULER_PERMISSIONS_SCHEMA","createPermissionSchema"],"mappings":";AAEO,MAAMA,+BAA+BC,uBAAuB;IAC/D,QAAQ;IACR,YAAY;IACZ,UAAU;QACN;YACI,IAAI;YACJ,YAAY;YACZ,QAAQ;gBAAC;gBAAQ;aAAM;QAC3B;KACH;AACL"}
@@ -1,4 +0,0 @@
1
- export declare const SchedulerPermissionsFeature: {
2
- name: string;
3
- register(container: import("@webiny/di").Container): void;
4
- };
@@ -1,7 +0,0 @@
1
- import { createPermissionsFeature } from "@webiny/api-core/exports/api/security.js";
2
- import { SCHEDULER_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
3
- import { SchedulerPermissions } from "./abstractions.js";
4
- const SchedulerPermissionsFeature = createPermissionsFeature(SCHEDULER_PERMISSIONS_SCHEMA, SchedulerPermissions);
5
- export { SchedulerPermissionsFeature };
6
-
7
- //# sourceMappingURL=feature.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/permissions/feature.js","sources":["../../../src/features/permissions/feature.ts"],"sourcesContent":["import { createPermissionsFeature } from \"@webiny/api-core/exports/api/security.js\";\nimport { SCHEDULER_PERMISSIONS_SCHEMA } from \"~/domain/permissionsSchema.js\";\nimport { SchedulerPermissions } from \"./abstractions.js\";\n\nexport const SchedulerPermissionsFeature = createPermissionsFeature(\n SCHEDULER_PERMISSIONS_SCHEMA,\n SchedulerPermissions\n);\n"],"names":["SchedulerPermissionsFeature","createPermissionsFeature","SCHEDULER_PERMISSIONS_SCHEMA","SchedulerPermissions"],"mappings":";;;AAIO,MAAMA,8BAA8BC,yBACvCC,8BACAC"}