@webiny/webhooks 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/admin/WebhookRoutes.d.ts +2 -0
- package/admin/WebhookRoutes.js +68 -0
- package/admin/WebhookRoutes.js.map +1 -0
- package/admin/Webhooks.d.ts +2 -0
- package/admin/Webhooks.js +64 -0
- package/admin/Webhooks.js.map +1 -0
- package/admin/features/ListWebhooks/ListWebhooksGateway.d.ts +11 -0
- package/admin/features/ListWebhooks/ListWebhooksGateway.js +62 -0
- package/admin/features/ListWebhooks/ListWebhooksGateway.js.map +1 -0
- package/admin/features/ListWebhooks/ListWebhooksRepository.d.ts +10 -0
- package/admin/features/ListWebhooks/ListWebhooksRepository.js +18 -0
- package/admin/features/ListWebhooks/ListWebhooksRepository.js.map +1 -0
- package/admin/features/ListWebhooks/ListWebhooksUseCase.d.ts +10 -0
- package/admin/features/ListWebhooks/ListWebhooksUseCase.js +18 -0
- package/admin/features/ListWebhooks/ListWebhooksUseCase.js.map +1 -0
- package/admin/features/ListWebhooks/abstractions.d.ts +36 -0
- package/admin/features/ListWebhooks/abstractions.js +7 -0
- package/admin/features/ListWebhooks/abstractions.js.map +1 -0
- package/admin/features/ListWebhooks/feature.d.ts +3 -0
- package/admin/features/ListWebhooks/feature.js +21 -0
- package/admin/features/ListWebhooks/feature.js.map +1 -0
- package/admin/features/ListWebhooks/index.d.ts +2 -0
- package/admin/features/ListWebhooks/index.js +2 -0
- package/admin/features/createWebhook/CreateWebhookGateway.d.ts +12 -0
- package/admin/features/createWebhook/CreateWebhookGateway.js +21 -0
- package/admin/features/createWebhook/CreateWebhookGateway.js.map +1 -0
- package/admin/features/createWebhook/CreateWebhookUseCase.d.ts +11 -0
- package/admin/features/createWebhook/CreateWebhookUseCase.js +18 -0
- package/admin/features/createWebhook/CreateWebhookUseCase.js.map +1 -0
- package/admin/features/createWebhook/abstractions.d.ts +23 -0
- package/admin/features/createWebhook/abstractions.js +6 -0
- package/admin/features/createWebhook/abstractions.js.map +1 -0
- package/admin/features/createWebhook/feature.d.ts +3 -0
- package/admin/features/createWebhook/feature.js +19 -0
- package/admin/features/createWebhook/feature.js.map +1 -0
- package/admin/features/createWebhook/index.d.ts +2 -0
- package/admin/features/createWebhook/index.js +2 -0
- package/admin/features/deleteWebhook/DeleteWebhookGateway.d.ts +11 -0
- package/admin/features/deleteWebhook/DeleteWebhookGateway.js +23 -0
- package/admin/features/deleteWebhook/DeleteWebhookGateway.js.map +1 -0
- package/admin/features/deleteWebhook/DeleteWebhookUseCase.d.ts +10 -0
- package/admin/features/deleteWebhook/DeleteWebhookUseCase.js +18 -0
- package/admin/features/deleteWebhook/DeleteWebhookUseCase.js.map +1 -0
- package/admin/features/deleteWebhook/abstractions.d.ts +14 -0
- package/admin/features/deleteWebhook/abstractions.js +6 -0
- package/admin/features/deleteWebhook/abstractions.js.map +1 -0
- package/admin/features/deleteWebhook/feature.d.ts +3 -0
- package/admin/features/deleteWebhook/feature.js +19 -0
- package/admin/features/deleteWebhook/feature.js.map +1 -0
- package/admin/features/deleteWebhook/index.d.ts +2 -0
- package/admin/features/deleteWebhook/index.js +2 -0
- package/admin/features/getWebhook/GetWebhookGateway.d.ts +12 -0
- package/admin/features/getWebhook/GetWebhookGateway.js +23 -0
- package/admin/features/getWebhook/GetWebhookGateway.js.map +1 -0
- package/admin/features/getWebhook/GetWebhookUseCase.d.ts +11 -0
- package/admin/features/getWebhook/GetWebhookUseCase.js +18 -0
- package/admin/features/getWebhook/GetWebhookUseCase.js.map +1 -0
- package/admin/features/getWebhook/abstractions.d.ts +15 -0
- package/admin/features/getWebhook/abstractions.js +6 -0
- package/admin/features/getWebhook/abstractions.js.map +1 -0
- package/admin/features/getWebhook/feature.d.ts +3 -0
- package/admin/features/getWebhook/feature.js +19 -0
- package/admin/features/getWebhook/feature.js.map +1 -0
- package/admin/features/getWebhook/index.d.ts +2 -0
- package/admin/features/getWebhook/index.js +2 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.js +41 -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/listAvailableEvents/ListAvailableEventsGateway.d.ts +12 -0
- package/admin/features/listAvailableEvents/ListAvailableEventsGateway.js +21 -0
- package/admin/features/listAvailableEvents/ListAvailableEventsGateway.js.map +1 -0
- package/admin/features/listAvailableEvents/ListAvailableEventsUseCase.d.ts +11 -0
- package/admin/features/listAvailableEvents/ListAvailableEventsUseCase.js +18 -0
- package/admin/features/listAvailableEvents/ListAvailableEventsUseCase.js.map +1 -0
- package/admin/features/listAvailableEvents/abstractions.d.ts +15 -0
- package/admin/features/listAvailableEvents/abstractions.js +6 -0
- package/admin/features/listAvailableEvents/abstractions.js.map +1 -0
- package/admin/features/listAvailableEvents/feature.d.ts +3 -0
- package/admin/features/listAvailableEvents/feature.js +19 -0
- package/admin/features/listAvailableEvents/feature.js.map +1 -0
- package/admin/features/listAvailableEvents/index.d.ts +2 -0
- package/admin/features/listAvailableEvents/index.js +2 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesGateway.d.ts +11 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesGateway.js +28 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesGateway.js.map +1 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesUseCase.d.ts +10 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesUseCase.js +18 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesUseCase.js.map +1 -0
- package/admin/features/listWebhookDeliveries/abstractions.d.ts +33 -0
- package/admin/features/listWebhookDeliveries/abstractions.js +6 -0
- package/admin/features/listWebhookDeliveries/abstractions.js.map +1 -0
- package/admin/features/listWebhookDeliveries/feature.d.ts +3 -0
- package/admin/features/listWebhookDeliveries/feature.js +19 -0
- package/admin/features/listWebhookDeliveries/feature.js.map +1 -0
- package/admin/features/listWebhookDeliveries/index.d.ts +2 -0
- package/admin/features/listWebhookDeliveries/index.js +2 -0
- package/admin/features/permissions/abstractions.d.ts +17 -0
- package/admin/features/permissions/abstractions.js +6 -0
- package/admin/features/permissions/abstractions.js.map +1 -0
- package/admin/features/permissions/feature.d.ts +14 -0
- package/admin/features/permissions/feature.js +7 -0
- package/admin/features/permissions/feature.js.map +1 -0
- package/admin/features/permissions/index.d.ts +2 -0
- package/admin/features/permissions/index.js +2 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryGateway.d.ts +11 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryGateway.js +23 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryGateway.js.map +1 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryUseCase.d.ts +10 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryUseCase.js +18 -0
- package/admin/features/resendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -0
- package/admin/features/resendWebhookDelivery/abstractions.d.ts +14 -0
- package/admin/features/resendWebhookDelivery/abstractions.js +6 -0
- package/admin/features/resendWebhookDelivery/abstractions.js.map +1 -0
- package/admin/features/resendWebhookDelivery/feature.d.ts +3 -0
- package/admin/features/resendWebhookDelivery/feature.js +19 -0
- package/admin/features/resendWebhookDelivery/feature.js.map +1 -0
- package/admin/features/resendWebhookDelivery/index.d.ts +2 -0
- package/admin/features/resendWebhookDelivery/index.js +2 -0
- package/admin/features/triggerWebhook/TriggerWebhookGateway.d.ts +12 -0
- package/admin/features/triggerWebhook/TriggerWebhookGateway.js +24 -0
- package/admin/features/triggerWebhook/TriggerWebhookGateway.js.map +1 -0
- package/admin/features/triggerWebhook/TriggerWebhookUseCase.d.ts +11 -0
- package/admin/features/triggerWebhook/TriggerWebhookUseCase.js +18 -0
- package/admin/features/triggerWebhook/TriggerWebhookUseCase.js.map +1 -0
- package/admin/features/triggerWebhook/abstractions.d.ts +15 -0
- package/admin/features/triggerWebhook/abstractions.js +6 -0
- package/admin/features/triggerWebhook/abstractions.js.map +1 -0
- package/admin/features/triggerWebhook/feature.d.ts +3 -0
- package/admin/features/triggerWebhook/feature.js +19 -0
- package/admin/features/triggerWebhook/feature.js.map +1 -0
- package/admin/features/triggerWebhook/index.d.ts +2 -0
- package/admin/features/triggerWebhook/index.js +2 -0
- package/admin/features/updateWebhook/UpdateWebhookGateway.d.ts +12 -0
- package/admin/features/updateWebhook/UpdateWebhookGateway.js +24 -0
- package/admin/features/updateWebhook/UpdateWebhookGateway.js.map +1 -0
- package/admin/features/updateWebhook/UpdateWebhookUseCase.d.ts +11 -0
- package/admin/features/updateWebhook/UpdateWebhookUseCase.js +18 -0
- package/admin/features/updateWebhook/UpdateWebhookUseCase.js.map +1 -0
- package/admin/features/updateWebhook/abstractions.d.ts +23 -0
- package/admin/features/updateWebhook/abstractions.js +6 -0
- package/admin/features/updateWebhook/abstractions.js.map +1 -0
- package/admin/features/updateWebhook/feature.d.ts +3 -0
- package/admin/features/updateWebhook/feature.js +19 -0
- package/admin/features/updateWebhook/feature.js.map +1 -0
- package/admin/features/updateWebhook/index.d.ts +2 -0
- package/admin/features/updateWebhook/index.js +2 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.js +44 -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 +19 -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/index.d.ts +2 -0
- package/admin/index.js +2 -0
- package/admin/permissions.d.ts +12 -0
- package/admin/permissions.js +22 -0
- package/admin/permissions.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesDataSource.d.ts +16 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesDataSource.js +68 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesDataSource.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.d.ts +21 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js +57 -0
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/abstractions.d.ts +18 -0
- package/admin/presentation/WebhookDeliveries/abstractions.js +5 -0
- package/admin/presentation/WebhookDeliveries/abstractions.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryAccordionRow.d.ts +11 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryAccordionRow.js +36 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryAccordionRow.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.d.ts +11 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js +32 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailContent.d.ts +7 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailContent.js +76 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailContent.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.d.ts +9 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.js +22 -0
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.d.ts +8 -0
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js +119 -0
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/components/statusVariant.d.ts +1 -0
- package/admin/presentation/WebhookDeliveries/components/statusVariant.js +13 -0
- package/admin/presentation/WebhookDeliveries/components/statusVariant.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/feature.d.ts +3 -0
- package/admin/presentation/WebhookDeliveries/feature.js +17 -0
- package/admin/presentation/WebhookDeliveries/feature.js.map +1 -0
- package/admin/presentation/WebhookDeliveries/index.d.ts +2 -0
- package/admin/presentation/WebhookDeliveries/index.js +2 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.d.ts +37 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js +196 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.d.ts +39 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.js +5 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js +43 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js +66 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js +45 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.d.ts +2 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +64 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.d.ts +3 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.js +17 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/index.d.ts +5 -0
- package/admin/presentation/WebhookDeliveriesPage/index.js +1 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.d.ts +42 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js +252 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -0
- package/admin/presentation/WebhookForm/abstractions.d.ts +27 -0
- package/admin/presentation/WebhookForm/abstractions.js +5 -0
- package/admin/presentation/WebhookForm/abstractions.js.map +1 -0
- package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +9 -0
- package/admin/presentation/WebhookForm/components/SigningSecret.js +47 -0
- package/admin/presentation/WebhookForm/components/SigningSecret.js.map +1 -0
- package/admin/presentation/WebhookForm/components/WebhookFormView.d.ts +2 -0
- package/admin/presentation/WebhookForm/components/WebhookFormView.js +97 -0
- package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -0
- package/admin/presentation/WebhookForm/feature.d.ts +3 -0
- package/admin/presentation/WebhookForm/feature.js +17 -0
- package/admin/presentation/WebhookForm/feature.js.map +1 -0
- package/admin/presentation/WebhookForm/index.d.ts +2 -0
- package/admin/presentation/WebhookForm/index.js +2 -0
- package/admin/presentation/WebhookList/WebhookListDataSource.d.ts +15 -0
- package/admin/presentation/WebhookList/WebhookListDataSource.js +67 -0
- package/admin/presentation/WebhookList/WebhookListDataSource.js.map +1 -0
- package/admin/presentation/WebhookList/WebhookListPresenter.d.ts +46 -0
- package/admin/presentation/WebhookList/WebhookListPresenter.js +92 -0
- package/admin/presentation/WebhookList/WebhookListPresenter.js.map +1 -0
- package/admin/presentation/WebhookList/abstractions.d.ts +45 -0
- package/admin/presentation/WebhookList/abstractions.js +5 -0
- package/admin/presentation/WebhookList/abstractions.js.map +1 -0
- package/admin/presentation/WebhookList/components/CreateWebhookButton.d.ts +2 -0
- package/admin/presentation/WebhookList/components/CreateWebhookButton.js +22 -0
- package/admin/presentation/WebhookList/components/CreateWebhookButton.js.map +1 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.d.ts +9 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.js +158 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.js.map +1 -0
- package/admin/presentation/WebhookList/components/WebhookListView.d.ts +2 -0
- package/admin/presentation/WebhookList/components/WebhookListView.js +46 -0
- package/admin/presentation/WebhookList/components/WebhookListView.js.map +1 -0
- package/admin/presentation/WebhookList/feature.d.ts +3 -0
- package/admin/presentation/WebhookList/feature.js +17 -0
- package/admin/presentation/WebhookList/feature.js.map +1 -0
- package/admin/presentation/WebhookList/index.d.ts +2 -0
- package/admin/presentation/WebhookList/index.js +2 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.d.ts +21 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js +89 -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/presentation/security/HasPermission.d.ts +12 -0
- package/admin/presentation/security/HasPermission.js +6 -0
- package/admin/presentation/security/HasPermission.js.map +1 -0
- package/admin/presentation/security/usePermissions.d.ts +12 -0
- package/admin/presentation/security/usePermissions.js +6 -0
- package/admin/presentation/security/usePermissions.js.map +1 -0
- package/admin/routes.d.ts +9 -0
- package/admin/routes.js +25 -0
- package/admin/routes.js.map +1 -0
- package/admin/shared/types.d.ts +9 -0
- package/admin/shared/types.js +0 -0
- package/api/Extension.d.ts +1 -0
- package/api/Extension.js +1 -0
- package/api/WebhooksFeature.d.ts +4 -0
- package/api/WebhooksFeature.js +65 -0
- package/api/WebhooksFeature.js.map +1 -0
- package/api/domain/Webhook.d.ts +27 -0
- package/api/domain/Webhook.js +0 -0
- package/api/domain/WebhookDelivery.d.ts +35 -0
- package/api/domain/WebhookDelivery.js +0 -0
- package/api/domain/WebhookSettings.d.ts +4 -0
- package/api/domain/WebhookSettings.js +0 -0
- package/api/domain/constants.d.ts +5 -0
- package/api/domain/constants.js +8 -0
- package/api/domain/constants.js.map +1 -0
- package/api/domain/errors.d.ts +41 -0
- package/api/domain/errors.js +83 -0
- package/api/domain/errors.js.map +1 -0
- package/api/features/CreateWebhook/CreateWebhookRepository.d.ts +18 -0
- package/api/features/CreateWebhook/CreateWebhookRepository.js +43 -0
- package/api/features/CreateWebhook/CreateWebhookRepository.js.map +1 -0
- package/api/features/CreateWebhook/CreateWebhookUseCase.d.ts +16 -0
- package/api/features/CreateWebhook/CreateWebhookUseCase.js +48 -0
- package/api/features/CreateWebhook/CreateWebhookUseCase.js.map +1 -0
- package/api/features/CreateWebhook/abstractions.d.ts +33 -0
- package/api/features/CreateWebhook/abstractions.js +6 -0
- package/api/features/CreateWebhook/abstractions.js.map +1 -0
- package/api/features/CreateWebhook/feature.d.ts +4 -0
- package/api/features/CreateWebhook/feature.js +13 -0
- package/api/features/CreateWebhook/feature.js.map +1 -0
- 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/CreateWebhookDelivery/CreateWebhookDeliveryRepository.d.ts +20 -0
- package/api/features/CreateWebhookDelivery/CreateWebhookDeliveryRepository.js +60 -0
- package/api/features/CreateWebhookDelivery/CreateWebhookDeliveryRepository.js.map +1 -0
- package/api/features/CreateWebhookDelivery/abstractions.d.ts +21 -0
- package/api/features/CreateWebhookDelivery/abstractions.js +5 -0
- package/api/features/CreateWebhookDelivery/abstractions.js.map +1 -0
- package/api/features/CreateWebhookDelivery/feature.d.ts +4 -0
- package/api/features/CreateWebhookDelivery/feature.js +11 -0
- package/api/features/CreateWebhookDelivery/feature.js.map +1 -0
- package/api/features/DeleteWebhook/DeleteWebhookRepository.d.ts +19 -0
- package/api/features/DeleteWebhook/DeleteWebhookRepository.js +66 -0
- package/api/features/DeleteWebhook/DeleteWebhookRepository.js.map +1 -0
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.d.ts +15 -0
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js +34 -0
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js.map +1 -0
- package/api/features/DeleteWebhook/abstractions.d.ts +20 -0
- package/api/features/DeleteWebhook/abstractions.js +6 -0
- package/api/features/DeleteWebhook/abstractions.js.map +1 -0
- package/api/features/DeleteWebhook/feature.d.ts +4 -0
- package/api/features/DeleteWebhook/feature.js +13 -0
- package/api/features/DeleteWebhook/feature.js.map +1 -0
- 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/GetWebhookRepository.d.ts +17 -0
- package/api/features/GetWebhook/GetWebhookRepository.js +39 -0
- package/api/features/GetWebhook/GetWebhookRepository.js.map +1 -0
- package/api/features/GetWebhook/GetWebhookUseCase.d.ts +14 -0
- package/api/features/GetWebhook/GetWebhookUseCase.js +29 -0
- package/api/features/GetWebhook/GetWebhookUseCase.js.map +1 -0
- package/api/features/GetWebhook/abstractions.d.ts +21 -0
- package/api/features/GetWebhook/abstractions.js +6 -0
- package/api/features/GetWebhook/abstractions.js.map +1 -0
- package/api/features/GetWebhook/feature.d.ts +4 -0
- package/api/features/GetWebhook/feature.js +13 -0
- package/api/features/GetWebhook/feature.js.map +1 -0
- 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/GetWebhookDeliveryRepository.d.ts +17 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryRepository.js +39 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryRepository.js.map +1 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.d.ts +14 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js +29 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js.map +1 -0
- package/api/features/GetWebhookDelivery/abstractions.d.ts +21 -0
- package/api/features/GetWebhookDelivery/abstractions.js +6 -0
- package/api/features/GetWebhookDelivery/abstractions.js.map +1 -0
- package/api/features/GetWebhookDelivery/feature.d.ts +4 -0
- package/api/features/GetWebhookDelivery/feature.js +13 -0
- package/api/features/GetWebhookDelivery/feature.js.map +1 -0
- 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 +57 -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/ListAvailableWebhookEvents/ListAvailableWebhookEventsUseCase.d.ts +14 -0
- package/api/features/ListAvailableWebhookEvents/ListAvailableWebhookEventsUseCase.js +30 -0
- package/api/features/ListAvailableWebhookEvents/ListAvailableWebhookEventsUseCase.js.map +1 -0
- package/api/features/ListAvailableWebhookEvents/abstractions.d.ts +9 -0
- package/api/features/ListAvailableWebhookEvents/abstractions.js +5 -0
- package/api/features/ListAvailableWebhookEvents/abstractions.js.map +1 -0
- package/api/features/ListAvailableWebhookEvents/feature.d.ts +4 -0
- package/api/features/ListAvailableWebhookEvents/feature.js +11 -0
- package/api/features/ListAvailableWebhookEvents/feature.js.map +1 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.d.ts +21 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js +63 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js.map +1 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.d.ts +14 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js +27 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js.map +1 -0
- package/api/features/ListWebhookDeliveries/abstractions.d.ts +40 -0
- package/api/features/ListWebhookDeliveries/abstractions.js +6 -0
- package/api/features/ListWebhookDeliveries/abstractions.js.map +1 -0
- package/api/features/ListWebhookDeliveries/feature.d.ts +4 -0
- package/api/features/ListWebhookDeliveries/feature.js +13 -0
- package/api/features/ListWebhookDeliveries/feature.js.map +1 -0
- 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/ListWebhooksRepository.d.ts +21 -0
- package/api/features/ListWebhooks/ListWebhooksRepository.js +63 -0
- package/api/features/ListWebhooks/ListWebhooksRepository.js.map +1 -0
- package/api/features/ListWebhooks/ListWebhooksUseCase.d.ts +14 -0
- package/api/features/ListWebhooks/ListWebhooksUseCase.js +27 -0
- package/api/features/ListWebhooks/ListWebhooksUseCase.js.map +1 -0
- package/api/features/ListWebhooks/abstractions.d.ts +41 -0
- package/api/features/ListWebhooks/abstractions.js +6 -0
- package/api/features/ListWebhooks/abstractions.js.map +1 -0
- package/api/features/ListWebhooks/feature.d.ts +4 -0
- package/api/features/ListWebhooks/feature.js +13 -0
- package/api/features/ListWebhooks/feature.js.map +1 -0
- 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 +22 -0
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js +70 -0
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -0
- package/api/features/ResendWebhookDelivery/abstractions.d.ts +12 -0
- package/api/features/ResendWebhookDelivery/abstractions.js +5 -0
- package/api/features/ResendWebhookDelivery/abstractions.js.map +1 -0
- package/api/features/ResendWebhookDelivery/feature.d.ts +4 -0
- package/api/features/ResendWebhookDelivery/feature.js +11 -0
- package/api/features/ResendWebhookDelivery/feature.js.map +1 -0
- 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 +33 -0
- package/api/features/SendWebhookTask/SendWebhookTask.js +111 -0
- package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -0
- package/api/features/SendWebhookTask/feature.d.ts +4 -0
- package/api/features/SendWebhookTask/feature.js +11 -0
- package/api/features/SendWebhookTask/feature.js.map +1 -0
- package/api/features/SendWebhookTask/types.d.ts +16 -0
- package/api/features/SendWebhookTask/types.js +0 -0
- package/api/features/Transformers/WebhookDeliveryTransformer.d.ts +13 -0
- package/api/features/Transformers/WebhookDeliveryTransformer.js +57 -0
- package/api/features/Transformers/WebhookDeliveryTransformer.js.map +1 -0
- package/api/features/Transformers/WebhookTransformer.d.ts +11 -0
- package/api/features/Transformers/WebhookTransformer.js +35 -0
- package/api/features/Transformers/WebhookTransformer.js.map +1 -0
- package/api/features/Transformers/abstractions/WebhookDeliveryTransformer.d.ts +10 -0
- package/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js +5 -0
- package/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js.map +1 -0
- package/api/features/Transformers/abstractions/WebhookTransformer.d.ts +10 -0
- package/api/features/Transformers/abstractions/WebhookTransformer.js +5 -0
- package/api/features/Transformers/abstractions/WebhookTransformer.js.map +1 -0
- package/api/features/Transformers/feature.d.ts +4 -0
- package/api/features/Transformers/feature.js +13 -0
- package/api/features/Transformers/feature.js.map +1 -0
- package/api/features/Transformers/index.d.ts +2 -0
- package/api/features/Transformers/index.js +2 -0
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.d.ts +21 -0
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js +65 -0
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js.map +1 -0
- package/api/features/TriggerWebhook/abstractions.d.ts +13 -0
- package/api/features/TriggerWebhook/abstractions.js +5 -0
- package/api/features/TriggerWebhook/abstractions.js.map +1 -0
- package/api/features/TriggerWebhook/feature.d.ts +4 -0
- package/api/features/TriggerWebhook/feature.js +11 -0
- package/api/features/TriggerWebhook/feature.js.map +1 -0
- 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/UpdateWebhookRepository.d.ts +21 -0
- package/api/features/UpdateWebhook/UpdateWebhookRepository.js +50 -0
- package/api/features/UpdateWebhook/UpdateWebhookRepository.js.map +1 -0
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.d.ts +16 -0
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js +42 -0
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js.map +1 -0
- package/api/features/UpdateWebhook/abstractions.d.ts +30 -0
- package/api/features/UpdateWebhook/abstractions.js +6 -0
- package/api/features/UpdateWebhook/abstractions.js.map +1 -0
- package/api/features/UpdateWebhook/feature.d.ts +4 -0
- package/api/features/UpdateWebhook/feature.js +13 -0
- package/api/features/UpdateWebhook/feature.js.map +1 -0
- 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/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.d.ts +22 -0
- package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js +62 -0
- package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js.map +1 -0
- package/api/features/UpdateWebhookDelivery/abstractions.d.ts +23 -0
- package/api/features/UpdateWebhookDelivery/abstractions.js +5 -0
- package/api/features/UpdateWebhookDelivery/abstractions.js.map +1 -0
- package/api/features/UpdateWebhookDelivery/feature.d.ts +4 -0
- package/api/features/UpdateWebhookDelivery/feature.js +11 -0
- package/api/features/UpdateWebhookDelivery/feature.js.map +1 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.d.ts +21 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +62 -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 +27 -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 +5 -0
- package/api/features/UpdateWebhookSettings/schema.js +9 -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/WebhookDispatcher/WebhookDispatcher.d.ts +19 -0
- package/api/features/WebhookDispatcher/WebhookDispatcher.js +61 -0
- package/api/features/WebhookDispatcher/WebhookDispatcher.js.map +1 -0
- package/api/features/WebhookDispatcher/feature.d.ts +4 -0
- package/api/features/WebhookDispatcher/feature.js +11 -0
- package/api/features/WebhookDispatcher/feature.js.map +1 -0
- package/api/features/WebhookPermissions/abstractions.d.ts +17 -0
- package/api/features/WebhookPermissions/abstractions.js +6 -0
- package/api/features/WebhookPermissions/abstractions.js.map +1 -0
- package/api/features/WebhookPermissions/feature.d.ts +4 -0
- package/api/features/WebhookPermissions/feature.js +7 -0
- package/api/features/WebhookPermissions/feature.js.map +1 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.d.ts +9 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.js +26 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.js.map +1 -0
- package/api/features/WebhookSignPayload/feature.d.ts +4 -0
- package/api/features/WebhookSignPayload/feature.js +11 -0
- package/api/features/WebhookSignPayload/feature.js.map +1 -0
- package/api/features/WebhookVerifyPayload/WebhookVerifyPayload.d.ts +10 -0
- package/api/features/WebhookVerifyPayload/WebhookVerifyPayload.js +22 -0
- package/api/features/WebhookVerifyPayload/WebhookVerifyPayload.js.map +1 -0
- package/api/features/WebhookVerifyPayload/feature.d.ts +4 -0
- package/api/features/WebhookVerifyPayload/feature.js +11 -0
- package/api/features/WebhookVerifyPayload/feature.js.map +1 -0
- package/api/graphql/WebhookCrudSchema.d.ts +8 -0
- package/api/graphql/WebhookCrudSchema.js +166 -0
- package/api/graphql/WebhookCrudSchema.js.map +1 -0
- package/api/graphql/WebhookDeliverySchema.d.ts +8 -0
- package/api/graphql/WebhookDeliverySchema.js +100 -0
- package/api/graphql/WebhookDeliverySchema.js.map +1 -0
- package/api/graphql/WebhookEventSchema.d.ts +8 -0
- package/api/graphql/WebhookEventSchema.js +45 -0
- package/api/graphql/WebhookEventSchema.js.map +1 -0
- package/api/graphql/WebhookSettingsSchema.d.ts +8 -0
- package/api/graphql/WebhookSettingsSchema.js +62 -0
- package/api/graphql/WebhookSettingsSchema.js.map +1 -0
- package/api/graphql/WebhookTriggerSchema.d.ts +8 -0
- package/api/graphql/WebhookTriggerSchema.js +36 -0
- package/api/graphql/WebhookTriggerSchema.js.map +1 -0
- package/api/index.d.ts +1 -0
- package/api/index.js +8 -0
- package/api/index.js.map +1 -0
- package/api/models/WebhookDeliveryModel.d.ts +8 -0
- package/api/models/WebhookDeliveryModel.js +36 -0
- package/api/models/WebhookDeliveryModel.js.map +1 -0
- package/api/models/WebhookModel.d.ts +8 -0
- package/api/models/WebhookModel.js +33 -0
- package/api/models/WebhookModel.js.map +1 -0
- package/api/models/WebhookSettingsModel.d.ts +8 -0
- package/api/models/WebhookSettingsModel.js +28 -0
- package/api/models/WebhookSettingsModel.js.map +1 -0
- package/api/permissions.d.ts +12 -0
- package/api/permissions.js +22 -0
- package/api/permissions.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 +5 -0
- package/exports/api/webhooks.js +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListWebhooksRepository, ListWebhooksUseCase } from "./abstractions.js";
|
|
3
|
+
import { ListWebhooksInputSchema } from "./schema.js";
|
|
4
|
+
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
5
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
6
|
+
class ListWebhooksUseCaseImpl {
|
|
7
|
+
constructor(permissions, repository){
|
|
8
|
+
this.permissions = permissions;
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
}
|
|
11
|
+
async execute(input) {
|
|
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));
|
|
15
|
+
return this.repository.execute(input);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const ListWebhooksUseCase_ListWebhooksUseCase = ListWebhooksUseCase.createImplementation({
|
|
19
|
+
implementation: ListWebhooksUseCaseImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
WebhookPermissions,
|
|
22
|
+
ListWebhooksRepository
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
export { ListWebhooksUseCase_ListWebhooksUseCase as ListWebhooksUseCase };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ListWebhooksUseCase.js.map
|
|
@@ -0,0 +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 { 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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { Webhook } from "../../../api/domain/Webhook.js";
|
|
3
|
+
import type { WebhookModelNotFoundError, WebhookPersistenceError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
4
|
+
import type { DateStringInterfaceGenerator, IdInterfaceGenerator, TextInterfaceGenerator, TruthfulInterfaceGenerator } from "@webiny/api";
|
|
5
|
+
export interface IListWebhooksInputWhere extends IdInterfaceGenerator<"id">, DateStringInterfaceGenerator<"createdOn">, DateStringInterfaceGenerator<"savedOn">, TextInterfaceGenerator<"name">, TextInterfaceGenerator<"slug">, TextInterfaceGenerator<"endpointUrl">, TextInterfaceGenerator<"events">, TruthfulInterfaceGenerator<"enabled"> {
|
|
6
|
+
}
|
|
7
|
+
export interface IListWebhooksInput {
|
|
8
|
+
where?: IListWebhooksInputWhere;
|
|
9
|
+
limit?: number;
|
|
10
|
+
after?: string;
|
|
11
|
+
sort?: (`${string}_ASC` | `${string}_DESC`)[];
|
|
12
|
+
}
|
|
13
|
+
export interface IListMeta {
|
|
14
|
+
cursor: string | null;
|
|
15
|
+
hasMoreItems: boolean;
|
|
16
|
+
totalCount: number;
|
|
17
|
+
}
|
|
18
|
+
type IError = WebhookModelNotFoundError | WebhookPersistenceError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
19
|
+
export interface IListWebhooksOutput {
|
|
20
|
+
items: Webhook[];
|
|
21
|
+
meta: IListMeta;
|
|
22
|
+
}
|
|
23
|
+
export interface IListWebhooksUseCase {
|
|
24
|
+
execute(input?: IListWebhooksInput): Promise<Result<IListWebhooksOutput, IError>>;
|
|
25
|
+
}
|
|
26
|
+
export declare const ListWebhooksUseCase: import("@webiny/di").Abstraction<IListWebhooksUseCase>;
|
|
27
|
+
export declare namespace ListWebhooksUseCase {
|
|
28
|
+
type Interface = IListWebhooksUseCase;
|
|
29
|
+
type Output = IListWebhooksOutput;
|
|
30
|
+
type Error = IError;
|
|
31
|
+
}
|
|
32
|
+
export interface IListWebhooksRepository {
|
|
33
|
+
execute(input?: IListWebhooksInput): Promise<Result<IListWebhooksOutput, IError>>;
|
|
34
|
+
}
|
|
35
|
+
export declare const ListWebhooksRepository: import("@webiny/di").Abstraction<IListWebhooksRepository>;
|
|
36
|
+
export declare namespace ListWebhooksRepository {
|
|
37
|
+
type Interface = IListWebhooksRepository;
|
|
38
|
+
type Output = IListWebhooksOutput;
|
|
39
|
+
type Error = IError;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ListWebhooksUseCase = createAbstraction("Webhooks/ListWebhooksUseCase");
|
|
3
|
+
const ListWebhooksRepository = createAbstraction("Webhooks/ListWebhooksRepository");
|
|
4
|
+
export { ListWebhooksRepository, ListWebhooksUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +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 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,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListWebhooksUseCase } from "./ListWebhooksUseCase.js";
|
|
3
|
+
import { ListWebhooksRepository } from "./ListWebhooksRepository.js";
|
|
4
|
+
const ListWebhooksFeature = createFeature({
|
|
5
|
+
name: "ListWebhooks",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListWebhooksUseCase);
|
|
8
|
+
container.register(ListWebhooksRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { ListWebhooksFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhooks/feature.js","sources":["../../../../src/api/features/ListWebhooks/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListWebhooksUseCase } from \"./ListWebhooksUseCase.js\";\nimport { ListWebhooksRepository } from \"./ListWebhooksRepository.js\";\n\nexport const ListWebhooksFeature = createFeature({\n name: \"ListWebhooks\",\n register(container) {\n container.register(ListWebhooksUseCase);\n container.register(ListWebhooksRepository).inSingletonScope();\n }\n});\n"],"names":["ListWebhooksFeature","createFeature","container","ListWebhooksUseCase","ListWebhooksRepository"],"mappings":";;;AAIO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,wBAAwB,gBAAgB;IAC/D;AACJ"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ResendWebhookDeliveryUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
|
+
import { GetWebhookDeliveryRepository } from "../../../api/features/GetWebhookDelivery/abstractions.js";
|
|
4
|
+
import { GetWebhookRepository } from "../../../api/features/GetWebhook/abstractions.js";
|
|
5
|
+
import { CreateWebhookDeliveryRepository } from "../../../api/features/CreateWebhookDelivery/abstractions.js";
|
|
6
|
+
import { GetWebhookSettingsRepository } from "../../../api/features/GetWebhookSettings/abstractions.js";
|
|
7
|
+
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
8
|
+
import { TaskService } from "@webiny/api-core/exports/api/tasks.js";
|
|
9
|
+
declare class ResendWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
10
|
+
private readonly permissions;
|
|
11
|
+
private readonly getDeliveryRepository;
|
|
12
|
+
private readonly getWebhookRepository;
|
|
13
|
+
private readonly createDeliveryRepository;
|
|
14
|
+
private readonly taskService;
|
|
15
|
+
private readonly getSettingsRepository;
|
|
16
|
+
constructor(permissions: WebhookPermissions.Interface, getDeliveryRepository: GetWebhookDeliveryRepository.Interface, getWebhookRepository: GetWebhookRepository.Interface, createDeliveryRepository: CreateWebhookDeliveryRepository.Interface, taskService: TaskService.Interface, getSettingsRepository: GetWebhookSettingsRepository.Interface);
|
|
17
|
+
execute(deliveryId: string): Promise<Result<boolean, UseCaseAbstraction.Error>>;
|
|
18
|
+
}
|
|
19
|
+
export declare const ResendWebhookDeliveryUseCase: typeof ResendWebhookDeliveryUseCaseImpl & {
|
|
20
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IResendWebhookDeliveryUseCase>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ResendWebhookDeliveryUseCase } from "./abstractions.js";
|
|
3
|
+
import { ResendWebhookDeliveryInputSchema } from "./schema.js";
|
|
4
|
+
import { GetWebhookDeliveryRepository } from "../GetWebhookDelivery/abstractions.js";
|
|
5
|
+
import { GetWebhookRepository } from "../GetWebhook/abstractions.js";
|
|
6
|
+
import { CreateWebhookDeliveryRepository } from "../CreateWebhookDelivery/abstractions.js";
|
|
7
|
+
import { GetWebhookSettingsRepository } from "../GetWebhookSettings/abstractions.js";
|
|
8
|
+
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
9
|
+
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
10
|
+
import { TaskService } from "@webiny/api-core/exports/api/tasks.js";
|
|
11
|
+
import { SEND_WEBHOOK_TASK, WEBHOOK_DELIVERY_MAX_RETENTION_DAYS } from "../../domain/constants.js";
|
|
12
|
+
class ResendWebhookDeliveryUseCaseImpl {
|
|
13
|
+
constructor(permissions, getDeliveryRepository, getWebhookRepository, createDeliveryRepository, taskService, getSettingsRepository){
|
|
14
|
+
this.permissions = permissions;
|
|
15
|
+
this.getDeliveryRepository = getDeliveryRepository;
|
|
16
|
+
this.getWebhookRepository = getWebhookRepository;
|
|
17
|
+
this.createDeliveryRepository = createDeliveryRepository;
|
|
18
|
+
this.taskService = taskService;
|
|
19
|
+
this.getSettingsRepository = getSettingsRepository;
|
|
20
|
+
}
|
|
21
|
+
async execute(deliveryId) {
|
|
22
|
+
if (!await this.permissions.canEdit("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
23
|
+
const parsed = ResendWebhookDeliveryInputSchema.safeParse({
|
|
24
|
+
deliveryId
|
|
25
|
+
});
|
|
26
|
+
if (!parsed.success) return Result.fail(new WebhookValidationError(parsed.error));
|
|
27
|
+
const deliveryResult = await this.getDeliveryRepository.execute(parsed.data.deliveryId);
|
|
28
|
+
if (deliveryResult.isFail()) return Result.fail(deliveryResult.error);
|
|
29
|
+
const delivery = deliveryResult.value;
|
|
30
|
+
const webhookResult = await this.getWebhookRepository.execute(delivery.webhookId);
|
|
31
|
+
if (webhookResult.isFail()) return Result.fail(webhookResult.error);
|
|
32
|
+
const originalPayload = delivery.payload;
|
|
33
|
+
const data = originalPayload?.data ?? {};
|
|
34
|
+
const settingsResult = await this.getSettingsRepository.execute();
|
|
35
|
+
const retentionDays = settingsResult.isOk() ? settingsResult.value.deliveryRetentionDays ?? WEBHOOK_DELIVERY_MAX_RETENTION_DAYS : WEBHOOK_DELIVERY_MAX_RETENTION_DAYS;
|
|
36
|
+
const expiresAt = new Date(Date.now() + 24 * retentionDays * 3600000);
|
|
37
|
+
const newDeliveryResult = await this.createDeliveryRepository.execute({
|
|
38
|
+
webhookId: delivery.webhookId,
|
|
39
|
+
eventType: delivery.eventType,
|
|
40
|
+
status: "pending",
|
|
41
|
+
payload: data,
|
|
42
|
+
expiresAt
|
|
43
|
+
});
|
|
44
|
+
if (newDeliveryResult.isFail()) return Result.fail(newDeliveryResult.error);
|
|
45
|
+
await this.taskService.trigger({
|
|
46
|
+
definition: SEND_WEBHOOK_TASK,
|
|
47
|
+
name: `Resend webhook: ${delivery.eventType}`,
|
|
48
|
+
input: {
|
|
49
|
+
webhookId: delivery.webhookId,
|
|
50
|
+
eventName: delivery.eventType,
|
|
51
|
+
deliveryId: newDeliveryResult.value.id
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return Result.ok(true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const ResendWebhookDeliveryUseCase_ResendWebhookDeliveryUseCase = ResendWebhookDeliveryUseCase.createImplementation({
|
|
58
|
+
implementation: ResendWebhookDeliveryUseCaseImpl,
|
|
59
|
+
dependencies: [
|
|
60
|
+
WebhookPermissions,
|
|
61
|
+
GetWebhookDeliveryRepository,
|
|
62
|
+
GetWebhookRepository,
|
|
63
|
+
CreateWebhookDeliveryRepository,
|
|
64
|
+
TaskService,
|
|
65
|
+
GetWebhookSettingsRepository
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
export { ResendWebhookDeliveryUseCase_ResendWebhookDeliveryUseCase as ResendWebhookDeliveryUseCase };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=ResendWebhookDeliveryUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js","sources":["../../../../src/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ResendWebhookDeliveryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ResendWebhookDeliveryInputSchema } from \"./schema.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { CreateWebhookDeliveryRepository } from \"~/api/features/CreateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport { TaskService } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { SEND_WEBHOOK_TASK, WEBHOOK_DELIVERY_MAX_RETENTION_DAYS } from \"~/api/domain/constants.js\";\nimport type { IWebhookPayload } from \"~/api/features/SendWebhookTask/types.js\";\n\nclass ResendWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly getDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly createDeliveryRepository: CreateWebhookDeliveryRepository.Interface,\n private readonly taskService: TaskService.Interface,\n private readonly getSettingsRepository: GetWebhookSettingsRepository.Interface\n ) {}\n\n async execute(deliveryId: string): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canEdit(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = ResendWebhookDeliveryInputSchema.safeParse({ deliveryId });\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n const deliveryResult = await this.getDeliveryRepository.execute(parsed.data.deliveryId);\n if (deliveryResult.isFail()) {\n return Result.fail(deliveryResult.error);\n }\n\n const delivery = deliveryResult.value;\n\n const webhookResult = await this.getWebhookRepository.execute(delivery.webhookId);\n if (webhookResult.isFail()) {\n return Result.fail(webhookResult.error);\n }\n\n const originalPayload = delivery.payload as IWebhookPayload | null;\n const data = originalPayload?.data ?? {};\n\n const settingsResult = await this.getSettingsRepository.execute();\n const retentionDays = settingsResult.isOk()\n ? (settingsResult.value.deliveryRetentionDays ?? WEBHOOK_DELIVERY_MAX_RETENTION_DAYS)\n : WEBHOOK_DELIVERY_MAX_RETENTION_DAYS;\n\n const expiresAt = new Date(Date.now() + retentionDays * 24 * 60 * 60 * 1000);\n\n const newDeliveryResult = await this.createDeliveryRepository.execute({\n webhookId: delivery.webhookId,\n eventType: delivery.eventType,\n status: \"pending\",\n payload: data as Record<string, unknown>,\n expiresAt\n });\n\n if (newDeliveryResult.isFail()) {\n return Result.fail(newDeliveryResult.error);\n }\n\n await this.taskService.trigger({\n definition: SEND_WEBHOOK_TASK,\n name: `Resend webhook: ${delivery.eventType}`,\n input: {\n webhookId: delivery.webhookId,\n eventName: delivery.eventType,\n deliveryId: newDeliveryResult.value.id\n }\n });\n\n return Result.ok(true);\n }\n}\n\nexport const ResendWebhookDeliveryUseCase = UseCaseAbstraction.createImplementation({\n implementation: ResendWebhookDeliveryUseCaseImpl,\n dependencies: [\n WebhookPermissions,\n GetWebhookDeliveryRepository,\n GetWebhookRepository,\n CreateWebhookDeliveryRepository,\n TaskService,\n GetWebhookSettingsRepository\n ]\n});\n"],"names":["ResendWebhookDeliveryUseCaseImpl","permissions","getDeliveryRepository","getWebhookRepository","createDeliveryRepository","taskService","getSettingsRepository","deliveryId","Result","WebhookNotAuthorizedError","parsed","ResendWebhookDeliveryInputSchema","WebhookValidationError","deliveryResult","delivery","webhookResult","originalPayload","data","settingsResult","retentionDays","WEBHOOK_DELIVERY_MAX_RETENTION_DAYS","expiresAt","Date","newDeliveryResult","SEND_WEBHOOK_TASK","ResendWebhookDeliveryUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookDeliveryRepository","GetWebhookRepository","CreateWebhookDeliveryRepository","TaskService","GetWebhookSettingsRepository"],"mappings":";;;;;;;;;;;AAaA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,qBAA6D,EAC7DC,oBAAoD,EACpDC,wBAAmE,EACnEC,WAAkC,EAClCC,qBAA6D,CAChF;aANmBL,WAAW,GAAXA;aACAC,qBAAqB,GAArBA;aACAC,oBAAoB,GAApBA;aACAC,wBAAwB,GAAxBA;aACAC,WAAW,GAAXA;aACAC,qBAAqB,GAArBA;IAClB;IAEH,MAAM,QAAQC,UAAkB,EAAsD;QAClF,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAASC,iCAAiC,SAAS,CAAC;YAAEJ;QAAW;QACvE,IAAI,CAACG,OAAO,OAAO,EACf,OAAOF,OAAO,IAAI,CAAC,IAAII,uBAAuBF,OAAO,KAAK;QAG9D,MAAMG,iBAAiB,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACH,OAAO,IAAI,CAAC,UAAU;QACtF,IAAIG,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,WAAWD,eAAe,KAAK;QAErC,MAAME,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACD,SAAS,SAAS;QAChF,IAAIC,cAAc,MAAM,IACpB,OAAOP,OAAO,IAAI,CAACO,cAAc,KAAK;QAG1C,MAAMC,kBAAkBF,SAAS,OAAO;QACxC,MAAMG,OAAOD,iBAAiB,QAAQ,CAAC;QAEvC,MAAME,iBAAiB,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO;QAC/D,MAAMC,gBAAgBD,eAAe,IAAI,KAClCA,eAAe,KAAK,CAAC,qBAAqB,IAAIE,sCAC/CA;QAEN,MAAMC,YAAY,IAAIC,KAAKA,KAAK,GAAG,KAAKH,AAAgB,KAAhBA,gBAAAA;QAExC,MAAMI,oBAAoB,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC;YAClE,WAAWT,SAAS,SAAS;YAC7B,WAAWA,SAAS,SAAS;YAC7B,QAAQ;YACR,SAASG;YACTI;QACJ;QAEA,IAAIE,kBAAkB,MAAM,IACxB,OAAOf,OAAO,IAAI,CAACe,kBAAkB,KAAK;QAG9C,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YAC3B,YAAYC;YACZ,MAAM,CAAC,gBAAgB,EAAEV,SAAS,SAAS,EAAE;YAC7C,OAAO;gBACH,WAAWA,SAAS,SAAS;gBAC7B,WAAWA,SAAS,SAAS;gBAC7B,YAAYS,kBAAkB,KAAK,CAAC,EAAE;YAC1C;QACJ;QAEA,OAAOf,OAAO,EAAE,CAAC;IACrB;AACJ;AAEO,MAAMiB,4DAA+BC,6BAAAA,oBAAuC,CAAC;IAChF,gBAAgB1B;IAChB,cAAc;QACV2B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Result } from "@webiny/feature/api";
|
|
2
|
+
import type { WebhookDeliveryNotFoundError, WebhookNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
3
|
+
type IError = WebhookDeliveryNotFoundError | WebhookNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError | WebhookValidationError;
|
|
4
|
+
export interface IResendWebhookDeliveryUseCase {
|
|
5
|
+
execute(deliveryId: string): Promise<Result<boolean, IError>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const ResendWebhookDeliveryUseCase: import("@webiny/di").Abstraction<IResendWebhookDeliveryUseCase>;
|
|
8
|
+
export declare namespace ResendWebhookDeliveryUseCase {
|
|
9
|
+
type Interface = IResendWebhookDeliveryUseCase;
|
|
10
|
+
type Error = IError;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/abstractions.js","sources":["../../../../src/api/features/ResendWebhookDelivery/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type {\n WebhookDeliveryNotFoundError,\n WebhookNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookDeliveryNotFoundError\n | WebhookNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IResendWebhookDeliveryUseCase {\n execute(deliveryId: string): Promise<Result<boolean, IError>>;\n}\n\nexport const ResendWebhookDeliveryUseCase = createAbstraction<IResendWebhookDeliveryUseCase>(\n \"Webhooks/ResendWebhookDeliveryUseCase\"\n);\n\nexport namespace ResendWebhookDeliveryUseCase {\n export type Interface = IResendWebhookDeliveryUseCase;\n export type Error = IError;\n}\n"],"names":["ResendWebhookDeliveryUseCase","createAbstraction"],"mappings":";AAsBO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ResendWebhookDeliveryUseCase } from "./ResendWebhookDeliveryUseCase.js";
|
|
3
|
+
const ResendWebhookDeliveryFeature = createFeature({
|
|
4
|
+
name: "ResendWebhookDelivery",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ResendWebhookDeliveryUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ResendWebhookDeliveryFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/feature.js","sources":["../../../../src/api/features/ResendWebhookDelivery/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ResendWebhookDeliveryUseCase } from \"./ResendWebhookDeliveryUseCase.js\";\n\nexport const ResendWebhookDeliveryFeature = createFeature({\n name: \"ResendWebhookDelivery\",\n register(container) {\n container.register(ResendWebhookDeliveryUseCase);\n }\n});\n"],"names":["ResendWebhookDeliveryFeature","createFeature","container","ResendWebhookDeliveryUseCase"],"mappings":";;AAGO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/schema.js","sources":["../../../../src/api/features/ResendWebhookDelivery/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ResendWebhookDeliveryInputSchema = z.object({\n deliveryId: z.string().min(1, \"Delivery ID is required.\")\n});\n"],"names":["ResendWebhookDeliveryInputSchema","z"],"mappings":";AAEO,MAAMA,mCAAmCC,EAAE,MAAM,CAAC;IACrD,YAAYA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;AAClC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "@webiny/tasks/types.js";
|
|
2
|
+
import { TaskDefinition } from "@webiny/api-core/exports/api/tasks.js";
|
|
3
|
+
import { TenantContext } from "@webiny/api-core/exports/api/tenancy.js";
|
|
4
|
+
import { WebhookSignPayload } from "@webiny/api-core/features/webhooks/index.js";
|
|
5
|
+
import { GetWebhookRepository } from "../../../api/features/GetWebhook/abstractions.js";
|
|
6
|
+
import { GetWebhookDeliveryRepository } from "../../../api/features/GetWebhookDelivery/abstractions.js";
|
|
7
|
+
import { UpdateWebhookDeliveryRepository } from "../../../api/features/UpdateWebhookDelivery/abstractions.js";
|
|
8
|
+
import { GetWebhookSettingsRepository } from "../../../api/features/GetWebhookSettings/abstractions.js";
|
|
9
|
+
import { WebhookDeliver } from "../../../api/features/WebhookDeliver/abstractions.js";
|
|
10
|
+
import type { ISendWebhookTaskInput, ISendWebhookTaskOutput } from "./types.js";
|
|
11
|
+
type IRunParams = TaskDefinition.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;
|
|
12
|
+
declare class SendWebhookTaskDefinition implements TaskDefinition.Interface<ISendWebhookTaskInput, ISendWebhookTaskOutput> {
|
|
13
|
+
private readonly getWebhookRepository;
|
|
14
|
+
private readonly getWebhookDeliveryRepository;
|
|
15
|
+
private readonly updateDeliveryRepository;
|
|
16
|
+
private readonly signPayload;
|
|
17
|
+
private readonly tenantContext;
|
|
18
|
+
private readonly getWebhookSettingsRepository;
|
|
19
|
+
private readonly deliver;
|
|
20
|
+
readonly id = "sendWebhook";
|
|
21
|
+
readonly title = "Send Webhook";
|
|
22
|
+
readonly maxIterations = 1;
|
|
23
|
+
readonly isPrivate = true;
|
|
24
|
+
readonly databaseLogs = false;
|
|
25
|
+
readonly description = "POST a signed event payload to a webhook endpoint and log the delivery.";
|
|
26
|
+
readonly selfCleanup = "always";
|
|
27
|
+
constructor(getWebhookRepository: GetWebhookRepository.Interface, getWebhookDeliveryRepository: GetWebhookDeliveryRepository.Interface, updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface, signPayload: WebhookSignPayload.Interface, tenantContext: TenantContext.Interface, getWebhookSettingsRepository: GetWebhookSettingsRepository.Interface, deliver: WebhookDeliver.Interface);
|
|
28
|
+
run(params: IRunParams): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultError | TaskDefinition.ResultDone<ISendWebhookTaskOutput>>;
|
|
29
|
+
}
|
|
30
|
+
export declare const SendWebhookTask: typeof SendWebhookTaskDefinition & {
|
|
31
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskOutput>>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "@webiny/tasks/types.js";
|
|
2
|
+
import { TaskDefinition } from "@webiny/api-core/exports/api/tasks.js";
|
|
3
|
+
import { TenantContext } from "@webiny/api-core/exports/api/tenancy.js";
|
|
4
|
+
import { WebhookSignPayload } from "@webiny/api-core/features/webhooks/index.js";
|
|
5
|
+
import { GetWebhookRepository } from "../GetWebhook/abstractions.js";
|
|
6
|
+
import { GetWebhookDeliveryRepository } from "../GetWebhookDelivery/abstractions.js";
|
|
7
|
+
import { UpdateWebhookDeliveryRepository } from "../UpdateWebhookDelivery/abstractions.js";
|
|
8
|
+
import { GetWebhookSettingsRepository } from "../GetWebhookSettings/abstractions.js";
|
|
9
|
+
import { WebhookDeliver } from "../WebhookDeliver/abstractions.js";
|
|
10
|
+
import { SEND_WEBHOOK_TASK } from "../../domain/constants.js";
|
|
11
|
+
class SendWebhookTaskDefinition {
|
|
12
|
+
constructor(getWebhookRepository, getWebhookDeliveryRepository, updateDeliveryRepository, signPayload, tenantContext, getWebhookSettingsRepository, deliver){
|
|
13
|
+
this.getWebhookRepository = getWebhookRepository;
|
|
14
|
+
this.getWebhookDeliveryRepository = getWebhookDeliveryRepository;
|
|
15
|
+
this.updateDeliveryRepository = updateDeliveryRepository;
|
|
16
|
+
this.signPayload = signPayload;
|
|
17
|
+
this.tenantContext = tenantContext;
|
|
18
|
+
this.getWebhookSettingsRepository = getWebhookSettingsRepository;
|
|
19
|
+
this.deliver = deliver;
|
|
20
|
+
this.id = SEND_WEBHOOK_TASK;
|
|
21
|
+
this.title = "Send Webhook";
|
|
22
|
+
this.maxIterations = 1;
|
|
23
|
+
this.isPrivate = true;
|
|
24
|
+
this.databaseLogs = false;
|
|
25
|
+
this.description = "POST a signed event payload to a webhook endpoint and log the delivery.";
|
|
26
|
+
this.selfCleanup = "always";
|
|
27
|
+
}
|
|
28
|
+
async run(params) {
|
|
29
|
+
const { input, controller } = params;
|
|
30
|
+
const taskId = controller.state.getTask().id;
|
|
31
|
+
const delivery = await this.getWebhookDeliveryRepository.execute(input.deliveryId);
|
|
32
|
+
if (delivery.isFail()) return controller.response.error(delivery.error);
|
|
33
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
34
|
+
backgroundTaskId: taskId,
|
|
35
|
+
status: "delivering"
|
|
36
|
+
});
|
|
37
|
+
const webhookResult = await this.getWebhookRepository.execute(input.webhookId);
|
|
38
|
+
if (webhookResult.isFail()) {
|
|
39
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
40
|
+
status: "failed"
|
|
41
|
+
});
|
|
42
|
+
return controller.response.error(webhookResult.error);
|
|
43
|
+
}
|
|
44
|
+
const webhook = webhookResult.value;
|
|
45
|
+
const now = new Date();
|
|
46
|
+
const payload = {
|
|
47
|
+
id: taskId,
|
|
48
|
+
event: input.eventName,
|
|
49
|
+
timestamp: now.toISOString(),
|
|
50
|
+
webhookId: input.webhookId,
|
|
51
|
+
deliveryId: input.deliveryId,
|
|
52
|
+
tenant: this.tenantContext.getTenant().id,
|
|
53
|
+
data: delivery.value.payload
|
|
54
|
+
};
|
|
55
|
+
const rawBody = JSON.stringify(payload);
|
|
56
|
+
let signHeaders;
|
|
57
|
+
const settingsResult = await this.getWebhookSettingsRepository.execute();
|
|
58
|
+
if (settingsResult.isFail()) {
|
|
59
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
60
|
+
status: "failed"
|
|
61
|
+
});
|
|
62
|
+
return controller.response.error(settingsResult.error);
|
|
63
|
+
}
|
|
64
|
+
const signingSecret = webhook.signingSecret || settingsResult.value.signingSecret || "";
|
|
65
|
+
try {
|
|
66
|
+
signHeaders = await this.signPayload.sign(taskId, now, rawBody, signingSecret);
|
|
67
|
+
} catch (ex) {
|
|
68
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
69
|
+
status: "failed"
|
|
70
|
+
});
|
|
71
|
+
return controller.response.error(ex);
|
|
72
|
+
}
|
|
73
|
+
const requestHeaders = {
|
|
74
|
+
"Content-Type": "application/json",
|
|
75
|
+
...signHeaders
|
|
76
|
+
};
|
|
77
|
+
const result = await this.deliver.execute({
|
|
78
|
+
url: webhook.endpointUrl,
|
|
79
|
+
headers: requestHeaders,
|
|
80
|
+
body: rawBody,
|
|
81
|
+
timeout: 600000,
|
|
82
|
+
maxRetries: 3,
|
|
83
|
+
initialDelay: 1000,
|
|
84
|
+
maxDelay: 30000
|
|
85
|
+
});
|
|
86
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
87
|
+
payload,
|
|
88
|
+
requestHeaders,
|
|
89
|
+
responseTime: result.responseTime,
|
|
90
|
+
responseStatus: result.status,
|
|
91
|
+
responseBody: result.body,
|
|
92
|
+
status: result.status > 0 ? "delivered" : "failed"
|
|
93
|
+
});
|
|
94
|
+
return controller.response.done();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const SendWebhookTask = TaskDefinition.createImplementation({
|
|
98
|
+
implementation: SendWebhookTaskDefinition,
|
|
99
|
+
dependencies: [
|
|
100
|
+
GetWebhookRepository,
|
|
101
|
+
GetWebhookDeliveryRepository,
|
|
102
|
+
UpdateWebhookDeliveryRepository,
|
|
103
|
+
WebhookSignPayload,
|
|
104
|
+
TenantContext,
|
|
105
|
+
GetWebhookSettingsRepository,
|
|
106
|
+
WebhookDeliver
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
export { SendWebhookTask };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=SendWebhookTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/SendWebhookTask/SendWebhookTask.js","sources":["../../../../src/api/features/SendWebhookTask/SendWebhookTask.ts"],"sourcesContent":["import \"@webiny/tasks/types.js\";\nimport { TaskDefinition } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { TenantContext } from \"@webiny/api-core/exports/api/tenancy.js\";\nimport { WebhookSignPayload } from \"@webiny/api-core/features/webhooks/index.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { UpdateWebhookDeliveryRepository } from \"~/api/features/UpdateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookDeliver } from \"~/api/features/WebhookDeliver/abstractions.js\";\nimport { SEND_WEBHOOK_TASK } from \"~/api/domain/constants.js\";\nimport type { ISendWebhookTaskInput, ISendWebhookTaskOutput, IWebhookPayload } from \"./types.js\";\nimport type { IWebhookSignPayloadHeaders } from \"@webiny/api-core/features/webhooks/WebhookSignPayload/abstractions.js\";\n\ntype IRunParams = TaskDefinition.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;\n\nclass SendWebhookTaskDefinition implements TaskDefinition.Interface<\n ISendWebhookTaskInput,\n ISendWebhookTaskOutput\n> {\n public readonly id = SEND_WEBHOOK_TASK;\n public readonly title = \"Send Webhook\";\n public readonly maxIterations = 1;\n public readonly isPrivate = true;\n public readonly databaseLogs = false;\n public readonly description =\n \"POST a signed event payload to a webhook endpoint and log the delivery.\";\n public readonly selfCleanup = \"always\";\n\n public constructor(\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly getWebhookDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface,\n private readonly signPayload: WebhookSignPayload.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly getWebhookSettingsRepository: GetWebhookSettingsRepository.Interface,\n private readonly deliver: WebhookDeliver.Interface\n ) {}\n\n public async run(params: IRunParams) {\n const { input, controller } = params;\n const taskId = controller.state.getTask().id;\n\n const delivery = await this.getWebhookDeliveryRepository.execute(input.deliveryId);\n if (delivery.isFail()) {\n return controller.response.error(delivery.error);\n }\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n backgroundTaskId: taskId,\n status: \"delivering\"\n });\n\n const webhookResult = await this.getWebhookRepository.execute(input.webhookId);\n if (webhookResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(webhookResult.error);\n }\n const webhook = webhookResult.value;\n\n const now = new Date();\n const payload: IWebhookPayload = {\n id: taskId,\n event: input.eventName,\n timestamp: now.toISOString(),\n webhookId: input.webhookId,\n deliveryId: input.deliveryId,\n tenant: this.tenantContext.getTenant().id,\n data: delivery.value.payload\n };\n const rawBody = JSON.stringify(payload);\n let signHeaders: IWebhookSignPayloadHeaders;\n\n const settingsResult = await this.getWebhookSettingsRepository.execute();\n if (settingsResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(settingsResult.error);\n }\n const signingSecret = webhook.signingSecret || settingsResult.value.signingSecret || \"\";\n\n try {\n signHeaders = await this.signPayload.sign(taskId, now, rawBody, signingSecret);\n } catch (ex) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(ex);\n }\n\n const requestHeaders: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...signHeaders\n };\n\n const result = await this.deliver.execute({\n url: webhook.endpointUrl,\n headers: requestHeaders,\n body: rawBody,\n timeout: 600_000,\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30_000\n });\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n payload,\n requestHeaders,\n responseTime: result.responseTime,\n responseStatus: result.status,\n responseBody: result.body,\n status: result.status > 0 ? \"delivered\" : \"failed\"\n });\n\n return controller.response.done();\n }\n}\n\nexport const SendWebhookTask = TaskDefinition.createImplementation({\n implementation: SendWebhookTaskDefinition,\n dependencies: [\n GetWebhookRepository,\n GetWebhookDeliveryRepository,\n UpdateWebhookDeliveryRepository,\n WebhookSignPayload,\n TenantContext,\n GetWebhookSettingsRepository,\n WebhookDeliver\n ]\n});\n"],"names":["SendWebhookTaskDefinition","getWebhookRepository","getWebhookDeliveryRepository","updateDeliveryRepository","signPayload","tenantContext","getWebhookSettingsRepository","deliver","SEND_WEBHOOK_TASK","params","input","controller","taskId","delivery","webhookResult","webhook","now","Date","payload","rawBody","JSON","signHeaders","settingsResult","signingSecret","ex","requestHeaders","result","SendWebhookTask","TaskDefinition","GetWebhookRepository","GetWebhookDeliveryRepository","UpdateWebhookDeliveryRepository","WebhookSignPayload","TenantContext","GetWebhookSettingsRepository","WebhookDeliver"],"mappings":";;;;;;;;;;AAeA,MAAMA;IAaF,YACqBC,oBAAoD,EACpDC,4BAAoE,EACpEC,wBAAmE,EACnEC,WAAyC,EACzCC,aAAsC,EACtCC,4BAAoE,EACpEC,OAAiC,CACpD;aAPmBN,oBAAoB,GAApBA;aACAC,4BAA4B,GAA5BA;aACAC,wBAAwB,GAAxBA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,4BAA4B,GAA5BA;aACAC,OAAO,GAAPA;aAhBL,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,aAAa,GAAG;aAChB,SAAS,GAAG;aACZ,YAAY,GAAG;aACf,WAAW,GACvB;aACY,WAAW,GAAG;IAU3B;IAEH,MAAa,IAAIC,MAAkB,EAAE;QACjC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;QAC9B,MAAMG,SAASD,WAAW,KAAK,CAAC,OAAO,GAAG,EAAE;QAE5C,MAAME,WAAW,MAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAACH,MAAM,UAAU;QACjF,IAAIG,SAAS,MAAM,IACf,OAAOF,WAAW,QAAQ,CAAC,KAAK,CAACE,SAAS,KAAK;QAGnD,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACH,MAAM,UAAU,EAAE;YAC1D,kBAAkBE;YAClB,QAAQ;QACZ;QAEA,MAAME,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACJ,MAAM,SAAS;QAC7E,IAAII,cAAc,MAAM,IAAI;YACxB,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACJ,MAAM,UAAU,EAAE;gBAAE,QAAQ;YAAS;YACjF,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAACG,cAAc,KAAK;QACxD;QACA,MAAMC,UAAUD,cAAc,KAAK;QAEnC,MAAME,MAAM,IAAIC;QAChB,MAAMC,UAA2B;YAC7B,IAAIN;YACJ,OAAOF,MAAM,SAAS;YACtB,WAAWM,IAAI,WAAW;YAC1B,WAAWN,MAAM,SAAS;YAC1B,YAAYA,MAAM,UAAU;YAC5B,QAAQ,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,EAAE;YACzC,MAAMG,SAAS,KAAK,CAAC,OAAO;QAChC;QACA,MAAMM,UAAUC,KAAK,SAAS,CAACF;QAC/B,IAAIG;QAEJ,MAAMC,iBAAiB,MAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO;QACtE,IAAIA,eAAe,MAAM,IAAI;YACzB,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACZ,MAAM,UAAU,EAAE;gBAAE,QAAQ;YAAS;YACjF,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAACW,eAAe,KAAK;QACzD;QACA,MAAMC,gBAAgBR,QAAQ,aAAa,IAAIO,eAAe,KAAK,CAAC,aAAa,IAAI;QAErF,IAAI;YACAD,cAAc,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAACT,QAAQI,KAAKG,SAASI;QACpE,EAAE,OAAOC,IAAI;YACT,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACd,MAAM,UAAU,EAAE;gBAAE,QAAQ;YAAS;YACjF,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAACa;QACrC;QAEA,MAAMC,iBAAyC;YAC3C,gBAAgB;YAChB,GAAGJ,WAAW;QAClB;QAEA,MAAMK,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACtC,KAAKX,QAAQ,WAAW;YACxB,SAASU;YACT,MAAMN;YACN,SAAS;YACT,YAAY;YACZ,cAAc;YACd,UAAU;QACd;QAEA,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACT,MAAM,UAAU,EAAE;YAC1DQ;YACAO;YACA,cAAcC,OAAO,YAAY;YACjC,gBAAgBA,OAAO,MAAM;YAC7B,cAAcA,OAAO,IAAI;YACzB,QAAQA,OAAO,MAAM,GAAG,IAAI,cAAc;QAC9C;QAEA,OAAOf,WAAW,QAAQ,CAAC,IAAI;IACnC;AACJ;AAEO,MAAMgB,kBAAkBC,eAAe,oBAAoB,CAAC;IAC/D,gBAAgB5B;IAChB,cAAc;QACV6B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { SendWebhookTask } from "./SendWebhookTask.js";
|
|
3
|
+
const SendWebhookTaskFeature = createFeature({
|
|
4
|
+
name: "SendWebhookTask",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SendWebhookTask);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SendWebhookTaskFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/SendWebhookTask/feature.js","sources":["../../../../src/api/features/SendWebhookTask/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SendWebhookTask } from \"./SendWebhookTask.js\";\n\nexport const SendWebhookTaskFeature = createFeature({\n name: \"SendWebhookTask\",\n register(container) {\n container.register(SendWebhookTask);\n }\n});\n"],"names":["SendWebhookTaskFeature","createFeature","container","SendWebhookTask"],"mappings":";;AAGO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ISendWebhookTaskInput {
|
|
2
|
+
webhookId: string;
|
|
3
|
+
eventName: string;
|
|
4
|
+
deliveryId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ISendWebhookTaskOutput {
|
|
7
|
+
}
|
|
8
|
+
export interface IWebhookPayload {
|
|
9
|
+
id: string;
|
|
10
|
+
event: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
webhookId: string;
|
|
13
|
+
deliveryId: string;
|
|
14
|
+
tenant: string;
|
|
15
|
+
data: unknown;
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WebhookDeliveryTransformer as WebhookDeliveryTransformerAbstraction } from "./abstractions/WebhookDeliveryTransformer.js";
|
|
2
|
+
import type { CmsEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { WebhookDelivery, WebhookDeliveryCmsEntryValues } from "../../../api/domain/WebhookDelivery.js";
|
|
4
|
+
declare class WebhookDeliveryTransformerImpl implements WebhookDeliveryTransformerAbstraction.Interface {
|
|
5
|
+
fromStorage(entry: CmsEntry<WebhookDeliveryCmsEntryValues>): WebhookDelivery;
|
|
6
|
+
toStorage(delivery: WebhookDelivery): WebhookDeliveryCmsEntryValues;
|
|
7
|
+
private compress;
|
|
8
|
+
private decompress;
|
|
9
|
+
}
|
|
10
|
+
export declare const WebhookDeliveryTransformer: typeof WebhookDeliveryTransformerImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/WebhookDeliveryTransformer.js").IWebhookDeliveryTransformer>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WebhookDeliveryTransformer } from "./abstractions/WebhookDeliveryTransformer.js";
|
|
2
|
+
class WebhookDeliveryTransformerImpl {
|
|
3
|
+
fromStorage(entry) {
|
|
4
|
+
return {
|
|
5
|
+
id: entry.entryId,
|
|
6
|
+
createdOn: entry.createdOn,
|
|
7
|
+
savedOn: entry.savedOn,
|
|
8
|
+
webhookId: entry.values.webhookId,
|
|
9
|
+
backgroundTaskId: entry.values.backgroundTaskId,
|
|
10
|
+
eventType: entry.values.eventType,
|
|
11
|
+
status: entry.values.status,
|
|
12
|
+
payload: this.decompress(entry.values.payload),
|
|
13
|
+
requestHeaders: this.decompress(entry.values.requestHeaders),
|
|
14
|
+
responseTime: entry.values.responseTime,
|
|
15
|
+
responseStatus: entry.values.responseStatus,
|
|
16
|
+
responseHeaders: this.decompress(entry.values.responseHeaders),
|
|
17
|
+
responseBody: this.decompress(entry.values.responseBody)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
toStorage(delivery) {
|
|
21
|
+
return {
|
|
22
|
+
webhookId: delivery.webhookId,
|
|
23
|
+
backgroundTaskId: delivery.backgroundTaskId,
|
|
24
|
+
eventType: delivery.eventType,
|
|
25
|
+
status: delivery.status,
|
|
26
|
+
payload: this.compress(delivery.payload),
|
|
27
|
+
requestHeaders: this.compress(delivery.requestHeaders),
|
|
28
|
+
responseTime: delivery.responseTime,
|
|
29
|
+
responseStatus: delivery.responseStatus,
|
|
30
|
+
responseHeaders: this.compress(delivery.responseHeaders),
|
|
31
|
+
responseBody: this.compress(delivery.responseBody)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
compress(value) {
|
|
35
|
+
if (null == value) return null;
|
|
36
|
+
try {
|
|
37
|
+
return JSON.stringify(value);
|
|
38
|
+
} catch {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
decompress(stored) {
|
|
43
|
+
if (!stored) return null;
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(stored);
|
|
46
|
+
} catch {
|
|
47
|
+
return stored;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const WebhookDeliveryTransformer_WebhookDeliveryTransformer = WebhookDeliveryTransformer.createImplementation({
|
|
52
|
+
implementation: WebhookDeliveryTransformerImpl,
|
|
53
|
+
dependencies: []
|
|
54
|
+
});
|
|
55
|
+
export { WebhookDeliveryTransformer_WebhookDeliveryTransformer as WebhookDeliveryTransformer };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=WebhookDeliveryTransformer.js.map
|