@webiny/webhooks 6.4.0-beta.1 → 6.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/WebhookRoutes.js +21 -3
- package/admin/WebhookRoutes.js.map +1 -1
- package/admin/Webhooks.js +11 -0
- package/admin/Webhooks.js.map +1 -1
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.js +40 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.js.map +1 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.d.ts +11 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.js +18 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.js.map +1 -0
- package/admin/features/getWebhookSettings/abstractions.d.ts +15 -0
- package/admin/features/getWebhookSettings/abstractions.js +6 -0
- package/admin/features/getWebhookSettings/abstractions.js.map +1 -0
- package/admin/features/getWebhookSettings/feature.d.ts +3 -0
- package/admin/features/getWebhookSettings/feature.js +19 -0
- package/admin/features/getWebhookSettings/feature.js.map +1 -0
- package/admin/features/getWebhookSettings/index.d.ts +2 -0
- package/admin/features/getWebhookSettings/index.js +2 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.js +43 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.js.map +1 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.d.ts +11 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.js +18 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.js.map +1 -0
- package/admin/features/updateWebhookSettings/abstractions.d.ts +18 -0
- package/admin/features/updateWebhookSettings/abstractions.js +6 -0
- package/admin/features/updateWebhookSettings/abstractions.js.map +1 -0
- package/admin/features/updateWebhookSettings/feature.d.ts +3 -0
- package/admin/features/updateWebhookSettings/feature.js +19 -0
- package/admin/features/updateWebhookSettings/feature.js.map +1 -0
- package/admin/features/updateWebhookSettings/index.d.ts +2 -0
- package/admin/features/updateWebhookSettings/index.js +2 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.d.ts +6 -2
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js +87 -14
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -1
- package/admin/presentation/WebhookForm/abstractions.d.ts +0 -4
- package/admin/presentation/WebhookForm/abstractions.js.map +1 -1
- package/admin/presentation/WebhookForm/components/WebhookFormView.js +5 -11
- package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -1
- package/admin/presentation/WebhookList/components/WebhookListView.js +28 -21
- package/admin/presentation/WebhookList/components/WebhookListView.js.map +1 -1
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.d.ts +21 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js +83 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js.map +1 -0
- package/admin/presentation/WebhookSettings/abstractions.d.ts +16 -0
- package/admin/presentation/WebhookSettings/abstractions.js +5 -0
- package/admin/presentation/WebhookSettings/abstractions.js.map +1 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.d.ts +2 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js +56 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js.map +1 -0
- package/admin/presentation/WebhookSettings/feature.d.ts +3 -0
- package/admin/presentation/WebhookSettings/feature.js +17 -0
- package/admin/presentation/WebhookSettings/feature.js.map +1 -0
- package/admin/presentation/WebhookSettings/index.d.ts +2 -0
- package/admin/presentation/WebhookSettings/index.js +2 -0
- package/admin/routes.d.ts +1 -0
- package/admin/routes.js +4 -0
- package/admin/routes.js.map +1 -1
- package/admin/shared/types.d.ts +3 -0
- package/api/WebhooksFeature.js +10 -0
- package/api/WebhooksFeature.js.map +1 -1
- package/api/domain/WebhookSettings.d.ts +3 -0
- package/api/domain/WebhookSettings.js +0 -0
- package/api/domain/constants.d.ts +1 -0
- package/api/domain/constants.js +2 -1
- package/api/domain/constants.js.map +1 -1
- package/api/domain/errors.d.ts +7 -2
- package/api/domain/errors.js +16 -3
- package/api/domain/errors.js.map +1 -1
- package/api/features/CreateWebhook/CreateWebhookUseCase.d.ts +3 -3
- package/api/features/CreateWebhook/CreateWebhookUseCase.js +10 -19
- package/api/features/CreateWebhook/CreateWebhookUseCase.js.map +1 -1
- package/api/features/CreateWebhook/abstractions.d.ts +1 -1
- package/api/features/CreateWebhook/abstractions.js.map +1 -1
- package/api/features/CreateWebhook/schema.d.ts +10 -0
- package/api/features/CreateWebhook/schema.js +16 -0
- package/api/features/CreateWebhook/schema.js.map +1 -0
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.d.ts +3 -3
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js +8 -3
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js.map +1 -1
- package/api/features/DeleteWebhook/abstractions.d.ts +2 -2
- package/api/features/DeleteWebhook/abstractions.js.map +1 -1
- package/api/features/DeleteWebhook/schema.d.ts +4 -0
- package/api/features/DeleteWebhook/schema.js +7 -0
- package/api/features/DeleteWebhook/schema.js.map +1 -0
- package/api/features/GetWebhook/GetWebhookUseCase.d.ts +2 -2
- package/api/features/GetWebhook/GetWebhookUseCase.js +7 -2
- package/api/features/GetWebhook/GetWebhookUseCase.js.map +1 -1
- package/api/features/GetWebhook/abstractions.d.ts +2 -2
- package/api/features/GetWebhook/abstractions.js.map +1 -1
- package/api/features/GetWebhook/schema.d.ts +4 -0
- package/api/features/GetWebhook/schema.js +7 -0
- package/api/features/GetWebhook/schema.js.map +1 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.d.ts +2 -2
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js +7 -2
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/GetWebhookDelivery/abstractions.d.ts +2 -2
- package/api/features/GetWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/GetWebhookDelivery/schema.d.ts +4 -0
- package/api/features/GetWebhookDelivery/schema.js +7 -0
- package/api/features/GetWebhookDelivery/schema.js.map +1 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.d.ts +19 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js +55 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js.map +1 -0
- package/api/features/GetWebhookSettings/abstractions.d.ts +13 -0
- package/api/features/GetWebhookSettings/abstractions.js +5 -0
- package/api/features/GetWebhookSettings/abstractions.js.map +1 -0
- package/api/features/GetWebhookSettings/feature.d.ts +4 -0
- package/api/features/GetWebhookSettings/feature.js +11 -0
- package/api/features/GetWebhookSettings/feature.js.map +1 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.d.ts +2 -2
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js +4 -1
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js.map +1 -1
- package/api/features/ListWebhookDeliveries/abstractions.d.ts +2 -2
- package/api/features/ListWebhookDeliveries/abstractions.js.map +1 -1
- package/api/features/ListWebhookDeliveries/schema.d.ts +7 -0
- package/api/features/ListWebhookDeliveries/schema.js +10 -0
- package/api/features/ListWebhookDeliveries/schema.js.map +1 -0
- package/api/features/ListWebhooks/ListWebhooksUseCase.d.ts +2 -2
- package/api/features/ListWebhooks/ListWebhooksUseCase.js +4 -1
- package/api/features/ListWebhooks/ListWebhooksUseCase.js.map +1 -1
- package/api/features/ListWebhooks/abstractions.d.ts +2 -2
- package/api/features/ListWebhooks/abstractions.js.map +1 -1
- package/api/features/ListWebhooks/schema.d.ts +7 -0
- package/api/features/ListWebhooks/schema.js +10 -0
- package/api/features/ListWebhooks/schema.js.map +1 -0
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.d.ts +5 -5
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js +7 -2
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/ResendWebhookDelivery/abstractions.d.ts +2 -2
- package/api/features/ResendWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/ResendWebhookDelivery/schema.d.ts +4 -0
- package/api/features/ResendWebhookDelivery/schema.js +7 -0
- package/api/features/ResendWebhookDelivery/schema.js.map +1 -0
- package/api/features/SendWebhookTask/SendWebhookTask.d.ts +6 -2
- package/api/features/SendWebhookTask/SendWebhookTask.js +45 -33
- package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
- package/api/features/SendWebhookTask/types.d.ts +1 -0
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js +8 -2
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js.map +1 -1
- package/api/features/TriggerWebhook/abstractions.d.ts +2 -2
- package/api/features/TriggerWebhook/abstractions.js.map +1 -1
- package/api/features/TriggerWebhook/schema.d.ts +5 -0
- package/api/features/TriggerWebhook/schema.js +8 -0
- package/api/features/TriggerWebhook/schema.js.map +1 -0
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.d.ts +4 -4
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js +9 -33
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js.map +1 -1
- package/api/features/UpdateWebhook/abstractions.d.ts +0 -1
- package/api/features/UpdateWebhook/abstractions.js.map +1 -1
- package/api/features/UpdateWebhook/schema.d.ts +9 -0
- package/api/features/UpdateWebhook/schema.js +15 -0
- package/api/features/UpdateWebhook/schema.js.map +1 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.d.ts +21 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +60 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js.map +1 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.d.ts +14 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.js +27 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.js.map +1 -0
- package/api/features/UpdateWebhookSettings/abstractions.d.ts +26 -0
- package/api/features/UpdateWebhookSettings/abstractions.js +6 -0
- package/api/features/UpdateWebhookSettings/abstractions.js.map +1 -0
- package/api/features/UpdateWebhookSettings/feature.d.ts +4 -0
- package/api/features/UpdateWebhookSettings/feature.js +13 -0
- package/api/features/UpdateWebhookSettings/feature.js.map +1 -0
- package/api/features/UpdateWebhookSettings/schema.d.ts +4 -0
- package/api/features/UpdateWebhookSettings/schema.js +7 -0
- package/api/features/UpdateWebhookSettings/schema.js.map +1 -0
- package/api/features/WebhookDeliver/WebhookDeliver.d.ts +13 -0
- package/api/features/WebhookDeliver/WebhookDeliver.js +79 -0
- package/api/features/WebhookDeliver/WebhookDeliver.js.map +1 -0
- package/api/features/WebhookDeliver/abstractions.d.ts +24 -0
- package/api/features/WebhookDeliver/abstractions.js +5 -0
- package/api/features/WebhookDeliver/abstractions.js.map +1 -0
- package/api/features/WebhookDeliver/feature.d.ts +4 -0
- package/api/features/WebhookDeliver/feature.js +11 -0
- package/api/features/WebhookDeliver/feature.js.map +1 -0
- package/api/features/WebhookDeliver/index.d.ts +2 -0
- package/api/features/WebhookDeliver/index.js +2 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.d.ts +1 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.js +7 -1
- package/api/features/WebhookSignPayload/WebhookSignPayload.js.map +1 -1
- package/api/graphql/WebhookCrudSchema.js +1 -2
- package/api/graphql/WebhookCrudSchema.js.map +1 -1
- package/api/graphql/WebhookEventSchema.js +1 -0
- package/api/graphql/WebhookEventSchema.js.map +1 -1
- package/api/graphql/WebhookSettingsSchema.d.ts +8 -0
- package/api/graphql/WebhookSettingsSchema.js +60 -0
- package/api/graphql/WebhookSettingsSchema.js.map +1 -0
- package/api/models/WebhookDeliveryModel.js +4 -4
- package/api/models/WebhookDeliveryModel.js.map +1 -1
- package/api/models/WebhookModel.js +1 -1
- package/api/models/WebhookModel.js.map +1 -1
- package/api/models/WebhookSettingsModel.d.ts +8 -0
- package/api/models/WebhookSettingsModel.js +27 -0
- package/api/models/WebhookSettingsModel.js.map +1 -0
- package/api/utils/isValidEndpointUrl.d.ts +1 -0
- package/api/utils/isValidEndpointUrl.js +13 -0
- package/api/utils/isValidEndpointUrl.js.map +1 -0
- package/exports/api/webhooks.d.ts +0 -1
- package/exports/api/webhooks.js +0 -1
- package/package.json +22 -20
- package/admin/SecurityPermission.d.ts +0 -2
- package/admin/SecurityPermission.js +0 -15
- package/admin/SecurityPermission.js.map +0 -1
- package/admin/presentation/WebhookForm/components/EventsSelector.d.ts +0 -12
- package/admin/presentation/WebhookForm/components/EventsSelector.js +0 -44
- package/admin/presentation/WebhookForm/components/EventsSelector.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
|
-
import type { WebhookNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError } from "../../../api/domain/errors.js";
|
|
3
|
-
type IError = WebhookNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError;
|
|
2
|
+
import type { WebhookNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
3
|
+
type IError = WebhookNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
4
4
|
export interface IDeleteWebhookUseCase {
|
|
5
5
|
execute(id: string): Promise<Result<boolean, IError>>;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/DeleteWebhook/abstractions.js","sources":["../../../../src/api/features/DeleteWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type {\n WebhookNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError;\n\nexport interface IDeleteWebhookUseCase {\n execute(id: string): Promise<Result<boolean, IError>>;\n}\n\nexport const DeleteWebhookUseCase = createAbstraction<IDeleteWebhookUseCase>(\n \"Webhooks/DeleteWebhookUseCase\"\n);\n\nexport namespace DeleteWebhookUseCase {\n export type Interface = IDeleteWebhookUseCase;\n export type Error = IError;\n}\n\nexport interface IDeleteWebhookRepository {\n execute(id: string): Promise<Result<boolean, IError>>;\n}\n\nexport const DeleteWebhookRepository = createAbstraction<IDeleteWebhookRepository>(\n \"Webhooks/DeleteWebhookRepository\"\n);\n\nexport namespace DeleteWebhookRepository {\n export type Interface = IDeleteWebhookRepository;\n export type Error = IError;\n}\n"],"names":["DeleteWebhookUseCase","createAbstraction","DeleteWebhookRepository"],"mappings":";
|
|
1
|
+
{"version":3,"file":"api/features/DeleteWebhook/abstractions.js","sources":["../../../../src/api/features/DeleteWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type {\n WebhookNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IDeleteWebhookUseCase {\n execute(id: string): Promise<Result<boolean, IError>>;\n}\n\nexport const DeleteWebhookUseCase = createAbstraction<IDeleteWebhookUseCase>(\n \"Webhooks/DeleteWebhookUseCase\"\n);\n\nexport namespace DeleteWebhookUseCase {\n export type Interface = IDeleteWebhookUseCase;\n export type Error = IError;\n}\n\nexport interface IDeleteWebhookRepository {\n execute(id: string): Promise<Result<boolean, IError>>;\n}\n\nexport const DeleteWebhookRepository = createAbstraction<IDeleteWebhookRepository>(\n \"Webhooks/DeleteWebhookRepository\"\n);\n\nexport namespace DeleteWebhookRepository {\n export type Interface = IDeleteWebhookRepository;\n export type Error = IError;\n}\n"],"names":["DeleteWebhookUseCase","createAbstraction","DeleteWebhookRepository"],"mappings":";AAoBO,MAAMA,uBAAuBC,kBAChC;AAYG,MAAMC,0BAA0BD,kBACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/DeleteWebhook/schema.js","sources":["../../../../src/api/features/DeleteWebhook/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const DeleteWebhookInputSchema = z.object({\n id: z.string().min(1, \"Webhook ID is required.\")\n});\n"],"names":["DeleteWebhookInputSchema","z"],"mappings":";AAEO,MAAMA,2BAA2BC,EAAE,MAAM,CAAC;IAC7C,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAC1B"}
|
|
@@ -3,8 +3,8 @@ import { GetWebhookUseCase as UseCaseAbstraction, GetWebhookRepository } from ".
|
|
|
3
3
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
4
4
|
import type { Webhook } from "../../../api/domain/Webhook.js";
|
|
5
5
|
declare class GetWebhookUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
-
private permissions;
|
|
7
|
-
private repository;
|
|
6
|
+
private readonly permissions;
|
|
7
|
+
private readonly repository;
|
|
8
8
|
constructor(permissions: WebhookPermissions.Interface, repository: GetWebhookRepository.Interface);
|
|
9
9
|
execute(id: string): Promise<Result<Webhook, UseCaseAbstraction.Error>>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetWebhookRepository, GetWebhookUseCase } from "./abstractions.js";
|
|
3
|
+
import { GetWebhookInputSchema } from "./schema.js";
|
|
3
4
|
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
4
|
-
import { WebhookNotAuthorizedError } from "../../domain/errors.js";
|
|
5
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
5
6
|
class GetWebhookUseCaseImpl {
|
|
6
7
|
constructor(permissions, repository){
|
|
7
8
|
this.permissions = permissions;
|
|
@@ -9,7 +10,11 @@ class GetWebhookUseCaseImpl {
|
|
|
9
10
|
}
|
|
10
11
|
async execute(id) {
|
|
11
12
|
if (!await this.permissions.canRead("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
12
|
-
|
|
13
|
+
const parsed = GetWebhookInputSchema.safeParse({
|
|
14
|
+
id
|
|
15
|
+
});
|
|
16
|
+
if (!parsed.success) return Result.fail(new WebhookValidationError(parsed.error));
|
|
17
|
+
return this.repository.execute(parsed.data.id);
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
const GetWebhookUseCase_GetWebhookUseCase = GetWebhookUseCase.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhook/GetWebhookUseCase.js","sources":["../../../../src/api/features/GetWebhook/GetWebhookUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetWebhookUseCase as UseCaseAbstraction, GetWebhookRepository } from \"./abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError } from \"~/api/domain/errors.js\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\n\nclass GetWebhookUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: WebhookPermissions.Interface,\n private repository: GetWebhookRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<Webhook, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n return this.repository.execute(id);\n }\n}\n\nexport const GetWebhookUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetWebhookUseCaseImpl,\n dependencies: [WebhookPermissions, GetWebhookRepository]\n});\n"],"names":["GetWebhookUseCaseImpl","permissions","repository","id","Result","WebhookNotAuthorizedError","GetWebhookUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhook/GetWebhookUseCase.js","sources":["../../../../src/api/features/GetWebhook/GetWebhookUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetWebhookUseCase as UseCaseAbstraction, GetWebhookRepository } from \"./abstractions.js\";\nimport { GetWebhookInputSchema } from \"./schema.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\n\nclass GetWebhookUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly repository: GetWebhookRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<Webhook, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = GetWebhookInputSchema.safeParse({ id });\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n return this.repository.execute(parsed.data.id);\n }\n}\n\nexport const GetWebhookUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetWebhookUseCaseImpl,\n dependencies: [WebhookPermissions, GetWebhookRepository]\n});\n"],"names":["GetWebhookUseCaseImpl","permissions","repository","id","Result","WebhookNotAuthorizedError","parsed","GetWebhookInputSchema","WebhookValidationError","GetWebhookUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookRepository"],"mappings":";;;;;AAOA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,UAA0C,CAC7D;aAFmBD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,QAAQC,EAAU,EAAsD;QAC1E,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAASC,sBAAsB,SAAS,CAAC;YAAEJ;QAAG;QACpD,IAAI,CAACG,OAAO,OAAO,EACf,OAAOF,OAAO,IAAI,CAAC,IAAII,uBAAuBF,OAAO,KAAK;QAG9D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA,OAAO,IAAI,CAAC,EAAE;IACjD;AACJ;AAEO,MAAMG,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBV;IAChB,cAAc;QAACW;QAAoBC;KAAqB;AAC5D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { Webhook } from "../../../api/domain/Webhook.js";
|
|
3
|
-
import type { WebhookNotFoundError, WebhookModelNotFoundError, WebhookPersistenceError, WebhookNotAuthorizedError } from "../../../api/domain/errors.js";
|
|
4
|
-
type IError = WebhookNotFoundError | WebhookModelNotFoundError | WebhookPersistenceError | WebhookNotAuthorizedError;
|
|
3
|
+
import type { WebhookNotFoundError, WebhookModelNotFoundError, WebhookPersistenceError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
4
|
+
type IError = WebhookNotFoundError | WebhookModelNotFoundError | WebhookPersistenceError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
5
5
|
export interface IGetWebhookUseCase {
|
|
6
6
|
execute(id: string): Promise<Result<Webhook, IError>>;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhook/abstractions.js","sources":["../../../../src/api/features/GetWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\nimport type {\n WebhookNotFoundError,\n WebhookModelNotFoundError,\n WebhookPersistenceError,\n WebhookNotAuthorizedError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookNotFoundError\n | WebhookModelNotFoundError\n | WebhookPersistenceError\n | WebhookNotAuthorizedError;\n\nexport interface IGetWebhookUseCase {\n execute(id: string): Promise<Result<Webhook, IError>>;\n}\n\nexport const GetWebhookUseCase = createAbstraction<IGetWebhookUseCase>(\n \"Webhooks/GetWebhookUseCase\"\n);\n\nexport namespace GetWebhookUseCase {\n export type Interface = IGetWebhookUseCase;\n export type Error = IError;\n}\n\nexport interface IGetWebhookRepository {\n execute(id: string): Promise<Result<Webhook, IError>>;\n}\n\nexport const GetWebhookRepository = createAbstraction<IGetWebhookRepository>(\n \"Webhooks/GetWebhookRepository\"\n);\n\nexport namespace GetWebhookRepository {\n export type Interface = IGetWebhookRepository;\n export type Error = IError;\n}\n"],"names":["GetWebhookUseCase","createAbstraction","GetWebhookRepository"],"mappings":";
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhook/abstractions.js","sources":["../../../../src/api/features/GetWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\nimport type {\n WebhookNotFoundError,\n WebhookModelNotFoundError,\n WebhookPersistenceError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookNotFoundError\n | WebhookModelNotFoundError\n | WebhookPersistenceError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IGetWebhookUseCase {\n execute(id: string): Promise<Result<Webhook, IError>>;\n}\n\nexport const GetWebhookUseCase = createAbstraction<IGetWebhookUseCase>(\n \"Webhooks/GetWebhookUseCase\"\n);\n\nexport namespace GetWebhookUseCase {\n export type Interface = IGetWebhookUseCase;\n export type Error = IError;\n}\n\nexport interface IGetWebhookRepository {\n execute(id: string): Promise<Result<Webhook, IError>>;\n}\n\nexport const GetWebhookRepository = createAbstraction<IGetWebhookRepository>(\n \"Webhooks/GetWebhookRepository\"\n);\n\nexport namespace GetWebhookRepository {\n export type Interface = IGetWebhookRepository;\n export type Error = IError;\n}\n"],"names":["GetWebhookUseCase","createAbstraction","GetWebhookRepository"],"mappings":";AAqBO,MAAMA,oBAAoBC,kBAC7B;AAYG,MAAMC,uBAAuBD,kBAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhook/schema.js","sources":["../../../../src/api/features/GetWebhook/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const GetWebhookInputSchema = z.object({\n id: z.string().min(1, \"Webhook ID is required.\")\n});\n"],"names":["GetWebhookInputSchema","z"],"mappings":";AAEO,MAAMA,wBAAwBC,EAAE,MAAM,CAAC;IAC1C,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAC1B"}
|
|
@@ -3,8 +3,8 @@ import { GetWebhookDeliveryUseCase as UseCaseAbstraction, GetWebhookDeliveryRepo
|
|
|
3
3
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
4
4
|
import type { WebhookDelivery } from "../../../api/domain/WebhookDelivery.js";
|
|
5
5
|
declare class GetWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
-
private permissions;
|
|
7
|
-
private repository;
|
|
6
|
+
private readonly permissions;
|
|
7
|
+
private readonly repository;
|
|
8
8
|
constructor(permissions: WebhookPermissions.Interface, repository: GetWebhookDeliveryRepository.Interface);
|
|
9
9
|
execute(id: string): Promise<ResultType<WebhookDelivery, UseCaseAbstraction.Error>>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetWebhookDeliveryRepository, GetWebhookDeliveryUseCase } from "./abstractions.js";
|
|
3
|
+
import { GetWebhookDeliveryInputSchema } from "./schema.js";
|
|
3
4
|
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
4
|
-
import { WebhookNotAuthorizedError } from "../../domain/errors.js";
|
|
5
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
5
6
|
class GetWebhookDeliveryUseCaseImpl {
|
|
6
7
|
constructor(permissions, repository){
|
|
7
8
|
this.permissions = permissions;
|
|
@@ -9,7 +10,11 @@ class GetWebhookDeliveryUseCaseImpl {
|
|
|
9
10
|
}
|
|
10
11
|
async execute(id) {
|
|
11
12
|
if (!await this.permissions.canRead("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
12
|
-
|
|
13
|
+
const parsed = GetWebhookDeliveryInputSchema.safeParse({
|
|
14
|
+
id
|
|
15
|
+
});
|
|
16
|
+
if (!parsed.success) return Result.fail(new WebhookValidationError(parsed.error));
|
|
17
|
+
return this.repository.execute(parsed.data.id);
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
const GetWebhookDeliveryUseCase_GetWebhookDeliveryUseCase = GetWebhookDeliveryUseCase.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js","sources":["../../../../src/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.ts"],"sourcesContent":["import { Result, type Result as ResultType } from \"@webiny/feature/api\";\nimport {\n GetWebhookDeliveryUseCase as UseCaseAbstraction,\n GetWebhookDeliveryRepository\n} from \"./abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError } from \"~/api/domain/errors.js\";\nimport type { WebhookDelivery } from \"~/api/domain/WebhookDelivery.js\";\n\nclass GetWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: WebhookPermissions.Interface,\n private repository: GetWebhookDeliveryRepository.Interface\n ) {}\n\n async execute(id: string): Promise<ResultType<WebhookDelivery, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n return this.repository.execute(id);\n }\n}\n\nexport const GetWebhookDeliveryUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetWebhookDeliveryUseCaseImpl,\n dependencies: [WebhookPermissions, GetWebhookDeliveryRepository]\n});\n"],"names":["GetWebhookDeliveryUseCaseImpl","permissions","repository","id","Result","WebhookNotAuthorizedError","GetWebhookDeliveryUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookDeliveryRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js","sources":["../../../../src/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.ts"],"sourcesContent":["import { Result, type Result as ResultType } from \"@webiny/feature/api\";\nimport {\n GetWebhookDeliveryUseCase as UseCaseAbstraction,\n GetWebhookDeliveryRepository\n} from \"./abstractions.js\";\nimport { GetWebhookDeliveryInputSchema } from \"./schema.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport type { WebhookDelivery } from \"~/api/domain/WebhookDelivery.js\";\n\nclass GetWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly repository: GetWebhookDeliveryRepository.Interface\n ) {}\n\n async execute(id: string): Promise<ResultType<WebhookDelivery, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = GetWebhookDeliveryInputSchema.safeParse({ id });\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n return this.repository.execute(parsed.data.id);\n }\n}\n\nexport const GetWebhookDeliveryUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetWebhookDeliveryUseCaseImpl,\n dependencies: [WebhookPermissions, GetWebhookDeliveryRepository]\n});\n"],"names":["GetWebhookDeliveryUseCaseImpl","permissions","repository","id","Result","WebhookNotAuthorizedError","parsed","GetWebhookDeliveryInputSchema","WebhookValidationError","GetWebhookDeliveryUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookDeliveryRepository"],"mappings":";;;;;AAUA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,UAAkD,CACrE;aAFmBD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,QAAQC,EAAU,EAAkE;QACtF,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAASC,8BAA8B,SAAS,CAAC;YAAEJ;QAAG;QAC5D,IAAI,CAACG,OAAO,OAAO,EACf,OAAOF,OAAO,IAAI,CAAC,IAAII,uBAAuBF,OAAO,KAAK;QAG9D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA,OAAO,IAAI,CAAC,EAAE;IACjD;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBV;IAChB,cAAc;QAACW;QAAoBC;KAA6B;AACpE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { WebhookDelivery } from "../../../api/domain/WebhookDelivery.js";
|
|
3
|
-
import type { WebhookDeliveryNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError } from "../../../api/domain/errors.js";
|
|
4
|
-
type IError = WebhookDeliveryNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError;
|
|
3
|
+
import type { WebhookDeliveryNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
4
|
+
type IError = WebhookDeliveryNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
5
5
|
export interface IGetWebhookDeliveryUseCase {
|
|
6
6
|
execute(id: string): Promise<Result<WebhookDelivery, IError>>;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhookDelivery/abstractions.js","sources":["../../../../src/api/features/GetWebhookDelivery/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { WebhookDelivery } from \"~/api/domain/WebhookDelivery.js\";\nimport type {\n WebhookDeliveryNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookDeliveryNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError;\n\nexport interface IGetWebhookDeliveryUseCase {\n execute(id: string): Promise<Result<WebhookDelivery, IError>>;\n}\n\nexport const GetWebhookDeliveryUseCase = createAbstraction<IGetWebhookDeliveryUseCase>(\n \"Webhooks/GetWebhookDeliveryUseCase\"\n);\n\nexport namespace GetWebhookDeliveryUseCase {\n export type Interface = IGetWebhookDeliveryUseCase;\n export type Error = IError;\n}\n\nexport interface IGetWebhookDeliveryRepository {\n execute(id: string): Promise<Result<WebhookDelivery, IError>>;\n}\n\nexport const GetWebhookDeliveryRepository = createAbstraction<IGetWebhookDeliveryRepository>(\n \"Webhooks/GetWebhookDeliveryRepository\"\n);\n\nexport namespace GetWebhookDeliveryRepository {\n export type Interface = IGetWebhookDeliveryRepository;\n export type Error = IError;\n}\n"],"names":["GetWebhookDeliveryUseCase","createAbstraction","GetWebhookDeliveryRepository"],"mappings":";
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookDelivery/abstractions.js","sources":["../../../../src/api/features/GetWebhookDelivery/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { WebhookDelivery } from \"~/api/domain/WebhookDelivery.js\";\nimport type {\n WebhookDeliveryNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookDeliveryNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IGetWebhookDeliveryUseCase {\n execute(id: string): Promise<Result<WebhookDelivery, IError>>;\n}\n\nexport const GetWebhookDeliveryUseCase = createAbstraction<IGetWebhookDeliveryUseCase>(\n \"Webhooks/GetWebhookDeliveryUseCase\"\n);\n\nexport namespace GetWebhookDeliveryUseCase {\n export type Interface = IGetWebhookDeliveryUseCase;\n export type Error = IError;\n}\n\nexport interface IGetWebhookDeliveryRepository {\n execute(id: string): Promise<Result<WebhookDelivery, IError>>;\n}\n\nexport const GetWebhookDeliveryRepository = createAbstraction<IGetWebhookDeliveryRepository>(\n \"Webhooks/GetWebhookDeliveryRepository\"\n);\n\nexport namespace GetWebhookDeliveryRepository {\n export type Interface = IGetWebhookDeliveryRepository;\n export type Error = IError;\n}\n"],"names":["GetWebhookDeliveryUseCase","createAbstraction","GetWebhookDeliveryRepository"],"mappings":";AAqBO,MAAMA,4BAA4BC,kBACrC;AAYG,MAAMC,+BAA+BD,kBACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookDelivery/schema.js","sources":["../../../../src/api/features/GetWebhookDelivery/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const GetWebhookDeliveryInputSchema = z.object({\n id: z.string().min(1, \"Delivery ID is required.\")\n});\n"],"names":["GetWebhookDeliveryInputSchema","z"],"mappings":";AAEO,MAAMA,gCAAgCC,EAAE,MAAM,CAAC;IAClD,IAAIA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAC1B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetModelRepository } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
3
|
+
import { GetLatestRevisionByEntryIdRepository } from "@webiny/api-headless-cms/features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
4
|
+
import { CreateEntryRepository } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry/index.js";
|
|
5
|
+
import { CreateEntryDataFactory } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
6
|
+
import { GetWebhookSettingsRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
7
|
+
import type { IWebhookSettings } from "../../../api/domain/WebhookSettings.js";
|
|
8
|
+
declare class GetWebhookSettingsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
9
|
+
private readonly getModelRepository;
|
|
10
|
+
private readonly getLatestRevisionRepository;
|
|
11
|
+
private readonly createEntryRepository;
|
|
12
|
+
private readonly createEntryDataFactory;
|
|
13
|
+
constructor(getModelRepository: GetModelRepository.Interface, getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface, createEntryRepository: CreateEntryRepository.Interface, createEntryDataFactory: CreateEntryDataFactory.Interface);
|
|
14
|
+
execute(): Promise<Result<IWebhookSettings, RepositoryAbstraction.Error>>;
|
|
15
|
+
}
|
|
16
|
+
export declare const GetWebhookSettingsRepository: typeof GetWebhookSettingsRepositoryImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetWebhookSettingsRepository>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { createCacheKey } from "@webiny/utils";
|
|
3
|
+
import { GetModelRepository } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
4
|
+
import { GetLatestRevisionByEntryIdRepository } from "@webiny/api-headless-cms/features/contentEntry/GetLatestRevisionByEntryId/index.js";
|
|
5
|
+
import { CreateEntryRepository } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry/index.js";
|
|
6
|
+
import { CreateEntryDataFactory } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
7
|
+
import { GetWebhookSettingsRepository } from "./abstractions.js";
|
|
8
|
+
import { WebhookModelNotFoundError, WebhookPersistenceError } from "../../domain/errors.js";
|
|
9
|
+
import { WEBHOOK_SETTINGS_MODEL_ID } from "../../domain/constants.js";
|
|
10
|
+
class GetWebhookSettingsRepositoryImpl {
|
|
11
|
+
constructor(getModelRepository, getLatestRevisionRepository, createEntryRepository, createEntryDataFactory){
|
|
12
|
+
this.getModelRepository = getModelRepository;
|
|
13
|
+
this.getLatestRevisionRepository = getLatestRevisionRepository;
|
|
14
|
+
this.createEntryRepository = createEntryRepository;
|
|
15
|
+
this.createEntryDataFactory = createEntryDataFactory;
|
|
16
|
+
}
|
|
17
|
+
async execute() {
|
|
18
|
+
try {
|
|
19
|
+
const modelResult = await this.getModelRepository.execute(WEBHOOK_SETTINGS_MODEL_ID);
|
|
20
|
+
if (modelResult.isFail()) return Result.fail(new WebhookModelNotFoundError(WEBHOOK_SETTINGS_MODEL_ID));
|
|
21
|
+
const model = modelResult.value;
|
|
22
|
+
const singletonId = createCacheKey(model.modelId);
|
|
23
|
+
const entryId = `${singletonId}#0001`;
|
|
24
|
+
const entryResult = await this.getLatestRevisionRepository.execute(model, {
|
|
25
|
+
id: entryId
|
|
26
|
+
});
|
|
27
|
+
if (entryResult.isOk()) return Result.ok({
|
|
28
|
+
signingSecret: entryResult.value.values.signingSecret
|
|
29
|
+
});
|
|
30
|
+
const { entry } = await this.createEntryDataFactory.create(model, {
|
|
31
|
+
id: singletonId,
|
|
32
|
+
values: {}
|
|
33
|
+
});
|
|
34
|
+
const createResult = await this.createEntryRepository.execute(model, entry);
|
|
35
|
+
if (createResult.isFail()) return Result.fail(WebhookPersistenceError.from(createResult.error));
|
|
36
|
+
return Result.ok({
|
|
37
|
+
signingSecret: void 0
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return Result.fail(WebhookPersistenceError.from(error));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const GetWebhookSettingsRepository_GetWebhookSettingsRepository = GetWebhookSettingsRepository.createImplementation({
|
|
45
|
+
implementation: GetWebhookSettingsRepositoryImpl,
|
|
46
|
+
dependencies: [
|
|
47
|
+
GetModelRepository,
|
|
48
|
+
GetLatestRevisionByEntryIdRepository,
|
|
49
|
+
CreateEntryRepository,
|
|
50
|
+
CreateEntryDataFactory
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
export { GetWebhookSettingsRepository_GetWebhookSettingsRepository as GetWebhookSettingsRepository };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=GetWebhookSettingsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/GetWebhookSettingsRepository.js","sources":["../../../../src/api/features/GetWebhookSettings/GetWebhookSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createCacheKey } from \"@webiny/utils\";\nimport { GetModelRepository } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { GetLatestRevisionByEntryIdRepository } from \"@webiny/api-headless-cms/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport { CreateEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry/index.js\";\nimport { CreateEntryDataFactory } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { GetWebhookSettingsRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_SETTINGS_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IWebhookSettings } from \"~/api/domain/WebhookSettings.js\";\n\ninterface WebhookSettingsValues {\n signingSecret?: string;\n}\n\nclass GetWebhookSettingsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly createEntryRepository: CreateEntryRepository.Interface,\n private readonly createEntryDataFactory: CreateEntryDataFactory.Interface\n ) {}\n\n async execute(): Promise<Result<IWebhookSettings, RepositoryAbstraction.Error>> {\n try {\n const modelResult = await this.getModelRepository.execute(WEBHOOK_SETTINGS_MODEL_ID);\n if (modelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_SETTINGS_MODEL_ID));\n }\n\n const model = modelResult.value;\n const singletonId = createCacheKey(model.modelId);\n const entryId = `${singletonId}#0001`;\n\n const entryResult =\n await this.getLatestRevisionRepository.execute<WebhookSettingsValues>(model, {\n id: entryId\n });\n\n if (entryResult.isOk()) {\n return Result.ok({\n signingSecret: entryResult.value.values.signingSecret\n });\n }\n\n /* Entry doesn't exist yet — create it with empty values. */\n const { entry } = await this.createEntryDataFactory.create<WebhookSettingsValues>(\n model,\n { id: singletonId, values: {} as WebhookSettingsValues }\n );\n\n const createResult = await this.createEntryRepository.execute(model, entry);\n if (createResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(createResult.error));\n }\n\n return Result.ok({ signingSecret: undefined });\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const GetWebhookSettingsRepository = RepositoryAbstraction.createImplementation({\n implementation: GetWebhookSettingsRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n CreateEntryRepository,\n CreateEntryDataFactory\n ]\n});\n"],"names":["GetWebhookSettingsRepositoryImpl","getModelRepository","getLatestRevisionRepository","createEntryRepository","createEntryDataFactory","modelResult","WEBHOOK_SETTINGS_MODEL_ID","Result","WebhookModelNotFoundError","model","singletonId","createCacheKey","entryId","entryResult","entry","createResult","WebhookPersistenceError","undefined","error","GetWebhookSettingsRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","CreateEntryRepository","CreateEntryDataFactory"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,qBAAsD,EACtDC,sBAAwD,CAC3E;aAJmBH,kBAAkB,GAAlBA;aACAC,2BAA2B,GAA3BA;aACAC,qBAAqB,GAArBA;aACAC,sBAAsB,GAAtBA;IAClB;IAEH,MAAM,UAA0E;QAC5E,IAAI;YACA,MAAMC,cAAc,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1D,IAAID,YAAY,MAAM,IAClB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,QAAQJ,YAAY,KAAK;YAC/B,MAAMK,cAAcC,eAAeF,MAAM,OAAO;YAChD,MAAMG,UAAU,GAAGF,YAAY,KAAK,CAAC;YAErC,MAAMG,cACF,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAwBJ,OAAO;gBACzE,IAAIG;YACR;YAEJ,IAAIC,YAAY,IAAI,IAChB,OAAON,OAAO,EAAE,CAAC;gBACb,eAAeM,YAAY,KAAK,CAAC,MAAM,CAAC,aAAa;YACzD;YAIJ,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CACtDL,OACA;gBAAE,IAAIC;gBAAa,QAAQ,CAAC;YAA2B;YAG3D,MAAMK,eAAe,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACN,OAAOK;YACrE,IAAIC,aAAa,MAAM,IACnB,OAAOR,OAAO,IAAI,CAACS,wBAAwB,IAAI,CAACD,aAAa,KAAK;YAGtE,OAAOR,OAAO,EAAE,CAAC;gBAAE,eAAeU;YAAU;QAChD,EAAE,OAAOC,OAAO;YACZ,OAAOX,OAAO,IAAI,CAACS,wBAAwB,IAAI,CAACE;QACpD;IACJ;AACJ;AAEO,MAAMC,4DAA+BC,6BAAAA,oBAA0C,CAAC;IACnF,gBAAgBpB;IAChB,cAAc;QACVqB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { IWebhookSettings } from "../../../api/domain/WebhookSettings.js";
|
|
3
|
+
import type { WebhookModelNotFoundError, WebhookPersistenceError } from "../../../api/domain/errors.js";
|
|
4
|
+
type IError = WebhookModelNotFoundError | WebhookPersistenceError;
|
|
5
|
+
export interface IGetWebhookSettingsRepository {
|
|
6
|
+
execute(): Promise<Result<IWebhookSettings, IError>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const GetWebhookSettingsRepository: import("@webiny/di").Abstraction<IGetWebhookSettingsRepository>;
|
|
9
|
+
export declare namespace GetWebhookSettingsRepository {
|
|
10
|
+
type Interface = IGetWebhookSettingsRepository;
|
|
11
|
+
type Error = IError;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/abstractions.js","sources":["../../../../src/api/features/GetWebhookSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { IWebhookSettings } from \"~/api/domain/WebhookSettings.js\";\nimport type { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\n\ntype IError = WebhookModelNotFoundError | WebhookPersistenceError;\n\nexport interface IGetWebhookSettingsRepository {\n execute(): Promise<Result<IWebhookSettings, IError>>;\n}\n\nexport const GetWebhookSettingsRepository = createAbstraction<IGetWebhookSettingsRepository>(\n \"Webhooks/GetWebhookSettingsRepository\"\n);\n\nexport namespace GetWebhookSettingsRepository {\n export type Interface = IGetWebhookSettingsRepository;\n export type Error = IError;\n}\n"],"names":["GetWebhookSettingsRepository","createAbstraction"],"mappings":";AAUO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GetWebhookSettingsRepository } from "./GetWebhookSettingsRepository.js";
|
|
3
|
+
const GetWebhookSettingsFeature = createFeature({
|
|
4
|
+
name: "GetWebhookSettings",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(GetWebhookSettingsRepository).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { GetWebhookSettingsFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/feature.js","sources":["../../../../src/api/features/GetWebhookSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetWebhookSettingsRepository } from \"./GetWebhookSettingsRepository.js\";\n\nexport const GetWebhookSettingsFeature = createFeature({\n name: \"GetWebhookSettings\",\n register(container) {\n container.register(GetWebhookSettingsRepository).inSingletonScope();\n }\n});\n"],"names":["GetWebhookSettingsFeature","createFeature","container","GetWebhookSettingsRepository"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,8BAA8B,gBAAgB;IACrE;AACJ"}
|
|
@@ -3,8 +3,8 @@ import { ListWebhookDeliveriesUseCase as UseCaseAbstraction, ListWebhookDeliveri
|
|
|
3
3
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
4
4
|
import type { IListWebhookDeliveriesInput } from "./abstractions.js";
|
|
5
5
|
declare class ListWebhookDeliveriesUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
-
private permissions;
|
|
7
|
-
private repository;
|
|
6
|
+
private readonly permissions;
|
|
7
|
+
private readonly repository;
|
|
8
8
|
constructor(permissions: WebhookPermissions.Interface, repository: ListWebhookDeliveriesRepository.Interface);
|
|
9
9
|
execute(input: IListWebhookDeliveriesInput): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListWebhookDeliveriesRepository, ListWebhookDeliveriesUseCase } from "./abstractions.js";
|
|
3
|
+
import { ListWebhookDeliveriesInputSchema } from "./schema.js";
|
|
3
4
|
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
4
|
-
import { WebhookNotAuthorizedError } from "../../domain/errors.js";
|
|
5
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
5
6
|
class ListWebhookDeliveriesUseCaseImpl {
|
|
6
7
|
constructor(permissions, repository){
|
|
7
8
|
this.permissions = permissions;
|
|
@@ -9,6 +10,8 @@ class ListWebhookDeliveriesUseCaseImpl {
|
|
|
9
10
|
}
|
|
10
11
|
async execute(input) {
|
|
11
12
|
if (!await this.permissions.canRead("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
13
|
+
const parsed = ListWebhookDeliveriesInputSchema.safeParse(input);
|
|
14
|
+
if (!parsed.success) return Result.fail(new WebhookValidationError(parsed.error));
|
|
12
15
|
return this.repository.execute(input);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js","sources":["../../../../src/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListWebhookDeliveriesUseCase as UseCaseAbstraction,\n ListWebhookDeliveriesRepository\n} from \"./abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError } from \"~/api/domain/errors.js\";\nimport type { IListWebhookDeliveriesInput } from \"./abstractions.js\";\n\nclass ListWebhookDeliveriesUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: WebhookPermissions.Interface,\n private repository: ListWebhookDeliveriesRepository.Interface\n ) {}\n\n async execute(\n input: IListWebhookDeliveriesInput\n ): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n return this.repository.execute(input);\n }\n}\n\nexport const ListWebhookDeliveriesUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListWebhookDeliveriesUseCaseImpl,\n dependencies: [WebhookPermissions, ListWebhookDeliveriesRepository]\n});\n"],"names":["ListWebhookDeliveriesUseCaseImpl","permissions","repository","input","Result","WebhookNotAuthorizedError","ListWebhookDeliveriesUseCase","UseCaseAbstraction","WebhookPermissions","ListWebhookDeliveriesRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js","sources":["../../../../src/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListWebhookDeliveriesUseCase as UseCaseAbstraction,\n ListWebhookDeliveriesRepository\n} from \"./abstractions.js\";\nimport { ListWebhookDeliveriesInputSchema } from \"./schema.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport type { IListWebhookDeliveriesInput } from \"./abstractions.js\";\n\nclass ListWebhookDeliveriesUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly repository: ListWebhookDeliveriesRepository.Interface\n ) {}\n\n async execute(\n input: IListWebhookDeliveriesInput\n ): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = ListWebhookDeliveriesInputSchema.safeParse(input);\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n return this.repository.execute(input);\n }\n}\n\nexport const ListWebhookDeliveriesUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListWebhookDeliveriesUseCaseImpl,\n dependencies: [WebhookPermissions, ListWebhookDeliveriesRepository]\n});\n"],"names":["ListWebhookDeliveriesUseCaseImpl","permissions","repository","input","Result","WebhookNotAuthorizedError","parsed","ListWebhookDeliveriesInputSchema","WebhookValidationError","ListWebhookDeliveriesUseCase","UseCaseAbstraction","WebhookPermissions","ListWebhookDeliveriesRepository"],"mappings":";;;;;AAUA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,UAAqD,CACxE;aAFmBD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,QACFC,KAAkC,EACkC;QACpE,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAASC,iCAAiC,SAAS,CAACJ;QAC1D,IAAI,CAACG,OAAO,OAAO,EACf,OAAOF,OAAO,IAAI,CAAC,IAAII,uBAAuBF,OAAO,KAAK;QAG9D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAACH;IACnC;AACJ;AAEO,MAAMM,4DAA+BC,6BAAAA,oBAAuC,CAAC;IAChF,gBAAgBV;IAChB,cAAc;QAACW;QAAoBC;KAAgC;AACvE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { WebhookDelivery, WebhookDeliveryStatus } from "../../../api/domain/WebhookDelivery.js";
|
|
3
|
-
import type { WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookPersistenceError } from "../../../api/domain/errors.js";
|
|
3
|
+
import type { WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookPersistenceError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
4
4
|
import type { DateStringInterfaceGenerator, IdInterfaceGenerator, NumericInterfaceGenerator, TextInterfaceGenerator } from "@webiny/api";
|
|
5
5
|
export interface IListWebhookDeliveriesInputWhere extends IdInterfaceGenerator<"id">, IdInterfaceGenerator<"webhookId">, IdInterfaceGenerator<"backgroundTaskId">, DateStringInterfaceGenerator<"createdOn">, DateStringInterfaceGenerator<"savedOn">, TextInterfaceGenerator<"eventType">, TextInterfaceGenerator<WebhookDeliveryStatus>, NumericInterfaceGenerator<"responseStatus"> {
|
|
6
6
|
}
|
|
@@ -15,7 +15,7 @@ export interface IListMeta {
|
|
|
15
15
|
hasMoreItems: boolean;
|
|
16
16
|
totalCount: number;
|
|
17
17
|
}
|
|
18
|
-
type IError = WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError;
|
|
18
|
+
type IError = WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
19
19
|
export interface IListWebhookDeliveriesOutput {
|
|
20
20
|
items: WebhookDelivery[];
|
|
21
21
|
meta: IListMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhookDeliveries/abstractions.js","sources":["../../../../src/api/features/ListWebhookDeliveries/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { WebhookDelivery, WebhookDeliveryStatus } from \"~/api/domain/WebhookDelivery.js\";\nimport type {\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookPersistenceError\n} from \"~/api/domain/errors.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdInterfaceGenerator,\n NumericInterfaceGenerator,\n TextInterfaceGenerator\n} from \"@webiny/api\";\n\nexport interface IListWebhookDeliveriesInputWhere\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"webhookId\">,\n IdInterfaceGenerator<\"backgroundTaskId\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n TextInterfaceGenerator<\"eventType\">,\n TextInterfaceGenerator<WebhookDeliveryStatus>,\n NumericInterfaceGenerator<\"responseStatus\"> {\n //\n}\n\nexport interface IListWebhookDeliveriesInput {\n where?: IListWebhookDeliveriesInputWhere;\n limit?: number;\n after?: string;\n sort?: (`${string}_ASC` | `${string}_DESC`)[];\n}\n\nexport interface IListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\ntype IError
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhookDeliveries/abstractions.js","sources":["../../../../src/api/features/ListWebhookDeliveries/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { WebhookDelivery, WebhookDeliveryStatus } from \"~/api/domain/WebhookDelivery.js\";\nimport type {\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookPersistenceError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdInterfaceGenerator,\n NumericInterfaceGenerator,\n TextInterfaceGenerator\n} from \"@webiny/api\";\n\nexport interface IListWebhookDeliveriesInputWhere\n extends\n IdInterfaceGenerator<\"id\">,\n IdInterfaceGenerator<\"webhookId\">,\n IdInterfaceGenerator<\"backgroundTaskId\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n TextInterfaceGenerator<\"eventType\">,\n TextInterfaceGenerator<WebhookDeliveryStatus>,\n NumericInterfaceGenerator<\"responseStatus\"> {\n //\n}\n\nexport interface IListWebhookDeliveriesInput {\n where?: IListWebhookDeliveriesInputWhere;\n limit?: number;\n after?: string;\n sort?: (`${string}_ASC` | `${string}_DESC`)[];\n}\n\nexport interface IListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\ntype IError =\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IListWebhookDeliveriesOutput {\n items: WebhookDelivery[];\n meta: IListMeta;\n}\n\nexport interface IListWebhookDeliveriesUseCase {\n execute(\n input: IListWebhookDeliveriesInput\n ): Promise<Result<IListWebhookDeliveriesOutput, IError>>;\n}\n\nexport const ListWebhookDeliveriesUseCase = createAbstraction<IListWebhookDeliveriesUseCase>(\n \"Webhooks/ListWebhookDeliveriesUseCase\"\n);\n\nexport namespace ListWebhookDeliveriesUseCase {\n export type Interface = IListWebhookDeliveriesUseCase;\n export type Output = IListWebhookDeliveriesOutput;\n export type Error = IError;\n}\n\nexport interface IListWebhookDeliveriesRepository {\n execute(\n input: IListWebhookDeliveriesInput\n ): Promise<Result<IListWebhookDeliveriesOutput, IError>>;\n}\n\nexport const ListWebhookDeliveriesRepository = createAbstraction<IListWebhookDeliveriesRepository>(\n \"Webhooks/ListWebhookDeliveriesRepository\"\n);\n\nexport namespace ListWebhookDeliveriesRepository {\n export type Interface = IListWebhookDeliveriesRepository;\n export type Error = IError;\n}\n"],"names":["ListWebhookDeliveriesUseCase","createAbstraction","ListWebhookDeliveriesRepository"],"mappings":";AA0DO,MAAMA,+BAA+BC,kBACxC;AAeG,MAAMC,kCAAkCD,kBAC3C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ListWebhookDeliveriesInputSchema: z.ZodObject<{
|
|
3
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const ListWebhookDeliveriesInputSchema = z.object({
|
|
3
|
+
where: z.record(z.string(), z.unknown()).optional(),
|
|
4
|
+
limit: z.number().int().positive("Limit must be a positive integer.").optional(),
|
|
5
|
+
after: z.string().optional(),
|
|
6
|
+
sort: z.array(z.string()).optional()
|
|
7
|
+
});
|
|
8
|
+
export { ListWebhookDeliveriesInputSchema };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhookDeliveries/schema.js","sources":["../../../../src/api/features/ListWebhookDeliveries/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ListWebhookDeliveriesInputSchema = z.object({\n where: z.record(z.string(), z.unknown()).optional(),\n limit: z.number().int().positive(\"Limit must be a positive integer.\").optional(),\n after: z.string().optional(),\n sort: z.array(z.string()).optional()\n});\n"],"names":["ListWebhookDeliveriesInputSchema","z"],"mappings":";AAEO,MAAMA,mCAAmCC,EAAE,MAAM,CAAC;IACrD,OAAOA,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO,IAAI,QAAQ;IACjD,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,qCAAqC,QAAQ;IAC9E,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,MAAMA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;AACtC"}
|
|
@@ -3,8 +3,8 @@ import { ListWebhooksUseCase as UseCaseAbstraction, ListWebhooksRepository } fro
|
|
|
3
3
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
4
4
|
import type { IListWebhooksInput } from "./abstractions.js";
|
|
5
5
|
declare class ListWebhooksUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
-
private permissions;
|
|
7
|
-
private repository;
|
|
6
|
+
private readonly permissions;
|
|
7
|
+
private readonly repository;
|
|
8
8
|
constructor(permissions: WebhookPermissions.Interface, repository: ListWebhooksRepository.Interface);
|
|
9
9
|
execute(input?: IListWebhooksInput): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListWebhooksRepository, ListWebhooksUseCase } from "./abstractions.js";
|
|
3
|
+
import { ListWebhooksInputSchema } from "./schema.js";
|
|
3
4
|
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
4
|
-
import { WebhookNotAuthorizedError } from "../../domain/errors.js";
|
|
5
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
5
6
|
class ListWebhooksUseCaseImpl {
|
|
6
7
|
constructor(permissions, repository){
|
|
7
8
|
this.permissions = permissions;
|
|
@@ -9,6 +10,8 @@ class ListWebhooksUseCaseImpl {
|
|
|
9
10
|
}
|
|
10
11
|
async execute(input) {
|
|
11
12
|
if (!await this.permissions.canRead("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
13
|
+
const parsed = ListWebhooksInputSchema.safeParse(input ?? {});
|
|
14
|
+
if (!parsed.success) return Result.fail(new WebhookValidationError(parsed.error));
|
|
12
15
|
return this.repository.execute(input);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhooks/ListWebhooksUseCase.js","sources":["../../../../src/api/features/ListWebhooks/ListWebhooksUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListWebhooksUseCase as UseCaseAbstraction,\n ListWebhooksRepository\n} from \"./abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError } from \"~/api/domain/errors.js\";\nimport type { IListWebhooksInput } from \"./abstractions.js\";\n\nclass ListWebhooksUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: WebhookPermissions.Interface,\n private repository: ListWebhooksRepository.Interface\n ) {}\n\n async execute(\n input?: IListWebhooksInput\n ): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n return this.repository.execute(input);\n }\n}\n\nexport const ListWebhooksUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListWebhooksUseCaseImpl,\n dependencies: [WebhookPermissions, ListWebhooksRepository]\n});\n"],"names":["ListWebhooksUseCaseImpl","permissions","repository","input","Result","WebhookNotAuthorizedError","ListWebhooksUseCase","UseCaseAbstraction","WebhookPermissions","ListWebhooksRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhooks/ListWebhooksUseCase.js","sources":["../../../../src/api/features/ListWebhooks/ListWebhooksUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListWebhooksUseCase as UseCaseAbstraction,\n ListWebhooksRepository\n} from \"./abstractions.js\";\nimport { ListWebhooksInputSchema } from \"./schema.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport type { IListWebhooksInput } from \"./abstractions.js\";\n\nclass ListWebhooksUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly repository: ListWebhooksRepository.Interface\n ) {}\n\n async execute(\n input?: IListWebhooksInput\n ): Promise<Result<UseCaseAbstraction.Output, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canRead(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = ListWebhooksInputSchema.safeParse(input ?? {});\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n return this.repository.execute(input);\n }\n}\n\nexport const ListWebhooksUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListWebhooksUseCaseImpl,\n dependencies: [WebhookPermissions, ListWebhooksRepository]\n});\n"],"names":["ListWebhooksUseCaseImpl","permissions","repository","input","Result","WebhookNotAuthorizedError","parsed","ListWebhooksInputSchema","WebhookValidationError","ListWebhooksUseCase","UseCaseAbstraction","WebhookPermissions","ListWebhooksRepository"],"mappings":";;;;;AAUA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,UAA4C,CAC/D;aAFmBD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,QACFC,KAA0B,EAC0C;QACpE,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAASC,wBAAwB,SAAS,CAACJ,SAAS,CAAC;QAC3D,IAAI,CAACG,OAAO,OAAO,EACf,OAAOF,OAAO,IAAI,CAAC,IAAII,uBAAuBF,OAAO,KAAK;QAG9D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAACH;IACnC;AACJ;AAEO,MAAMM,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBV;IAChB,cAAc;QAACW;QAAoBC;KAAuB;AAC9D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { Webhook } from "../../../api/domain/Webhook.js";
|
|
3
|
-
import type { WebhookModelNotFoundError, WebhookPersistenceError, WebhookNotAuthorizedError } from "../../../api/domain/errors.js";
|
|
3
|
+
import type { WebhookModelNotFoundError, WebhookPersistenceError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
4
4
|
import type { DateStringInterfaceGenerator, IdInterfaceGenerator, TextInterfaceGenerator, TruthfulInterfaceGenerator } from "@webiny/api";
|
|
5
5
|
export interface IListWebhooksInputWhere extends IdInterfaceGenerator<"id">, DateStringInterfaceGenerator<"createdOn">, DateStringInterfaceGenerator<"savedOn">, TextInterfaceGenerator<"name">, TextInterfaceGenerator<"slug">, TextInterfaceGenerator<"endpointUrl">, TextInterfaceGenerator<"events">, TruthfulInterfaceGenerator<"enabled"> {
|
|
6
6
|
}
|
|
@@ -15,7 +15,7 @@ export interface IListMeta {
|
|
|
15
15
|
hasMoreItems: boolean;
|
|
16
16
|
totalCount: number;
|
|
17
17
|
}
|
|
18
|
-
type IError = WebhookModelNotFoundError | WebhookPersistenceError | WebhookNotAuthorizedError;
|
|
18
|
+
type IError = WebhookModelNotFoundError | WebhookPersistenceError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
19
19
|
export interface IListWebhooksOutput {
|
|
20
20
|
items: Webhook[];
|
|
21
21
|
meta: IListMeta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhooks/abstractions.js","sources":["../../../../src/api/features/ListWebhooks/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\nimport type {\n WebhookModelNotFoundError,\n WebhookPersistenceError,\n WebhookNotAuthorizedError\n} from \"~/api/domain/errors.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdInterfaceGenerator,\n TextInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport interface IListWebhooksInputWhere\n extends\n IdInterfaceGenerator<\"id\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n TextInterfaceGenerator<\"name\">,\n TextInterfaceGenerator<\"slug\">,\n TextInterfaceGenerator<\"endpointUrl\">,\n TextInterfaceGenerator<\"events\">,\n TruthfulInterfaceGenerator<\"enabled\"> {\n //\n}\n\nexport interface IListWebhooksInput {\n where?: IListWebhooksInputWhere;\n limit?: number;\n after?: string;\n sort?: (`${string}_ASC` | `${string}_DESC`)[];\n}\n\nexport interface IListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\ntype IError
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhooks/abstractions.js","sources":["../../../../src/api/features/ListWebhooks/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { Webhook } from \"~/api/domain/Webhook.js\";\nimport type {\n WebhookModelNotFoundError,\n WebhookPersistenceError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\nimport type {\n DateStringInterfaceGenerator,\n IdInterfaceGenerator,\n TextInterfaceGenerator,\n TruthfulInterfaceGenerator\n} from \"@webiny/api\";\n\nexport interface IListWebhooksInputWhere\n extends\n IdInterfaceGenerator<\"id\">,\n DateStringInterfaceGenerator<\"createdOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n TextInterfaceGenerator<\"name\">,\n TextInterfaceGenerator<\"slug\">,\n TextInterfaceGenerator<\"endpointUrl\">,\n TextInterfaceGenerator<\"events\">,\n TruthfulInterfaceGenerator<\"enabled\"> {\n //\n}\n\nexport interface IListWebhooksInput {\n where?: IListWebhooksInputWhere;\n limit?: number;\n after?: string;\n sort?: (`${string}_ASC` | `${string}_DESC`)[];\n}\n\nexport interface IListMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\ntype IError =\n | WebhookModelNotFoundError\n | WebhookPersistenceError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IListWebhooksOutput {\n items: Webhook[];\n meta: IListMeta;\n}\n\nexport interface IListWebhooksUseCase {\n execute(input?: IListWebhooksInput): Promise<Result<IListWebhooksOutput, IError>>;\n}\n\nexport const ListWebhooksUseCase = createAbstraction<IListWebhooksUseCase>(\n \"Webhooks/ListWebhooksUseCase\"\n);\n\nexport namespace ListWebhooksUseCase {\n export type Interface = IListWebhooksUseCase;\n export type Output = IListWebhooksOutput;\n export type Error = IError;\n}\n\nexport interface IListWebhooksRepository {\n execute(input?: IListWebhooksInput): Promise<Result<IListWebhooksOutput, IError>>;\n}\n\nexport const ListWebhooksRepository = createAbstraction<IListWebhooksRepository>(\n \"Webhooks/ListWebhooksRepository\"\n);\n\nexport namespace ListWebhooksRepository {\n export type Interface = IListWebhooksRepository;\n export type Output = IListWebhooksOutput;\n export type Error = IError;\n}\n"],"names":["ListWebhooksUseCase","createAbstraction","ListWebhooksRepository"],"mappings":";AAwDO,MAAMA,sBAAsBC,kBAC/B;AAaG,MAAMC,yBAAyBD,kBAClC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ListWebhooksInputSchema: z.ZodObject<{
|
|
3
|
+
where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
4
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
sort: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const ListWebhooksInputSchema = z.object({
|
|
3
|
+
where: z.record(z.string(), z.unknown()).optional(),
|
|
4
|
+
limit: z.number().int().positive("Limit must be a positive integer.").optional(),
|
|
5
|
+
after: z.string().optional(),
|
|
6
|
+
sort: z.array(z.string()).optional()
|
|
7
|
+
});
|
|
8
|
+
export { ListWebhooksInputSchema };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhooks/schema.js","sources":["../../../../src/api/features/ListWebhooks/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ListWebhooksInputSchema = z.object({\n where: z.record(z.string(), z.unknown()).optional(),\n limit: z.number().int().positive(\"Limit must be a positive integer.\").optional(),\n after: z.string().optional(),\n sort: z.array(z.string()).optional()\n});\n"],"names":["ListWebhooksInputSchema","z"],"mappings":";AAEO,MAAMA,0BAA0BC,EAAE,MAAM,CAAC;IAC5C,OAAOA,EAAE,MAAM,CAACA,EAAE,MAAM,IAAIA,EAAE,OAAO,IAAI,QAAQ;IACjD,OAAOA,EAAE,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,qCAAqC,QAAQ;IAC9E,OAAOA,EAAE,MAAM,GAAG,QAAQ;IAC1B,MAAMA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;AACtC"}
|