@webiny/webhooks 0.0.0-unstable.b6d7105cee → 0.0.0-unstable.eb81deee7e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/admin/WebhookRoutes.js +20 -4
  2. package/admin/WebhookRoutes.js.map +1 -1
  3. package/admin/features/permissions/feature.d.ts +1 -1
  4. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.d.ts +2 -2
  5. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.d.ts +2 -2
  6. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js +37 -24
  7. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js.map +1 -1
  8. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.d.ts +2 -2
  9. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +3 -3
  10. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -1
  11. package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +2 -2
  12. package/admin/presentation/WebhookList/components/WebhookListContent.d.ts +2 -2
  13. package/api/features/SendWebhookTask/SendWebhookTask.d.ts +10 -5
  14. package/api/features/SendWebhookTask/SendWebhookTask.js +20 -11
  15. package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
  16. package/api/features/UpdateWebhook/UpdateWebhookRepository.js +3 -1
  17. package/api/features/UpdateWebhook/UpdateWebhookRepository.js.map +1 -1
  18. package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js +3 -1
  19. package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js.map +1 -1
  20. package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +3 -1
  21. package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js.map +1 -1
  22. package/api/graphql/WebhookCrudSchema.d.ts +3 -2
  23. package/api/graphql/WebhookCrudSchema.js +6 -2
  24. package/api/graphql/WebhookCrudSchema.js.map +1 -1
  25. package/api/graphql/WebhookDeliverySchema.d.ts +3 -2
  26. package/api/graphql/WebhookDeliverySchema.js +6 -2
  27. package/api/graphql/WebhookDeliverySchema.js.map +1 -1
  28. package/api/graphql/WebhookEventSchema.d.ts +3 -2
  29. package/api/graphql/WebhookEventSchema.js +6 -2
  30. package/api/graphql/WebhookEventSchema.js.map +1 -1
  31. package/api/graphql/WebhookSettingsSchema.d.ts +3 -2
  32. package/api/graphql/WebhookSettingsSchema.js +6 -2
  33. package/api/graphql/WebhookSettingsSchema.js.map +1 -1
  34. package/api/graphql/WebhookTriggerSchema.d.ts +3 -2
  35. package/api/graphql/WebhookTriggerSchema.js +6 -2
  36. package/api/graphql/WebhookTriggerSchema.js.map +1 -1
  37. package/api/index.d.ts +3 -0
  38. package/api/index.js +1 -1
  39. package/api/index.js.map +1 -1
  40. package/api/models/WebhookDeliveryModel.js +2 -1
  41. package/api/models/WebhookDeliveryModel.js.map +1 -1
  42. package/api/models/WebhookModel.js +2 -1
  43. package/api/models/WebhookModel.js.map +1 -1
  44. package/api/models/WebhookSettingsModel.js +2 -1
  45. package/api/models/WebhookSettingsModel.js.map +1 -1
  46. package/package.json +23 -22
@@ -11,6 +11,13 @@ const { Menu: Menu, Route: Route } = AdminConfig;
11
11
  const beta = /*#__PURE__*/ react.createElement(Menu.Link.Badge, {
12
12
  text: "BETA"
13
13
  });
14
+ const WebhooksBreadcrumbsRoot = ()=>/*#__PURE__*/ react.createElement(AdminConfig.Breadcrumb, {
15
+ name: "webhooks",
16
+ label: "Webhooks",
17
+ to: {
18
+ route: Routes.List
19
+ }
20
+ });
14
21
  const WebhookRoutes = ()=>{
15
22
  const { getLink } = useRouter();
16
23
  return /*#__PURE__*/ react.createElement(AdminConfig, null, /*#__PURE__*/ react.createElement(HasPermission, {
@@ -19,22 +26,31 @@ const WebhookRoutes = ()=>{
19
26
  route: Routes.List,
20
27
  element: /*#__PURE__*/ react.createElement(AdminLayout, {
21
28
  title: "Webhooks"
22
- }, /*#__PURE__*/ react.createElement(WebhookListView, null))
29
+ }, /*#__PURE__*/ react.createElement(WebhooksBreadcrumbsRoot, null), /*#__PURE__*/ react.createElement(WebhookListView, null))
23
30
  }), /*#__PURE__*/ react.createElement(Route, {
24
31
  route: Routes.Deliveries,
25
32
  element: /*#__PURE__*/ react.createElement(AdminLayout, {
26
33
  title: "Delivery Log"
27
- }, /*#__PURE__*/ react.createElement(WebhookDeliveriesPage, null))
34
+ }, /*#__PURE__*/ react.createElement(WebhooksBreadcrumbsRoot, null), /*#__PURE__*/ react.createElement(AdminConfig.Breadcrumb, {
35
+ name: "webhooks.deliveries",
36
+ label: "Delivery Log"
37
+ }), /*#__PURE__*/ react.createElement(WebhookDeliveriesPage, null))
28
38
  }), /*#__PURE__*/ react.createElement(Route, {
29
39
  route: Routes.Settings,
30
40
  element: /*#__PURE__*/ react.createElement(AdminLayout, {
31
41
  title: "Webhook Settings"
32
- }, /*#__PURE__*/ react.createElement(WebhookSettingsView, null))
42
+ }, /*#__PURE__*/ react.createElement(WebhooksBreadcrumbsRoot, null), /*#__PURE__*/ react.createElement(AdminConfig.Breadcrumb, {
43
+ name: "webhooks.settings",
44
+ label: "Settings"
45
+ }), /*#__PURE__*/ react.createElement(WebhookSettingsView, null))
33
46
  }), /*#__PURE__*/ react.createElement(Route, {
34
47
  route: Routes.Form,
35
48
  element: /*#__PURE__*/ react.createElement(AdminLayout, {
36
49
  title: "Webhooks"
37
- }, /*#__PURE__*/ react.createElement(WebhookFormView, null))
50
+ }, /*#__PURE__*/ react.createElement(WebhooksBreadcrumbsRoot, null), /*#__PURE__*/ react.createElement(AdminConfig.Breadcrumb, {
51
+ name: "webhooks.form",
52
+ label: "Webhook"
53
+ }), /*#__PURE__*/ react.createElement(WebhookFormView, null))
38
54
  }), /*#__PURE__*/ react.createElement(Menu, {
39
55
  name: "webhooks.deliveries",
40
56
  parent: "dev-tools",
@@ -1 +1 @@
1
- {"version":3,"file":"admin/WebhookRoutes.js","sources":["../../src/admin/WebhookRoutes.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { AdminLayout } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookDeliveryIcon } from \"@webiny/icons/webhook.svg\";\nimport { HasPermission } from \"./presentation/security/HasPermission.js\";\nimport { WebhookListView } from \"./presentation/WebhookList/components/WebhookListView.js\";\nimport { WebhookFormView } from \"./presentation/WebhookForm/components/WebhookFormView.js\";\nimport { WebhookSettingsView } from \"./presentation/WebhookSettings/components/WebhookSettingsView.js\";\nimport { WebhookDeliveriesPage } from \"./presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst beta = <Menu.Link.Badge text=\"BETA\" />;\n\nexport const WebhookRoutes = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <HasPermission entity=\"webhook\">\n <Route\n route={Routes.List}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhookListView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Deliveries}\n element={\n <AdminLayout title=\"Delivery Log\">\n <WebhookDeliveriesPage />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title=\"Webhook Settings\">\n <WebhookSettingsView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Form}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhookFormView />\n </AdminLayout>\n }\n />\n <Menu\n name=\"webhooks.deliveries\"\n parent=\"dev-tools\"\n element={\n <Menu.Link\n text=\"Webhooks\"\n badge={beta}\n to={getLink(Routes.Deliveries)}\n icon={\n <Menu.Link.Icon\n label=\"Webhooks\"\n element={<WebhookDeliveryIcon />}\n />\n }\n />\n }\n />\n <Menu\n name=\"webhooks.settings\"\n parent=\"settings.system\"\n element={\n <Menu.Link badge={beta} text=\"Webhooks\" to={getLink(Routes.Settings)} />\n }\n />\n </HasPermission>\n </AdminConfig>\n );\n};\n"],"names":["Menu","Route","AdminConfig","beta","WebhookRoutes","getLink","useRouter","HasPermission","Routes","AdminLayout","WebhookListView","WebhookDeliveriesPage","WebhookSettingsView","WebhookFormView","WebhookDeliveryIcon"],"mappings":";;;;;;;;;AAYA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAExB,MAAMC,OAAO,WAAHA,GAAG,oBAACH,KAAK,IAAI,CAAC,KAAK;IAAC,MAAK;;AAE5B,MAAMI,gBAAgB;IACzB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,OAAO,WAAP,GACI,oBAACJ,aAAWA,MAAAA,WAAAA,GACR,oBAACK,eAAaA;QAAC,QAAO;qBAClB,oBAACN,OAAKA;QACF,OAAOO,OAAO,IAAI;QAClB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACC,iBAAeA;sBAI5B,oBAACT,OAAKA;QACF,OAAOO,OAAO,UAAU;QACxB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACE,uBAAqBA;sBAIlC,oBAACV,OAAKA;QACF,OAAOO,OAAO,QAAQ;QACtB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACG,qBAAmBA;sBAIhC,oBAACX,OAAKA;QACF,OAAOO,OAAO,IAAI;QAClB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACI,iBAAeA;sBAI5B,oBAACb,MAAIA;QACD,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YACN,MAAK;YACL,OAAOG;YACP,IAAIE,QAAQG,OAAO,UAAU;YAC7B,oBACI,oBAACR,KAAK,IAAI,CAAC,IAAI;gBACX,OAAM;gBACN,uBAAS,oBAACc,gBAAmBA;;;sBAMjD,oBAACd,MAAIA;QACD,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YAAC,OAAOG;YAAM,MAAK;YAAW,IAAIE,QAAQG,OAAO,QAAQ;;;AAM3F"}
1
+ {"version":3,"file":"admin/WebhookRoutes.js","sources":["../../src/admin/WebhookRoutes.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { AdminLayout } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookDeliveryIcon } from \"@webiny/icons/webhook.svg\";\nimport { HasPermission } from \"./presentation/security/HasPermission.js\";\nimport { WebhookListView } from \"./presentation/WebhookList/components/WebhookListView.js\";\nimport { WebhookFormView } from \"./presentation/WebhookForm/components/WebhookFormView.js\";\nimport { WebhookSettingsView } from \"./presentation/WebhookSettings/components/WebhookSettingsView.js\";\nimport { WebhookDeliveriesPage } from \"./presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst beta = <Menu.Link.Badge text=\"BETA\" />;\n\n// Shared leading breadcrumb for all webhook routes.\nconst WebhooksBreadcrumbsRoot = () => (\n <AdminConfig.Breadcrumb name=\"webhooks\" label=\"Webhooks\" to={{ route: Routes.List }} />\n);\n\nexport const WebhookRoutes = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <HasPermission entity=\"webhook\">\n <Route\n route={Routes.List}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhooksBreadcrumbsRoot />\n <WebhookListView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Deliveries}\n element={\n <AdminLayout title=\"Delivery Log\">\n <WebhooksBreadcrumbsRoot />\n <AdminConfig.Breadcrumb\n name=\"webhooks.deliveries\"\n label=\"Delivery Log\"\n />\n <WebhookDeliveriesPage />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title=\"Webhook Settings\">\n <WebhooksBreadcrumbsRoot />\n <AdminConfig.Breadcrumb name=\"webhooks.settings\" label=\"Settings\" />\n <WebhookSettingsView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Form}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhooksBreadcrumbsRoot />\n <AdminConfig.Breadcrumb name=\"webhooks.form\" label=\"Webhook\" />\n <WebhookFormView />\n </AdminLayout>\n }\n />\n <Menu\n name=\"webhooks.deliveries\"\n parent=\"dev-tools\"\n element={\n <Menu.Link\n text=\"Webhooks\"\n badge={beta}\n to={getLink(Routes.Deliveries)}\n icon={\n <Menu.Link.Icon\n label=\"Webhooks\"\n element={<WebhookDeliveryIcon />}\n />\n }\n />\n }\n />\n <Menu\n name=\"webhooks.settings\"\n parent=\"settings.system\"\n element={\n <Menu.Link badge={beta} text=\"Webhooks\" to={getLink(Routes.Settings)} />\n }\n />\n </HasPermission>\n </AdminConfig>\n );\n};\n"],"names":["Menu","Route","AdminConfig","beta","WebhooksBreadcrumbsRoot","Routes","WebhookRoutes","getLink","useRouter","HasPermission","AdminLayout","WebhookListView","WebhookDeliveriesPage","WebhookSettingsView","WebhookFormView","WebhookDeliveryIcon"],"mappings":";;;;;;;;;AAYA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAExB,MAAMC,OAAO,WAAHA,GAAG,oBAACH,KAAK,IAAI,CAAC,KAAK;IAAC,MAAK;;AAGnC,MAAMI,0BAA0B,kBAC5B,oBAACF,YAAY,UAAU;QAAC,MAAK;QAAW,OAAM;QAAW,IAAI;YAAE,OAAOG,OAAO,IAAI;QAAC;;AAG/E,MAAMC,gBAAgB;IACzB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,OAAO,WAAP,GACI,oBAACN,aAAWA,MAAAA,WAAAA,GACR,oBAACO,eAAaA;QAAC,QAAO;qBAClB,oBAACR,OAAKA;QACF,OAAOI,OAAO,IAAI;QAClB,uBACI,oBAACK,aAAWA;YAAC,OAAM;yBACf,oBAACN,yBAAuBA,OAAAA,WAAAA,GACxB,oBAACO,iBAAeA;sBAI5B,oBAACV,OAAKA;QACF,OAAOI,OAAO,UAAU;QACxB,uBACI,oBAACK,aAAWA;YAAC,OAAM;yBACf,oBAACN,yBAAuBA,OAAAA,WAAAA,GACxB,oBAACF,YAAY,UAAU;YACnB,MAAK;YACL,OAAM;0BAEV,oBAACU,uBAAqBA;sBAIlC,oBAACX,OAAKA;QACF,OAAOI,OAAO,QAAQ;QACtB,uBACI,oBAACK,aAAWA;YAAC,OAAM;yBACf,oBAACN,yBAAuBA,OAAAA,WAAAA,GACxB,oBAACF,YAAY,UAAU;YAAC,MAAK;YAAoB,OAAM;0BACvD,oBAACW,qBAAmBA;sBAIhC,oBAACZ,OAAKA;QACF,OAAOI,OAAO,IAAI;QAClB,uBACI,oBAACK,aAAWA;YAAC,OAAM;yBACf,oBAACN,yBAAuBA,OAAAA,WAAAA,GACxB,oBAACF,YAAY,UAAU;YAAC,MAAK;YAAgB,OAAM;0BACnD,oBAACY,iBAAeA;sBAI5B,oBAACd,MAAIA;QACD,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YACN,MAAK;YACL,OAAOG;YACP,IAAII,QAAQF,OAAO,UAAU;YAC7B,oBACI,oBAACL,KAAK,IAAI,CAAC,IAAI;gBACX,OAAM;gBACN,uBAAS,oBAACe,gBAAmBA;;;sBAMjD,oBAACf,MAAIA;QACD,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YAAC,OAAOG;YAAM,MAAK;YAAW,IAAII,QAAQF,OAAO,QAAQ;;;AAM3F"}
@@ -1,4 +1,4 @@
1
- export declare const WebhookPermissionsFeature: import("@webiny/feature/admin").FeatureDefinition<{
1
+ export declare const WebhookPermissionsFeature: import("@webiny/feature/admin/createFeature.js").FeatureDefinition<{
2
2
  permissions: {
3
3
  canAccess: (entityId: "webhook") => boolean;
4
4
  canAction: (action: string, entityId: "webhook") => boolean;
@@ -3,7 +3,7 @@ import type { IWebhookDeliveriesPagePresenter } from "../abstractions.js";
3
3
  interface DeliveryBottomInfoBarProps {
4
4
  presenter: IWebhookDeliveriesPagePresenter;
5
5
  }
6
- export declare const DeliveryBottomInfoBar: (({ presenter }: DeliveryBottomInfoBarProps) => React.JSX.Element | null) & {
7
- displayName: string;
6
+ export declare const DeliveryBottomInfoBar: (({ presenter }: DeliveryBottomInfoBarProps) => React.JSX.Element | null) & React.NamedExoticComponent<DeliveryBottomInfoBarProps> & {
7
+ readonly type: ({ presenter }: DeliveryBottomInfoBarProps) => React.JSX.Element | null;
8
8
  };
9
9
  export {};
@@ -3,7 +3,7 @@ import type { IWebhookDeliveriesPagePresenter } from "../abstractions.js";
3
3
  interface DeliveryFiltersProps {
4
4
  presenter: IWebhookDeliveriesPagePresenter;
5
5
  }
6
- export declare const DeliveryFilters: (({ presenter }: DeliveryFiltersProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const DeliveryFilters: (({ presenter }: DeliveryFiltersProps) => React.JSX.Element) & React.NamedExoticComponent<DeliveryFiltersProps> & {
7
+ readonly type: ({ presenter }: DeliveryFiltersProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -1,6 +1,7 @@
1
- import react from "react";
1
+ import react, { useState } from "react";
2
2
  import { observer } from "mobx-react-lite";
3
- import { Button, Grid, MultiSelect, Select } from "@webiny/admin-ui";
3
+ import { Drawer, IconButton, MultiSelect, Select } from "@webiny/admin-ui";
4
+ import { ReactComponent } from "@webiny/icons/filter_list.svg";
4
5
  const STATUS_OPTIONS = [
5
6
  {
6
7
  value: "pending",
@@ -21,30 +22,51 @@ const STATUS_OPTIONS = [
21
22
  ];
22
23
  const DeliveryFilters = observer(({ presenter })=>{
23
24
  const { vm } = presenter;
24
- return /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
25
- span: 2
25
+ const [open, setOpen] = useState(false);
26
+ return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(IconButton, {
27
+ variant: vm.hasFilters ? "primary" : "ghost",
28
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
29
+ onClick: ()=>setOpen(true),
30
+ "data-testid": "webhooks.toggle-filters"
31
+ }), /*#__PURE__*/ react.createElement(Drawer, {
32
+ open: open,
33
+ onClose: ()=>setOpen(false),
34
+ modal: true,
35
+ width: 360,
36
+ title: "Filters",
37
+ headerSeparator: true,
38
+ footerSeparator: true,
39
+ bodyPadding: false,
40
+ actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Drawer.CancelButton, {
41
+ text: "Clear all",
42
+ onClick: ()=>presenter.clearFilters()
43
+ }), /*#__PURE__*/ react.createElement(Drawer.ConfirmButton, {
44
+ text: "Apply filters",
45
+ onClick: ()=>setOpen(false)
46
+ }))
47
+ }, /*#__PURE__*/ react.createElement("div", {
48
+ className: "flex flex-col gap-lg p-lg"
26
49
  }, /*#__PURE__*/ react.createElement(Select, {
27
50
  size: "md",
51
+ label: "Webhook",
28
52
  placeholder: "All webhooks",
29
53
  value: vm.filters.webhookId ?? "",
30
54
  options: vm.availableWebhooks,
31
55
  onChange: (value)=>presenter.setWebhookFilter(value || null),
32
56
  displayResetAction: true,
33
57
  onValueReset: ()=>presenter.setWebhookFilter(null)
34
- })), /*#__PURE__*/ react.createElement(Grid.Column, {
35
- span: 2
36
- }, /*#__PURE__*/ react.createElement(Select, {
58
+ }), /*#__PURE__*/ react.createElement(Select, {
37
59
  size: "md",
60
+ label: "Application",
38
61
  placeholder: "All apps",
39
62
  value: vm.filters.app ?? "",
40
63
  options: vm.availableApps,
41
64
  onChange: (value)=>presenter.setAppFilter(value || null),
42
65
  displayResetAction: true,
43
66
  onValueReset: ()=>presenter.setAppFilter(null)
44
- })), /*#__PURE__*/ react.createElement(Grid.Column, {
45
- span: 2
46
- }, /*#__PURE__*/ react.createElement(Select, {
67
+ }), /*#__PURE__*/ react.createElement(Select, {
47
68
  size: "md",
69
+ label: "Entity",
48
70
  placeholder: "All entities",
49
71
  value: vm.filters.entity ?? "",
50
72
  options: vm.availableEntities,
@@ -52,10 +74,9 @@ const DeliveryFilters = observer(({ presenter })=>{
52
74
  disabled: !vm.filters.app,
53
75
  displayResetAction: true,
54
76
  onValueReset: ()=>presenter.setEntityFilter(null)
55
- })), /*#__PURE__*/ react.createElement(Grid.Column, {
56
- span: 2
57
- }, /*#__PURE__*/ react.createElement(Select, {
77
+ }), /*#__PURE__*/ react.createElement(Select, {
58
78
  size: "md",
79
+ label: "Event",
59
80
  placeholder: "All events",
60
81
  value: vm.filters.eventName ?? "",
61
82
  options: vm.availableEventNames,
@@ -63,22 +84,14 @@ const DeliveryFilters = observer(({ presenter })=>{
63
84
  disabled: !vm.filters.app,
64
85
  displayResetAction: true,
65
86
  onValueReset: ()=>presenter.setEventFilter(null)
66
- })), /*#__PURE__*/ react.createElement(Grid.Column, {
67
- span: 2
68
- }, /*#__PURE__*/ react.createElement(MultiSelect, {
87
+ }), /*#__PURE__*/ react.createElement(MultiSelect, {
69
88
  size: "md",
89
+ label: "Status",
70
90
  placeholder: "All statuses",
71
91
  value: vm.filters.status,
72
92
  options: STATUS_OPTIONS,
73
93
  onChange: (values)=>presenter.setStatusFilter(values)
74
- })), /*#__PURE__*/ react.createElement(Grid.Column, {
75
- span: 2
76
- }, /*#__PURE__*/ react.createElement(Button, {
77
- variant: "tertiary",
78
- size: "md",
79
- onClick: ()=>presenter.clearFilters(),
80
- disabled: !vm.hasFilters
81
- }, "Clear filters")));
94
+ }))));
82
95
  });
83
96
  export { DeliveryFilters };
84
97
 
@@ -1 +1 @@
1
- {"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Grid, MultiSelect, Select } from \"@webiny/admin-ui\";\nimport type { IWebhookDeliveriesPagePresenter } from \"../abstractions.js\";\nimport { Button } from \"@webiny/admin-ui\";\n\ninterface DeliveryFiltersProps {\n presenter: IWebhookDeliveriesPagePresenter;\n}\n\nconst STATUS_OPTIONS = [\n { value: \"pending\", label: \"Pending\" },\n { value: \"delivering\", label: \"Delivering\" },\n { value: \"delivered\", label: \"Delivered\" },\n { value: \"failed\", label: \"Failed\" }\n];\n\nexport const DeliveryFilters = observer(({ presenter }: DeliveryFiltersProps) => {\n const { vm } = presenter;\n return (\n <Grid>\n <Grid.Column span={2}>\n <Select\n size={\"md\"}\n placeholder=\"All webhooks\"\n value={vm.filters.webhookId ?? \"\"}\n options={vm.availableWebhooks}\n onChange={value => presenter.setWebhookFilter(value || null)}\n displayResetAction={true}\n onValueReset={() => presenter.setWebhookFilter(null)}\n />\n </Grid.Column>\n <Grid.Column span={2}>\n <Select\n size={\"md\"}\n placeholder=\"All apps\"\n value={vm.filters.app ?? \"\"}\n options={vm.availableApps}\n onChange={value => presenter.setAppFilter(value || null)}\n displayResetAction={true}\n onValueReset={() => presenter.setAppFilter(null)}\n />\n </Grid.Column>\n <Grid.Column span={2}>\n <Select\n size={\"md\"}\n placeholder=\"All entities\"\n value={vm.filters.entity ?? \"\"}\n options={vm.availableEntities}\n onChange={value => presenter.setEntityFilter(value || null)}\n disabled={!vm.filters.app}\n displayResetAction={true}\n onValueReset={() => presenter.setEntityFilter(null)}\n />\n </Grid.Column>\n <Grid.Column span={2}>\n <Select\n size={\"md\"}\n placeholder=\"All events\"\n value={vm.filters.eventName ?? \"\"}\n options={vm.availableEventNames}\n onChange={value => presenter.setEventFilter(value || null)}\n disabled={!vm.filters.app}\n displayResetAction={true}\n onValueReset={() => presenter.setEventFilter(null)}\n />\n </Grid.Column>\n <Grid.Column span={2}>\n <MultiSelect\n size={\"md\"}\n placeholder=\"All statuses\"\n value={vm.filters.status}\n options={STATUS_OPTIONS}\n onChange={values => presenter.setStatusFilter(values)}\n />\n </Grid.Column>\n <Grid.Column span={2}>\n <Button\n variant=\"tertiary\"\n size=\"md\"\n onClick={() => presenter.clearFilters()}\n disabled={!vm.hasFilters}\n >\n Clear filters\n </Button>\n </Grid.Column>\n </Grid>\n );\n});\n"],"names":["STATUS_OPTIONS","DeliveryFilters","observer","presenter","vm","Grid","Select","value","MultiSelect","values","Button"],"mappings":";;;AAUA,MAAMA,iBAAiB;IACnB;QAAE,OAAO;QAAW,OAAO;IAAU;IACrC;QAAE,OAAO;QAAc,OAAO;IAAa;IAC3C;QAAE,OAAO;QAAa,OAAO;IAAY;IACzC;QAAE,OAAO;QAAU,OAAO;IAAS;CACtC;AAEM,MAAMC,kBAAkBC,SAAS,CAAC,EAAEC,SAAS,EAAwB;IACxE,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,OAAO,WAAP,GACI,oBAACE,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,QAAMA;QACH,MAAM;QACN,aAAY;QACZ,OAAOF,GAAG,OAAO,CAAC,SAAS,IAAI;QAC/B,SAASA,GAAG,iBAAiB;QAC7B,UAAUG,CAAAA,QAASJ,UAAU,gBAAgB,CAACI,SAAS;QACvD,oBAAoB;QACpB,cAAc,IAAMJ,UAAU,gBAAgB,CAAC;uBAGvD,oBAACE,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,QAAMA;QACH,MAAM;QACN,aAAY;QACZ,OAAOF,GAAG,OAAO,CAAC,GAAG,IAAI;QACzB,SAASA,GAAG,aAAa;QACzB,UAAUG,CAAAA,QAASJ,UAAU,YAAY,CAACI,SAAS;QACnD,oBAAoB;QACpB,cAAc,IAAMJ,UAAU,YAAY,CAAC;uBAGnD,oBAACE,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,QAAMA;QACH,MAAM;QACN,aAAY;QACZ,OAAOF,GAAG,OAAO,CAAC,MAAM,IAAI;QAC5B,SAASA,GAAG,iBAAiB;QAC7B,UAAUG,CAAAA,QAASJ,UAAU,eAAe,CAACI,SAAS;QACtD,UAAU,CAACH,GAAG,OAAO,CAAC,GAAG;QACzB,oBAAoB;QACpB,cAAc,IAAMD,UAAU,eAAe,CAAC;uBAGtD,oBAACE,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,QAAMA;QACH,MAAM;QACN,aAAY;QACZ,OAAOF,GAAG,OAAO,CAAC,SAAS,IAAI;QAC/B,SAASA,GAAG,mBAAmB;QAC/B,UAAUG,CAAAA,QAASJ,UAAU,cAAc,CAACI,SAAS;QACrD,UAAU,CAACH,GAAG,OAAO,CAAC,GAAG;QACzB,oBAAoB;QACpB,cAAc,IAAMD,UAAU,cAAc,CAAC;uBAGrD,oBAACE,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACG,aAAWA;QACR,MAAM;QACN,aAAY;QACZ,OAAOJ,GAAG,OAAO,CAAC,MAAM;QACxB,SAASJ;QACT,UAAUS,CAAAA,SAAUN,UAAU,eAAe,CAACM;uBAGtD,oBAACJ,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACK,QAAMA;QACH,SAAQ;QACR,MAAK;QACL,SAAS,IAAMP,UAAU,YAAY;QACrC,UAAU,CAACC,GAAG,UAAU;OAC3B;AAMjB"}
1
+ {"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Drawer, IconButton, MultiSelect, Select } from \"@webiny/admin-ui\";\nimport { ReactComponent as FilterIcon } from \"@webiny/icons/filter_list.svg\";\nimport type { IWebhookDeliveriesPagePresenter } from \"../abstractions.js\";\n\ninterface DeliveryFiltersProps {\n presenter: IWebhookDeliveriesPagePresenter;\n}\n\nconst STATUS_OPTIONS = [\n { value: \"pending\", label: \"Pending\" },\n { value: \"delivering\", label: \"Delivering\" },\n { value: \"delivered\", label: \"Delivered\" },\n { value: \"failed\", label: \"Failed\" }\n];\n\nexport const DeliveryFilters = observer(({ presenter }: DeliveryFiltersProps) => {\n const { vm } = presenter;\n const [open, setOpen] = useState(false);\n\n return (\n <>\n <IconButton\n variant={vm.hasFilters ? \"primary\" : \"ghost\"}\n icon={<FilterIcon />}\n onClick={() => setOpen(true)}\n data-testid=\"webhooks.toggle-filters\"\n />\n <Drawer\n open={open}\n onClose={() => setOpen(false)}\n modal={true}\n width={360}\n title=\"Filters\"\n headerSeparator={true}\n footerSeparator={true}\n bodyPadding={false}\n actions={\n <>\n <Drawer.CancelButton\n text=\"Clear all\"\n onClick={() => presenter.clearFilters()}\n />\n <Drawer.ConfirmButton text=\"Apply filters\" onClick={() => setOpen(false)} />\n </>\n }\n >\n <div className=\"flex flex-col gap-lg p-lg\">\n <Select\n size={\"md\"}\n label=\"Webhook\"\n placeholder=\"All webhooks\"\n value={vm.filters.webhookId ?? \"\"}\n options={vm.availableWebhooks}\n onChange={value => presenter.setWebhookFilter(value || null)}\n displayResetAction={true}\n onValueReset={() => presenter.setWebhookFilter(null)}\n />\n <Select\n size={\"md\"}\n label=\"Application\"\n placeholder=\"All apps\"\n value={vm.filters.app ?? \"\"}\n options={vm.availableApps}\n onChange={value => presenter.setAppFilter(value || null)}\n displayResetAction={true}\n onValueReset={() => presenter.setAppFilter(null)}\n />\n <Select\n size={\"md\"}\n label=\"Entity\"\n placeholder=\"All entities\"\n value={vm.filters.entity ?? \"\"}\n options={vm.availableEntities}\n onChange={value => presenter.setEntityFilter(value || null)}\n disabled={!vm.filters.app}\n displayResetAction={true}\n onValueReset={() => presenter.setEntityFilter(null)}\n />\n <Select\n size={\"md\"}\n label=\"Event\"\n placeholder=\"All events\"\n value={vm.filters.eventName ?? \"\"}\n options={vm.availableEventNames}\n onChange={value => presenter.setEventFilter(value || null)}\n disabled={!vm.filters.app}\n displayResetAction={true}\n onValueReset={() => presenter.setEventFilter(null)}\n />\n <MultiSelect\n size={\"md\"}\n label=\"Status\"\n placeholder=\"All statuses\"\n value={vm.filters.status}\n options={STATUS_OPTIONS}\n onChange={values => presenter.setStatusFilter(values)}\n />\n </div>\n </Drawer>\n </>\n );\n});\n"],"names":["STATUS_OPTIONS","DeliveryFilters","observer","presenter","vm","open","setOpen","useState","IconButton","FilterIcon","Drawer","Select","value","MultiSelect","values"],"mappings":";;;;AAUA,MAAMA,iBAAiB;IACnB;QAAE,OAAO;QAAW,OAAO;IAAU;IACrC;QAAE,OAAO;QAAc,OAAO;IAAa;IAC3C;QAAE,OAAO;QAAa,OAAO;IAAY;IACzC;QAAE,OAAO;QAAU,OAAO;IAAS;CACtC;AAEM,MAAMC,kBAAkBC,SAAS,CAAC,EAAEC,SAAS,EAAwB;IACxE,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,CAACE,MAAMC,QAAQ,GAAGC,SAAS;IAEjC,OAAO,WAAP,GACI,wDACI,oBAACC,YAAUA;QACP,SAASJ,GAAG,UAAU,GAAG,YAAY;QACrC,oBAAM,oBAACK,gBAAUA;QACjB,SAAS,IAAMH,QAAQ;QACvB,eAAY;sBAEhB,oBAACI,QAAMA;QACH,MAAML;QACN,SAAS,IAAMC,QAAQ;QACvB,OAAO;QACP,OAAO;QACP,OAAM;QACN,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,uBACI,wDACI,oBAACI,OAAO,YAAY;YAChB,MAAK;YACL,SAAS,IAAMP,UAAU,YAAY;0BAEzC,oBAACO,OAAO,aAAa;YAAC,MAAK;YAAgB,SAAS,IAAMJ,QAAQ;;qBAI1E,oBAAC;QAAI,WAAU;qBACX,oBAACK,QAAMA;QACH,MAAM;QACN,OAAM;QACN,aAAY;QACZ,OAAOP,GAAG,OAAO,CAAC,SAAS,IAAI;QAC/B,SAASA,GAAG,iBAAiB;QAC7B,UAAUQ,CAAAA,QAAST,UAAU,gBAAgB,CAACS,SAAS;QACvD,oBAAoB;QACpB,cAAc,IAAMT,UAAU,gBAAgB,CAAC;sBAEnD,oBAACQ,QAAMA;QACH,MAAM;QACN,OAAM;QACN,aAAY;QACZ,OAAOP,GAAG,OAAO,CAAC,GAAG,IAAI;QACzB,SAASA,GAAG,aAAa;QACzB,UAAUQ,CAAAA,QAAST,UAAU,YAAY,CAACS,SAAS;QACnD,oBAAoB;QACpB,cAAc,IAAMT,UAAU,YAAY,CAAC;sBAE/C,oBAACQ,QAAMA;QACH,MAAM;QACN,OAAM;QACN,aAAY;QACZ,OAAOP,GAAG,OAAO,CAAC,MAAM,IAAI;QAC5B,SAASA,GAAG,iBAAiB;QAC7B,UAAUQ,CAAAA,QAAST,UAAU,eAAe,CAACS,SAAS;QACtD,UAAU,CAACR,GAAG,OAAO,CAAC,GAAG;QACzB,oBAAoB;QACpB,cAAc,IAAMD,UAAU,eAAe,CAAC;sBAElD,oBAACQ,QAAMA;QACH,MAAM;QACN,OAAM;QACN,aAAY;QACZ,OAAOP,GAAG,OAAO,CAAC,SAAS,IAAI;QAC/B,SAASA,GAAG,mBAAmB;QAC/B,UAAUQ,CAAAA,QAAST,UAAU,cAAc,CAACS,SAAS;QACrD,UAAU,CAACR,GAAG,OAAO,CAAC,GAAG;QACzB,oBAAoB;QACpB,cAAc,IAAMD,UAAU,cAAc,CAAC;sBAEjD,oBAACU,aAAWA;QACR,MAAM;QACN,OAAM;QACN,aAAY;QACZ,OAAOT,GAAG,OAAO,CAAC,MAAM;QACxB,SAASJ;QACT,UAAUc,CAAAA,SAAUX,UAAU,eAAe,CAACW;;AAMtE"}
@@ -3,7 +3,7 @@ import type { IWebhookDeliveriesPagePresenter } from "../abstractions.js";
3
3
  interface DeliveryListProps {
4
4
  presenter: IWebhookDeliveriesPagePresenter;
5
5
  }
6
- export declare const DeliveryList: (({ presenter }: DeliveryListProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const DeliveryList: (({ presenter }: DeliveryListProps) => React.JSX.Element) & React.NamedExoticComponent<DeliveryListProps> & {
7
+ readonly type: ({ presenter }: DeliveryListProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -43,11 +43,11 @@ const WebhookDeliveriesPage_WebhookDeliveriesPageInner = observer(function() {
43
43
  className: "flex items-center justify-between py-sm px-md"
44
44
  }, /*#__PURE__*/ react.createElement(Heading, {
45
45
  level: 5
46
- }, "Webhook Deliveries"), /*#__PURE__*/ react.createElement(WebhookDefinitionsButton, null)), /*#__PURE__*/ react.createElement(Separator, null), /*#__PURE__*/ react.createElement("div", {
47
- className: "p-sm"
46
+ }, "Webhook Deliveries"), /*#__PURE__*/ react.createElement("div", {
47
+ className: "flex items-center gap-sm"
48
48
  }, /*#__PURE__*/ react.createElement(DeliveryFilters, {
49
49
  presenter: presenter
50
- })), /*#__PURE__*/ react.createElement(Separator, null), vm.loading ? /*#__PURE__*/ react.createElement(Loader, null) : /*#__PURE__*/ react.createElement(DeliveryList, {
50
+ }), /*#__PURE__*/ react.createElement(WebhookDefinitionsButton, null))), /*#__PURE__*/ react.createElement(Separator, null), vm.loading ? /*#__PURE__*/ react.createElement(Loader, null) : /*#__PURE__*/ react.createElement(DeliveryList, {
51
51
  presenter: presenter
52
52
  }));
53
53
  });
@@ -1 +1 @@
1
- {"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.tsx"],"sourcesContent":["import React, { useMemo, useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport { Separator } from \"@webiny/admin-ui\";\nimport { Skeleton } from \"@webiny/admin-ui\";\nimport { Button, Heading, Text } from \"@webiny/admin-ui\";\nimport { ListWebhookDeliveriesFeature } from \"~/admin/features/listWebhookDeliveries/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { ResendWebhookDeliveryFeature } from \"~/admin/features/resendWebhookDelivery/feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { WebhookDeliveriesPagePresenterFeature } from \"../feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { DeliveryFilters } from \"./DeliveryFilters.js\";\nimport { DeliveryList } from \"./DeliveryList.js\";\nimport { WebhookDefinitionsButton } from \"~/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js\";\n\nconst Loader = () => {\n return (\n <div className=\"flex flex-col gap-sm p-md\">\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n </div>\n );\n};\n\nconst WebhookDeliveriesPageInner = observer(function WebhookDeliveriesPageInner() {\n const { presenter } = useFeature(WebhookDeliveriesPagePresenterFeature);\n const { route } = useRoute(Routes.Deliveries);\n const webhookId = route?.params?.webhookId;\n\n useEffect(() => {\n void presenter.init(webhookId);\n }, [presenter, webhookId]);\n\n const { vm } = presenter;\n\n if (vm.error) {\n return (\n <div className=\"flex flex-col items-center gap-sm p-md\">\n <Text>{vm.error}</Text>\n <Button variant=\"secondary\" onClick={() => void presenter.init()}>\n Retry\n </Button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-main-content\">\n <div className=\"flex items-center justify-between py-sm px-md\">\n <Heading level={5}>Webhook Deliveries</Heading>\n <WebhookDefinitionsButton />\n </div>\n <Separator />\n <div className={\"p-sm\"}>\n <DeliveryFilters presenter={presenter} />\n </div>\n <Separator />\n {vm.loading ? <Loader /> : <DeliveryList presenter={presenter} />}\n </div>\n );\n});\n\nexport const WebhookDeliveriesPage = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhookDeliveriesFeature.register(child);\n ListAvailableEventsFeature.register(child);\n ResendWebhookDeliveryFeature.register(child);\n ListWebhooksFeature.register(child);\n WebhookDeliveriesPagePresenterFeature.register(child);\n return child;\n }, [container]);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookDeliveriesPageInner />\n </DiContainerProvider>\n );\n};\n"],"names":["Loader","Skeleton","WebhookDeliveriesPageInner","observer","presenter","useFeature","WebhookDeliveriesPagePresenterFeature","route","useRoute","Routes","webhookId","useEffect","vm","Text","Button","Heading","WebhookDefinitionsButton","Separator","DeliveryFilters","DeliveryList","WebhookDeliveriesPage","container","useContainer","scopedContainer","useMemo","child","ListWebhookDeliveriesFeature","ListAvailableEventsFeature","ResendWebhookDeliveryFeature","ListWebhooksFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMA,SAAS,IACJ,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;;AAKhC,MAAMC,mDAA6BC,SAAS;IACxC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,UAAU;IAC5C,MAAMC,YAAYH,OAAO,QAAQ;IAEjCI,UAAU;QACDP,UAAU,IAAI,CAACM;IACxB,GAAG;QAACN;QAAWM;KAAU;IAEzB,MAAM,EAAEE,EAAE,EAAE,GAAGR;IAEf,IAAIQ,GAAG,KAAK,EACR,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,MAAIA,MAAED,GAAG,KAAK,iBACf,oBAACE,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAM,KAAKV,UAAU,IAAI;OAAI;IAO9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACW,SAAOA;QAAC,OAAO;OAAG,qCACnB,oBAACC,0BAAwBA,QAAAA,WAAAA,GAE7B,oBAACC,WAASA,OAAAA,WAAAA,GACV,oBAAC;QAAI,WAAW;qBACZ,oBAACC,iBAAeA;QAAC,WAAWd;uBAEhC,oBAACa,WAASA,OACTL,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACZ,QAAMA,QAAAA,WAAAA,GAAM,oBAACmB,cAAYA;QAAC,WAAWf;;AAGhE;AAEO,MAAMgB,wBAAwB;IACjC,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBC,QAAQ;QAC5B,MAAMC,QAAQJ,UAAU,oBAAoB;QAC5CK,6BAA6B,QAAQ,CAACD;QACtCE,2BAA2B,QAAQ,CAACF;QACpCG,6BAA6B,QAAQ,CAACH;QACtCI,oBAAoB,QAAQ,CAACJ;QAC7BnB,sCAAsC,QAAQ,CAACmB;QAC/C,OAAOA;IACX,GAAG;QAACJ;KAAU;IAEd,OAAO,WAAP,GACI,oBAACS,qBAAmBA;QAAC,WAAWP;qBAC5B,oBAACrB,kDAA0BA;AAGvC"}
1
+ {"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.tsx"],"sourcesContent":["import React, { useMemo, useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport { Separator } from \"@webiny/admin-ui\";\nimport { Skeleton } from \"@webiny/admin-ui\";\nimport { Button, Heading, Text } from \"@webiny/admin-ui\";\nimport { ListWebhookDeliveriesFeature } from \"~/admin/features/listWebhookDeliveries/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { ResendWebhookDeliveryFeature } from \"~/admin/features/resendWebhookDelivery/feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { WebhookDeliveriesPagePresenterFeature } from \"../feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { DeliveryFilters } from \"./DeliveryFilters.js\";\nimport { DeliveryList } from \"./DeliveryList.js\";\nimport { WebhookDefinitionsButton } from \"~/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js\";\n\nconst Loader = () => {\n return (\n <div className=\"flex flex-col gap-sm p-md\">\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n </div>\n );\n};\n\nconst WebhookDeliveriesPageInner = observer(function WebhookDeliveriesPageInner() {\n const { presenter } = useFeature(WebhookDeliveriesPagePresenterFeature);\n const { route } = useRoute(Routes.Deliveries);\n const webhookId = route?.params?.webhookId;\n\n useEffect(() => {\n void presenter.init(webhookId);\n }, [presenter, webhookId]);\n\n const { vm } = presenter;\n\n if (vm.error) {\n return (\n <div className=\"flex flex-col items-center gap-sm p-md\">\n <Text>{vm.error}</Text>\n <Button variant=\"secondary\" onClick={() => void presenter.init()}>\n Retry\n </Button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-main-content\">\n <div className=\"flex items-center justify-between py-sm px-md\">\n <Heading level={5}>Webhook Deliveries</Heading>\n <div className=\"flex items-center gap-sm\">\n <DeliveryFilters presenter={presenter} />\n <WebhookDefinitionsButton />\n </div>\n </div>\n <Separator />\n {vm.loading ? <Loader /> : <DeliveryList presenter={presenter} />}\n </div>\n );\n});\n\nexport const WebhookDeliveriesPage = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhookDeliveriesFeature.register(child);\n ListAvailableEventsFeature.register(child);\n ResendWebhookDeliveryFeature.register(child);\n ListWebhooksFeature.register(child);\n WebhookDeliveriesPagePresenterFeature.register(child);\n return child;\n }, [container]);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookDeliveriesPageInner />\n </DiContainerProvider>\n );\n};\n"],"names":["Loader","Skeleton","WebhookDeliveriesPageInner","observer","presenter","useFeature","WebhookDeliveriesPagePresenterFeature","route","useRoute","Routes","webhookId","useEffect","vm","Text","Button","Heading","DeliveryFilters","WebhookDefinitionsButton","Separator","DeliveryList","WebhookDeliveriesPage","container","useContainer","scopedContainer","useMemo","child","ListWebhookDeliveriesFeature","ListAvailableEventsFeature","ResendWebhookDeliveryFeature","ListWebhooksFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;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;IACX,GAAG;QAACJ;KAAU;IAEd,OAAO,WAAP,GACI,oBAACS,qBAAmBA;QAAC,WAAWP;qBAC5B,oBAACrB,kDAA0BA;AAGvC"}
@@ -3,7 +3,7 @@ import type { IWebhookFormPresenter } from "../abstractions.js";
3
3
  interface SigningSecretProps {
4
4
  presenter: IWebhookFormPresenter;
5
5
  }
6
- export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & {
7
- displayName: string;
6
+ export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & React.NamedExoticComponent<SigningSecretProps> & {
7
+ readonly type: ({ presenter }: SigningSecretProps) => React.JSX.Element | null;
8
8
  };
9
9
  export {};
@@ -3,7 +3,7 @@ import type { IWebhookListPresenter } from "../abstractions.js";
3
3
  interface WebhookListContentProps {
4
4
  presenter: IWebhookListPresenter;
5
5
  }
6
- export declare const WebhookListContent: (({ presenter }: WebhookListContentProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const WebhookListContent: (({ presenter }: WebhookListContentProps) => React.JSX.Element) & React.NamedExoticComponent<WebhookListContentProps> & {
7
+ readonly type: ({ presenter }: WebhookListContentProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -1,5 +1,5 @@
1
1
  import "@webiny/background-tasks/api/types.js";
2
- import { TaskDefinition } from "@webiny/api-core/exports/api/tasks.js";
2
+ import { TaskDefinition, TaskHandler } from "@webiny/api-core/exports/api/tasks.js";
3
3
  import { TenantContext } from "@webiny/api-core/exports/api/tenancy.js";
4
4
  import { WebhookSignPayload } from "@webiny/api-core/features/webhooks/index.js";
5
5
  import { GetWebhookRepository } from "../../../api/features/GetWebhook/abstractions.js";
@@ -8,8 +8,8 @@ import { UpdateWebhookDeliveryRepository } from "../../../api/features/UpdateWeb
8
8
  import { GetWebhookSettingsRepository } from "../../../api/features/GetWebhookSettings/abstractions.js";
9
9
  import { WebhookDeliver } from "../../../api/features/WebhookDeliver/abstractions.js";
10
10
  import type { ISendWebhookTaskInput, ISendWebhookTaskOutput } from "./types.js";
11
- type IRunParams = TaskDefinition.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;
12
- declare class SendWebhookTaskDefinition implements TaskDefinition.Interface<ISendWebhookTaskInput, ISendWebhookTaskOutput> {
11
+ type IRunParams = TaskHandler.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;
12
+ declare class SendWebhookTaskHandlerImpl implements TaskHandler.Interface<ISendWebhookTaskInput, ISendWebhookTaskOutput> {
13
13
  private readonly getWebhookRepository;
14
14
  private readonly getWebhookDeliveryRepository;
15
15
  private readonly updateDeliveryRepository;
@@ -17,6 +17,10 @@ declare class SendWebhookTaskDefinition implements TaskDefinition.Interface<ISen
17
17
  private readonly tenantContext;
18
18
  private readonly getWebhookSettingsRepository;
19
19
  private readonly deliver;
20
+ constructor(getWebhookRepository: GetWebhookRepository.Interface, getWebhookDeliveryRepository: GetWebhookDeliveryRepository.Interface, updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface, signPayload: WebhookSignPayload.Interface, tenantContext: TenantContext.Interface, getWebhookSettingsRepository: GetWebhookSettingsRepository.Interface, deliver: WebhookDeliver.Interface);
21
+ run(params: IRunParams): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskResultError | TaskDefinition.ResultDone<ISendWebhookTaskOutput>>;
22
+ }
23
+ declare class SendWebhookTaskDefinition implements TaskDefinition.Interface {
20
24
  readonly id = "sendWebhook";
21
25
  readonly title = "Send Webhook";
22
26
  readonly maxIterations = 1;
@@ -24,8 +28,9 @@ declare class SendWebhookTaskDefinition implements TaskDefinition.Interface<ISen
24
28
  readonly databaseLogs = false;
25
29
  readonly description = "POST a signed event payload to a webhook endpoint and log the delivery.";
26
30
  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>>;
31
+ handler: typeof SendWebhookTaskHandlerImpl & {
32
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions.js").ITaskOutput>>;
33
+ };
29
34
  }
30
35
  export declare const SendWebhookTask: typeof SendWebhookTaskDefinition & {
31
36
  __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>>;
@@ -1,5 +1,5 @@
1
1
  import "@webiny/background-tasks/api/types.js";
2
- import { TaskDefinition } from "@webiny/api-core/exports/api/tasks.js";
2
+ import { TaskDefinition, TaskHandler } from "@webiny/api-core/exports/api/tasks.js";
3
3
  import { TenantContext } from "@webiny/api-core/exports/api/tenancy.js";
4
4
  import { WebhookSignPayload } from "@webiny/api-core/features/webhooks/index.js";
5
5
  import { GetWebhookRepository } from "../GetWebhook/abstractions.js";
@@ -8,7 +8,7 @@ import { UpdateWebhookDeliveryRepository } from "../UpdateWebhookDelivery/abstra
8
8
  import { GetWebhookSettingsRepository } from "../GetWebhookSettings/abstractions.js";
9
9
  import { WebhookDeliver } from "../WebhookDeliver/abstractions.js";
10
10
  import { SEND_WEBHOOK_TASK } from "../../domain/constants.js";
11
- class SendWebhookTaskDefinition {
11
+ class SendWebhookTaskHandlerImpl {
12
12
  constructor(getWebhookRepository, getWebhookDeliveryRepository, updateDeliveryRepository, signPayload, tenantContext, getWebhookSettingsRepository, deliver){
13
13
  this.getWebhookRepository = getWebhookRepository;
14
14
  this.getWebhookDeliveryRepository = getWebhookDeliveryRepository;
@@ -17,13 +17,6 @@ class SendWebhookTaskDefinition {
17
17
  this.tenantContext = tenantContext;
18
18
  this.getWebhookSettingsRepository = getWebhookSettingsRepository;
19
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
20
  }
28
21
  async run(params) {
29
22
  const { input, controller } = params;
@@ -94,8 +87,8 @@ class SendWebhookTaskDefinition {
94
87
  return controller.response.done();
95
88
  }
96
89
  }
97
- const SendWebhookTask = TaskDefinition.createImplementation({
98
- implementation: SendWebhookTaskDefinition,
90
+ const SendWebhookTaskHandler = TaskHandler.createImplementation({
91
+ implementation: SendWebhookTaskHandlerImpl,
99
92
  dependencies: [
100
93
  GetWebhookRepository,
101
94
  GetWebhookDeliveryRepository,
@@ -106,6 +99,22 @@ const SendWebhookTask = TaskDefinition.createImplementation({
106
99
  WebhookDeliver
107
100
  ]
108
101
  });
102
+ class SendWebhookTaskDefinition {
103
+ constructor(){
104
+ this.id = SEND_WEBHOOK_TASK;
105
+ this.title = "Send Webhook";
106
+ this.maxIterations = 1;
107
+ this.isPrivate = true;
108
+ this.databaseLogs = false;
109
+ this.description = "POST a signed event payload to a webhook endpoint and log the delivery.";
110
+ this.selfCleanup = "always";
111
+ this.handler = SendWebhookTaskHandler;
112
+ }
113
+ }
114
+ const SendWebhookTask = TaskDefinition.createImplementation({
115
+ implementation: SendWebhookTaskDefinition,
116
+ dependencies: []
117
+ });
109
118
  export { SendWebhookTask };
110
119
 
111
120
  //# sourceMappingURL=SendWebhookTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api/features/SendWebhookTask/SendWebhookTask.js","sources":["../../../../src/api/features/SendWebhookTask/SendWebhookTask.ts"],"sourcesContent":["import \"@webiny/background-tasks/api/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,CA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AAQ,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"}
1
+ {"version":3,"file":"api/features/SendWebhookTask/SendWebhookTask.js","sources":["../../../../src/api/features/SendWebhookTask/SendWebhookTask.ts"],"sourcesContent":["import \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition, TaskHandler } 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 = TaskHandler.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;\n\nclass SendWebhookTaskHandlerImpl implements TaskHandler.Interface<\n ISendWebhookTaskInput,\n ISendWebhookTaskOutput\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\nconst SendWebhookTaskHandler = TaskHandler.createImplementation({\n implementation: SendWebhookTaskHandlerImpl,\n dependencies: [\n GetWebhookRepository,\n GetWebhookDeliveryRepository,\n UpdateWebhookDeliveryRepository,\n WebhookSignPayload,\n TenantContext,\n GetWebhookSettingsRepository,\n WebhookDeliver\n ]\n});\n\nclass SendWebhookTaskDefinition implements TaskDefinition.Interface {\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 handler = SendWebhookTaskHandler;\n}\n\nexport const SendWebhookTask = TaskDefinition.createImplementation({\n implementation: SendWebhookTaskDefinition,\n dependencies: []\n});\n"],"names":["SendWebhookTaskHandlerImpl","getWebhookRepository","getWebhookDeliveryRepository","updateDeliveryRepository","signPayload","tenantContext","getWebhookSettingsRepository","deliver","params","input","controller","taskId","delivery","webhookResult","webhook","now","Date","payload","rawBody","JSON","signHeaders","settingsResult","signingSecret","ex","requestHeaders","result","SendWebhookTaskHandler","TaskHandler","GetWebhookRepository","GetWebhookDeliveryRepository","UpdateWebhookDeliveryRepository","WebhookSignPayload","TenantContext","GetWebhookSettingsRepository","WebhookDeliver","SendWebhookTaskDefinition","SEND_WEBHOOK_TASK","SendWebhookTask","TaskDefinition"],"mappings":";;;;;;;;;;AAeA,MAAMA;IAIF,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;IAClB;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,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AG,IAAI,cAAc;QAC9C;QAEA,OAAOf,WAAW,QAAQ,CAAC,IAAI;IACnC;AACJ;AAEA,MAAMgB,yBAAyBC,YAAY,oBAAoB,CAAC;IAC5D,gBAAgB3B;IAChB,cAAc;QACV4B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,aAAa,GAAG;aAChB,SAAS,GAAG;aACZ,YAAY,GAAG;aACf,WAAW,GACvB;aACY,WAAW,GAAG;aAE9B,OAAO,GAAGV;;AACd;AAEO,MAAMW,kBAAkBC,eAAe,oBAAoB,CAAC;IAC/D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -24,9 +24,11 @@ class UpdateWebhookRepositoryImpl {
24
24
  });
25
25
  if (entryResult.isFail()) return Result.fail(WebhookPersistenceError.from(entryResult.error));
26
26
  const values = this.transformer.toStorage(webhook);
27
- const { entry } = await this.updateEntryDataFactory.create(modelResult.value, {
27
+ const dataResult = await this.updateEntryDataFactory.create(modelResult.value, {
28
28
  values
29
29
  }, entryResult.value);
30
+ if (dataResult.isFail()) return Result.fail(WebhookPersistenceError.from(dataResult.error));
31
+ const { entry } = dataResult.value;
30
32
  const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);
31
33
  if (updateResult.isFail()) return Result.fail(WebhookPersistenceError.from(updateResult.error));
32
34
  return Result.ok(webhook);
@@ -1 +1 @@
1
- {"version":3,"file":"api/features/UpdateWebhook/UpdateWebhookRepository.js","sources":["../../../../src/api/features/UpdateWebhook/UpdateWebhookRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\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 { UpdateEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { UpdateEntryDataFactory } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { WebhookTransformer } from \"~/api/features/Transformers/abstractions/WebhookTransformer.js\";\nimport { UpdateWebhookRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { Webhook, WebhookCmsEntryValues } from \"~/api/domain/Webhook.js\";\n\nclass UpdateWebhookRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly updateEntryDataFactory: UpdateEntryDataFactory.Interface,\n private readonly updateEntryRepository: UpdateEntryRepository.Interface,\n private readonly transformer: WebhookTransformer.Interface\n ) {}\n\n async execute(webhook: Webhook): Promise<Result<Webhook, RepositoryAbstraction.Error>> {\n try {\n const modelResult = await this.getModelRepository.execute(WEBHOOK_MODEL_ID);\n if (modelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_MODEL_ID));\n }\n\n const entryResult =\n await this.getLatestRevisionRepository.execute<WebhookCmsEntryValues>(\n modelResult.value,\n { id: webhook.id }\n );\n if (entryResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(entryResult.error));\n }\n\n const values = this.transformer.toStorage(webhook);\n\n const { entry } = await this.updateEntryDataFactory.create<WebhookCmsEntryValues>(\n modelResult.value,\n { values },\n entryResult.value\n );\n\n const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);\n\n if (updateResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(updateResult.error));\n }\n\n return Result.ok(webhook);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const UpdateWebhookRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateWebhookRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n UpdateEntryDataFactory,\n UpdateEntryRepository,\n WebhookTransformer\n ]\n});\n"],"names":["UpdateWebhookRepositoryImpl","getModelRepository","getLatestRevisionRepository","updateEntryDataFactory","updateEntryRepository","transformer","webhook","modelResult","WEBHOOK_MODEL_ID","Result","WebhookModelNotFoundError","entryResult","WebhookPersistenceError","values","entry","updateResult","error","UpdateWebhookRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","UpdateEntryDataFactory","UpdateEntryRepository","WebhookTransformer"],"mappings":";;;;;;;;;AAWA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,sBAAwD,EACxDC,qBAAsD,EACtDC,WAAyC,CAC5D;aALmBJ,kBAAkB,GAAlBA;aACAC,2BAA2B,GAA3BA;aACAC,sBAAsB,GAAtBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;IAClB;IAEH,MAAM,QAAQC,OAAgB,EAAyD;QACnF,IAAI;YACA,MAAMC,cAAc,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1D,IAAID,YAAY,MAAM,IAClB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,cACF,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAC1CJ,YAAY,KAAK,EACjB;gBAAE,IAAID,QAAQ,EAAE;YAAC;YAEzB,IAAIK,YAAY,MAAM,IAClB,OAAOF,OAAO,IAAI,CAACG,wBAAwB,IAAI,CAACD,YAAY,KAAK;YAGrE,MAAME,SAAS,IAAI,CAAC,WAAW,CAAC,SAAS,CAACP;YAE1C,MAAM,EAAEQ,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CACtDP,YAAY,KAAK,EACjB;gBAAEM;YAAO,GACTF,YAAY,KAAK;YAGrB,MAAMI,eAAe,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACR,YAAY,KAAK,EAAEO;YAEjF,IAAIC,aAAa,MAAM,IACnB,OAAON,OAAO,IAAI,CAACG,wBAAwB,IAAI,CAACG,aAAa,KAAK;YAGtE,OAAON,OAAO,EAAE,CAACH;QACrB,EAAE,OAAOU,OAAO;YACZ,OAAOP,OAAO,IAAI,CAACG,wBAAwB,IAAI,CAACI;QACpD;IACJ;AACJ;AAEO,MAAMC,kDAA0BC,wBAAAA,oBAA0C,CAAC;IAC9E,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"api/features/UpdateWebhook/UpdateWebhookRepository.js","sources":["../../../../src/api/features/UpdateWebhook/UpdateWebhookRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\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 { UpdateEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { UpdateEntryDataFactory } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { WebhookTransformer } from \"~/api/features/Transformers/abstractions/WebhookTransformer.js\";\nimport { UpdateWebhookRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { Webhook, WebhookCmsEntryValues } from \"~/api/domain/Webhook.js\";\n\nclass UpdateWebhookRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly updateEntryDataFactory: UpdateEntryDataFactory.Interface,\n private readonly updateEntryRepository: UpdateEntryRepository.Interface,\n private readonly transformer: WebhookTransformer.Interface\n ) {}\n\n async execute(webhook: Webhook): Promise<Result<Webhook, RepositoryAbstraction.Error>> {\n try {\n const modelResult = await this.getModelRepository.execute(WEBHOOK_MODEL_ID);\n if (modelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_MODEL_ID));\n }\n\n const entryResult =\n await this.getLatestRevisionRepository.execute<WebhookCmsEntryValues>(\n modelResult.value,\n { id: webhook.id }\n );\n if (entryResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(entryResult.error));\n }\n\n const values = this.transformer.toStorage(webhook);\n\n const dataResult = await this.updateEntryDataFactory.create<WebhookCmsEntryValues>(\n modelResult.value,\n { values },\n entryResult.value\n );\n if (dataResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(dataResult.error));\n }\n const { entry } = dataResult.value;\n\n const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);\n\n if (updateResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(updateResult.error));\n }\n\n return Result.ok(webhook);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const UpdateWebhookRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateWebhookRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n UpdateEntryDataFactory,\n UpdateEntryRepository,\n WebhookTransformer\n ]\n});\n"],"names":["UpdateWebhookRepositoryImpl","getModelRepository","getLatestRevisionRepository","updateEntryDataFactory","updateEntryRepository","transformer","webhook","modelResult","WEBHOOK_MODEL_ID","Result","WebhookModelNotFoundError","entryResult","WebhookPersistenceError","values","dataResult","entry","updateResult","error","UpdateWebhookRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","UpdateEntryDataFactory","UpdateEntryRepository","WebhookTransformer"],"mappings":";;;;;;;;;AAWA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,sBAAwD,EACxDC,qBAAsD,EACtDC,WAAyC,CAC5D;aALmBJ,k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@@ -36,9 +36,11 @@ class UpdateWebhookDeliveryRepositoryImpl {
36
36
  responseBody: input.responseBody ?? existing.responseBody
37
37
  };
38
38
  const storageValues = this.transformer.toStorage(updated);
39
- const { entry } = await this.updateEntryDataFactory.create(modelResult.value, {
39
+ const dataResult = await this.updateEntryDataFactory.create(modelResult.value, {
40
40
  values: storageValues
41
41
  }, originalEntry);
42
+ if (dataResult.isFail()) return Result.fail(WebhookPersistenceError.from(dataResult.error));
43
+ const { entry } = dataResult.value;
42
44
  const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);
43
45
  if (updateResult.isFail()) return Result.fail(WebhookPersistenceError.from(updateResult.error));
44
46
  return Result.ok(updated);
@@ -1 +1 @@
1
- {"version":3,"file":"api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js","sources":["../../../../src/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\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 { UpdateEntryDataFactory } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { UpdateEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WebhookDeliveryTransformer } from \"~/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js\";\nimport { UpdateWebhookDeliveryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport {\n WebhookDeliveryNotFoundError,\n WebhookModelNotFoundError,\n WebhookPersistenceError\n} from \"~/api/domain/errors.js\";\nimport { WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IUpdateDeliveryInput } from \"./abstractions.js\";\nimport type {\n WebhookDelivery,\n WebhookDeliveryCmsEntryValues\n} from \"~/api/domain/WebhookDelivery.js\";\n\nclass UpdateWebhookDeliveryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly updateEntryDataFactory: UpdateEntryDataFactory.Interface,\n private readonly updateEntryRepository: UpdateEntryRepository.Interface,\n private readonly transformer: WebhookDeliveryTransformer.Interface\n ) {}\n\n async execute(\n id: string,\n input: IUpdateDeliveryInput\n ): Promise<Result<WebhookDelivery, RepositoryAbstraction.Error>> {\n try {\n const modelResult = await this.getModelRepository.execute(WEBHOOK_DELIVERY_MODEL_ID);\n if (modelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_DELIVERY_MODEL_ID));\n }\n\n const entryResult =\n await this.getLatestRevisionRepository.execute<WebhookDeliveryCmsEntryValues>(\n modelResult.value,\n { id }\n );\n\n if (entryResult.isFail()) {\n return Result.fail(new WebhookDeliveryNotFoundError(id));\n }\n\n const originalEntry = entryResult.value;\n const existing = this.transformer.fromStorage(originalEntry);\n\n const updated: WebhookDelivery = {\n ...existing,\n backgroundTaskId: input.backgroundTaskId ?? existing.backgroundTaskId,\n status: input.status ?? existing.status,\n payload: input.payload ?? existing.payload,\n requestHeaders: input.requestHeaders ?? existing.requestHeaders,\n responseTime: input.responseTime ?? existing.responseTime,\n responseStatus: input.responseStatus ?? existing.responseStatus,\n responseBody: input.responseBody ?? existing.responseBody\n };\n\n const storageValues = this.transformer.toStorage(updated);\n\n const { entry } =\n await this.updateEntryDataFactory.create<WebhookDeliveryCmsEntryValues>(\n modelResult.value,\n { values: storageValues },\n originalEntry\n );\n\n const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);\n\n if (updateResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(updateResult.error));\n }\n\n return Result.ok(updated);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const UpdateWebhookDeliveryRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateWebhookDeliveryRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n UpdateEntryDataFactory,\n UpdateEntryRepository,\n WebhookDeliveryTransformer\n ]\n});\n"],"names":["UpdateWebhookDeliveryRepositoryImpl","getModelRepository","getLatestRevisionRepository","updateEntryDataFactory","updateEntryRepository","transformer","id","input","modelResult","WEBHOOK_DELIVERY_MODEL_ID","Result","WebhookModelNotFoundError","entryResult","WebhookDeliveryNotFoundError","originalEntry","existing","updated","storageValues","entry","updateResult","WebhookPersistenceError","error","UpdateWebhookDeliveryRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","UpdateEntryDataFactory","UpdateEntryRepository","WebhookDeliveryTransformer"],"mappings":";;;;;;;;;AAmBA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,sBAAwD,EACxDC,qBAAsD,EACtDC,WAAiD,CACpE;aALmBJ,kBAAkB,GAAlBA;aACAC,2BAA2B,GAA3BA;aACAC,sBAAsB,GAAtBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;IAClB;IAEH,MAAM,QACFC,EAAU,EACVC,KAA2B,EACkC;QAC7D,IAAI;YACA,MAAMC,cAAc,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1D,IAAID,YAAY,MAAM,IAClB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,cACF,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAC1CJ,YAAY,KAAK,EACjB;gBAAEF;YAAG;YAGb,IAAIM,YAAY,MAAM,IAClB,OAAOF,OAAO,IAAI,CAAC,IAAIG,6BAA6BP;YAGxD,MAAMQ,gBAAgBF,YAAY,KAAK;YACvC,MAAMG,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,CAACD;YAE9C,MAAME,UAA2B;gBAC7B,GAAGD,QAAQ;gBACX,kBAAkBR,MAAM,gBAAgB,IAAIQ,SAAS,gBAAgB;gBACrE,QAAQR,MAAM,MAAM,IAAIQ,SAAS,MAAM;gBACvC,SAASR,MAAM,OAAO,IAAIQ,SAAS,OAAO;gBAC1C,gBAAgBR,MAAM,cAAc,IAAIQ,SAAS,cAAc;gBAC/D,cAAcR,MAAM,YAAY,IAAIQ,SAAS,YAAY;gBACzD,gBAAgBR,MAAM,cAAc,IAAIQ,SAAS,cAAc;gBAC/D,cAAcR,MAAM,YAAY,IAAIQ,SAAS,YAAY;YAC7D;YAEA,MAAME,gBAAgB,IAAI,CAAC,WAAW,CAAC,SAAS,CAACD;YAEjD,MAAM,EAAEE,KAAK,EAAE,GACX,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CACpCV,YAAY,KAAK,EACjB;gBAAE,QAAQS;YAAc,GACxBH;YAGR,MAAMK,eAAe,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACX,YAAY,KAAK,EAAEU;YAEjF,IAAIC,aAAa,MAAM,IACnB,OAAOT,OAAO,IAAI,CAACU,wBAAwB,IAAI,CAACD,aAAa,KAAK;YAGtE,OAAOT,OAAO,EAAE,CAACM;QACrB,EAAE,OAAOK,OAAO;YACZ,OAAOX,OAAO,IAAI,CAACU,wBAAwB,IAAI,CAACC;QACpD;IACJ;AACJ;AAEO,MAAMC,kEAAkCC,gCAAAA,oBAA0C,CAAC;IACtF,gBAAgBvB;IAChB,cAAc;QACVwB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js","sources":["../../../../src/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\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 { UpdateEntryDataFactory } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { UpdateEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { WebhookDeliveryTransformer } from \"~/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js\";\nimport { UpdateWebhookDeliveryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport {\n WebhookDeliveryNotFoundError,\n WebhookModelNotFoundError,\n WebhookPersistenceError\n} from \"~/api/domain/errors.js\";\nimport { WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IUpdateDeliveryInput } from \"./abstractions.js\";\nimport type {\n WebhookDelivery,\n WebhookDeliveryCmsEntryValues\n} from \"~/api/domain/WebhookDelivery.js\";\n\nclass UpdateWebhookDeliveryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly updateEntryDataFactory: UpdateEntryDataFactory.Interface,\n private readonly updateEntryRepository: UpdateEntryRepository.Interface,\n private readonly transformer: WebhookDeliveryTransformer.Interface\n ) {}\n\n async execute(\n id: string,\n input: IUpdateDeliveryInput\n ): Promise<Result<WebhookDelivery, RepositoryAbstraction.Error>> {\n try {\n const modelResult = await this.getModelRepository.execute(WEBHOOK_DELIVERY_MODEL_ID);\n if (modelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_DELIVERY_MODEL_ID));\n }\n\n const entryResult =\n await this.getLatestRevisionRepository.execute<WebhookDeliveryCmsEntryValues>(\n modelResult.value,\n { id }\n );\n\n if (entryResult.isFail()) {\n return Result.fail(new WebhookDeliveryNotFoundError(id));\n }\n\n const originalEntry = entryResult.value;\n const existing = this.transformer.fromStorage(originalEntry);\n\n const updated: WebhookDelivery = {\n ...existing,\n backgroundTaskId: input.backgroundTaskId ?? existing.backgroundTaskId,\n status: input.status ?? existing.status,\n payload: input.payload ?? existing.payload,\n requestHeaders: input.requestHeaders ?? existing.requestHeaders,\n responseTime: input.responseTime ?? existing.responseTime,\n responseStatus: input.responseStatus ?? existing.responseStatus,\n responseBody: input.responseBody ?? existing.responseBody\n };\n\n const storageValues = this.transformer.toStorage(updated);\n\n const dataResult =\n await this.updateEntryDataFactory.create<WebhookDeliveryCmsEntryValues>(\n modelResult.value,\n { values: storageValues },\n originalEntry\n );\n if (dataResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(dataResult.error));\n }\n const { entry } = dataResult.value;\n\n const updateResult = await this.updateEntryRepository.execute(modelResult.value, entry);\n\n if (updateResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(updateResult.error));\n }\n\n return Result.ok(updated);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const UpdateWebhookDeliveryRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateWebhookDeliveryRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n UpdateEntryDataFactory,\n UpdateEntryRepository,\n WebhookDeliveryTransformer\n ]\n});\n"],"names":["UpdateWebhookDeliveryRepositoryImpl","getModelRepository","getLatestRevisionRepository","updateEntryDataFactory","updateEntryRepository","transformer","id","input","modelResult","WEBHOOK_DELIVERY_MODEL_ID","Result","WebhookModelNotFoundError","entryResult","WebhookDeliveryNotFoundError","originalEntry","existing","updated","storageValues","dataResult","WebhookPersistenceError","entry","updateResult","error","UpdateWebhookDeliveryRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","UpdateEntryDataFactory","UpdateEntryRepository","WebhookDeliveryTransformer"],"mappings":";;;;;;;;;AAmBA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,sBAAwD,EACxDC,qBAAsD,EACtDC,WAAiD,CACpE;aALmBJ,kBAAkB,GAAlBA;aACAC,2BAA2B,GAA3BA;aACAC,sBAAsB,GAAtBA;aACAC,qBAAqB,G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