@webiny/api-scheduler 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/constants.d.ts +5 -0
  2. package/constants.js +11 -8
  3. package/constants.js.map +1 -1
  4. package/context.d.ts +1 -1
  5. package/context.js +32 -26
  6. package/context.js.map +1 -1
  7. package/createEventHandler.d.ts +1 -0
  8. package/createEventHandler.js +26 -39
  9. package/createEventHandler.js.map +1 -1
  10. package/createScheduler.d.ts +1 -1
  11. package/createScheduler.js +5 -7
  12. package/createScheduler.js.map +1 -1
  13. package/domain/SchedulePrivateModel.js +25 -22
  14. package/domain/SchedulePrivateModel.js.map +1 -1
  15. package/domain/ScheduledActionId.js +12 -4
  16. package/domain/ScheduledActionId.js.map +1 -1
  17. package/domain/ScheduledActionIdWithVersion.js +5 -6
  18. package/domain/ScheduledActionIdWithVersion.js.map +1 -1
  19. package/domain/ScheduledActionMapper.d.ts +16 -0
  20. package/domain/ScheduledActionMapper.js +36 -0
  21. package/domain/ScheduledActionMapper.js.map +1 -0
  22. package/domain/errors.d.ts +19 -1
  23. package/domain/errors.js +54 -56
  24. package/domain/errors.js.map +1 -1
  25. package/domain/isValidDate.d.ts +1 -1
  26. package/domain/isValidDate.js +4 -9
  27. package/domain/isValidDate.js.map +1 -1
  28. package/domain/permissionsSchema.d.ts +9 -0
  29. package/domain/permissionsSchema.js +18 -0
  30. package/domain/permissionsSchema.js.map +1 -0
  31. package/exports/api/scheduler.d.ts +10 -0
  32. package/exports/api/scheduler.js +8 -0
  33. package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +4 -2
  34. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +45 -61
  35. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  36. package/features/CancelScheduledAction/abstractions.d.ts +9 -2
  37. package/features/CancelScheduledAction/abstractions.js +2 -10
  38. package/features/CancelScheduledAction/abstractions.js.map +1 -1
  39. package/features/CancelScheduledAction/feature.d.ts +4 -1
  40. package/features/CancelScheduledAction/feature.js +6 -12
  41. package/features/CancelScheduledAction/feature.js.map +1 -1
  42. package/features/CancelScheduledAction/index.js +0 -2
  43. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +1 -1
  44. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +65 -89
  45. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  46. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
  47. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
  48. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
  49. package/features/ExecuteScheduledAction/abstractions.d.ts +9 -2
  50. package/features/ExecuteScheduledAction/abstractions.js +12 -36
  51. package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
  52. package/features/ExecuteScheduledAction/feature.d.ts +4 -1
  53. package/features/ExecuteScheduledAction/feature.js +7 -13
  54. package/features/ExecuteScheduledAction/feature.js.map +1 -1
  55. package/features/ExecuteScheduledAction/index.js +0 -2
  56. package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +6 -2
  57. package/features/GetScheduledAction/GetScheduledActionUseCase.js +38 -39
  58. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  59. package/features/GetScheduledAction/abstractions.d.ts +9 -2
  60. package/features/GetScheduledAction/abstractions.js +2 -11
  61. package/features/GetScheduledAction/abstractions.js.map +1 -1
  62. package/features/GetScheduledAction/feature.d.ts +4 -1
  63. package/features/GetScheduledAction/feature.js +6 -12
  64. package/features/GetScheduledAction/feature.js.map +1 -1
  65. package/features/GetScheduledAction/index.js +0 -2
  66. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +32 -0
  67. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +64 -0
  68. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
  69. package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
  70. package/features/GetTargetScheduledAction/abstractions.js +5 -0
  71. package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
  72. package/features/GetTargetScheduledAction/feature.d.ts +10 -0
  73. package/features/GetTargetScheduledAction/feature.js +11 -0
  74. package/features/GetTargetScheduledAction/feature.js.map +1 -0
  75. package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -2
  76. package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -1
  77. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +53 -67
  78. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  79. package/features/ListScheduledActions/abstractions.d.ts +11 -3
  80. package/features/ListScheduledActions/abstractions.js +2 -12
  81. package/features/ListScheduledActions/abstractions.js.map +1 -1
  82. package/features/ListScheduledActions/feature.d.ts +4 -1
  83. package/features/ListScheduledActions/feature.js +6 -12
  84. package/features/ListScheduledActions/feature.js.map +1 -1
  85. package/features/ListScheduledActions/index.js +0 -2
  86. package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
  87. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +26 -0
  88. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
  89. package/features/NamespaceHandler/abstractions.d.ts +50 -0
  90. package/features/NamespaceHandler/abstractions.js +6 -0
  91. package/features/NamespaceHandler/abstractions.js.map +1 -0
  92. package/features/NamespaceHandler/index.d.ts +1 -0
  93. package/features/NamespaceHandler/index.js +1 -0
  94. package/features/ScheduleAction/ScheduleActionUseCase.d.ts +4 -4
  95. package/features/ScheduleAction/ScheduleActionUseCase.js +146 -143
  96. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  97. package/features/ScheduleAction/abstractions.d.ts +11 -11
  98. package/features/ScheduleAction/abstractions.js +2 -10
  99. package/features/ScheduleAction/abstractions.js.map +1 -1
  100. package/features/ScheduleAction/feature.d.ts +4 -1
  101. package/features/ScheduleAction/feature.js +6 -12
  102. package/features/ScheduleAction/feature.js.map +1 -1
  103. package/features/ScheduleAction/index.js +0 -2
  104. package/features/SchedulerFeature.d.ts +4 -1
  105. package/features/SchedulerFeature.js +12 -20
  106. package/features/SchedulerFeature.js.map +1 -1
  107. package/features/SchedulerService/EventBridgeSchedulerService.d.ts +1 -1
  108. package/features/SchedulerService/EventBridgeSchedulerService.js +86 -120
  109. package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
  110. package/features/SchedulerService/VoidSchedulerService.js +17 -24
  111. package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
  112. package/features/permissions/abstractions.d.ts +14 -0
  113. package/features/permissions/abstractions.js +6 -0
  114. package/features/permissions/abstractions.js.map +1 -0
  115. package/features/permissions/feature.d.ts +4 -0
  116. package/features/permissions/feature.js +7 -0
  117. package/features/permissions/feature.js.map +1 -0
  118. package/graphql/SchedulerGraphQLFactory.d.ts +8 -0
  119. package/graphql/SchedulerGraphQLFactory.js +219 -0
  120. package/graphql/SchedulerGraphQLFactory.js.map +1 -0
  121. package/graphql/index.d.ts +1 -0
  122. package/graphql/index.js +1 -0
  123. package/index.d.ts +0 -6
  124. package/index.js +1 -11
  125. package/manifest.js +26 -30
  126. package/manifest.js.map +1 -1
  127. package/package.json +29 -31
  128. package/shared/abstractions.d.ts +19 -6
  129. package/shared/abstractions.js +4 -29
  130. package/shared/abstractions.js.map +1 -1
  131. package/features/CancelScheduledAction/index.js.map +0 -1
  132. package/features/ExecuteScheduledAction/index.js.map +0 -1
  133. package/features/GetScheduledAction/index.js.map +0 -1
  134. package/features/ListScheduledActions/index.js.map +0 -1
  135. package/features/RunAction/RunActionUseCase.d.ts +0 -23
  136. package/features/RunAction/RunActionUseCase.js +0 -37
  137. package/features/RunAction/RunActionUseCase.js.map +0 -1
  138. package/features/RunAction/abstractions.d.ts +0 -35
  139. package/features/RunAction/abstractions.js +0 -15
  140. package/features/RunAction/abstractions.js.map +0 -1
  141. package/features/RunAction/feature.d.ts +0 -7
  142. package/features/RunAction/feature.js +0 -17
  143. package/features/RunAction/feature.js.map +0 -1
  144. package/features/RunAction/index.js.map +0 -1
  145. package/features/ScheduleAction/index.js.map +0 -1
  146. package/index.js.map +0 -1
  147. /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["Result","GetScheduledActionUseCase","UseCaseAbstraction","ScheduledActionModel","ScheduledActionNotFoundError","ScheduledActionPersistenceError","GetEntryByIdUseCase","ScheduledActionIdWithVersion","GetScheduledActionUseCaseImpl","constructor","getEntryByIdUseCase","model","execute","id","scheduleId","from","entryResult","isFail","error","code","fail","entry","value","ok","entryId","namespace","values","actionType","targetId","scheduledBy","scheduledFor","payload","title","createImplementation","implementation","dependencies"],"sources":["GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Retrieves a scheduled action by its ID\n *\n * Flow:\n * 1. Fetch schedule entry from CMS storage by ID\n * 2. Return null if not found\n * 3. Transform CMS entry to IScheduledAction format\n */\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n id: string\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n // Get entry from CMS\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledAction<T>>(\n this.model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const entry = entryResult.value;\n\n return Result.ok({\n id: entry.entryId,\n namespace: entry.values.namespace,\n actionType: entry.values.actionType,\n targetId: entry.values.targetId,\n scheduledBy: entry.values.scheduledBy,\n scheduledFor: entry.values.scheduledFor,\n payload: entry.values.payload,\n title: entry.values.title,\n error: entry.values.error\n });\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [GetEntryByIdUseCase, ScheduledActionModel]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,yBAAyB,IAAIC,kBAAkB;AAExD,SAASC,oBAAoB;AAC7B,SAASC,4BAA4B,EAAEC,+BAA+B;AACtE,SAASC,mBAAmB,QAAQ,sEAAsE;AAC1G,SAASC,4BAA4B;AAGrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,6BAA6B,CAAyC;EACxEC,WAAWA,CACCC,mBAAkD,EAClDC,KAAqC,EAC/C;IAAA,KAFUD,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,KAAqC,GAArCA,KAAqC;EAC9C;EAEH,MAAMC,OAAOA,CACTC,EAAU,EACoD;IAC9D;IACA,MAAMC,UAAU,GAAGP,4BAA4B,CAACQ,IAAI,CAACF,EAAE,CAAC;IACxD,MAAMG,WAAW,GAAG,MAAM,IAAI,CAACN,mBAAmB,CAACE,OAAO,CACtD,IAAI,CAACD,KAAK,EACVG,UACJ,CAAC;IAED,IAAIE,WAAW,CAACC,MAAM,CAAC,CAAC,EAAE;MACtB,IAAID,WAAW,CAACE,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;QACjD,OAAOnB,MAAM,CAACoB,IAAI,CAAC,IAAIhB,4BAA4B,CAACU,UAAU,CAAC,CAAC;MACpE;MAEA,OAAOd,MAAM,CAACoB,IAAI,CAAC,IAAIf,+BAA+B,CAACW,WAAW,CAACE,KAAK,CAAC,CAAC;IAC9E;IAEA,MAAMG,KAAK,GAAGL,WAAW,CAACM,KAAK;IAE/B,OAAOtB,MAAM,CAACuB,EAAE,CAAC;MACbV,EAAE,EAAEQ,KAAK,CAACG,OAAO;MACjBC,SAAS,EAAEJ,KAAK,CAACK,MAAM,CAACD,SAAS;MACjCE,UAAU,EAAEN,KAAK,CAACK,MAAM,CAACC,UAAU;MACnCC,QAAQ,EAAEP,KAAK,CAACK,MAAM,CAACE,QAAQ;MAC/BC,WAAW,EAAER,KAAK,CAACK,MAAM,CAACG,WAAW;MACrCC,YAAY,EAAET,KAAK,CAACK,MAAM,CAACI,YAAY;MACvCC,OAAO,EAAEV,KAAK,CAACK,MAAM,CAACK,OAAO;MAC7BC,KAAK,EAAEX,KAAK,CAACK,MAAM,CAACM,KAAK;MACzBd,KAAK,EAAEG,KAAK,CAACK,MAAM,CAACR;IACxB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMjB,yBAAyB,GAAGC,kBAAkB,CAAC+B,oBAAoB,CAAC;EAC7EC,cAAc,EAAE1B,6BAA6B;EAC7C2B,YAAY,EAAE,CAAC7B,mBAAmB,EAAEH,oBAAoB;AAC5D,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/GetScheduledActionUseCase.js","sources":["../../../src/features/GetScheduledAction/GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissions } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\n\n/**\n * Retrieves a scheduled action by its ID\n *\n * Flow:\n * 1. Fetch schedule entry from CMS storage by ID\n * 2. Return null if not found\n * 3. Transform CMS entry to IScheduledAction format\n */\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissions: SchedulerPermissions.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"action\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n const { id, namespace } = params;\n // Get entry from CMS\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await this.permissions.onlyOwnRecords(\"action\");\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n /**\n * Always check if the namespace is correct because entry is loaded directly, not via filtering.\n */\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n\n return Result.ok(action);\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [GetEntryByIdUseCase, ScheduledActionModel, SchedulerPermissions, IdentityContext]\n});\n"],"names":["GetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissions","identityContext","params","hasPermission","Result","NotAuthorizedError","id","namespace","scheduleId","ScheduledActionIdWithVersion","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","GetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissions","IdentityContext"],"mappings":";;;;;;;;;AAwBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,WAA2C,EAC3CC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,WAAW,GAAXA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAE3B,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGL;QAE1B,MAAMM,aAAaC,6BAA6B,IAAI,CAACH;QACrD,MAAMI,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CACtD,IAAI,CAAC,KAAK,EACVF;QAGJ,IAAIE,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAON,OAAO,IAAI,CAAC,IAAIO,6BAA6BH;YAGxD,OAAOJ,OAAO,IAAI,CAAC,IAAIQ,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;QAC7D,IAAIA,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAON,OAAO,IAAI,CAAC,IAAIC;QAC3B;QAGJ,MAAMS,QAAQJ,YAAY,KAAK;QAI/B,IAAII,MAAM,MAAM,CAAC,SAAS,KAAKP,WAC3B,OAAOH,OAAO,IAAI,CAAC,IAAIO,6BAA6BH;QAExD,MAAMO,SAASC,sBAAsB,QAAQ,CAAIF;QAEjD,OAAOV,OAAO,EAAE,CAACW;IACrB;AACJ;AAEO,MAAME,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBrB;IAChB,cAAc;QAACsB;QAAqBC;QAAsBC;QAAsBC;KAAgB;AACpG"}
@@ -1,6 +1,6 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import type { IScheduledAction } from "../../shared/abstractions.js";
3
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
3
+ import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, NotAuthorizedError } from "../../domain/errors.js";
4
4
  import type { GenericRecord } from "@webiny/api/types.js";
5
5
  /**
6
6
  * GetScheduledActionUseCase - Retrieve a scheduled action by ID
@@ -13,14 +13,21 @@ import type { GenericRecord } from "@webiny/api/types.js";
13
13
  export interface IGetScheduledActionErrors {
14
14
  persistence: ScheduledActionPersistenceError;
15
15
  notFound: ScheduledActionNotFoundError;
16
+ unauthorized: NotAuthorizedError;
16
17
  }
17
18
  type GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];
19
+ export interface IGetScheduledActionUseCaseParams {
20
+ namespace: string;
21
+ id: string;
22
+ }
18
23
  export interface IGetScheduledActionUseCase {
19
- execute<T extends GenericRecord>(scheduleId: string): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;
24
+ execute<T extends GenericRecord>(params: IGetScheduledActionUseCaseParams): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;
20
25
  }
26
+ /** Retrieve a scheduled action. */
21
27
  export declare const GetScheduledActionUseCase: import("@webiny/di").Abstraction<IGetScheduledActionUseCase>;
22
28
  export declare namespace GetScheduledActionUseCase {
23
29
  type Interface = IGetScheduledActionUseCase;
24
30
  type Error = GetScheduledActionError;
31
+ type Params = IGetScheduledActionUseCaseParams;
25
32
  }
26
33
  export {};
@@ -1,14 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * GetScheduledActionUseCase - Retrieve a scheduled action by ID
5
- *
6
- * Used to check if a schedule exists (for reschedule logic) and to retrieve
7
- * schedule details for display/management purposes.
8
- *
9
- * Returns null value (Result.ok(null)) if schedule not found.
10
- */
11
-
12
- export const GetScheduledActionUseCase = createAbstraction("GetScheduledActionUseCase");
2
+ const GetScheduledActionUseCase = createAbstraction("Scheduler/GetScheduledActionUseCase");
3
+ export { GetScheduledActionUseCase };
13
4
 
14
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","GetScheduledActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * GetScheduledActionUseCase - Retrieve a scheduled action by ID\n *\n * Used to check if a schedule exists (for reschedule logic) and to retrieve\n * schedule details for display/management purposes.\n *\n * Returns null value (Result.ok(null)) if schedule not found.\n */\n\nexport interface IGetScheduledActionErrors {\n persistence: ScheduledActionPersistenceError;\n notFound: ScheduledActionNotFoundError;\n}\n\ntype GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];\n\nexport interface IGetScheduledActionUseCase {\n execute<T extends GenericRecord>(\n scheduleId: string\n ): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;\n}\n\nexport const GetScheduledActionUseCase = createAbstraction<IGetScheduledActionUseCase>(\n \"GetScheduledActionUseCase\"\n);\n\nexport namespace GetScheduledActionUseCase {\n export type Interface = IGetScheduledActionUseCase;\n export type Error = GetScheduledActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAMvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,MAAMC,yBAAyB,GAAGD,iBAAiB,CACtD,2BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/abstractions.js","sources":["../../../src/features/GetScheduledAction/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport {\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n NotAuthorizedError\n} from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * GetScheduledActionUseCase - Retrieve a scheduled action by ID\n *\n * Used to check if a schedule exists (for reschedule logic) and to retrieve\n * schedule details for display/management purposes.\n *\n * Returns null value (Result.ok(null)) if schedule not found.\n */\n\nexport interface IGetScheduledActionErrors {\n persistence: ScheduledActionPersistenceError;\n notFound: ScheduledActionNotFoundError;\n unauthorized: NotAuthorizedError;\n}\n\ntype GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];\n\nexport interface IGetScheduledActionUseCaseParams {\n namespace: string;\n id: string;\n}\n\nexport interface IGetScheduledActionUseCase {\n execute<T extends GenericRecord>(\n params: IGetScheduledActionUseCaseParams\n ): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;\n}\n\n/** Retrieve a scheduled action. */\nexport const GetScheduledActionUseCase = createAbstraction<IGetScheduledActionUseCase>(\n \"Scheduler/GetScheduledActionUseCase\"\n);\n\nexport namespace GetScheduledActionUseCase {\n export type Interface = IGetScheduledActionUseCase;\n export type Error = GetScheduledActionError;\n export type Params = IGetScheduledActionUseCaseParams;\n}\n"],"names":["GetScheduledActionUseCase","createAbstraction"],"mappings":";AAsCO,MAAMA,4BAA4BC,kBACrC"}
@@ -4,4 +4,7 @@
4
4
  * Provides the ability to retrieve a scheduled action by ID.
5
5
  * Used for checking if schedules exist and displaying schedule details.
6
6
  */
7
- export declare const GetScheduledActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
7
+ export declare const GetScheduledActionFeature: {
8
+ name: string;
9
+ register(container: import("@webiny/di").Container): void;
10
+ };
@@ -1,17 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { GetScheduledActionUseCase } from "./GetScheduledActionUseCase.js";
3
-
4
- /**
5
- * GetScheduledAction Feature
6
- *
7
- * Provides the ability to retrieve a scheduled action by ID.
8
- * Used for checking if schedules exist and displaying schedule details.
9
- */
10
- export const GetScheduledActionFeature = createFeature({
11
- name: "GetScheduledAction",
12
- register(container) {
13
- container.register(GetScheduledActionUseCase);
14
- }
3
+ const GetScheduledActionFeature = createFeature({
4
+ name: "GetScheduledAction",
5
+ register (container) {
6
+ container.register(GetScheduledActionUseCase);
7
+ }
15
8
  });
9
+ export { GetScheduledActionFeature };
16
10
 
17
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","GetScheduledActionUseCase","GetScheduledActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase } from \"./GetScheduledActionUseCase.js\";\n\n/**\n * GetScheduledAction Feature\n *\n * Provides the ability to retrieve a scheduled action by ID.\n * Used for checking if schedules exist and displaying schedule details.\n */\nexport const GetScheduledActionFeature = createFeature({\n name: \"GetScheduledAction\",\n register(container) {\n container.register(GetScheduledActionUseCase);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAGF,aAAa,CAAC;EACnDG,IAAI,EAAE,oBAAoB;EAC1BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yBAAyB,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/feature.js","sources":["../../../src/features/GetScheduledAction/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase } from \"./GetScheduledActionUseCase.js\";\n\n/**\n * GetScheduledAction Feature\n *\n * Provides the ability to retrieve a scheduled action by ID.\n * Used for checking if schedules exist and displaying schedule details.\n */\nexport const GetScheduledActionFeature = createFeature({\n name: \"GetScheduledAction\",\n register(container) {\n container.register(GetScheduledActionUseCase);\n }\n});\n"],"names":["GetScheduledActionFeature","createFeature","container","GetScheduledActionUseCase"],"mappings":";;AASO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -1,3 +1 @@
1
1
  export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetTargetScheduledActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
+ import type { IScheduledAction } from "../../shared/abstractions.js";
4
+ import { ScheduledActionModel } from "../../shared/abstractions.js";
5
+ import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
6
+ import type { GenericRecord } from "@webiny/api/types.js";
7
+ import { SchedulerPermissions } from "../../features/permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
9
+ /**
10
+ * Retrieves a scheduled action by its ID
11
+ *
12
+ * Flow:
13
+ * 1. Fetch schedule entry from CMS storage by ID
14
+ * 2. Return null if not found
15
+ * 3. Transform CMS entry to IScheduledAction format
16
+ */
17
+ declare class GetTargetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {
18
+ private getEntryByIdUseCase;
19
+ private model;
20
+ private permissions;
21
+ private identityContext;
22
+ constructor(getEntryByIdUseCase: GetEntryByIdUseCase.Interface, model: ScheduledActionModel.Interface, permissions: SchedulerPermissions.Interface, identityContext: IdentityContext.Interface);
23
+ execute<T extends GenericRecord>(params: UseCaseAbstraction.Params): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>>;
24
+ /**
25
+ * We always need to fetch both publish and unpublish actions because we don't know the type of the action that is being searched for.
26
+ */
27
+ private getRecord;
28
+ }
29
+ export declare const GetTargetScheduledActionUseCase: typeof GetTargetScheduledActionUseCaseImpl & {
30
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetTargetScheduledActionUseCase>;
31
+ };
32
+ export {};
@@ -0,0 +1,64 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetTargetScheduledActionUseCase } from "./abstractions.js";
3
+ import { ScheduledActionModel } from "../../shared/abstractions.js";
4
+ import { NotAuthorizedError, ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
5
+ import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
6
+ import { SchedulerPermissions } from "../permissions/abstractions.js";
7
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
8
+ import { ScheduledActionMapper } from "../../domain/ScheduledActionMapper.js";
9
+ import { ScheduledActionId } from "../../domain/ScheduledActionId.js";
10
+ import { ScheduledActionIdWithVersion } from "../../domain/ScheduledActionIdWithVersion.js";
11
+ import { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from "../../constants.js";
12
+ class GetTargetScheduledActionUseCaseImpl {
13
+ constructor(getEntryByIdUseCase, model, permissions, identityContext){
14
+ this.getEntryByIdUseCase = getEntryByIdUseCase;
15
+ this.model = model;
16
+ this.permissions = permissions;
17
+ this.identityContext = identityContext;
18
+ }
19
+ async execute(params) {
20
+ const hasPermission = await this.permissions.canRead("action");
21
+ if (!hasPermission) return Result.fail(new NotAuthorizedError());
22
+ const { id, namespace } = params;
23
+ const entryResult = await this.getRecord(params);
24
+ if (entryResult.isFail()) {
25
+ if ("Cms/Entry/NotFound" === entryResult.error.code) return Result.fail(new ScheduledActionNotFoundError(id));
26
+ return Result.fail(new ScheduledActionPersistenceError(entryResult.error));
27
+ }
28
+ const ownRecordsOnly = await this.permissions.onlyOwnRecords("action");
29
+ if (ownRecordsOnly) {
30
+ if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) return Result.fail(new NotAuthorizedError());
31
+ }
32
+ const entry = entryResult.value;
33
+ if (entry.values.namespace !== namespace) return Result.fail(new ScheduledActionNotFoundError(id));
34
+ const action = ScheduledActionMapper.toAction(entry);
35
+ return Result.ok(action);
36
+ }
37
+ async getRecord(params) {
38
+ const schedulePublishId = ScheduledActionId.from({
39
+ namespace: params.namespace,
40
+ targetId: params.id,
41
+ actionType: SCHEDULED_ACTION_PUBLISH
42
+ });
43
+ const publishResult = await this.getEntryByIdUseCase.execute(this.model, ScheduledActionIdWithVersion.from(schedulePublishId));
44
+ if (publishResult.isOk()) return publishResult;
45
+ const scheduleUnpublishId = ScheduledActionId.from({
46
+ namespace: params.namespace,
47
+ targetId: params.id,
48
+ actionType: SCHEDULED_ACTION_UNPUBLISH
49
+ });
50
+ return this.getEntryByIdUseCase.execute(this.model, ScheduledActionIdWithVersion.from(scheduleUnpublishId));
51
+ }
52
+ }
53
+ const GetTargetScheduledActionUseCase_GetTargetScheduledActionUseCase = GetTargetScheduledActionUseCase.createImplementation({
54
+ implementation: GetTargetScheduledActionUseCaseImpl,
55
+ dependencies: [
56
+ GetEntryByIdUseCase,
57
+ ScheduledActionModel,
58
+ SchedulerPermissions,
59
+ IdentityContext
60
+ ]
61
+ });
62
+ export { GetTargetScheduledActionUseCase_GetTargetScheduledActionUseCase as GetTargetScheduledActionUseCase };
63
+
64
+ //# sourceMappingURL=GetTargetScheduledActionUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js","sources":["../../../src/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetTargetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissions } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { ScheduledActionId } from \"~/domain/ScheduledActionId.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\n/**\n * Retrieves a scheduled action by its ID\n *\n * Flow:\n * 1. Fetch schedule entry from CMS storage by ID\n * 2. Return null if not found\n * 3. Transform CMS entry to IScheduledAction format\n */\nclass GetTargetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissions: SchedulerPermissions.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"action\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n const { id, namespace } = params;\n\n const entryResult = await this.getRecord<T>(params);\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await this.permissions.onlyOwnRecords(\"action\");\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n /**\n * Always check if the namespace is correct because entry is loaded directly, not via filtering.\n */\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n return Result.ok(action);\n }\n /**\n * We always need to fetch both publish and unpublish actions because we don't know the type of the action that is being searched for.\n */\n private async getRecord<T extends GenericRecord>(params: UseCaseAbstraction.Params) {\n const schedulePublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_PUBLISH\n });\n const publishResult = await this.getEntryByIdUseCase.execute<\n IScheduledActionEntryValues<T>\n >(this.model, ScheduledActionIdWithVersion.from(schedulePublishId));\n if (publishResult.isOk()) {\n return publishResult;\n }\n const scheduleUnpublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_UNPUBLISH\n });\n return this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n ScheduledActionIdWithVersion.from(scheduleUnpublishId)\n );\n }\n}\n\nexport const GetTargetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetTargetScheduledActionUseCaseImpl,\n dependencies: [GetEntryByIdUseCase, ScheduledActionModel, SchedulerPermissions, IdentityContext]\n});\n"],"names":["GetTargetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissions","identityContext","params","hasPermission","Result","NotAuthorizedError","id","namespace","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","schedulePublishId","ScheduledActionId","SCHEDULED_ACTION_PUBLISH","publishResult","ScheduledActionIdWithVersion","scheduleUnpublishId","SCHEDULED_ACTION_UNPUBLISH","GetTargetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissions","IdentityContext"],"mappings":";;;;;;;;;;;AA0BA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,WAA2C,EAC3CC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,WAAW,GAAXA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAE3B,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGL;QAE1B,MAAMM,cAAc,MAAM,IAAI,CAAC,SAAS,CAAIN;QAE5C,IAAIM,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOJ,OAAO,IAAI,CAAC,IAAIK,6BAA6BH;YAGxD,OAAOF,OAAO,IAAI,CAAC,IAAIM,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;QAC7D,IAAIA,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAOJ,OAAO,IAAI,CAAC,IAAIC;QAC3B;QAGJ,MAAMO,QAAQJ,YAAY,KAAK;QAI/B,IAAII,MAAM,MAAM,CAAC,SAAS,KAAKL,WAC3B,OAAOH,OAAO,IAAI,CAAC,IAAIK,6BAA6BH;QAExD,MAAMO,SAASC,sBAAsB,QAAQ,CAAIF;QACjD,OAAOR,OAAO,EAAE,CAACS;IACrB;IAIA,MAAc,UAAmCX,MAAiC,EAAE;QAChF,MAAMa,oBAAoBC,kBAAkB,IAAI,CAAC;YAC7C,WAAWd,OAAO,SAAS;YAC3B,UAAUA,OAAO,EAAE;YACnB,YAAYe;QAChB;QACA,MAAMC,gBAAgB,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAE1D,IAAI,CAAC,KAAK,EAAEC,6BAA6B,IAAI,CAACJ;QAChD,IAAIG,cAAc,IAAI,IAClB,OAAOA;QAEX,MAAME,sBAAsBJ,kBAAkB,IAAI,CAAC;YAC/C,WAAWd,OAAO,SAAS;YAC3B,UAAUA,OAAO,EAAE;YACnB,YAAYmB;QAChB;QACA,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CACnC,IAAI,CAAC,KAAK,EACVF,6BAA6B,IAAI,CAACC;IAE1C;AACJ;AAEO,MAAME,kEAAkCC,gCAAAA,oBAAuC,CAAC;IACnF,gBAAgB1B;IAChB,cAAc;QAAC2B;QAAqBC;QAAsBC;QAAsBC;KAAgB;AACpG"}
@@ -0,0 +1,24 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import type { IScheduledAction } from "../../shared/abstractions.js";
3
+ import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, NotAuthorizedError } from "../../domain/errors.js";
4
+ import type { GenericRecord } from "@webiny/api/types.js";
5
+ export interface IGetTargetScheduledActionErrors {
6
+ persistence: ScheduledActionPersistenceError;
7
+ notFound: ScheduledActionNotFoundError;
8
+ unauthorized: NotAuthorizedError;
9
+ }
10
+ type GetTargetScheduledActionError = IGetTargetScheduledActionErrors[keyof IGetTargetScheduledActionErrors];
11
+ export interface IGetTargetScheduledActionUseCaseParams {
12
+ namespace: string;
13
+ id: string;
14
+ }
15
+ export interface IGetTargetScheduledActionUseCase {
16
+ execute<T extends GenericRecord>(params: IGetTargetScheduledActionUseCaseParams): Promise<Result<IScheduledAction<T>, GetTargetScheduledActionError>>;
17
+ }
18
+ export declare const GetTargetScheduledActionUseCase: import("@webiny/di").Abstraction<IGetTargetScheduledActionUseCase>;
19
+ export declare namespace GetTargetScheduledActionUseCase {
20
+ type Interface = IGetTargetScheduledActionUseCase;
21
+ type Error = GetTargetScheduledActionError;
22
+ type Params = IGetTargetScheduledActionUseCaseParams;
23
+ }
24
+ export {};
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const GetTargetScheduledActionUseCase = createAbstraction("Scheduler/GetTargetScheduledActionUseCase");
3
+ export { GetTargetScheduledActionUseCase };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetTargetScheduledAction/abstractions.js","sources":["../../../src/features/GetTargetScheduledAction/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport {\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n NotAuthorizedError\n} from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IGetTargetScheduledActionErrors {\n persistence: ScheduledActionPersistenceError;\n notFound: ScheduledActionNotFoundError;\n unauthorized: NotAuthorizedError;\n}\n\ntype GetTargetScheduledActionError =\n IGetTargetScheduledActionErrors[keyof IGetTargetScheduledActionErrors];\n\nexport interface IGetTargetScheduledActionUseCaseParams {\n namespace: string;\n id: string;\n}\n\nexport interface IGetTargetScheduledActionUseCase {\n execute<T extends GenericRecord>(\n params: IGetTargetScheduledActionUseCaseParams\n ): Promise<Result<IScheduledAction<T>, GetTargetScheduledActionError>>;\n}\n\nexport const GetTargetScheduledActionUseCase = createAbstraction<IGetTargetScheduledActionUseCase>(\n \"Scheduler/GetTargetScheduledActionUseCase\"\n);\n\nexport namespace GetTargetScheduledActionUseCase {\n export type Interface = IGetTargetScheduledActionUseCase;\n export type Error = GetTargetScheduledActionError;\n export type Params = IGetTargetScheduledActionUseCaseParams;\n}\n"],"names":["GetTargetScheduledActionUseCase","createAbstraction"],"mappings":";AA6BO,MAAMA,kCAAkCC,kBAC3C"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * GetTargetScheduledAction Feature
3
+ *
4
+ * Provides the ability to retrieve a target scheduled action by ID.
5
+ * Used for checking if schedules exist and displaying schedule details.
6
+ */
7
+ export declare const GetTargetScheduledActionFeature: {
8
+ name: string;
9
+ register(container: import("@webiny/di").Container): void;
10
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { GetTargetScheduledActionUseCase } from "./GetTargetScheduledActionUseCase.js";
3
+ const GetTargetScheduledActionFeature = createFeature({
4
+ name: "GetTargetScheduledAction",
5
+ register (container) {
6
+ container.register(GetTargetScheduledActionUseCase);
7
+ }
8
+ });
9
+ export { GetTargetScheduledActionFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetTargetScheduledAction/feature.js","sources":["../../../src/features/GetTargetScheduledAction/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetTargetScheduledActionUseCase } from \"./GetTargetScheduledActionUseCase.js\";\n\n/**\n * GetTargetScheduledAction Feature\n *\n * Provides the ability to retrieve a target scheduled action by ID.\n * Used for checking if schedules exist and displaying schedule details.\n */\nexport const GetTargetScheduledActionFeature = createFeature({\n name: \"GetTargetScheduledAction\",\n register(container) {\n container.register(GetTargetScheduledActionUseCase);\n }\n});\n"],"names":["GetTargetScheduledActionFeature","createFeature","container","GetTargetScheduledActionUseCase"],"mappings":";;AASO,MAAMA,kCAAkCC,cAAc;IACzD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -1,3 +1 @@
1
1
  export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -4,6 +4,8 @@ import { IListScheduledActionsParams, IListScheduledActionsResponse, ListSchedul
4
4
  import { ScheduledActionModel } from "../../shared/abstractions.js";
5
5
  import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
6
6
  import type { GenericRecord } from "@webiny/api/types.js";
7
+ import { SchedulerPermissions } from "../../features/permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
7
9
  /**
8
10
  * Lists scheduled actions with optional filtering
9
11
  *
@@ -18,7 +20,9 @@ declare class ListScheduledActionsUseCaseImpl implements UseCaseAbstraction.Inte
18
20
  private model;
19
21
  private cmsWhereMapper;
20
22
  private cmsSortMapper;
21
- constructor(listEntriesUseCase: ListLatestEntriesUseCase.Interface, model: ScheduledActionModel.Interface, cmsWhereMapper: CmsWhereMapper.Interface, cmsSortMapper: CmsSortMapper.Interface);
23
+ private permissions;
24
+ private identityContext;
25
+ constructor(listEntriesUseCase: ListLatestEntriesUseCase.Interface, model: ScheduledActionModel.Interface, cmsWhereMapper: CmsWhereMapper.Interface, cmsSortMapper: CmsSortMapper.Interface, permissions: SchedulerPermissions.Interface, identityContext: IdentityContext.Interface);
22
26
  execute<T extends GenericRecord>(params: IListScheduledActionsParams): Promise<Result<IListScheduledActionsResponse<T>, UseCaseAbstraction.Error>>;
23
27
  }
24
28
  export declare const ListScheduledActionsUseCase: typeof ListScheduledActionsUseCaseImpl & {
@@ -1,77 +1,63 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js";
3
- import { ListScheduledActionsUseCase as UseCaseAbstraction } from "./abstractions.js";
3
+ import { ListScheduledActionsUseCase } from "./abstractions.js";
4
4
  import { ScheduledActionModel } from "../../shared/abstractions.js";
5
- import { ScheduledActionPersistenceError } from "../../domain/errors.js";
5
+ import { NotAuthorizedError, ScheduledActionPersistenceError } from "../../domain/errors.js";
6
6
  import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
7
- /**
8
- * Lists scheduled actions with optional filtering
9
- *
10
- * Flow:
11
- * 1. Build query filters based on where params (namespace, actionType, targetId, etc.)
12
- * 2. Fetch entries from CMS storage with pagination and sorting
13
- * 3. Transform CMS entries to IScheduledAction format
14
- * 4. Return paginated results with metadata
15
- */
7
+ import { SchedulerPermissions } from "../permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
9
+ import { ScheduledActionMapper } from "../../domain/ScheduledActionMapper.js";
16
10
  class ListScheduledActionsUseCaseImpl {
17
- constructor(listEntriesUseCase, model, cmsWhereMapper, cmsSortMapper) {
18
- this.listEntriesUseCase = listEntriesUseCase;
19
- this.model = model;
20
- this.cmsWhereMapper = cmsWhereMapper;
21
- this.cmsSortMapper = cmsSortMapper;
22
- }
23
- async execute(params) {
24
- const {
25
- where,
26
- sort: sortInput,
27
- limit,
28
- after
29
- } = params;
30
- const sort = this.cmsSortMapper.map({
31
- input: sortInput,
32
- fields: this.model.fields
33
- });
34
- // List entries from CMS
35
- const listResult = await this.listEntriesUseCase.execute(this.model, {
36
- where: this.cmsWhereMapper.map({
37
- input: where,
38
- fields: this.model.fields
39
- }),
40
- sort,
41
- limit,
42
- after
43
- });
44
- if (listResult.isFail()) {
45
- return Result.fail(new ScheduledActionPersistenceError(listResult.error));
11
+ constructor(listEntriesUseCase, model, cmsWhereMapper, cmsSortMapper, permissions, identityContext){
12
+ this.listEntriesUseCase = listEntriesUseCase;
13
+ this.model = model;
14
+ this.cmsWhereMapper = cmsWhereMapper;
15
+ this.cmsSortMapper = cmsSortMapper;
16
+ this.permissions = permissions;
17
+ this.identityContext = identityContext;
18
+ }
19
+ async execute(params) {
20
+ const hasPermission = await this.permissions.canRead("action");
21
+ if (!hasPermission) return Result.fail(new NotAuthorizedError());
22
+ const ownRecordsOnly = await this.permissions.onlyOwnRecords("action");
23
+ const { where: initialWhere, sort: sortInput, limit, after } = params;
24
+ const where = this.cmsWhereMapper.map({
25
+ input: initialWhere || {},
26
+ fields: this.model.fields
27
+ });
28
+ if (ownRecordsOnly) {
29
+ const identity = this.identityContext.getIdentity();
30
+ where.createdBy = identity.id;
31
+ }
32
+ const sort = this.cmsSortMapper.map({
33
+ input: sortInput,
34
+ fields: this.model.fields
35
+ });
36
+ const listResult = await this.listEntriesUseCase.execute(this.model, {
37
+ where,
38
+ sort,
39
+ limit,
40
+ after
41
+ });
42
+ if (listResult.isFail()) return Result.fail(new ScheduledActionPersistenceError(listResult.error));
43
+ const { entries, meta } = listResult.value;
44
+ return Result.ok({
45
+ items: ScheduledActionMapper.toActions(entries),
46
+ meta
47
+ });
46
48
  }
47
- const {
48
- entries,
49
- meta
50
- } = listResult.value;
51
-
52
- // Transform entries to IScheduledAction format
53
- const scheduledActions = entries.map(entry => {
54
- return {
55
- id: entry.entryId,
56
- title: entry.values.title,
57
- namespace: entry.values.namespace,
58
- actionType: entry.values.actionType,
59
- targetId: entry.values.targetId,
60
- scheduledBy: entry.values.scheduledBy,
61
- scheduledFor: entry.values.scheduledFor,
62
- payload: entry.values.payload,
63
- error: entry.values.error
64
- };
65
- });
66
- return Result.ok({
67
- items: scheduledActions,
68
- meta
69
- });
70
- }
71
49
  }
72
- export const ListScheduledActionsUseCase = UseCaseAbstraction.createImplementation({
73
- implementation: ListScheduledActionsUseCaseImpl,
74
- dependencies: [ListLatestEntriesUseCase, ScheduledActionModel, CmsWhereMapper, CmsSortMapper]
50
+ const ListScheduledActionsUseCase_ListScheduledActionsUseCase = ListScheduledActionsUseCase.createImplementation({
51
+ implementation: ListScheduledActionsUseCaseImpl,
52
+ dependencies: [
53
+ ListLatestEntriesUseCase,
54
+ ScheduledActionModel,
55
+ CmsWhereMapper,
56
+ CmsSortMapper,
57
+ SchedulerPermissions,
58
+ IdentityContext
59
+ ]
75
60
  });
61
+ export { ListScheduledActionsUseCase_ListScheduledActionsUseCase as ListScheduledActionsUseCase };
76
62
 
77
63
  //# sourceMappingURL=ListScheduledActionsUseCase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","ListLatestEntriesUseCase","ListScheduledActionsUseCase","UseCaseAbstraction","ScheduledActionModel","ScheduledActionPersistenceError","CmsSortMapper","CmsWhereMapper","ListScheduledActionsUseCaseImpl","constructor","listEntriesUseCase","model","cmsWhereMapper","cmsSortMapper","execute","params","where","sort","sortInput","limit","after","map","input","fields","listResult","isFail","fail","error","entries","meta","value","scheduledActions","entry","id","entryId","title","values","namespace","actionType","targetId","scheduledBy","scheduledFor","payload","ok","items","createImplementation","implementation","dependencies"],"sources":["ListScheduledActionsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport {\n IListScheduledActionsParams,\n IListScheduledActionsResponse,\n ListScheduledActionsUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport { ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport { CmsSortMapper, CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Lists scheduled actions with optional filtering\n *\n * Flow:\n * 1. Build query filters based on where params (namespace, actionType, targetId, etc.)\n * 2. Fetch entries from CMS storage with pagination and sorting\n * 3. Transform CMS entries to IScheduledAction format\n * 4. Return paginated results with metadata\n */\nclass ListScheduledActionsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private listEntriesUseCase: ListLatestEntriesUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface,\n private cmsSortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: IListScheduledActionsParams\n ): Promise<Result<IListScheduledActionsResponse<T>, UseCaseAbstraction.Error>> {\n const { where, sort: sortInput, limit, after } = params;\n\n const sort = this.cmsSortMapper.map({\n input: sortInput,\n fields: this.model.fields\n });\n // List entries from CMS\n const listResult = await this.listEntriesUseCase.execute<IScheduledAction<T>>(this.model, {\n where: this.cmsWhereMapper.map({\n input: where,\n fields: this.model.fields\n }),\n sort,\n limit,\n after\n });\n\n if (listResult.isFail()) {\n return Result.fail(new ScheduledActionPersistenceError(listResult.error));\n }\n\n const { entries, meta } = listResult.value;\n\n // Transform entries to IScheduledAction format\n const scheduledActions: IScheduledAction<T>[] = entries.map(entry => {\n return {\n id: entry.entryId,\n title: entry.values.title,\n namespace: entry.values.namespace,\n actionType: entry.values.actionType,\n targetId: entry.values.targetId,\n scheduledBy: entry.values.scheduledBy,\n scheduledFor: entry.values.scheduledFor,\n payload: entry.values.payload,\n error: entry.values.error\n };\n });\n\n return Result.ok({\n items: scheduledActions,\n meta\n });\n }\n}\n\nexport const ListScheduledActionsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListScheduledActionsUseCaseImpl,\n dependencies: [ListLatestEntriesUseCase, ScheduledActionModel, CmsWhereMapper, CmsSortMapper]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,wBAAwB,QAAQ,4EAA4E;AACrH,SAGIC,2BAA2B,IAAIC,kBAAkB;AAGrD,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,aAAa,EAAEC,cAAc,QAAQ,0BAA0B;AAGxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,+BAA+B,CAAyC;EAC1EC,WAAWA,CACCC,kBAAsD,EACtDC,KAAqC,EACrCC,cAAwC,EACxCC,aAAsC,EAChD;IAAA,KAJUH,kBAAsD,GAAtDA,kBAAsD;IAAA,KACtDC,KAAqC,GAArCA,KAAqC;IAAA,KACrCC,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,aAAsC,GAAtCA,aAAsC;EAC/C;EAEH,MAAMC,OAAOA,CACTC,MAAmC,EACwC;IAC3E,MAAM;MAAEC,KAAK;MAAEC,IAAI,EAAEC,SAAS;MAAEC,KAAK;MAAEC;IAAM,CAAC,GAAGL,MAAM;IAEvD,MAAME,IAAI,GAAG,IAAI,CAACJ,aAAa,CAACQ,GAAG,CAAC;MAChCC,KAAK,EAAEJ,SAAS;MAChBK,MAAM,EAAE,IAAI,CAACZ,KAAK,CAACY;IACvB,CAAC,CAAC;IACF;IACA,MAAMC,UAAU,GAAG,MAAM,IAAI,CAACd,kBAAkB,CAACI,OAAO,CAAsB,IAAI,CAACH,KAAK,EAAE;MACtFK,KAAK,EAAE,IAAI,CAACJ,cAAc,CAACS,GAAG,CAAC;QAC3BC,KAAK,EAAEN,KAAK;QACZO,MAAM,EAAE,IAAI,CAACZ,KAAK,CAACY;MACvB,CAAC,CAAC;MACFN,IAAI;MACJE,KAAK;MACLC;IACJ,CAAC,CAAC;IAEF,IAAII,UAAU,CAACC,MAAM,CAAC,CAAC,EAAE;MACrB,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIrB,+BAA+B,CAACmB,UAAU,CAACG,KAAK,CAAC,CAAC;IAC7E;IAEA,MAAM;MAAEC,OAAO;MAAEC;IAAK,CAAC,GAAGL,UAAU,CAACM,KAAK;;IAE1C;IACA,MAAMC,gBAAuC,GAAGH,OAAO,CAACP,GAAG,CAACW,KAAK,IAAI;MACjE,OAAO;QACHC,EAAE,EAAED,KAAK,CAACE,OAAO;QACjBC,KAAK,EAAEH,KAAK,CAACI,MAAM,CAACD,KAAK;QACzBE,SAAS,EAAEL,KAAK,CAACI,MAAM,CAACC,SAAS;QACjCC,UAAU,EAAEN,KAAK,CAACI,MAAM,CAACE,UAAU;QACnCC,QAAQ,EAAEP,KAAK,CAACI,MAAM,CAACG,QAAQ;QAC/BC,WAAW,EAAER,KAAK,CAACI,MAAM,CAACI,WAAW;QACrCC,YAAY,EAAET,KAAK,CAACI,MAAM,CAACK,YAAY;QACvCC,OAAO,EAAEV,KAAK,CAACI,MAAM,CAACM,OAAO;QAC7Bf,KAAK,EAAEK,KAAK,CAACI,MAAM,CAACT;MACxB,CAAC;IACL,CAAC,CAAC;IAEF,OAAO3B,MAAM,CAAC2C,EAAE,CAAC;MACbC,KAAK,EAAEb,gBAAgB;MACvBF;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAM3B,2BAA2B,GAAGC,kBAAkB,CAAC0C,oBAAoB,CAAC;EAC/EC,cAAc,EAAEtC,+BAA+B;EAC/CuC,YAAY,EAAE,CAAC9C,wBAAwB,EAAEG,oBAAoB,EAAEG,cAAc,EAAED,aAAa;AAChG,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/ListScheduledActions/ListScheduledActionsUseCase.js","sources":["../../../src/features/ListScheduledActions/ListScheduledActionsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport {\n IListScheduledActionsParams,\n IListScheduledActionsResponse,\n ListScheduledActionsUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport type { IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport { NotAuthorizedError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport { CmsSortMapper, CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissions } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\n\n/**\n * Lists scheduled actions with optional filtering\n *\n * Flow:\n * 1. Build query filters based on where params (namespace, actionType, targetId, etc.)\n * 2. Fetch entries from CMS storage with pagination and sorting\n * 3. Transform CMS entries to IScheduledAction format\n * 4. Return paginated results with metadata\n */\nclass ListScheduledActionsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private listEntriesUseCase: ListLatestEntriesUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface,\n private cmsSortMapper: CmsSortMapper.Interface,\n private permissions: SchedulerPermissions.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: IListScheduledActionsParams\n ): Promise<Result<IListScheduledActionsResponse<T>, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"action\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const ownRecordsOnly = await this.permissions.onlyOwnRecords(\"action\");\n\n const { where: initialWhere, sort: sortInput, limit, after } = params;\n\n const where = this.cmsWhereMapper.map({\n input: initialWhere || {},\n fields: this.model.fields\n });\n\n if (ownRecordsOnly) {\n const identity = this.identityContext.getIdentity();\n where!.createdBy = identity.id;\n }\n\n const sort = this.cmsSortMapper.map({\n input: sortInput,\n fields: this.model.fields\n });\n // List entries from CMS\n const listResult = await this.listEntriesUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n {\n where,\n sort,\n limit,\n after\n }\n );\n\n if (listResult.isFail()) {\n return Result.fail(new ScheduledActionPersistenceError(listResult.error));\n }\n\n const { entries, meta } = listResult.value;\n\n return Result.ok({\n items: ScheduledActionMapper.toActions<T>(entries),\n meta\n });\n }\n}\n\nexport const ListScheduledActionsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListScheduledActionsUseCaseImpl,\n dependencies: [\n ListLatestEntriesUseCase,\n ScheduledActionModel,\n CmsWhereMapper,\n CmsSortMapper,\n SchedulerPermissions,\n IdentityContext\n ]\n});\n"],"names":["ListScheduledActionsUseCaseImpl","listEntriesUseCase","model","cmsWhereMapper","cmsSortMapper","permissions","identityContext","params","hasPermission","Result","NotAuthorizedError","ownRecordsOnly","initialWhere","sortInput","limit","after","where","identity","sort","listResult","ScheduledActionPersistenceError","entries","meta","ScheduledActionMapper","ListScheduledActionsUseCase","UseCaseAbstraction","ListLatestEntriesUseCase","ScheduledActionModel","CmsWhereMapper","CmsSortMapper","SchedulerPermissions","IdentityContext"],"mappings":";;;;;;;;;AAyBA,MAAMA;IACF,YACYC,kBAAsD,EACtDC,KAAqC,EACrCC,cAAwC,EACxCC,aAAsC,EACtCC,WAA2C,EAC3CC,eAA0C,CACpD;aANUL,kBAAkB,GAAlBA;aACAC,KAAK,GAALA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,WAAW,GAAXA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAmC,EACwC;QAC3E,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;QAE7D,MAAM,EAAE,OAAOC,YAAY,EAAE,MAAMC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGR;QAE/D,MAAMS,QAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;YAClC,OAAOJ,gBAAgB,CAAC;YACxB,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM;QAC7B;QAEA,IAAID,gBAAgB;YAChB,MAAMM,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;YACjDD,MAAO,SAAS,GAAGC,SAAS,EAAE;QAClC;QAEA,MAAMC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YAChC,OAAOL;YACP,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM;QAC7B;QAEA,MAAMM,aAAa,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CACpD,IAAI,CAAC,KAAK,EACV;YACIH;YACAE;YACAJ;YACAC;QACJ;QAGJ,IAAII,WAAW,MAAM,IACjB,OAAOV,OAAO,IAAI,CAAC,IAAIW,gCAAgCD,WAAW,KAAK;QAG3E,MAAM,EAAEE,OAAO,EAAEC,IAAI,EAAE,GAAGH,WAAW,KAAK;QAE1C,OAAOV,OAAO,EAAE,CAAC;YACb,OAAOc,sBAAsB,SAAS,CAAIF;YAC1CC;QACJ;IACJ;AACJ;AAEO,MAAME,0DAA8BC,4BAAAA,oBAAuC,CAAC;IAC/E,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,6 +1,6 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import type { IScheduledAction } from "../../shared/abstractions.js";
3
- import { ScheduledActionPersistenceError } from "../../domain/errors.js";
2
+ import type { IScheduledAction, ScheduledActionType } from "../../shared/abstractions.js";
3
+ import { ScheduledActionPersistenceError, NotAuthorizedError } from "../../domain/errors.js";
4
4
  import type { CmsEntryListSort, CmsEntryMeta } from "@webiny/api-headless-cms/types/index.js";
5
5
  import type { GenericRecord } from "@webiny/api/types.js";
6
6
  /**
@@ -16,7 +16,7 @@ export type DateISOString = `${number}-${number}-${number}T${number}:${number}:$
16
16
  export interface IListScheduledActionsWhere {
17
17
  namespace?: string;
18
18
  namespace_startsWith?: string;
19
- actionType?: string;
19
+ actionType?: ScheduledActionType;
20
20
  targetId?: string;
21
21
  targetId_startsWith?: string;
22
22
  scheduledBy?: string;
@@ -24,6 +24,7 @@ export interface IListScheduledActionsWhere {
24
24
  scheduledFor_gte?: DateISOString;
25
25
  scheduledFor_lte?: DateISOString;
26
26
  }
27
+ export type IListScheduledActionsMeta = CmsEntryMeta;
27
28
  export interface IListScheduledActionsParams {
28
29
  where: IListScheduledActionsWhere;
29
30
  sort?: CmsEntryListSort;
@@ -36,14 +37,21 @@ export interface IListScheduledActionsResponse<T extends GenericRecord> {
36
37
  }
37
38
  export interface IListScheduledActionsErrors {
38
39
  persistence: ScheduledActionPersistenceError;
40
+ unauthorized: NotAuthorizedError;
39
41
  }
40
42
  type ListScheduledActionsError = IListScheduledActionsErrors[keyof IListScheduledActionsErrors];
41
43
  export interface IListScheduledActionsUseCase {
42
44
  execute<T extends GenericRecord>(params: IListScheduledActionsParams): Promise<Result<IListScheduledActionsResponse<T>, ListScheduledActionsError>>;
43
45
  }
46
+ /** List scheduled actions. */
44
47
  export declare const ListScheduledActionsUseCase: import("@webiny/di").Abstraction<IListScheduledActionsUseCase>;
45
48
  export declare namespace ListScheduledActionsUseCase {
46
49
  type Interface = IListScheduledActionsUseCase;
47
50
  type Error = ListScheduledActionsError;
51
+ type Params = IListScheduledActionsParams;
52
+ type Where = IListScheduledActionsWhere;
53
+ type Sort = CmsEntryListSort;
54
+ type Meta = IListScheduledActionsMeta;
55
+ type Response<T extends GenericRecord> = IListScheduledActionsResponse<T>;
48
56
  }
49
57
  export {};
@@ -1,15 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * ListScheduledActionsUseCase - List scheduled actions with optional filtering
5
- *
6
- * Used to retrieve all scheduled actions for a namespace (e.g., all actions for Article model)
7
- * or all actions of a specific type across namespaces.
8
- *
9
- * This is critical for CMS CRUD views where we need to show ALL scheduled actions
10
- * (publish, unpublish, delete) for a specific content model.
11
- */
12
-
13
- export const ListScheduledActionsUseCase = createAbstraction("ListScheduledActionsUseCase");
2
+ const ListScheduledActionsUseCase = createAbstraction("Scheduler/ListScheduledActionsUseCase");
3
+ export { ListScheduledActionsUseCase };
14
4
 
15
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","ListScheduledActionsUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport type { CmsEntryListSort, CmsEntryMeta } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * ListScheduledActionsUseCase - List scheduled actions with optional filtering\n *\n * Used to retrieve all scheduled actions for a namespace (e.g., all actions for Article model)\n * or all actions of a specific type across namespaces.\n *\n * This is critical for CMS CRUD views where we need to show ALL scheduled actions\n * (publish, unpublish, delete) for a specific content model.\n */\n\nexport type DateISOString =\n `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;\n\nexport interface IListScheduledActionsWhere {\n namespace?: string;\n namespace_startsWith?: string;\n actionType?: string;\n targetId?: string;\n targetId_startsWith?: string;\n scheduledBy?: string;\n scheduledFor?: DateISOString;\n scheduledFor_gte?: DateISOString;\n scheduledFor_lte?: DateISOString;\n}\n\nexport interface IListScheduledActionsParams {\n where: IListScheduledActionsWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n after?: string;\n}\n\nexport interface IListScheduledActionsResponse<T extends GenericRecord> {\n items: IScheduledAction<T>[];\n meta: CmsEntryMeta;\n}\n\nexport interface IListScheduledActionsErrors {\n persistence: ScheduledActionPersistenceError;\n}\n\ntype ListScheduledActionsError = IListScheduledActionsErrors[keyof IListScheduledActionsErrors];\n\nexport interface IListScheduledActionsUseCase {\n execute<T extends GenericRecord>(\n params: IListScheduledActionsParams\n ): Promise<Result<IListScheduledActionsResponse<T>, ListScheduledActionsError>>;\n}\n\nexport const ListScheduledActionsUseCase = createAbstraction<IListScheduledActionsUseCase>(\n \"ListScheduledActionsUseCase\"\n);\n\nexport namespace ListScheduledActionsUseCase {\n export type Interface = IListScheduledActionsUseCase;\n export type Error = ListScheduledActionsError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAOvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA,OAAO,MAAMC,2BAA2B,GAAGD,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/ListScheduledActions/abstractions.js","sources":["../../../src/features/ListScheduledActions/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionPersistenceError, NotAuthorizedError } from \"~/domain/errors.js\";\nimport type { CmsEntryListSort, CmsEntryMeta } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * ListScheduledActionsUseCase - List scheduled actions with optional filtering\n *\n * Used to retrieve all scheduled actions for a namespace (e.g., all actions for Article model)\n * or all actions of a specific type across namespaces.\n *\n * This is critical for CMS CRUD views where we need to show ALL scheduled actions\n * (publish, unpublish, delete) for a specific content model.\n */\n\nexport type DateISOString =\n `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;\n\nexport interface IListScheduledActionsWhere {\n namespace?: string;\n namespace_startsWith?: string;\n actionType?: ScheduledActionType;\n targetId?: string;\n targetId_startsWith?: string;\n scheduledBy?: string;\n scheduledFor?: DateISOString;\n scheduledFor_gte?: DateISOString;\n scheduledFor_lte?: DateISOString;\n}\n\nexport type IListScheduledActionsMeta = CmsEntryMeta;\n\nexport interface IListScheduledActionsParams {\n where: IListScheduledActionsWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n after?: string;\n}\n\nexport interface IListScheduledActionsResponse<T extends GenericRecord> {\n items: IScheduledAction<T>[];\n meta: CmsEntryMeta;\n}\n\nexport interface IListScheduledActionsErrors {\n persistence: ScheduledActionPersistenceError;\n unauthorized: NotAuthorizedError;\n}\n\ntype ListScheduledActionsError = IListScheduledActionsErrors[keyof IListScheduledActionsErrors];\n\nexport interface IListScheduledActionsUseCase {\n execute<T extends GenericRecord>(\n params: IListScheduledActionsParams\n ): Promise<Result<IListScheduledActionsResponse<T>, ListScheduledActionsError>>;\n}\n\n/** List scheduled actions. */\nexport const ListScheduledActionsUseCase = createAbstraction<IListScheduledActionsUseCase>(\n \"Scheduler/ListScheduledActionsUseCase\"\n);\n\nexport namespace ListScheduledActionsUseCase {\n export type Interface = IListScheduledActionsUseCase;\n export type Error = ListScheduledActionsError;\n export type Params = IListScheduledActionsParams;\n export type Where = IListScheduledActionsWhere;\n export type Sort = CmsEntryListSort;\n export type Meta = IListScheduledActionsMeta;\n export type Response<T extends GenericRecord> = IListScheduledActionsResponse<T>;\n}\n"],"names":["ListScheduledActionsUseCase","createAbstraction"],"mappings":";AA4DO,MAAMA,8BAA8BC,kBACvC"}