@webiny/webhooks 6.4.12-beta.4 → 6.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/features/ListWebhooks/ListWebhooksGateway.js +8 -2
- package/admin/features/ListWebhooks/ListWebhooksGateway.js.map +1 -1
- package/admin/features/ListWebhooks/abstractions.d.ts +1 -0
- package/admin/features/ListWebhooks/abstractions.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.d.ts +2 -2
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.d.ts +2 -2
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js +37 -24
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.d.ts +2 -2
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +3 -3
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.d.ts +1 -1
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js +1 -1
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -1
- package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +2 -2
- package/admin/presentation/WebhookForm/components/WebhookFormView.js +3 -4
- package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -1
- package/admin/presentation/WebhookList/WebhookListDataSource.d.ts +7 -8
- package/admin/presentation/WebhookList/WebhookListDataSource.js +23 -50
- package/admin/presentation/WebhookList/WebhookListDataSource.js.map +1 -1
- package/admin/presentation/WebhookList/components/WebhookListContent.d.ts +2 -2
- package/admin/presentation/WebhookList/components/WebhookListContent.js +1 -1
- package/admin/presentation/WebhookList/components/WebhookListContent.js.map +1 -1
- package/api/features/DeleteWebhook/DeleteWebhookRepository.js +1 -2
- package/api/features/DeleteWebhook/DeleteWebhookRepository.js.map +1 -1
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js +4 -7
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js.map +1 -1
- package/api/features/ListWebhooks/ListWebhooksRepository.js +4 -7
- package/api/features/ListWebhooks/ListWebhooksRepository.js.map +1 -1
- package/api/graphql/WebhookCrudSchema.js +11 -0
- package/api/graphql/WebhookCrudSchema.js.map +1 -1
- package/api/index.js +5 -1
- package/api/index.js.map +1 -1
- package/api/utils/isValidEndpointUrl.js +1 -1
- package/api/utils/isValidEndpointUrl.js.map +1 -1
- package/package.json +25 -25
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
|
|
2
2
|
import { ListWebhooksGateway } from "./abstractions.js";
|
|
3
3
|
const LIST_WEBHOOKS = `
|
|
4
|
-
query ListWebhooks(
|
|
4
|
+
query ListWebhooks(
|
|
5
|
+
$where: ListWebhooksWhereInput
|
|
6
|
+
$sort: [ListWebhooksSort!]
|
|
7
|
+
$limit: Int
|
|
8
|
+
$after: String
|
|
9
|
+
) {
|
|
5
10
|
webhooks {
|
|
6
|
-
listWebhooks(where: $where, limit: $limit, after: $after) {
|
|
11
|
+
listWebhooks(where: $where, sort: $sort, limit: $limit, after: $after) {
|
|
7
12
|
data {
|
|
8
13
|
id
|
|
9
14
|
name
|
|
@@ -39,6 +44,7 @@ class ListWebhooksGraphQLGateway {
|
|
|
39
44
|
query: LIST_WEBHOOKS,
|
|
40
45
|
variables: {
|
|
41
46
|
where: input.where,
|
|
47
|
+
sort: input.sort,
|
|
42
48
|
limit: input.limit,
|
|
43
49
|
after: input.after
|
|
44
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/features/ListWebhooks/ListWebhooksGateway.js","sources":["../../../../src/admin/features/ListWebhooks/ListWebhooksGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport {\n ListWebhooksGateway as GatewayAbstraction,\n type IListWebhooksInput,\n type IListWebhooksOutput\n} from \"./abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nconst LIST_WEBHOOKS = /* GraphQL */ `\n query ListWebhooks($where: ListWebhooksWhereInput
|
|
1
|
+
{"version":3,"file":"admin/features/ListWebhooks/ListWebhooksGateway.js","sources":["../../../../src/admin/features/ListWebhooks/ListWebhooksGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport {\n ListWebhooksGateway as GatewayAbstraction,\n type IListWebhooksInput,\n type IListWebhooksOutput\n} from \"./abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nconst LIST_WEBHOOKS = /* GraphQL */ `\n query ListWebhooks(\n $where: ListWebhooksWhereInput\n $sort: [ListWebhooksSort!]\n $limit: Int\n $after: String\n ) {\n webhooks {\n listWebhooks(where: $where, sort: $sort, limit: $limit, after: $after) {\n data {\n id\n name\n slug\n endpointUrl\n description\n enabled\n events\n signingSecret\n createdOn\n modifiedOn\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n\ntype ListWebhooksResponse = {\n webhooks: {\n listWebhooks:\n | {\n data: Webhook[];\n meta: { cursor: string | null; hasMoreItems: boolean; totalCount: number };\n error: null;\n }\n | {\n data: null;\n meta: null;\n error: { code: string; message: string; data: unknown };\n };\n };\n};\n\nclass ListWebhooksGraphQLGateway implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(input: IListWebhooksInput): Promise<IListWebhooksOutput> {\n const response = await this.client.execute<ListWebhooksResponse>({\n query: LIST_WEBHOOKS,\n variables: {\n where: input.where,\n sort: input.sort,\n limit: input.limit,\n after: input.after\n }\n });\n\n const envelope = response.webhooks.listWebhooks;\n if (envelope.error) {\n throw new Error(envelope.error.message);\n }\n\n return {\n items: envelope.data,\n meta: envelope.meta\n };\n }\n}\n\nexport const ListWebhooksGateway = GatewayAbstraction.createImplementation({\n implementation: ListWebhooksGraphQLGateway,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["LIST_WEBHOOKS","ListWebhooksGraphQLGateway","client","input","response","envelope","Error","ListWebhooksGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAQA,MAAMA,gBAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCrC,CAAC;AAkBD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,KAAyB,EAAgC;QACnE,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAuB;YAC7D,OAAOJ;YACP,WAAW;gBACP,OAAOG,MAAM,KAAK;gBAClB,MAAMA,MAAM,IAAI;gBAChB,OAAOA,MAAM,KAAK;gBAClB,OAAOA,MAAM,KAAK;YACtB;QACJ;QAEA,MAAME,WAAWD,SAAS,QAAQ,CAAC,YAAY;QAC/C,IAAIC,SAAS,KAAK,EACd,MAAM,IAAIC,MAAMD,SAAS,KAAK,CAAC,OAAO;QAG1C,OAAO;YACH,OAAOA,SAAS,IAAI;YACpB,MAAMA,SAAS,IAAI;QACvB;IACJ;AACJ;AAEO,MAAME,0CAAsBC,oBAAAA,oBAAuC,CAAC;IACvE,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/features/ListWebhooks/abstractions.js","sources":["../../../../src/admin/features/ListWebhooks/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface IListWebhooksInput {\n where?: Record<string, unknown>;\n limit?: number;\n after?: string;\n}\n\nexport interface IListWebhooksMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\nexport interface IListWebhooksOutput {\n items: Webhook[];\n meta: IListWebhooksMeta;\n}\n\nexport interface IListWebhooksGateway {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksGateway = createAbstraction<IListWebhooksGateway>(\"ListWebhooksGateway\");\n\nexport namespace ListWebhooksGateway {\n export type Interface = IListWebhooksGateway;\n}\n\nexport interface IListWebhooksRepository {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksRepository =\n createAbstraction<IListWebhooksRepository>(\"ListWebhooksRepository\");\n\nexport namespace ListWebhooksRepository {\n export type Interface = IListWebhooksRepository;\n}\n\nexport interface IListWebhooksUseCase {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksUseCase = createAbstraction<IListWebhooksUseCase>(\"ListWebhooksUseCase\");\n\nexport namespace ListWebhooksUseCase {\n export type Interface = IListWebhooksUseCase;\n}\n"],"names":["ListWebhooksGateway","createAbstraction","ListWebhooksRepository","ListWebhooksUseCase"],"mappings":";
|
|
1
|
+
{"version":3,"file":"admin/features/ListWebhooks/abstractions.js","sources":["../../../../src/admin/features/ListWebhooks/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface IListWebhooksInput {\n where?: Record<string, unknown>;\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport interface IListWebhooksMeta {\n cursor: string | null;\n hasMoreItems: boolean;\n totalCount: number;\n}\n\nexport interface IListWebhooksOutput {\n items: Webhook[];\n meta: IListWebhooksMeta;\n}\n\nexport interface IListWebhooksGateway {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksGateway = createAbstraction<IListWebhooksGateway>(\"ListWebhooksGateway\");\n\nexport namespace ListWebhooksGateway {\n export type Interface = IListWebhooksGateway;\n}\n\nexport interface IListWebhooksRepository {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksRepository =\n createAbstraction<IListWebhooksRepository>(\"ListWebhooksRepository\");\n\nexport namespace ListWebhooksRepository {\n export type Interface = IListWebhooksRepository;\n}\n\nexport interface IListWebhooksUseCase {\n execute(input: IListWebhooksInput): Promise<IListWebhooksOutput>;\n}\n\nexport const ListWebhooksUseCase = createAbstraction<IListWebhooksUseCase>(\"ListWebhooksUseCase\");\n\nexport namespace ListWebhooksUseCase {\n export type Interface = IListWebhooksUseCase;\n}\n"],"names":["ListWebhooksGateway","createAbstraction","ListWebhooksRepository","ListWebhooksUseCase"],"mappings":";AAyBO,MAAMA,sBAAsBC,kBAAwC;AAUpE,MAAMC,yBACTD,kBAA2C;AAUxC,MAAME,sBAAsBF,kBAAwC"}
|
|
@@ -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
|
-
|
|
6
|
+
export declare const DeliveryBottomInfoBar: (({ presenter }: DeliveryBottomInfoBarProps) => React.JSX.Element | null) & {
|
|
7
|
+
displayName: string;
|
|
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
|
-
|
|
6
|
+
export declare const DeliveryFilters: (({ presenter }: DeliveryFiltersProps) => React.JSX.Element) & {
|
|
7
|
+
displayName: string;
|
|
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 {
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
})
|
|
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
|
-
})
|
|
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
|
-
})
|
|
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
|
-
})
|
|
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
|
-
}))
|
|
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 {
|
|
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
|
-
|
|
6
|
+
export declare const DeliveryList: (({ presenter }: DeliveryListProps) => React.JSX.Element) & {
|
|
7
|
+
displayName: string;
|
|
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(
|
|
47
|
-
className: "
|
|
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 <
|
|
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":";;;;;;;;;;;;;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,oBAAC;QAAI,WAAU;qBACX,oBAACC,iBAAeA;QAAC,WAAWZ;sBAC5B,oBAACa,0BAAwBA,SAAAA,WAAAA,GAGjC,oBAACC,WAASA,OACTN,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 +1 @@
|
|
|
1
|
-
export declare const statusVariant: (status: string) => "
|
|
1
|
+
export declare const statusVariant: (status: string) => "destructive" | "success" | "warning";
|
|
@@ -46,7 +46,7 @@ class WebhookFormPresenterImpl {
|
|
|
46
46
|
return this.formModelFactory.create({
|
|
47
47
|
fields: (fields)=>({
|
|
48
48
|
name: fields.text().label("Name").required("Name is required"),
|
|
49
|
-
slug: fields.text().label("Slug").required("Slug is required").computedUntilDirty((form)=>{
|
|
49
|
+
slug: fields.text().label("Slug").required("Slug is required").computedUntilDirty(({ form })=>{
|
|
50
50
|
const name = String(form.field("name").getValue() ?? "");
|
|
51
51
|
return name.trim().toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-");
|
|
52
52
|
}).schema(z.string().min(3, "Slug must be at least 3 characters long")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/WebhookFormPresenter.js","sources":["../../../../src/admin/presentation/WebhookForm/WebhookFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { WebhookEvent } from \"~/admin/shared/types.js\";\nimport {\n WebhookFormPresenter as Abstraction,\n type IWebhookFormPresenter,\n type IWebhookFormViewModel\n} from \"./abstractions.js\";\nimport { GetWebhookUseCase } from \"~/admin/features/getWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/admin/features/createWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/admin/features/updateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { ListAvailableEventsUseCase } from \"~/admin/features/listAvailableEvents/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\nimport {\n FormModelFactory,\n type IFormModel,\n type ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nclass WebhookFormPresenterImpl implements IWebhookFormPresenter {\n private _loading = false;\n private _saving = false;\n private _isNew = false;\n private _webhook: Webhook | null = null;\n private _webhookId: string | null = null;\n private _form: IFormModel;\n private _entityFieldNames: string[] = [];\n private _entityGroups: Map<string, Map<string, WebhookEvent[]>> = new Map();\n\n public get vm(): IWebhookFormViewModel {\n return {\n loading: this._loading,\n saving: this._saving,\n isNew: this._isNew,\n webhook: this._webhook,\n permissions: {\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n },\n form: this._form.vm\n };\n }\n\n public constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly getWebhookUseCase: GetWebhookUseCase.Interface,\n private readonly createWebhookUseCase: CreateWebhookUseCase.Interface,\n private readonly updateWebhookUseCase: UpdateWebhookUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly listAvailableEventsUseCase: ListAvailableEventsUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n this._form = this.buildForm();\n\n makeAutoObservable(this, { vm: computed });\n }\n\n private buildForm(): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required\"),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required\")\n .computedUntilDirty(form => {\n const name = String(form.field(\"name\").getValue() ?? \"\");\n return name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n })\n .schema(z.string().min(3, \"Slug must be at least 3 characters long\")),\n endpointUrl: fields\n .text()\n .label(\"Endpoint URL\")\n .required(\"Endpoint URL is required\")\n .placeholder(\"https://\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\"),\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false)\n }),\n layout: layout => [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ]\n });\n }\n\n private entityFieldName(appLabel: string, entityLabel: string): string {\n const slug = `${appLabel}_${entityLabel}`\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return `events_${slug}`;\n }\n\n private addEventFields(events: WebhookEvent[]): void {\n const grouped = new Map<string, Map<string, WebhookEvent[]>>();\n for (const event of events) {\n let appMap = grouped.get(event.appLabel);\n if (!appMap) {\n appMap = new Map();\n grouped.set(event.appLabel, appMap);\n }\n const existing = appMap.get(event.entityLabel) ?? [];\n existing.push(event);\n appMap.set(event.entityLabel, existing);\n }\n\n this._entityGroups = grouped;\n this._entityFieldNames = [];\n\n this._form.fields(fields => {\n const result: Record<string, ReturnType<typeof fields.object>> = {};\n\n for (const [appLabel, entities] of grouped) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n this._entityFieldNames.push(fieldName);\n\n result[fieldName] = fields\n .object()\n .label(entityLabel)\n .renderer(\"objectAccordionSingle\", { open: false })\n .fields(f => {\n return {\n selected: f\n .text()\n .list()\n .options(\n entityEvents.map(e => ({\n label: e.label,\n value: e.eventName\n }))\n )\n .renderer(\"checkboxes\")\n };\n });\n }\n }\n\n return result;\n });\n\n this._form.setLayout(layout => {\n const rows: ILayoutNodeBuilder[] = [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ];\n\n for (const [appLabel, entities] of grouped) {\n rows.push(layout.separator());\n rows.push(layout.element(\"sectionHeading\", { label: appLabel }));\n\n for (const [entityLabel] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n rows.push(layout.object(fieldName, inner => [inner.row(\"selected\")]));\n }\n }\n\n return rows;\n });\n\n this._form.addRule(form => {\n if (this._entityFieldNames.length === 0) {\n return [];\n }\n for (const fieldName of this._entityFieldNames) {\n const objectField = form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n return [];\n }\n }\n\n return [{ path: \"Events\", message: \"At least one event must be selected.\" }];\n });\n }\n\n private collectEvents(): string[] {\n const allEvents: string[] = [];\n\n for (const fieldName of this._entityFieldNames) {\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n allEvents.push(...values);\n }\n }\n\n return allEvents;\n }\n\n private distributeEvents(webhookEvents: string[]): void {\n const eventSet = new Set(webhookEvents);\n\n for (const [appLabel, entities] of this._entityGroups) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n\n const selected = entityEvents\n .filter(e => eventSet.has(e.eventName))\n .map(e => e.eventName);\n selectedField.setValue(selected);\n }\n }\n }\n\n public async save(): Promise<boolean> {\n const data = await this._form.submit<Record<string, unknown>>();\n if (data === false) {\n return false;\n }\n\n runInAction(() => {\n this._saving = true;\n });\n\n try {\n const merged = {\n name: data.name as string,\n slug: data.slug as string,\n endpointUrl: data.endpointUrl as string,\n description: (data.description as string) || undefined,\n enabled: data.enabled as boolean,\n events: this.collectEvents()\n };\n\n if (this._isNew) {\n const created = await this.createWebhookUseCase.execute(merged);\n\n runInAction(() => {\n this._webhook = created;\n this._webhookId = created.id;\n this._isNew = false;\n this._form.field(\"slug\").setDisabled(true);\n });\n } else {\n const updated = await this.updateWebhookUseCase.execute(this._webhookId!, merged);\n\n runInAction(() => {\n this._webhook = updated;\n });\n }\n } finally {\n runInAction(() => {\n this._saving = false;\n });\n }\n\n return true;\n }\n\n public async deleteWebhook(): Promise<void> {\n if (!this._webhookId || this._isNew) {\n return;\n }\n await this.deleteWebhookUseCase.execute(this._webhookId);\n }\n\n public async init(id: string): Promise<void> {\n this._loading = true;\n this._isNew = id === \"new\";\n this._webhookId = id === \"new\" ? null : id;\n\n const eventsPromise = this.listAvailableEventsUseCase.execute();\n\n if (!this._isNew) {\n const [webhook, events] = await Promise.all([\n this.getWebhookUseCase.execute(id),\n eventsPromise\n ]);\n\n runInAction(() => {\n this._webhook = webhook;\n this._form = this.buildForm();\n this.addEventFields(events);\n this._form.setData({\n name: webhook.name,\n slug: webhook.slug,\n endpointUrl: webhook.endpointUrl,\n description: webhook.description ?? \"\",\n enabled: webhook.enabled\n });\n this._form.field(\"slug\").setDisabled(true);\n this.distributeEvents(webhook.events);\n this._loading = false;\n });\n } else {\n const events = await eventsPromise;\n\n runInAction(() => {\n this._form = this.buildForm();\n this.addEventFields(events);\n this._loading = false;\n });\n }\n }\n}\n\nexport const WebhookFormPresenter = Abstraction.createImplementation({\n implementation: WebhookFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n GetWebhookUseCase,\n CreateWebhookUseCase,\n UpdateWebhookUseCase,\n DeleteWebhookUseCase,\n ListAvailableEventsUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookFormPresenterImpl","formModelFactory","getWebhookUseCase","createWebhookUseCase","updateWebhookUseCase","deleteWebhookUseCase","listAvailableEventsUseCase","permissions","Map","makeAutoObservable","computed","fields","form","name","String","z","layout","appLabel","entityLabel","slug","events","grouped","event","appMap","existing","result","entities","entityEvents","fieldName","f","e","rows","inner","objectField","selectedField","values","allEvents","webhookEvents","eventSet","Set","selected","data","runInAction","merged","undefined","created","updated","id","eventsPromise","webhook","Promise","WebhookFormPresenter","Abstraction","FormModelFactory","GetWebhookUseCase","CreateWebhookUseCase","UpdateWebhookUseCase","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;;AAqBA,MAAMA;IAUF,IAAW,KAA4B;QACnC,OAAO;YACH,SAAS,IAAI,CAAC,QAAQ;YACtB,QAAQ,IAAI,CAAC,OAAO;YACpB,OAAO,IAAI,CAAC,MAAM;YAClB,SAAS,IAAI,CAAC,QAAQ;YACtB,aAAa;gBACT,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAClC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YAC1C;YACA,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE;QACvB;IACJ;IAEA,YACqBC,gBAA4C,EAC5CC,iBAA8C,EAC9CC,oBAAoD,EACpDC,oBAAoD,EACpDC,oBAAoD,EACpDC,0BAAgE,EAChEC,WAAyC,CAC5D;aAPmBN,gBAAgB,GAAhBA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,oBAAoB,GAApBA;aACAC,oBAAoB,GAApBA;aACAC,0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,CAAC;oBACf,MAAM6B,QAAQ,IAAI;oBAClB,MAAMA,QAAQ,IAAI;oBAClB,aAAaA,QAAQ,WAAW;oBAChC,aAAaA,QAAQ,WAAW,IAAI;oBACpC,SAASA,QAAQ,OAAO;gBAC5B;gBACA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,CAAC;gBACrC,IAAI,CAAC,gBAAgB,CAACA,QAAQ,MAAM;gBACpC,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ;IASJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBpD;IAChB,cAAc;QACVqD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/WebhookFormPresenter.js","sources":["../../../../src/admin/presentation/WebhookForm/WebhookFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { WebhookEvent } from \"~/admin/shared/types.js\";\nimport {\n WebhookFormPresenter as Abstraction,\n type IWebhookFormPresenter,\n type IWebhookFormViewModel\n} from \"./abstractions.js\";\nimport { GetWebhookUseCase } from \"~/admin/features/getWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/admin/features/createWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/admin/features/updateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { ListAvailableEventsUseCase } from \"~/admin/features/listAvailableEvents/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\nimport {\n FormModelFactory,\n type IFormModel,\n type ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nclass WebhookFormPresenterImpl implements IWebhookFormPresenter {\n private _loading = false;\n private _saving = false;\n private _isNew = false;\n private _webhook: Webhook | null = null;\n private _webhookId: string | null = null;\n private _form: IFormModel;\n private _entityFieldNames: string[] = [];\n private _entityGroups: Map<string, Map<string, WebhookEvent[]>> = new Map();\n\n public get vm(): IWebhookFormViewModel {\n return {\n loading: this._loading,\n saving: this._saving,\n isNew: this._isNew,\n webhook: this._webhook,\n permissions: {\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n },\n form: this._form.vm\n };\n }\n\n public constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly getWebhookUseCase: GetWebhookUseCase.Interface,\n private readonly createWebhookUseCase: CreateWebhookUseCase.Interface,\n private readonly updateWebhookUseCase: UpdateWebhookUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly listAvailableEventsUseCase: ListAvailableEventsUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n this._form = this.buildForm();\n\n makeAutoObservable(this, { vm: computed });\n }\n\n private buildForm(): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required\"),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required\")\n .computedUntilDirty(({ form }) => {\n const name = String(form.field(\"name\").getValue() ?? \"\");\n return name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n })\n .schema(z.string().min(3, \"Slug must be at least 3 characters long\")),\n endpointUrl: fields\n .text()\n .label(\"Endpoint URL\")\n .required(\"Endpoint URL is required\")\n .placeholder(\"https://\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\"),\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false)\n }),\n layout: layout => [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ]\n });\n }\n\n private entityFieldName(appLabel: string, entityLabel: string): string {\n const slug = `${appLabel}_${entityLabel}`\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return `events_${slug}`;\n }\n\n private addEventFields(events: WebhookEvent[]): void {\n const grouped = new Map<string, Map<string, WebhookEvent[]>>();\n for (const event of events) {\n let appMap = grouped.get(event.appLabel);\n if (!appMap) {\n appMap = new Map();\n grouped.set(event.appLabel, appMap);\n }\n const existing = appMap.get(event.entityLabel) ?? [];\n existing.push(event);\n appMap.set(event.entityLabel, existing);\n }\n\n this._entityGroups = grouped;\n this._entityFieldNames = [];\n\n this._form.fields(fields => {\n const result: Record<string, ReturnType<typeof fields.object>> = {};\n\n for (const [appLabel, entities] of grouped) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n this._entityFieldNames.push(fieldName);\n\n result[fieldName] = fields\n .object()\n .label(entityLabel)\n .renderer(\"objectAccordionSingle\", { open: false })\n .fields(f => {\n return {\n selected: f\n .text()\n .list()\n .options(\n entityEvents.map(e => ({\n label: e.label,\n value: e.eventName\n }))\n )\n .renderer(\"checkboxes\")\n };\n });\n }\n }\n\n return result;\n });\n\n this._form.setLayout(layout => {\n const rows: ILayoutNodeBuilder[] = [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ];\n\n for (const [appLabel, entities] of grouped) {\n rows.push(layout.separator());\n rows.push(layout.element(\"sectionHeading\", { label: appLabel }));\n\n for (const [entityLabel] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n rows.push(layout.object(fieldName, inner => [inner.row(\"selected\")]));\n }\n }\n\n return rows;\n });\n\n this._form.addRule(form => {\n if (this._entityFieldNames.length === 0) {\n return [];\n }\n for (const fieldName of this._entityFieldNames) {\n const objectField = form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n return [];\n }\n }\n\n return [{ path: \"Events\", message: \"At least one event must be selected.\" }];\n });\n }\n\n private collectEvents(): string[] {\n const allEvents: string[] = [];\n\n for (const fieldName of this._entityFieldNames) {\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n allEvents.push(...values);\n }\n }\n\n return allEvents;\n }\n\n private distributeEvents(webhookEvents: string[]): void {\n const eventSet = new Set(webhookEvents);\n\n for (const [appLabel, entities] of this._entityGroups) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n\n const selected = entityEvents\n .filter(e => eventSet.has(e.eventName))\n .map(e => e.eventName);\n selectedField.setValue(selected);\n }\n }\n }\n\n public async save(): Promise<boolean> {\n const data = await this._form.submit<Record<string, unknown>>();\n if (data === false) {\n return false;\n }\n\n runInAction(() => {\n this._saving = true;\n });\n\n try {\n const merged = {\n name: data.name as string,\n slug: data.slug as string,\n endpointUrl: data.endpointUrl as string,\n description: (data.description as string) || undefined,\n enabled: data.enabled as boolean,\n events: this.collectEvents()\n };\n\n if (this._isNew) {\n const created = await this.createWebhookUseCase.execute(merged);\n\n runInAction(() => {\n this._webhook = created;\n this._webhookId = created.id;\n this._isNew = false;\n this._form.field(\"slug\").setDisabled(true);\n });\n } else {\n const updated = await this.updateWebhookUseCase.execute(this._webhookId!, merged);\n\n runInAction(() => {\n this._webhook = updated;\n });\n }\n } finally {\n runInAction(() => {\n this._saving = false;\n });\n }\n\n return true;\n }\n\n public async deleteWebhook(): Promise<void> {\n if (!this._webhookId || this._isNew) {\n return;\n }\n await this.deleteWebhookUseCase.execute(this._webhookId);\n }\n\n public async init(id: string): Promise<void> {\n this._loading = true;\n this._isNew = id === \"new\";\n this._webhookId = id === \"new\" ? null : id;\n\n const eventsPromise = this.listAvailableEventsUseCase.execute();\n\n if (!this._isNew) {\n const [webhook, events] = await Promise.all([\n this.getWebhookUseCase.execute(id),\n eventsPromise\n ]);\n\n runInAction(() => {\n this._webhook = webhook;\n this._form = this.buildForm();\n this.addEventFields(events);\n this._form.setData({\n name: webhook.name,\n slug: webhook.slug,\n endpointUrl: webhook.endpointUrl,\n description: webhook.description ?? \"\",\n enabled: webhook.enabled\n });\n this._form.field(\"slug\").setDisabled(true);\n this.distributeEvents(webhook.events);\n this._loading = false;\n });\n } else {\n const events = await eventsPromise;\n\n runInAction(() => {\n this._form = this.buildForm();\n this.addEventFields(events);\n this._loading = false;\n });\n }\n }\n}\n\nexport const WebhookFormPresenter = Abstraction.createImplementation({\n implementation: WebhookFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n GetWebhookUseCase,\n CreateWebhookUseCase,\n UpdateWebhookUseCase,\n DeleteWebhookUseCase,\n ListAvailableEventsUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookFormPresenterImpl","formModelFactory","getWebhookUseCase","createWebhookUseCase","updateWebhookUseCase","deleteWebhookUseCase","listAvailableEventsUseCase","permissions","Map","makeAutoObservable","computed","fields","form","name","String","z","layout","appLabel","entityLabel","slug","events","grouped","event","appMap","existing","result","entities","entityEvents","fieldName","f","e","rows","inner","objectField","selectedField","values","allEvents","webhookEvents","eventSet","Set","selected","data","runInAction","merged","undefined","created","updated","id","eventsPromise","webhook","Promise","WebhookFormPresenter","Abstraction","FormModelFactory","GetWebhookUseCase","CreateWebhookUseCase","UpdateWebhookUseCase","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;;AAqBA,MAAMA;IAUF,IAAW,KAA4B;QACnC,OAAO;YACH,SAAS,IAAI,CAAC,QAAQ;YACtB,QAAQ,IAAI,CAAC,OAAO;YACpB,OAAO,IAAI,CAAC,MAAM;YAClB,SAAS,IAAI,CAAC,QAAQ;YACtB,aAAa;gBACT,SAA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KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,cAAc,CAACtB;gBACpB,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ,OA7BkB;YACd,MAAM,CAAC6B,SAAS7B,OAAO,GAAG,MAAM8B,QAAQ,GAAG,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACH;gBAC/BC;aACH;YAEDN,YAAY;gBACR,IAAI,CAAC,QAAQ,GAAGO;gBAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,cAAc,CAAC7B;gBACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;oBACf,MAAM6B,QAAQ,IAAI;oBAClB,MAAMA,QAAQ,IAAI;oBAClB,aAAaA,QAAQ,WAAW;oBAChC,aAAaA,QAAQ,WAAW,IAAI;oBACpC,SAASA,QAAQ,OAAO;gBAC5B;gBACA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,CAAC;gBACrC,IAAI,CAAC,gBAAgB,CAACA,QAAQ,MAAM;gBACpC,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ;IASJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBpD;IAChB,cAAc;QACVqD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -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
|
-
|
|
6
|
+
export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & {
|
|
7
|
+
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
|
@@ -48,11 +48,10 @@ const WebhookFormView_WebhookFormViewInner = observer(function() {
|
|
|
48
48
|
text: "Loading..."
|
|
49
49
|
}) : null, vm.saving ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
50
50
|
text: "Saving..."
|
|
51
|
-
}) : null,
|
|
51
|
+
}) : null, /*#__PURE__*/ react.createElement(FormErrors, {
|
|
52
|
+
form: vm.form,
|
|
52
53
|
className: "mb-lg"
|
|
53
|
-
}, /*#__PURE__*/ react.createElement(
|
|
54
|
-
form: vm.form
|
|
55
|
-
})) : null, /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
54
|
+
}), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
56
55
|
title: vm.isNew ? "Create Webhook" : vm.webhook?.name ?? "Edit Webhook"
|
|
57
56
|
}), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(FormView, {
|
|
58
57
|
name: "Webhook",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/components/WebhookFormView.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/WebhookFormView.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport {\n FormErrors,\n useRouter,\n useFieldRenderers,\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent,\n SimpleFormFooter,\n FormView\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { WebhookFormPresenterFeature } from \"../feature.js\";\nimport { GetWebhookFeature } from \"~/admin/features/getWebhook/feature.js\";\nimport { CreateWebhookFeature } from \"~/admin/features/createWebhook/feature.js\";\nimport { UpdateWebhookFeature } from \"~/admin/features/updateWebhook/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { SigningSecret } from \"./SigningSecret.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\n\nconst SectionHeading = ({ field }: { field: any }) => {\n return <span className=\"text-md font-semibold\">{String(field.label ?? \"\")}</span>;\n};\n\nconst WebhookFormViewInner = observer(function WebhookFormViewInner() {\n const { presenter } = useFeature(WebhookFormPresenterFeature);\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Form);\n const toast = useToast();\n const id = route.params.id;\n const defaultRenderers = useFieldRenderers();\n\n const renderers = useMemo(() => {\n return {\n ...defaultRenderers,\n \"element:sectionHeading\": SectionHeading\n };\n }, [defaultRenderers]);\n\n useEffect(() => {\n void presenter.init(id);\n }, [presenter, id]);\n\n const saveForm = useCallback(async () => {\n const res = await presenter.save();\n if (res) {\n toast.showSuccessToast({ title: \"Webhook saved successfully!\" });\n }\n }, [presenter]);\n\n const { vm } = presenter;\n\n return (\n <SimpleForm>\n {vm.loading ? <OverlayLoader text={\"Loading...\"} /> : null}\n {vm.saving ? <OverlayLoader text={\"Saving...\"} /> : null}\n {vm.form
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/components/WebhookFormView.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/WebhookFormView.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport {\n FormErrors,\n useRouter,\n useFieldRenderers,\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent,\n SimpleFormFooter,\n FormView\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { WebhookFormPresenterFeature } from \"../feature.js\";\nimport { GetWebhookFeature } from \"~/admin/features/getWebhook/feature.js\";\nimport { CreateWebhookFeature } from \"~/admin/features/createWebhook/feature.js\";\nimport { UpdateWebhookFeature } from \"~/admin/features/updateWebhook/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { SigningSecret } from \"./SigningSecret.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\n\nconst SectionHeading = ({ field }: { field: any }) => {\n return <span className=\"text-md font-semibold\">{String(field.label ?? \"\")}</span>;\n};\n\nconst WebhookFormViewInner = observer(function WebhookFormViewInner() {\n const { presenter } = useFeature(WebhookFormPresenterFeature);\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Form);\n const toast = useToast();\n const id = route.params.id;\n const defaultRenderers = useFieldRenderers();\n\n const renderers = useMemo(() => {\n return {\n ...defaultRenderers,\n \"element:sectionHeading\": SectionHeading\n };\n }, [defaultRenderers]);\n\n useEffect(() => {\n void presenter.init(id);\n }, [presenter, id]);\n\n const saveForm = useCallback(async () => {\n const res = await presenter.save();\n if (res) {\n toast.showSuccessToast({ title: \"Webhook saved successfully!\" });\n }\n }, [presenter]);\n\n const { vm } = presenter;\n\n return (\n <SimpleForm>\n {vm.loading ? <OverlayLoader text={\"Loading...\"} /> : null}\n {vm.saving ? <OverlayLoader text={\"Saving...\"} /> : null}\n <FormErrors form={vm.form} className={\"mb-lg\"} />\n <SimpleFormHeader\n title={vm.isNew ? \"Create Webhook\" : (vm.webhook?.name ?? \"Edit Webhook\")}\n />\n <SimpleFormContent>\n <FormView name=\"Webhook\" form={vm.form} renderers={renderers} />\n <SigningSecret presenter={presenter} />\n </SimpleFormContent>\n <SimpleFormFooter className={\"border-t-sm border-t-neutral-dimmed pt-lg\"}>\n <Button variant=\"secondary\" onClick={() => goToRoute(Routes.List)}>\n Cancel\n </Button>\n <HasPermission entity=\"webhook\" action=\"edit\">\n <Button variant=\"primary\" onClick={saveForm} disabled={vm.saving}>\n {vm.saving ? \"Saving...\" : \"Save\"}\n </Button>\n </HasPermission>\n </SimpleFormFooter>\n </SimpleForm>\n );\n});\n\nexport const WebhookFormView = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n GetWebhookFeature.register(child);\n CreateWebhookFeature.register(child);\n UpdateWebhookFeature.register(child);\n DeleteWebhookFeature.register(child);\n ListAvailableEventsFeature.register(child);\n WebhookPermissionsFeature.register(child);\n WebhookFormPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookFormViewInner />\n </DiContainerProvider>\n );\n};\n"],"names":["SectionHeading","field","String","WebhookFormViewInner","observer","presenter","useFeature","WebhookFormPresenterFeature","goToRoute","useRouter","route","useRoute","Routes","toast","useToast","id","defaultRenderers","useFieldRenderers","renderers","useMemo","useEffect","saveForm","useCallback","res","vm","SimpleForm","OverlayLoader","FormErrors","SimpleFormHeader","SimpleFormContent","FormView","SigningSecret","SimpleFormFooter","Button","HasPermission","WebhookFormView","container","useContainer","scopedContainer","child","GetWebhookFeature","CreateWebhookFeature","UpdateWebhookFeature","DeleteWebhookFeature","ListAvailableEventsFeature","WebhookPermissionsFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAMA,iBAAiB,CAAC,EAAEC,KAAK,EAAkB,GACtC,WAAP,GAAO,oBAAC;QAAK,WAAU;OAAyBC,OAAOD,MAAM,KAAK,IAAI;AAG1E,MAAME,uCAAuBC,SAAS;IAClC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,IAAI;IACtC,MAAMC,QAAQC;IACd,MAAMC,KAAKL,MAAM,MAAM,CAAC,EAAE;IAC1B,M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oBAAoB;QAC5CI,kBAAkB,QAAQ,CAACD;QAC3BE,qBAAqB,QAAQ,CAACF;QAC9BG,qBAAqB,QAAQ,CAACH;QAC9BI,qBAAqB,QAAQ,CAACJ;QAC9BK,2BAA2B,QAAQ,CAACL;QACpCM,0BAA0B,QAAQ,CAACN;QACnChC,4BAA4B,QAAQ,CAACgC;QACrC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACO,qBAAmBA;QAAC,WAAWR;qBAC5B,oBAACnC,sCAAoBA;AAGjC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
|
|
2
|
+
import type { FetchResult } from "@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js";
|
|
3
|
+
import type { IDataSourceQuery } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
|
|
2
4
|
import type { Webhook } from "../../../admin/shared/types.js";
|
|
3
5
|
import type { IListWebhooksUseCase } from "../../../admin/features/ListWebhooks/abstractions.js";
|
|
4
|
-
export declare class WebhookListDataSource
|
|
6
|
+
export declare class WebhookListDataSource extends SimpleDataSource<Webhook> {
|
|
5
7
|
private readonly listWebhooksUseCase;
|
|
6
8
|
private _rows;
|
|
7
|
-
private _meta;
|
|
8
|
-
private _loading;
|
|
9
9
|
constructor(listWebhooksUseCase: IListWebhooksUseCase);
|
|
10
10
|
get rows(): Webhook[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
loadMore(params: IDataSourceQuery): Promise<void>;
|
|
11
|
+
fetch(params: IDataSourceQuery): Promise<FetchResult<Webhook>>;
|
|
12
|
+
onQueryResult(data: Webhook[]): void;
|
|
13
|
+
onLoadMoreResult(data: Webhook[]): void;
|
|
15
14
|
}
|
|
@@ -1,65 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { makeObservable, observable } from "mobx";
|
|
2
|
+
import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
|
|
3
|
+
class WebhookListDataSource extends SimpleDataSource {
|
|
3
4
|
constructor(listWebhooksUseCase){
|
|
4
|
-
this.listWebhooksUseCase = listWebhooksUseCase;
|
|
5
|
-
this
|
|
6
|
-
|
|
7
|
-
cursor: null,
|
|
8
|
-
hasMoreItems: false,
|
|
9
|
-
totalCount: 0
|
|
10
|
-
};
|
|
11
|
-
this._loading = false;
|
|
12
|
-
makeAutoObservable(this, {
|
|
13
|
-
listWebhooksUseCase: false,
|
|
14
|
-
rows: computed
|
|
5
|
+
super(), this.listWebhooksUseCase = listWebhooksUseCase, this._rows = [];
|
|
6
|
+
makeObservable(this, {
|
|
7
|
+
_rows: observable
|
|
15
8
|
});
|
|
16
9
|
}
|
|
17
10
|
get rows() {
|
|
18
11
|
return this._rows;
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return this._loading;
|
|
25
|
-
}
|
|
26
|
-
async query(params) {
|
|
27
|
-
this._loading = true;
|
|
13
|
+
async fetch(params) {
|
|
14
|
+
const sort = params.sort ? [
|
|
15
|
+
`${params.sort.field}_${params.sort.direction}`
|
|
16
|
+
] : void 0;
|
|
28
17
|
const result = await this.listWebhooksUseCase.execute({
|
|
29
18
|
where: params.filters,
|
|
19
|
+
sort,
|
|
30
20
|
limit: params.limit,
|
|
31
21
|
after: params.cursor
|
|
32
22
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
hasMoreItems: result.meta.hasMoreItems,
|
|
38
|
-
totalCount: result.meta.totalCount
|
|
39
|
-
};
|
|
40
|
-
this._loading = false;
|
|
41
|
-
});
|
|
23
|
+
return {
|
|
24
|
+
data: result.items,
|
|
25
|
+
meta: result.meta
|
|
26
|
+
};
|
|
42
27
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
runInAction(()=>{
|
|
52
|
-
this._rows = [
|
|
53
|
-
...this._rows,
|
|
54
|
-
...result.items
|
|
55
|
-
];
|
|
56
|
-
this._meta = {
|
|
57
|
-
cursor: result.meta.cursor,
|
|
58
|
-
hasMoreItems: result.meta.hasMoreItems,
|
|
59
|
-
totalCount: result.meta.totalCount
|
|
60
|
-
};
|
|
61
|
-
this._loading = false;
|
|
62
|
-
});
|
|
28
|
+
onQueryResult(data) {
|
|
29
|
+
this._rows = data;
|
|
30
|
+
}
|
|
31
|
+
onLoadMoreResult(data) {
|
|
32
|
+
this._rows = [
|
|
33
|
+
...this._rows,
|
|
34
|
+
...data
|
|
35
|
+
];
|
|
63
36
|
}
|
|
64
37
|
}
|
|
65
38
|
export { WebhookListDataSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookList/WebhookListDataSource.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListDataSource.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookList/WebhookListDataSource.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListDataSource.ts"],"sourcesContent":["import { makeObservable, observable } from \"mobx\";\nimport { SimpleDataSource } from \"@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js\";\nimport type { FetchResult } from \"@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js\";\nimport type { IDataSourceQuery } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IListWebhooksUseCase } from \"~/admin/features/ListWebhooks/abstractions.js\";\n\nexport class WebhookListDataSource extends SimpleDataSource<Webhook> {\n private _rows: Webhook[] = [];\n\n constructor(private readonly listWebhooksUseCase: IListWebhooksUseCase) {\n super();\n makeObservable<WebhookListDataSource, \"_rows\">(this, {\n _rows: observable\n });\n }\n\n get rows(): Webhook[] {\n return this._rows;\n }\n\n async fetch(params: IDataSourceQuery): Promise<FetchResult<Webhook>> {\n const sort = params.sort ? [`${params.sort.field}_${params.sort.direction}`] : undefined;\n const result = await this.listWebhooksUseCase.execute({\n where: params.filters as { enabled?: boolean } | undefined,\n sort,\n limit: params.limit,\n after: params.cursor\n });\n return { data: result.items, meta: result.meta };\n }\n\n override onQueryResult(data: Webhook[]): void {\n this._rows = data;\n }\n\n override onLoadMoreResult(data: Webhook[]): void {\n this._rows = [...this._rows, ...data];\n }\n}\n"],"names":["WebhookListDataSource","SimpleDataSource","listWebhooksUseCase","makeObservable","observable","params","sort","undefined","result","data"],"mappings":";;AAOO,MAAMA,8BAA8BC;IAGvC,YAA6BC,mBAAyC,CAAE;QACpE,KAAK,SADoBA,mBAAmB,GAAnBA,qBAAAA,IAAAA,CAFrB,KAAK,GAAc,EAAE;QAIzBC,eAA+C,IAAI,EAAE;YACjD,OAAOC;QACX;IACJ;IAEA,IAAI,OAAkB;QAClB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,MAAM,MAAMC,MAAwB,EAAiC;QACjE,MAAMC,OAAOD,OAAO,IAAI,GAAG;YAAC,GAAGA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAEA,OAAO,IAAI,CAAC,SAAS,EAAE;SAAC,GAAGE;QAC/E,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAClD,OAAOH,OAAO,OAAO;YACrBC;YACA,OAAOD,OAAO,KAAK;YACnB,OAAOA,OAAO,MAAM;QACxB;QACA,OAAO;YAAE,MAAMG,OAAO,KAAK;YAAE,MAAMA,OAAO,IAAI;QAAC;IACnD;IAES,cAAcC,IAAe,EAAQ;QAC1C,IAAI,CAAC,KAAK,GAAGA;IACjB;IAES,iBAAiBA,IAAe,EAAQ;QAC7C,IAAI,CAAC,KAAK,GAAG;eAAI,IAAI,CAAC,KAAK;eAAKA;SAAK;IACzC;AACJ"}
|
|
@@ -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
|
-
|
|
6
|
+
export declare const WebhookListContent: (({ presenter }: WebhookListContentProps) => React.JSX.Element) & {
|
|
7
|
+
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
export {};
|
|
@@ -128,7 +128,7 @@ const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
|
|
|
128
128
|
entity: "webhook",
|
|
129
129
|
action: "delete"
|
|
130
130
|
}, /*#__PURE__*/ react.createElement(DropdownMenu.Separator, null), /*#__PURE__*/ react.createElement(DropdownMenu.Item, {
|
|
131
|
-
|
|
131
|
+
variant: "destructive",
|
|
132
132
|
onClick: ()=>{
|
|
133
133
|
showDeleteConfirmation(()=>presenter.deleteWebhook(row.id));
|
|
134
134
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookList/components/WebhookListContent.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListContent.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport type { DataTableSorting, OnDataTableSortingChange } from \"@webiny/admin-ui\";\nimport {\n Button,\n DataTable,\n DropdownMenu,\n IconButton,\n Scrollbar,\n Tag,\n Text,\n TimeAgo\n} from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useConfirmationDialog } from \"@webiny/app-admin/hooks/index.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as Edit } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as Delete } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport type { IWebhookListPresenter } from \"../abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\ninterface WebhookListContentProps {\n presenter: IWebhookListPresenter;\n}\n\nexport const WebhookListContent = observer(function WebhookListContent({\n presenter\n}: WebhookListContentProps) {\n const { vm } = presenter;\n const { goToRoute } = useRouter();\n const toast = useToast();\n\n const { showConfirmation: showDeleteConfirmation } = useConfirmationDialog({\n title: \"Delete Webhook\",\n message: \"Are you sure you want to delete this webhook?\"\n });\n\n const loadMoreOnScroll = useMemo(\n () =>\n debounce(async ({ scrollFrame }: { scrollFrame: { top: number } }) => {\n if (scrollFrame.top > 0.8) {\n await presenter.loadMore();\n }\n }, 200),\n [presenter]\n );\n\n const sorting: DataTableSorting = useMemo(() => {\n const sort = vm.list.sort;\n if (!sort || !sort.field) {\n return [];\n }\n return [{ id: sort.field, desc: sort.direction === \"DESC\" }];\n }, [vm.list.sort]);\n\n const onSortingChange: OnDataTableSortingChange = useCallback(\n updater => {\n const next = typeof updater === \"function\" ? updater(sorting) : updater;\n if (next.length > 0) {\n const { id, desc } = next[0];\n presenter.sort.set(id, desc ? \"DESC\" : \"ASC\");\n }\n },\n [sorting, presenter.sort]\n );\n\n const columns = useMemo(\n () => ({\n name: {\n header: \"Name\",\n cell: (row: Webhook) => (\n <Text\n className=\"cursor-pointer text-primary hover:underline\"\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n >\n {row.name}\n </Text>\n ),\n enableSorting: true,\n size: 200\n },\n endpointUrl: {\n header: \"Endpoint\",\n cell: (row: Webhook) => (\n <Text className=\"font-mono text-sm truncate\">{row.endpointUrl}</Text>\n ),\n size: 250\n },\n enabled: {\n header: \"Status\",\n cell: (row: Webhook) => (\n <Tag\n variant={row.enabled ? \"success\" : \"neutral-muted\"}\n content={row.enabled ? \"Active\" : \"Disabled\"}\n />\n ),\n enableSorting: true,\n size: 100\n },\n createdOn: {\n header: \"Created\",\n cell: (row: Webhook) =>\n row.createdOn ? <TimeAgo datetime={row.createdOn} /> : <Text size=\"sm\">—</Text>,\n enableSorting: true,\n size: 120\n },\n deliveries: {\n header: \"Deliveries\",\n truncate: false,\n cell: (row: Webhook) => {\n return (\n <Button\n variant={\"secondary\"}\n onClick={() => {\n goToRoute(Routes.Deliveries, { webhookId: row.id });\n }}\n >\n Deliveries\n </Button>\n );\n }\n },\n actions: {\n header: \" \",\n cell: (row: Webhook) => (\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVerticalIcon />}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Actions\"\n />\n }\n >\n <DropdownMenu.Item\n icon={<Edit />}\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n text={\"Edit\"}\n />\n <HasPermission entity=\"webhook\" action=\"edit\">\n <DropdownMenu.Item\n icon={<WebhookIcon />}\n onClick={() => {\n void presenter.triggerWebhook(row.id).then(() => {\n toast.showSuccessToast({ title: \"Test event triggered!\" });\n });\n }}\n text={\"Trigger Test\"}\n />\n </HasPermission>\n <HasPermission entity=\"webhook\" action=\"delete\">\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n className={\"text-destructive-primary! [&_svg]:fill-destructive\"}\n onClick={() => {\n showDeleteConfirmation(() => presenter.deleteWebhook(row.id));\n }}\n icon={<Delete />}\n text={\"Delete\"}\n />\n </HasPermission>\n </DropdownMenu>\n ),\n size: 56,\n enableSorting: false,\n enableHiding: false,\n enableResizing: false\n }\n }),\n [presenter]\n );\n\n if (!vm.list.pagination.loading && vm.list.rows.length === 0) {\n return (\n <div className=\"flex-1 overflow-hidden\">\n <div className=\"flex flex-col items-center justify-center h-full gap-md\">\n <Text className=\"text-neutral-strong\">No webhooks found.</Text>\n <CreateWebhookButton />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex-1 overflow-hidden\">\n <Scrollbar onScrollFrame={scrollFrame => loadMoreOnScroll({ scrollFrame })}>\n <DataTable<Webhook>\n columns={columns}\n data={vm.list.rows}\n loading={vm.list.pagination.loading}\n sorting={sorting}\n onSortingChange={onSortingChange}\n stickyHeader\n />\n </Scrollbar>\n </div>\n );\n});\n"],"names":["WebhookListContent","observer","presenter","vm","goToRoute","useRouter","toast","useToast","showDeleteConfirmation","useConfirmationDialog","loadMoreOnScroll","useMemo","debounce","scrollFrame","sorting","sort","onSortingChange","useCallback","updater","next","id","desc","columns","row","Text","Routes","Tag","TimeAgo","Button","DropdownMenu","IconButton","MoreVerticalIcon","Edit","HasPermission","WebhookIcon","Delete","CreateWebhookButton","Scrollbar","DataTable"],"mappings":";;;;;;;;;;;;;AA+BO,MAAMA,wCAAqBC,SAAS,SAA4B,EACnEC,SAAS,EACa;IACtB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,EAAEE,SAAS,EAAE,GAAGC;IACtB,MAAMC,QAAQC;IAEd,MAAM,EAAE,kBAAkBC,sBAAsB,EAAE,GAAGC,sBAAsB;QACvE,OAAO;QACP,SAAS;IACb;IAEA,MAAMC,mBAAmBC,QACrB,IACIC,SAAS,OAAO,EAAEC,WAAW,EAAoC;YAC7D,IAAIA,YAAY,GAAG,GAAG,KAClB,MAAMX,UAAU,QAAQ;QAEhC,GAAG,MACP;QAACA;KAAU;IAGf,MAAMY,UAA4BH,QAAQ;QACtC,MAAMI,OAAOZ,GAAG,IAAI,CAAC,IAAI;QACzB,IAAI,CAACY,QAAQ,CAACA,KAAK,KAAK,EACpB,OAAO,EAAE;QAEb,OAAO;YAAC;gBAAE,IAAIA,KAAK,KAAK;gBAAE,MAAMA,AAAmB,WAAnBA,KAAK,SAAS;YAAY;SAAE;IAChE,GAAG;QAACZ,GAAG,IAAI,CAAC,IAAI;KAAC;IAEjB,MAAMa,kBAA4CC,YAC9CC,CAAAA;QACI,MAAMC,OAAO,AAAmB,cAAnB,OAAOD,UAAyBA,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ACN,SAAShB;QACT,MAAMnB,GAAG,IAAI,CAAC,IAAI;QAClB,SAASA,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO;QACnC,SAASW;QACT,iBAAiBE;QACjB;;AAKpB"}
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookList/components/WebhookListContent.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListContent.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport type { DataTableSorting, OnDataTableSortingChange } from \"@webiny/admin-ui\";\nimport {\n Button,\n DataTable,\n DropdownMenu,\n IconButton,\n Scrollbar,\n Tag,\n Text,\n TimeAgo\n} from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useConfirmationDialog } from \"@webiny/app-admin/hooks/index.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as Edit } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as Delete } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport type { IWebhookListPresenter } from \"../abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\ninterface WebhookListContentProps {\n presenter: IWebhookListPresenter;\n}\n\nexport const WebhookListContent = observer(function WebhookListContent({\n presenter\n}: WebhookListContentProps) {\n const { vm } = presenter;\n const { goToRoute } = useRouter();\n const toast = useToast();\n\n const { showConfirmation: showDeleteConfirmation } = useConfirmationDialog({\n title: \"Delete Webhook\",\n message: \"Are you sure you want to delete this webhook?\"\n });\n\n const loadMoreOnScroll = useMemo(\n () =>\n debounce(async ({ scrollFrame }: { scrollFrame: { top: number } }) => {\n if (scrollFrame.top > 0.8) {\n await presenter.loadMore();\n }\n }, 200),\n [presenter]\n );\n\n const sorting: DataTableSorting = useMemo(() => {\n const sort = vm.list.sort;\n if (!sort || !sort.field) {\n return [];\n }\n return [{ id: sort.field, desc: sort.direction === \"DESC\" }];\n }, [vm.list.sort]);\n\n const onSortingChange: OnDataTableSortingChange = useCallback(\n updater => {\n const next = typeof updater === \"function\" ? updater(sorting) : updater;\n if (next.length > 0) {\n const { id, desc } = next[0];\n presenter.sort.set(id, desc ? \"DESC\" : \"ASC\");\n }\n },\n [sorting, presenter.sort]\n );\n\n const columns = useMemo(\n () => ({\n name: {\n header: \"Name\",\n cell: (row: Webhook) => (\n <Text\n className=\"cursor-pointer text-primary hover:underline\"\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n >\n {row.name}\n </Text>\n ),\n enableSorting: true,\n size: 200\n },\n endpointUrl: {\n header: \"Endpoint\",\n cell: (row: Webhook) => (\n <Text className=\"font-mono text-sm truncate\">{row.endpointUrl}</Text>\n ),\n size: 250\n },\n enabled: {\n header: \"Status\",\n cell: (row: Webhook) => (\n <Tag\n variant={row.enabled ? \"success\" : \"neutral-muted\"}\n content={row.enabled ? \"Active\" : \"Disabled\"}\n />\n ),\n enableSorting: true,\n size: 100\n },\n createdOn: {\n header: \"Created\",\n cell: (row: Webhook) =>\n row.createdOn ? <TimeAgo datetime={row.createdOn} /> : <Text size=\"sm\">—</Text>,\n enableSorting: true,\n size: 120\n },\n deliveries: {\n header: \"Deliveries\",\n truncate: false,\n cell: (row: Webhook) => {\n return (\n <Button\n variant={\"secondary\"}\n onClick={() => {\n goToRoute(Routes.Deliveries, { webhookId: row.id });\n }}\n >\n Deliveries\n </Button>\n );\n }\n },\n actions: {\n header: \" \",\n cell: (row: Webhook) => (\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVerticalIcon />}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Actions\"\n />\n }\n >\n <DropdownMenu.Item\n icon={<Edit />}\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n text={\"Edit\"}\n />\n <HasPermission entity=\"webhook\" action=\"edit\">\n <DropdownMenu.Item\n icon={<WebhookIcon />}\n onClick={() => {\n void presenter.triggerWebhook(row.id).then(() => {\n toast.showSuccessToast({ title: \"Test event triggered!\" });\n });\n }}\n text={\"Trigger Test\"}\n />\n </HasPermission>\n <HasPermission entity=\"webhook\" action=\"delete\">\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n variant={\"destructive\"}\n onClick={() => {\n showDeleteConfirmation(() => presenter.deleteWebhook(row.id));\n }}\n icon={<Delete />}\n text={\"Delete\"}\n />\n </HasPermission>\n </DropdownMenu>\n ),\n size: 56,\n enableSorting: false,\n enableHiding: false,\n enableResizing: false\n }\n }),\n [presenter]\n );\n\n if (!vm.list.pagination.loading && vm.list.rows.length === 0) {\n return (\n <div className=\"flex-1 overflow-hidden\">\n <div className=\"flex flex-col items-center justify-center h-full gap-md\">\n <Text className=\"text-neutral-strong\">No webhooks found.</Text>\n <CreateWebhookButton />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex-1 overflow-hidden\">\n <Scrollbar onScrollFrame={scrollFrame => loadMoreOnScroll({ scrollFrame })}>\n <DataTable<Webhook>\n columns={columns}\n data={vm.list.rows}\n loading={vm.list.pagination.loading}\n sorting={sorting}\n onSortingChange={onSortingChange}\n stickyHeader\n />\n </Scrollbar>\n </div>\n );\n});\n"],"names":["WebhookListContent","observer","presenter","vm","goToRoute","useRouter","toast","useToast","showDeleteConfirmation","useConfirmationDialog","loadMoreOnScroll","useMemo","debounce","scrollFrame","sorting","sort","onSortingChange","useCallback","updater","next","id","desc","columns","row","Text","Routes","Tag","TimeAgo","Button","DropdownMenu","IconButton","MoreVerticalIcon","Edit","HasPermission","WebhookIcon","Delete","CreateWebhookButton","Scrollbar","DataTable"],"mappings":";;;;;;;;;;;;;AA+BO,MAAMA,wCAAqBC,SAAS,SAA4B,EACnEC,SAAS,EAC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;wBACA,MAAM;uCAGd,oBAAC2B,eAAaA;wBAAC,QAAO;wBAAU,QAAO;qCACnC,oBAACJ,aAAa,SAAS,uBACvB,oBAACA,aAAa,IAAI;wBACd,SAAS;wBACT,SAAS;4BACLrB,uBAAuB,IAAMN,UAAU,aAAa,CAACqB,IAAI,EAAE;wBAC/D;wBACA,oBAAM,oBAACY,2BAAMA;wBACb,MAAM;;gBAKtB,MAAM;gBACN,eAAe;gBACf,cAAc;gBACd,gBAAgB;YACpB;QACJ,IACA;QAACjC;KAAU;IAGf,IAAI,CAACC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,IAAIA,AAAwB,MAAxBA,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAClD,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACqB,MAAIA;QAAC,WAAU;OAAsB,qCACtC,oBAACY,qBAAmBA;IAMpC,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,WAASA;QAAC,eAAexB,CAAAA,cAAeH,iBAAiB;gBAAEG;YAAY;qBACpE,oBAACyB,WAASA;QACN,SAAShB;QACT,MAAMnB,GAAG,IAAI,CAAC,IAAI;QAClB,SAASA,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO;QACnC,SAASW;QACT,iBAAiBE;QACjB;;AAKpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/DeleteWebhook/DeleteWebhookRepository.js","sources":["../../../../src/api/features/DeleteWebhook/DeleteWebhookRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/exports/api/cms/model.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\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 { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { DeleteEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { DeleteWebhookRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID, WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\n\nclass DeleteWebhookRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly deleteEntryRepository: DeleteEntryRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<boolean, RepositoryAbstraction.Error>> {\n try {\n const webhookModelResult = await this.getModelRepository.execute(WEBHOOK_MODEL_ID);\n if (webhookModelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_MODEL_ID));\n }\n\n const deliveryModelResult =\n await this.getModelRepository.execute(WEBHOOK_DELIVERY_MODEL_ID);\n if (!deliveryModelResult.isFail()) {\n try {\n await this.deleteAllDeliveries(deliveryModelResult.value, id);\n } catch {\n /* Delivery cleanup is best-effort; proceed with webhook delete regardless. */\n }\n }\n\n const entryResult = await this.getLatestRevisionRepository.execute(\n webhookModelResult.value,\n { id }\n );\n if (entryResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(entryResult.error));\n }\n\n const deleteResult = await this.deleteEntryRepository.execute(\n webhookModelResult.value,\n entryResult.value\n );\n\n if (deleteResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(deleteResult.error));\n }\n\n return Result.ok(true);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n\n private async deleteAllDeliveries(deliveryModel: CmsModel, webhookId: string): Promise<void> {\n let cursor: string | undefined = undefined;\n let hasMore = true;\n while (hasMore) {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n const listResult: Result<any, any> = await this.listEntriesRepository.execute(\n deliveryModel,\n {\n where: { values: { webhookId }
|
|
1
|
+
{"version":3,"file":"api/features/DeleteWebhook/DeleteWebhookRepository.js","sources":["../../../../src/api/features/DeleteWebhook/DeleteWebhookRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/exports/api/cms/model.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\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 { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { DeleteEntryRepository } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { DeleteWebhookRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID, WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\n\nclass DeleteWebhookRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly getLatestRevisionRepository: GetLatestRevisionByEntryIdRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly deleteEntryRepository: DeleteEntryRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<boolean, RepositoryAbstraction.Error>> {\n try {\n const webhookModelResult = await this.getModelRepository.execute(WEBHOOK_MODEL_ID);\n if (webhookModelResult.isFail()) {\n return Result.fail(new WebhookModelNotFoundError(WEBHOOK_MODEL_ID));\n }\n\n const deliveryModelResult =\n await this.getModelRepository.execute(WEBHOOK_DELIVERY_MODEL_ID);\n if (!deliveryModelResult.isFail()) {\n try {\n await this.deleteAllDeliveries(deliveryModelResult.value, id);\n } catch {\n /* Delivery cleanup is best-effort; proceed with webhook delete regardless. */\n }\n }\n\n const entryResult = await this.getLatestRevisionRepository.execute(\n webhookModelResult.value,\n { id }\n );\n if (entryResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(entryResult.error));\n }\n\n const deleteResult = await this.deleteEntryRepository.execute(\n webhookModelResult.value,\n entryResult.value\n );\n\n if (deleteResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(deleteResult.error));\n }\n\n return Result.ok(true);\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n\n private async deleteAllDeliveries(deliveryModel: CmsModel, webhookId: string): Promise<void> {\n let cursor: string | undefined = undefined;\n let hasMore = true;\n while (hasMore) {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n const listResult: Result<any, any> = await this.listEntriesRepository.execute(\n deliveryModel,\n {\n where: { values: { webhookId } },\n limit: 100,\n after: cursor\n }\n );\n\n if (listResult.isFail()) {\n throw listResult.error;\n }\n\n for (const entry of listResult.value.entries as CmsEntry[]) {\n /* Individual delivery delete failures are best-effort; continue with the rest. */\n await this.deleteEntryRepository.execute(deliveryModel, entry);\n }\n\n cursor = listResult.value.meta.cursor ?? undefined;\n hasMore = !!cursor;\n }\n }\n}\n\nexport const DeleteWebhookRepository = RepositoryAbstraction.createImplementation({\n implementation: DeleteWebhookRepositoryImpl,\n dependencies: [\n GetModelRepository,\n GetLatestRevisionByEntryIdRepository,\n ListEntriesRepository,\n DeleteEntryRepository\n ]\n});\n"],"names":["DeleteWebhookRepositoryImpl","getModelRepository","getLatestRevisionRepository","listEntriesRepository","deleteEntryRepository","id","webhookModelResult","WEBHOOK_MODEL_ID","Result","WebhookModelNotFoundError","deliveryModelResult","WEBHOOK_DELIVERY_MODEL_ID","entryResult","WebhookPersistenceError","deleteResult","error","deliveryModel","webhookId","cursor","hasMore","listResult","entry","undefined","DeleteWebhookRepository","RepositoryAbstraction","GetModelRepository","GetLatestRevisionByEntryIdRepository","ListEntriesRepository","DeleteEntryRepository"],"mappings":";;;;;;;;AAWA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,2BAA2E,EAC3EC,qBAAsD,EACtDC,qBAAsD,CACzE;aAJmBH,kBAAkB,GAAlBA;aACAC,2BAA2B,GAA3BA;aACAC,qBAAqB,GAArBA;aACAC,qBAAqB,GAArBA;IAClB;IAEH,MAAM,QAAQC,EAAU,EAAyD;QAC7E,IAAI;YACA,MAAMC,qBAAqB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YACjE,IAAID,mBAAmB,MAAM,IACzB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,sBACF,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1C,IAAI,CAACD,oBAAoB,MAAM,IAC3B,IAAI;gBACA,MAAM,IAAI,CAAC,mBAAmB,CAACA,oBAAoB,KAAK,EAAEL;YAC9D,EAAE,OAAM,CAER;YAGJ,MAAMO,cAAc,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAC9DN,mBAAmB,KAAK,EACxB;gBAAED;YAAG;YAET,IAAIO,YAAY,MAAM,IAClB,OAAOJ,OAAO,IAAI,CAACK,wBAAwB,IAAI,CAACD,YAAY,KAAK;YAGrE,MAAME,eAAe,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CACzDR,mBAAmB,KAAK,EACxBM,YAAY,KAAK;YAGrB,IAAIE,aAAa,MAAM,IACnB,OAAON,OAAO,IAAI,CAACK,wBAAwB,IAAI,CAACC,aAAa,KAAK;YAGtE,OAAON,OAAO,EAAE,CAAC;QACrB,EAAE,OAAOO,OAAO;YACZ,OAAOP,OAAO,IAAI,CAACK,wBAAwB,IAAI,CAACE;QACpD;IACJ;IAEA,MAAc,oBAAoBC,aAAuB,EAAEC,SAAiB,EAAiB;QACzF,IAAIC;QACJ,IAAIC,UAAU;QACd,MAAOA,QAAS;YAEZ,MAAMC,aAA+B,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CACzEJ,eACA;gBACI,OAAO;oBAAE,QAAQ;wBAAEC;oBAAU;gBAAE;gBAC/B,OAAO;gBACP,OAAOC;YACX;YAGJ,IAAIE,WAAW,MAAM,IACjB,MAAMA,WAAW,KAAK;YAG1B,KAAK,MAAMC,SAASD,WAAW,KAAK,CAAC,OAAO,CAExC,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACJ,eAAeK;YAG5DH,SAASE,WAAW,KAAK,CAAC,IAAI,CAAC,MAAM,IAAIE;YACzCH,UAAU,CAAC,CAACD;QAChB;IACJ;AACJ;AAEO,MAAMK,kDAA0BC,wBAAAA,oBAA0C,CAAC;IAC9E,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -21,13 +21,10 @@ class ListWebhookDeliveriesRepositoryImpl {
|
|
|
21
21
|
if (modelResult.isFail()) return Result.fail(new WebhookModelNotFoundError(WEBHOOK_DELIVERY_MODEL_ID));
|
|
22
22
|
const model = modelResult.value;
|
|
23
23
|
const listResult = await this.listEntriesRepository.execute(model, {
|
|
24
|
-
where: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
latest: true
|
|
30
|
-
},
|
|
24
|
+
where: this.whereMapper.map({
|
|
25
|
+
fields: model.fields,
|
|
26
|
+
input: params.where
|
|
27
|
+
}),
|
|
31
28
|
sort: this.sortMapper.map({
|
|
32
29
|
fields: model.fields,
|
|
33
30
|
input: params.sort
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js","sources":["../../../../src/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetModelRepository } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { WebhookDeliveryTransformer } from \"~/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js\";\nimport {\n ListWebhookDeliveriesRepository as RepositoryAbstraction,\n type IListWebhookDeliveriesOutput\n} from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IListWebhookDeliveriesInput } from \"./abstractions.js\";\nimport type { WebhookDeliveryCmsEntryValues } from \"~/api/domain/WebhookDelivery.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms/features/whereMapper/abstractions.js\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms/features/sortMapper/abstractions.js\";\n\nclass ListWebhookDeliveriesRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly transformer: WebhookDeliveryTransformer.Interface,\n private readonly whereMapper: CmsWhereMapper.Interface,\n private readonly sortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n params: IListWebhookDeliveriesInput\n ): Promise<Result<IListWebhookDeliveriesOutput, 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 model = modelResult.value;\n\n const listResult =\n await this.listEntriesRepository.execute<WebhookDeliveryCmsEntryValues>(model, {\n where:
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js","sources":["../../../../src/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetModelRepository } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { WebhookDeliveryTransformer } from \"~/api/features/Transformers/abstractions/WebhookDeliveryTransformer.js\";\nimport {\n ListWebhookDeliveriesRepository as RepositoryAbstraction,\n type IListWebhookDeliveriesOutput\n} from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_DELIVERY_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IListWebhookDeliveriesInput } from \"./abstractions.js\";\nimport type { WebhookDeliveryCmsEntryValues } from \"~/api/domain/WebhookDelivery.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms/features/whereMapper/abstractions.js\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms/features/sortMapper/abstractions.js\";\n\nclass ListWebhookDeliveriesRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly transformer: WebhookDeliveryTransformer.Interface,\n private readonly whereMapper: CmsWhereMapper.Interface,\n private readonly sortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n params: IListWebhookDeliveriesInput\n ): Promise<Result<IListWebhookDeliveriesOutput, 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 model = modelResult.value;\n\n const listResult =\n await this.listEntriesRepository.execute<WebhookDeliveryCmsEntryValues>(model, {\n where: this.whereMapper.map({\n fields: model.fields,\n input: params.where\n }),\n sort: this.sortMapper.map({\n fields: model.fields,\n input: params.sort\n }),\n limit: params.limit ?? 100,\n after: params.after\n });\n\n if (listResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(listResult.error));\n }\n\n const { entries, meta } = listResult.value;\n const items = entries.map(entry => this.transformer.fromStorage(entry));\n\n return Result.ok({\n items,\n meta: {\n cursor: meta.cursor,\n hasMoreItems: meta.hasMoreItems,\n totalCount: meta.totalCount\n }\n });\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const ListWebhookDeliveriesRepository = RepositoryAbstraction.createImplementation({\n implementation: ListWebhookDeliveriesRepositoryImpl,\n dependencies: [\n GetModelRepository,\n ListEntriesRepository,\n WebhookDeliveryTransformer,\n CmsWhereMapper,\n CmsSortMapper\n ]\n});\n"],"names":["ListWebhookDeliveriesRepositoryImpl","getModelRepository","listEntriesRepository","transformer","whereMapper","sortMapper","params","modelResult","WEBHOOK_DELIVERY_MODEL_ID","Result","WebhookModelNotFoundError","model","listResult","WebhookPersistenceError","entries","meta","items","entry","error","ListWebhookDeliveriesRepository","RepositoryAbstraction","GetModelRepository","ListEntriesRepository","WebhookDeliveryTransformer","CmsWhereMapper","CmsSortMapper"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,qBAAsD,EACtDC,WAAiD,EACjDC,WAAqC,EACrCC,UAAmC,CACtD;aALmBJ,kBAAkB,GAAlBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,QACFC,MAAmC,EACuC;QAC1E,IAAI;YACA,MAAMC,cAAc,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1D,IAAID,YAAY,MAAM,IAClB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,QAAQJ,YAAY,KAAK;YAE/B,MAAMK,aACF,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAgCD,OAAO;gBAC3E,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;oBACxB,QAAQA,MAAM,MAAM;oBACpB,OAAOL,OAAO,KAAK;gBACvB;gBACA,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;oBACtB,QAAQK,MAAM,MAAM;oBACpB,OAAOL,OAAO,IAAI;gBACtB;gBACA,OAAOA,OAAO,KAAK,IAAI;gBACvB,OAAOA,OAAO,KAAK;YACvB;YAEJ,IAAIM,WAAW,MAAM,IACjB,OAAOH,OAAO,IAAI,CAACI,wBAAwB,IAAI,CAACD,WAAW,KAAK;YAGpE,MAAM,EAAEE,OAAO,EAAEC,IAAI,EAAE,GAAGH,WAAW,KAAK;YAC1C,MAAMI,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAI,CAAC,WAAW,CAAC,WAAW,CAACA;YAEhE,OAAOR,OAAO,EAAE,CAAC;gBACbO;gBACA,MAAM;oBACF,QAAQD,KAAK,MAAM;oBACnB,cAAcA,KAAK,YAAY;oBAC/B,YAAYA,KAAK,UAAU;gBAC/B;YACJ;QACJ,EAAE,OAAOG,OAAO;YACZ,OAAOT,OAAO,IAAI,CAACI,wBAAwB,IAAI,CAACK;QACpD;IACJ;AACJ;AAEO,MAAMC,kEAAkCC,gCAAAA,oBAA0C,CAAC;IACtF,gBAAgBpB;IAChB,cAAc;QACVqB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -21,13 +21,10 @@ class ListWebhooksRepositoryImpl {
|
|
|
21
21
|
if (modelResult.isFail()) return Result.fail(new WebhookModelNotFoundError(WEBHOOK_MODEL_ID));
|
|
22
22
|
const webhookModel = modelResult.value;
|
|
23
23
|
const listResult = await this.listEntriesRepository.execute(modelResult.value, {
|
|
24
|
-
where: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
latest: true
|
|
30
|
-
},
|
|
24
|
+
where: this.whereMapper.map({
|
|
25
|
+
fields: webhookModel.fields,
|
|
26
|
+
input: params?.where
|
|
27
|
+
}),
|
|
31
28
|
sort: this.sortMapper.map({
|
|
32
29
|
fields: webhookModel.fields,
|
|
33
30
|
input: params?.sort
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ListWebhooks/ListWebhooksRepository.js","sources":["../../../../src/api/features/ListWebhooks/ListWebhooksRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetModelRepository } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { WebhookTransformer } from \"~/api/features/Transformers/abstractions/WebhookTransformer.js\";\nimport { ListWebhooksRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IListWebhooksInput } from \"./abstractions.js\";\nimport type { WebhookCmsEntryValues } from \"~/api/domain/Webhook.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms/features/whereMapper/abstractions.js\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms/features/sortMapper/abstractions.js\";\n\nclass ListWebhooksRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly transformer: WebhookTransformer.Interface,\n private whereMapper: CmsWhereMapper.Interface,\n private sortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n params?: IListWebhooksInput\n ): Promise<Result<RepositoryAbstraction.Output, 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 webhookModel = modelResult.value;\n\n const listResult = await this.listEntriesRepository.execute<WebhookCmsEntryValues>(\n modelResult.value,\n {\n where:
|
|
1
|
+
{"version":3,"file":"api/features/ListWebhooks/ListWebhooksRepository.js","sources":["../../../../src/api/features/ListWebhooks/ListWebhooksRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetModelRepository } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { ListEntriesRepository } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport { WebhookTransformer } from \"~/api/features/Transformers/abstractions/WebhookTransformer.js\";\nimport { ListWebhooksRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { WebhookModelNotFoundError, WebhookPersistenceError } from \"~/api/domain/errors.js\";\nimport { WEBHOOK_MODEL_ID } from \"~/api/domain/constants.js\";\nimport type { IListWebhooksInput } from \"./abstractions.js\";\nimport type { WebhookCmsEntryValues } from \"~/api/domain/Webhook.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms/features/whereMapper/abstractions.js\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms/features/sortMapper/abstractions.js\";\n\nclass ListWebhooksRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private readonly getModelRepository: GetModelRepository.Interface,\n private readonly listEntriesRepository: ListEntriesRepository.Interface,\n private readonly transformer: WebhookTransformer.Interface,\n private whereMapper: CmsWhereMapper.Interface,\n private sortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n params?: IListWebhooksInput\n ): Promise<Result<RepositoryAbstraction.Output, 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 webhookModel = modelResult.value;\n\n const listResult = await this.listEntriesRepository.execute<WebhookCmsEntryValues>(\n modelResult.value,\n {\n where: this.whereMapper.map({\n fields: webhookModel.fields,\n input: params?.where\n }),\n sort: this.sortMapper.map({\n fields: webhookModel.fields,\n input: params?.sort\n }),\n limit: params?.limit ?? 100,\n after: params?.after\n }\n );\n\n if (listResult.isFail()) {\n return Result.fail(WebhookPersistenceError.from(listResult.error));\n }\n\n const { entries, meta } = listResult.value;\n const items = entries.map(entry => this.transformer.fromStorage(entry));\n\n return Result.ok({\n items,\n meta: {\n cursor: meta.cursor,\n hasMoreItems: meta.hasMoreItems,\n totalCount: meta.totalCount\n }\n });\n } catch (error) {\n return Result.fail(WebhookPersistenceError.from(error));\n }\n }\n}\n\nexport const ListWebhooksRepository = RepositoryAbstraction.createImplementation({\n implementation: ListWebhooksRepositoryImpl,\n dependencies: [\n GetModelRepository,\n ListEntriesRepository,\n WebhookTransformer,\n CmsWhereMapper,\n CmsSortMapper\n ]\n});\n"],"names":["ListWebhooksRepositoryImpl","getModelRepository","listEntriesRepository","transformer","whereMapper","sortMapper","params","modelResult","WEBHOOK_MODEL_ID","Result","WebhookModelNotFoundError","webhookModel","listResult","WebhookPersistenceError","entries","meta","items","entry","error","ListWebhooksRepository","RepositoryAbstraction","GetModelRepository","ListEntriesRepository","WebhookTransformer","CmsWhereMapper","CmsSortMapper"],"mappings":";;;;;;;;;AAYA,MAAMA;IACF,YACqBC,kBAAgD,EAChDC,qBAAsD,EACtDC,WAAyC,EAClDC,WAAqC,EACrCC,UAAmC,CAC7C;aALmBJ,kBAAkB,GAAlBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;aACTC,WAAW,GAAXA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,MAA2B,EAC+C;QAC1E,IAAI;YACA,MAAMC,cAAc,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACC;YAC1D,IAAID,YAAY,MAAM,IAClB,OAAOE,OAAO,IAAI,CAAC,IAAIC,0BAA0BF;YAGrD,MAAMG,eAAeJ,YAAY,KAAK;YAEtC,MAAMK,aAAa,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CACvDL,YAAY,KAAK,EACjB;gBACI,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;oBACxB,QAAQI,aAAa,MAAM;oBAC3B,OAAOL,QAAQ;gBACnB;gBACA,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;oBACtB,QAAQK,aAAa,MAAM;oBAC3B,OAAOL,QAAQ;gBACnB;gBACA,OAAOA,QAAQ,SAAS;gBACxB,OAAOA,QAAQ;YACnB;YAGJ,IAAIM,WAAW,MAAM,IACjB,OAAOH,OAAO,IAAI,CAACI,wBAAwB,IAAI,CAACD,WAAW,KAAK;YAGpE,MAAM,EAAEE,OAAO,EAAEC,IAAI,EAAE,GAAGH,WAAW,KAAK;YAC1C,MAAMI,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAI,CAAC,WAAW,CAAC,WAAW,CAACA;YAEhE,OAAOR,OAAO,EAAE,CAAC;gBACbO;gBACA,MAAM;oBACF,QAAQD,KAAK,MAAM;oBACnB,cAAcA,KAAK,YAAY;oBAC/B,YAAYA,KAAK,UAAU;gBAC/B;YACJ;QACJ,EAAE,OAAOG,OAAO;YACZ,OAAOT,OAAO,IAAI,CAACI,wBAAwB,IAAI,CAACK;QACpD;IACJ;AACJ;AAEO,MAAMC,gDAAyBC,uBAAAA,oBAA0C,CAAC;IAC7E,gBAAgBpB;IAChB,cAAc;QACVqB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -12,6 +12,7 @@ class WebhookCrudSchema_ {
|
|
|
12
12
|
code: String
|
|
13
13
|
message: String
|
|
14
14
|
data: JSON
|
|
15
|
+
stack: String
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
type WebhookListMeta {
|
|
@@ -66,9 +67,19 @@ class WebhookCrudSchema_ {
|
|
|
66
67
|
enabled: Boolean
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
enum ListWebhooksSort {
|
|
71
|
+
createdOn_ASC
|
|
72
|
+
createdOn_DESC
|
|
73
|
+
modifiedOn_ASC
|
|
74
|
+
modifiedOn_DESC
|
|
75
|
+
name_ASC
|
|
76
|
+
name_DESC
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
type WebhookQuery {
|
|
70
80
|
listWebhooks(
|
|
71
81
|
where: ListWebhooksWhereInput
|
|
82
|
+
sort: [ListWebhooksSort!]
|
|
72
83
|
limit: Int
|
|
73
84
|
after: String
|
|
74
85
|
): WebhookListResponse!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/graphql/WebhookCrudSchema.js","sources":["../../../src/api/graphql/WebhookCrudSchema.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.js\";\nimport { Response } from \"@webiny/handler-graphql\";\nimport { ErrorResponse } from \"@webiny/handler-graphql\";\nimport { ListResponse } from \"@webiny/handler-graphql\";\nimport { ListErrorResponse } from \"@webiny/handler-graphql\";\nimport { ListWebhooksUseCase } from \"~/api/features/ListWebhooks/abstractions.js\";\nimport type { IListWebhooksInput } from \"~/api/features/ListWebhooks/abstractions.js\";\nimport { GetWebhookUseCase } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/api/features/CreateWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/api/features/UpdateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/api/features/DeleteWebhook/abstractions.js\";\n\ninterface IIdArgs {\n id: string;\n}\n\ninterface ICreateWebhookArgs {\n input: CreateWebhookUseCase.Input;\n}\n\ninterface IUpdateWebhookArgs {\n id: string;\n input: UpdateWebhookUseCase.Input;\n}\n\nclass WebhookCrudSchema_ implements GraphQLSchemaFactory.Interface {\n async execute(\n builder: GraphQLSchemaFactory.SchemaBuilder\n ): Promise<GraphQLSchemaFactory.SchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WebhookError {\n code: String\n message: String\n data: JSON\n }\n\n type WebhookListMeta {\n cursor: String\n hasMoreItems: Boolean!\n totalCount: Int!\n }\n\n type Webhook {\n id: ID!\n name: String!\n slug: String!\n endpointUrl: String!\n description: String\n enabled: Boolean!\n events: [String!]!\n signingSecret: String\n createdOn: DateTime\n modifiedOn: DateTime\n }\n\n type WebhookResponse {\n data: Webhook\n error: WebhookError\n }\n\n type WebhookListResponse {\n data: [Webhook!]\n meta: WebhookListMeta\n error: WebhookError\n }\n\n input CreateWebhookInput {\n name: String!\n slug: String\n endpointUrl: String!\n description: String\n enabled: Boolean\n events: [String!]!\n signingSecret: String\n }\n\n input UpdateWebhookInput {\n name: String\n endpointUrl: String\n description: String\n enabled: Boolean\n events: [String!]\n }\n\n input ListWebhooksWhereInput {\n enabled: Boolean\n }\n\n type WebhookQuery {\n listWebhooks(\n where: ListWebhooksWhereInput\n limit: Int\n after: String\n ): WebhookListResponse!\n getWebhook(id: ID!): WebhookResponse!\n }\n\n type WebhookMutation {\n createWebhook(input: CreateWebhookInput!): WebhookResponse!\n updateWebhook(id: ID!, input: UpdateWebhookInput!): WebhookResponse!\n deleteWebhook(id: ID!): BooleanResponse!\n }\n\n extend type Query {\n webhooks: WebhookQuery!\n }\n\n extend type Mutation {\n webhooks: WebhookMutation!\n }\n `);\n\n builder.addResolver({\n path: \"Query.webhooks\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.webhooks\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver<IListWebhooksInput>({\n path: \"WebhookQuery.listWebhooks\",\n dependencies: [ListWebhooksUseCase],\n resolver: (listWebhooks: ListWebhooksUseCase.Interface) => {\n return async ({ args }) => {\n const result = await listWebhooks.execute(args);\n if (result.isFail()) {\n return new ListErrorResponse(result.error);\n }\n return new ListResponse(result.value.items, result.value.meta);\n };\n }\n });\n\n builder.addResolver<IIdArgs>({\n path: \"WebhookQuery.getWebhook\",\n dependencies: [GetWebhookUseCase],\n resolver: (getWebhook: GetWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await getWebhook.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<ICreateWebhookArgs>({\n path: \"WebhookMutation.createWebhook\",\n dependencies: [CreateWebhookUseCase],\n resolver: (createWebhook: CreateWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await createWebhook.execute(args.input);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<IUpdateWebhookArgs>({\n path: \"WebhookMutation.updateWebhook\",\n dependencies: [UpdateWebhookUseCase],\n resolver: (updateWebhook: UpdateWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await updateWebhook.execute(args.id, args.input);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<IIdArgs>({\n path: \"WebhookMutation.deleteWebhook\",\n dependencies: [DeleteWebhookUseCase],\n resolver: (deleteWebhook: DeleteWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await deleteWebhook.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(true);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const WebhookCrudSchema = GraphQLSchemaFactory.createImplementation({\n implementation: WebhookCrudSchema_,\n dependencies: []\n});\n"],"names":["WebhookCrudSchema_","builder","ListWebhooksUseCase","listWebhooks","args","result","ListErrorResponse","ListResponse","GetWebhookUseCase","getWebhook","ErrorResponse","Response","CreateWebhookUseCase","createWebhook","UpdateWebhookUseCase","updateWebhook","DeleteWebhookUseCase","deleteWebhook","WebhookCrudSchema","GraphQLSchemaFactory"],"mappings":";;;;;;;AAyBA,MAAMA;IACF,MAAM,QACFC,OAA2C,EACA;QAC3CA,QAAQ,WAAW,CAAe,CAAC
|
|
1
|
+
{"version":3,"file":"api/graphql/WebhookCrudSchema.js","sources":["../../../src/api/graphql/WebhookCrudSchema.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.js\";\nimport { Response } from \"@webiny/handler-graphql\";\nimport { ErrorResponse } from \"@webiny/handler-graphql\";\nimport { ListResponse } from \"@webiny/handler-graphql\";\nimport { ListErrorResponse } from \"@webiny/handler-graphql\";\nimport { ListWebhooksUseCase } from \"~/api/features/ListWebhooks/abstractions.js\";\nimport type { IListWebhooksInput } from \"~/api/features/ListWebhooks/abstractions.js\";\nimport { GetWebhookUseCase } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/api/features/CreateWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/api/features/UpdateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/api/features/DeleteWebhook/abstractions.js\";\n\ninterface IIdArgs {\n id: string;\n}\n\ninterface ICreateWebhookArgs {\n input: CreateWebhookUseCase.Input;\n}\n\ninterface IUpdateWebhookArgs {\n id: string;\n input: UpdateWebhookUseCase.Input;\n}\n\nclass WebhookCrudSchema_ implements GraphQLSchemaFactory.Interface {\n async execute(\n builder: GraphQLSchemaFactory.SchemaBuilder\n ): Promise<GraphQLSchemaFactory.SchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WebhookError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WebhookListMeta {\n cursor: String\n hasMoreItems: Boolean!\n totalCount: Int!\n }\n\n type Webhook {\n id: ID!\n name: String!\n slug: String!\n endpointUrl: String!\n description: String\n enabled: Boolean!\n events: [String!]!\n signingSecret: String\n createdOn: DateTime\n modifiedOn: DateTime\n }\n\n type WebhookResponse {\n data: Webhook\n error: WebhookError\n }\n\n type WebhookListResponse {\n data: [Webhook!]\n meta: WebhookListMeta\n error: WebhookError\n }\n\n input CreateWebhookInput {\n name: String!\n slug: String\n endpointUrl: String!\n description: String\n enabled: Boolean\n events: [String!]!\n signingSecret: String\n }\n\n input UpdateWebhookInput {\n name: String\n endpointUrl: String\n description: String\n enabled: Boolean\n events: [String!]\n }\n\n input ListWebhooksWhereInput {\n enabled: Boolean\n }\n\n enum ListWebhooksSort {\n createdOn_ASC\n createdOn_DESC\n modifiedOn_ASC\n modifiedOn_DESC\n name_ASC\n name_DESC\n }\n\n type WebhookQuery {\n listWebhooks(\n where: ListWebhooksWhereInput\n sort: [ListWebhooksSort!]\n limit: Int\n after: String\n ): WebhookListResponse!\n getWebhook(id: ID!): WebhookResponse!\n }\n\n type WebhookMutation {\n createWebhook(input: CreateWebhookInput!): WebhookResponse!\n updateWebhook(id: ID!, input: UpdateWebhookInput!): WebhookResponse!\n deleteWebhook(id: ID!): BooleanResponse!\n }\n\n extend type Query {\n webhooks: WebhookQuery!\n }\n\n extend type Mutation {\n webhooks: WebhookMutation!\n }\n `);\n\n builder.addResolver({\n path: \"Query.webhooks\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.webhooks\",\n dependencies: [],\n resolver: () => () => ({})\n });\n\n builder.addResolver<IListWebhooksInput>({\n path: \"WebhookQuery.listWebhooks\",\n dependencies: [ListWebhooksUseCase],\n resolver: (listWebhooks: ListWebhooksUseCase.Interface) => {\n return async ({ args }) => {\n const result = await listWebhooks.execute(args);\n if (result.isFail()) {\n return new ListErrorResponse(result.error);\n }\n return new ListResponse(result.value.items, result.value.meta);\n };\n }\n });\n\n builder.addResolver<IIdArgs>({\n path: \"WebhookQuery.getWebhook\",\n dependencies: [GetWebhookUseCase],\n resolver: (getWebhook: GetWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await getWebhook.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<ICreateWebhookArgs>({\n path: \"WebhookMutation.createWebhook\",\n dependencies: [CreateWebhookUseCase],\n resolver: (createWebhook: CreateWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await createWebhook.execute(args.input);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<IUpdateWebhookArgs>({\n path: \"WebhookMutation.updateWebhook\",\n dependencies: [UpdateWebhookUseCase],\n resolver: (updateWebhook: UpdateWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await updateWebhook.execute(args.id, args.input);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(result.value);\n };\n }\n });\n\n builder.addResolver<IIdArgs>({\n path: \"WebhookMutation.deleteWebhook\",\n dependencies: [DeleteWebhookUseCase],\n resolver: (deleteWebhook: DeleteWebhookUseCase.Interface) => {\n return async ({ args }) => {\n const result = await deleteWebhook.execute(args.id);\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n return new Response(true);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const WebhookCrudSchema = GraphQLSchemaFactory.createImplementation({\n implementation: WebhookCrudSchema_,\n dependencies: []\n});\n"],"names":["WebhookCrudSchema_","builder","ListWebhooksUseCase","listWebhooks","args","result","ListErrorResponse","ListResponse","GetWebhookUseCase","getWebhook","ErrorResponse","Response","CreateWebhookUseCase","createWebhook","UpdateWebhookUseCase","updateWebhook","DeleteWebhookUseCase","deleteWebhook","WebhookCrudSchema","GraphQLSchemaFactory"],"mappings":";;;;;;;AAyBA,MAAMA;IACF,MAAM,QACFC,OAA2C,EACA;QAC3CA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4FnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc,EAAE;YAChB,UAAU,IAAM,IAAO,EAAC;QAC5B;QAEAA,QAAQ,WAAW,CAAqB;YACpC,MAAM;YACN,cAAc;gBAACC;aAAoB;YACnC,UAAU,CAACC,eACA,OAAO,EAAEC,IAAI,EAA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MAAMY,cAAc,OAAO,CAACb,KAAK,EAAE;oBAClD,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIK,cAAcL,OAAO,KAAK;oBAEzC,OAAO,IAAIM,SAAS;gBACxB;QAER;QAEA,OAAOV;IACX;AACJ;AAEO,MAAMiB,oBAAoBC,qBAAqB,oBAAoB,CAAC;IACvE,gBAAgBnB;IAChB,cAAc,EAAE;AACpB"}
|
package/api/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { WebhooksFeature } from "./WebhooksFeature.js";
|
|
2
2
|
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
3
|
-
const createWebhooks = ()=>
|
|
3
|
+
const createWebhooks = ()=>{
|
|
4
|
+
const plugin = createRegisterExtensionPlugin(async (context)=>{
|
|
4
5
|
WebhooksFeature.register(context.container);
|
|
5
6
|
});
|
|
7
|
+
plugin.name = "webhooks.extension";
|
|
8
|
+
return plugin;
|
|
9
|
+
};
|
|
6
10
|
export { createWebhooks };
|
|
7
11
|
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/index.js","sources":["../../src/api/index.ts"],"sourcesContent":["import { WebhooksFeature } from \"./WebhooksFeature.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\nexport const createWebhooks = () => {\n
|
|
1
|
+
{"version":3,"file":"api/index.js","sources":["../../src/api/index.ts"],"sourcesContent":["import { WebhooksFeature } from \"./WebhooksFeature.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\nexport const createWebhooks = () => {\n const plugin = createRegisterExtensionPlugin(async context => {\n WebhooksFeature.register(context.container);\n });\n\n plugin.name = \"webhooks.extension\";\n\n return plugin;\n};\n"],"names":["createWebhooks","plugin","createRegisterExtensionPlugin","context","WebhooksFeature"],"mappings":";;AAGO,MAAMA,iBAAiB;IAC1B,MAAMC,SAASC,8BAA8B,OAAMC;QAC/CC,gBAAgB,QAAQ,CAACD,QAAQ,SAAS;IAC9C;IAEAF,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
|
|
@@ -2,7 +2,7 @@ const isValidEndpointUrl = (url)=>{
|
|
|
2
2
|
try {
|
|
3
3
|
const parsed = new URL(url);
|
|
4
4
|
if ("https:" === parsed.protocol) return true;
|
|
5
|
-
|
|
5
|
+
if ("http:" === parsed.protocol && ("localhost" === parsed.hostname || "127.0.0.1" === parsed.hostname)) return true;
|
|
6
6
|
return false;
|
|
7
7
|
} catch {
|
|
8
8
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/utils/isValidEndpointUrl.js","sources":["../../../src/api/utils/isValidEndpointUrl.ts"],"sourcesContent":["export const isValidEndpointUrl = (url: string): boolean => {\n try {\n const parsed = new URL(url);\n if (parsed.protocol === \"https:\") {\n return true;\n } else if (\n parsed.protocol === \"http:\" &&\n (parsed.hostname === \"localhost\" || parsed.hostname === \"127.0.0.1\")\n ) {\n return true;\n }\n return false;\n } catch {\n return false;\n }\n};\n"],"names":["isValidEndpointUrl","url","parsed","URL"],"mappings":"AAAO,MAAMA,qBAAqB,CAACC;IAC/B,IAAI;QACA,MAAMC,SAAS,IAAIC,IAAIF;QACvB,IAAIC,AAAoB,aAApBA,OAAO,QAAQ,EACf,OAAO;
|
|
1
|
+
{"version":3,"file":"api/utils/isValidEndpointUrl.js","sources":["../../../src/api/utils/isValidEndpointUrl.ts"],"sourcesContent":["export const isValidEndpointUrl = (url: string): boolean => {\n try {\n const parsed = new URL(url);\n if (parsed.protocol === \"https:\") {\n return true;\n } else if (\n parsed.protocol === \"http:\" &&\n (parsed.hostname === \"localhost\" || parsed.hostname === \"127.0.0.1\")\n ) {\n return true;\n }\n return false;\n } catch {\n return false;\n }\n};\n"],"names":["isValidEndpointUrl","url","parsed","URL"],"mappings":"AAAO,MAAMA,qBAAqB,CAACC;IAC/B,IAAI;QACA,MAAMC,SAAS,IAAIC,IAAIF;QACvB,IAAIC,AAAoB,aAApBA,OAAO,QAAQ,EACf,OAAO;QACJ,IACHA,AAAoB,YAApBA,OAAO,QAAQ,IACdA,CAAAA,AAAoB,gBAApBA,OAAO,QAAQ,IAAoBA,AAAoB,gBAApBA,OAAO,QAAQ,AAAe,GAElE,OAAO;QAEX,OAAO;IACX,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/webhooks",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -19,35 +19,35 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@webiny/admin-ui": "6.
|
|
23
|
-
"@webiny/api-core": "6.
|
|
24
|
-
"@webiny/api-headless-cms": "6.
|
|
25
|
-
"@webiny/app": "6.
|
|
26
|
-
"@webiny/app-admin": "6.
|
|
27
|
-
"@webiny/background-tasks": "6.
|
|
28
|
-
"@webiny/feature": "6.
|
|
29
|
-
"@webiny/handler-graphql": "6.
|
|
30
|
-
"@webiny/icons": "6.
|
|
31
|
-
"@webiny/sdk": "6.
|
|
32
|
-
"@webiny/utils": "6.
|
|
22
|
+
"@webiny/admin-ui": "6.5.0-beta.0",
|
|
23
|
+
"@webiny/api-core": "6.5.0-beta.0",
|
|
24
|
+
"@webiny/api-headless-cms": "6.5.0-beta.0",
|
|
25
|
+
"@webiny/app": "6.5.0-beta.0",
|
|
26
|
+
"@webiny/app-admin": "6.5.0-beta.0",
|
|
27
|
+
"@webiny/background-tasks": "6.5.0-beta.0",
|
|
28
|
+
"@webiny/feature": "6.5.0-beta.0",
|
|
29
|
+
"@webiny/handler-graphql": "6.5.0-beta.0",
|
|
30
|
+
"@webiny/icons": "6.5.0-beta.0",
|
|
31
|
+
"@webiny/sdk": "6.5.0-beta.0",
|
|
32
|
+
"@webiny/utils": "6.5.0-beta.0",
|
|
33
33
|
"lodash": "4.18.1",
|
|
34
|
-
"mobx": "
|
|
35
|
-
"mobx-react-lite": "
|
|
34
|
+
"mobx": "6.16.1",
|
|
35
|
+
"mobx-react-lite": "4.1.1",
|
|
36
36
|
"react": "18.3.1",
|
|
37
37
|
"react-dom": "18.3.1",
|
|
38
|
-
"standardwebhooks": "1.
|
|
39
|
-
"zod": "4.
|
|
38
|
+
"standardwebhooks": "1.0.0",
|
|
39
|
+
"zod": "4.4.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@webiny/api": "6.
|
|
43
|
-
"@webiny/build-tools": "6.
|
|
44
|
-
"@webiny/di": "1.
|
|
45
|
-
"@webiny/handler": "6.
|
|
46
|
-
"@webiny/handler-aws": "6.
|
|
47
|
-
"@webiny/plugins": "6.
|
|
48
|
-
"@webiny/project-utils": "6.
|
|
49
|
-
"typescript": "
|
|
50
|
-
"vitest": "
|
|
42
|
+
"@webiny/api": "6.5.0-beta.0",
|
|
43
|
+
"@webiny/build-tools": "6.5.0-beta.0",
|
|
44
|
+
"@webiny/di": "1.0.2",
|
|
45
|
+
"@webiny/handler": "6.5.0-beta.0",
|
|
46
|
+
"@webiny/handler-aws": "6.5.0-beta.0",
|
|
47
|
+
"@webiny/plugins": "6.5.0-beta.0",
|
|
48
|
+
"@webiny/project-utils": "6.5.0-beta.0",
|
|
49
|
+
"typescript": "7.0.2",
|
|
50
|
+
"vitest": "4.1.10"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|