@webiny/webhooks 0.0.0-unstable.33e4fd9647 → 0.0.0-unstable.48a4e5b6c1
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/Webhooks.d.ts +6 -0
- package/Webhooks.js +11 -0
- package/Webhooks.js.map +1 -0
- package/admin/Extension.d.ts +1 -0
- package/admin/Extension.js +1 -0
- package/admin/WebhookRoutes.js +1 -1
- package/admin/WebhookRoutes.js.map +1 -1
- package/admin/Webhooks.js +1 -1
- package/admin/Webhooks.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.d.ts +8 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js +64 -25
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.test.d.ts +1 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.test.js +119 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.test.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.d.ts +2 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -1
- package/admin/presentation/WebhookList/WebhookListPresenter.d.ts +1 -0
- package/admin/presentation/WebhookList/WebhookListPresenter.js +12 -1
- package/admin/presentation/WebhookList/WebhookListPresenter.js.map +1 -1
- package/admin/presentation/WebhookList/abstractions.d.ts +2 -0
- package/admin/presentation/WebhookList/abstractions.js.map +1 -1
- package/admin/presentation/WebhookList/components/WebhookListView.js +1 -0
- package/admin/presentation/WebhookList/components/WebhookListView.js.map +1 -1
- package/api/domain/errors.d.ts +12 -0
- package/api/domain/errors.js +12 -1
- package/api/domain/errors.js.map +1 -1
- package/api/features/CreateWebhook/schema.js +1 -1
- package/api/features/CreateWebhook/schema.js.map +1 -1
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.d.ts +14 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.js +24 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.js.map +1 -0
- package/api/features/GetWebhookSettings/abstractions.d.ts +14 -1
- package/api/features/GetWebhookSettings/abstractions.js +2 -1
- package/api/features/GetWebhookSettings/abstractions.js.map +1 -1
- package/api/features/GetWebhookSettings/feature.js +2 -0
- package/api/features/GetWebhookSettings/feature.js.map +1 -1
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.d.ts +3 -1
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js +18 -5
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/ResendWebhookDelivery/abstractions.d.ts +2 -1
- package/api/features/ResendWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/SendWebhookTask/SendWebhookTask.js +15 -1
- package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.d.ts +3 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js +18 -5
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js.map +1 -1
- package/api/features/TriggerWebhook/abstractions.d.ts +2 -1
- package/api/features/TriggerWebhook/abstractions.js.map +1 -1
- package/api/features/UpdateWebhook/schema.js +1 -1
- package/api/features/UpdateWebhook/schema.js.map +1 -1
- package/api/features/WebhookDeliver/WebhookDeliver.js +1 -0
- package/api/features/WebhookDeliver/WebhookDeliver.js.map +1 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.d.ts +5 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.js +25 -4
- package/api/features/WebhookDispatcher/WebhookDispatcher.js.map +1 -1
- package/api/graphql/WebhookCrudSchema.js +21 -6
- package/api/graphql/WebhookCrudSchema.js.map +1 -1
- package/api/graphql/WebhookSettingsSchema.js +2 -2
- package/api/graphql/WebhookSettingsSchema.js.map +1 -1
- package/api/utils/isValidEndpointUrl.js +29 -3
- package/api/utils/isValidEndpointUrl.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +28 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookList/WebhookListPresenter.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport {\n WebhookListPresenter as Abstraction,\n type IWebhookListPresenter,\n type IWebhookListViewModel\n} from \"./abstractions.js\";\nimport { WebhookListDataSource } from \"./WebhookListDataSource.js\";\nimport { ListWebhooksUseCase } from \"~/admin/features/ListWebhooks/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { TriggerWebhookUseCase } from \"~/admin/features/triggerWebhook/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\n\nclass WebhookListPresenterImpl implements IWebhookListPresenter {\n constructor(\n private readonly listPresenter: ListPresenter.Interface<Webhook>,\n private readonly listWebhooksUseCase: ListWebhooksUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly triggerWebhookUseCase: TriggerWebhookUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IWebhookListViewModel {\n return {\n list: this.listPresenter.vm,\n permissions: {\n canRead: this.permissions.canRead(\"webhook\"),\n canCreate: this.permissions.canCreate(\"webhook\"),\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n }\n };\n }\n\n public readonly search = {\n set: (query: string) => this.listPresenter.actions.search.set(query),\n clear: () => this.listPresenter.actions.search.clear()\n };\n\n public readonly sort = {\n set: (field: string, direction: \"ASC\" | \"DESC\") =>\n this.listPresenter.actions.sort.set(field, direction),\n toggle: (field: string) => this.listPresenter.actions.sort.toggle(field)\n };\n\n public readonly filter = {\n set: (key: string, value: unknown) => this.listPresenter.actions.filter.set(key, value),\n clear: (key: string) => this.listPresenter.actions.filter.clear(key),\n clearAll: () => this.listPresenter.actions.filter.clearAll()\n };\n\n public readonly selection = {\n toggle: (id: string) => this.listPresenter.actions.selection.toggle(id),\n selectRangeTo: (id: string) => this.listPresenter.actions.selection.selectRangeTo(id),\n selectAll: () => this.listPresenter.actions.selection.selectAll(),\n deselectAll: () => this.listPresenter.actions.selection.deselectAll(),\n selectRows: (ids: string[]) => this.listPresenter.actions.selection.selectRows(ids),\n isSelected: (id: string) => this.listPresenter.actions.selection.isSelected(id)\n };\n\n public async loadMore(): Promise<void> {\n await this.listPresenter.actions.loadMore();\n }\n\n public async refresh(): Promise<void> {\n await this.listPresenter.actions.refresh();\n }\n\n public async deleteWebhook(id: string): Promise<void> {\n await this.deleteWebhookUseCase.execute(id);\n await this.listPresenter.actions.refresh();\n }\n\n public async triggerWebhook(id: string): Promise<void> {\n await this.triggerWebhookUseCase.execute(id, { test: true });\n await this.listPresenter.actions.refresh();\n }\n\n init(): void {\n const dataSource = new WebhookListDataSource(this.listWebhooksUseCase);\n this.listPresenter.init({\n dataSource,\n initialSort: { field: \"createdOn\", direction: \"DESC\" },\n limit: 20\n });\n }\n}\n\nexport const WebhookListPresenter = Abstraction.createImplementation({\n implementation: WebhookListPresenterImpl,\n dependencies: [\n ListPresenter,\n ListWebhooksUseCase,\n DeleteWebhookUseCase,\n TriggerWebhookUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookListPresenterImpl","listPresenter","listWebhooksUseCase","deleteWebhookUseCase","triggerWebhookUseCase","permissions","query","field","direction","key","value","id","ids","makeAutoObservable","computed","dataSource","WebhookListDataSource","WebhookListPresenter","Abstraction","ListPresenter","ListWebhooksUseCase","DeleteWebhookUseCase","TriggerWebhookUseCase","WebhookPermissions"],"mappings":";;;;;;;;AAcA,MAAMA;IACF,YACqBC,aAA+C,EAC/CC,mBAAkD,EAClDC,oBAAoD,EACpDC,qBAAsD,EACtDC,WAAyC,CAC5D;aALmBJ,aAAa,GAAbA;aACAC,mBAAmB,GAAnBA;aACAC,oBAAoB,GAApBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;aAiBL,MAAM,GAAG;YACrB,KAAK,CAACC,QAAkB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAACA;YAC9D,OAAO,IAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QACxD;aAEgB,IAAI,GAAG;YACnB,KAAK,CAACC,OAAeC,YACjB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAACD,OAAOC;YAC/C,QAAQ,CAACD,QAAkB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAACA;QACtE;aAEgB,MAAM,GAAG;YACrB,KAAK,CAACE,KAAaC,QAAmB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAACD,KAAKC;YACjF,OAAO,CAACD,MAAgB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAACA;YAChE,UAAU,IAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ;QAC9D;aAEgB,SAAS,GAAG;YACxB,QAAQ,CAACE,KAAe,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAACA;YACpE,eAAe,CAACA,KAAe,IAAI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AMI,aAAa,IAAIC,sBAAsB,IAAI,CAAC,mBAAmB;QACrE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACpBD;YACA,aAAa;gBAAE,OAAO;gBAAa,WAAW;YAAO;YACrD,OAAO;
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookList/WebhookListPresenter.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { ListPresenter } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport {\n WebhookListPresenter as Abstraction,\n type IWebhookListPresenter,\n type IWebhookListViewModel\n} from \"./abstractions.js\";\nimport { WebhookListDataSource } from \"./WebhookListDataSource.js\";\nimport { ListWebhooksUseCase } from \"~/admin/features/ListWebhooks/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { TriggerWebhookUseCase } from \"~/admin/features/triggerWebhook/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\n\nclass WebhookListPresenterImpl implements IWebhookListPresenter {\n constructor(\n private readonly listPresenter: ListPresenter.Interface<Webhook>,\n private readonly listWebhooksUseCase: ListWebhooksUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly triggerWebhookUseCase: TriggerWebhookUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n makeAutoObservable(this, { vm: computed });\n }\n\n get vm(): IWebhookListViewModel {\n return {\n list: this.listPresenter.vm,\n permissions: {\n canRead: this.permissions.canRead(\"webhook\"),\n canCreate: this.permissions.canCreate(\"webhook\"),\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n }\n };\n }\n\n public readonly search = {\n set: (query: string) => this.listPresenter.actions.search.set(query),\n clear: () => this.listPresenter.actions.search.clear()\n };\n\n public readonly sort = {\n set: (field: string, direction: \"ASC\" | \"DESC\") =>\n this.listPresenter.actions.sort.set(field, direction),\n toggle: (field: string) => this.listPresenter.actions.sort.toggle(field)\n };\n\n public readonly filter = {\n set: (key: string, value: unknown) => this.listPresenter.actions.filter.set(key, value),\n clear: (key: string) => this.listPresenter.actions.filter.clear(key),\n clearAll: () => this.listPresenter.actions.filter.clearAll()\n };\n\n public readonly selection = {\n toggle: (id: string) => this.listPresenter.actions.selection.toggle(id),\n selectRangeTo: (id: string) => this.listPresenter.actions.selection.selectRangeTo(id),\n selectAll: () => this.listPresenter.actions.selection.selectAll(),\n deselectAll: () => this.listPresenter.actions.selection.deselectAll(),\n selectRows: (ids: string[]) => this.listPresenter.actions.selection.selectRows(ids),\n isSelected: (id: string) => this.listPresenter.actions.selection.isSelected(id)\n };\n\n public async loadMore(): Promise<void> {\n await this.listPresenter.actions.loadMore();\n }\n\n public async refresh(): Promise<void> {\n await this.listPresenter.actions.refresh();\n }\n\n public async deleteWebhook(id: string): Promise<void> {\n await this.deleteWebhookUseCase.execute(id);\n await this.listPresenter.actions.refresh();\n }\n\n public async triggerWebhook(id: string): Promise<void> {\n await this.triggerWebhookUseCase.execute(id, { test: true });\n await this.listPresenter.actions.refresh();\n }\n\n init(): void {\n const dataSource = new WebhookListDataSource(this.listWebhooksUseCase);\n this.listPresenter.init({\n dataSource,\n initialSort: { field: \"createdOn\", direction: \"DESC\" },\n limit: 20,\n itemLabel: { singular: \"webhook\", plural: \"webhooks\" },\n assistant: {\n view: () => \"Webhooks\",\n rowTitle: webhook => webhook.name\n }\n });\n }\n\n dispose(): void {\n this.listPresenter.dispose();\n }\n}\n\nexport const WebhookListPresenter = Abstraction.createImplementation({\n implementation: WebhookListPresenterImpl,\n dependencies: [\n ListPresenter,\n ListWebhooksUseCase,\n DeleteWebhookUseCase,\n TriggerWebhookUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookListPresenterImpl","listPresenter","listWebhooksUseCase","deleteWebhookUseCase","triggerWebhookUseCase","permissions","query","field","direction","key","value","id","ids","makeAutoObservable","computed","dataSource","WebhookListDataSource","webhook","WebhookListPresenter","Abstraction","ListPresenter","ListWebhooksUseCase","DeleteWebhookUseCase","TriggerWebhookUseCase","WebhookPermissions"],"mappings":";;;;;;;;AAcA,MAAMA;IACF,YACqBC,aAA+C,EAC/CC,mBAAkD,EAClDC,oBAAoD,EACpDC,qBAAsD,EACtDC,WAAyC,CAC5D;aALmBJ,aAAa,GAAbA;aACAC,mBAAmB,GAAnBA;aACAC,oBAAoB,GAApBA;aACAC,qBAAqB,GAArBA;aACAC,WAAW,GAAXA;aAiBL,MAAM,GAAG;YACrB,KAAK,CAACC,QAAkB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAACA;YAC9D,OAAO,IAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QACxD;aAEgB,IAAI,GAAG;YACnB,KAAK,CAACC,OAAeC,YACjB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAACD,OAAOC;YAC/C,QAAQ,CAACD,QAAkB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAACA;QACtE;aAEgB,MAAM,GAAG;YACrB,KAAK,CAACE,KAAaC,QAAmB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAACD,KAAKC;YACjF,OAAO,CAACD,MAAgB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAACA;YAChE,UAAU,IAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ;QAC9D;aAEgB,SAAS,GAAG;YACxB,QAAQ,CAACE,KAAe,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAACA;YACpE,eAAe,CAACA,KAAe,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS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C,mBAAmB;QACrE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACpBD;YACA,aAAa;gBAAE,OAAO;gBAAa,WAAW;YAAO;YACrD,OAAO;YACP,WAAW;gBAAE,UAAU;gBAAW,QAAQ;YAAW;YACrD,WAAW;gBACP,MAAM,IAAM;gBACZ,UAAUE,CAAAA,UAAWA,QAAQ,IAAI;YACrC;QACJ;IACJ;IAEA,UAAgB;QACZ,IAAI,CAAC,aAAa,CAAC,OAAO;IAC9B;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -12,6 +12,8 @@ export interface IWebhookListViewModel {
|
|
|
12
12
|
export interface IWebhookListPresenter {
|
|
13
13
|
vm: IWebhookListViewModel;
|
|
14
14
|
init(): void;
|
|
15
|
+
/** Stops telling the assistant about the webhooks list. */
|
|
16
|
+
dispose(): void;
|
|
15
17
|
search: {
|
|
16
18
|
set(query: string): void;
|
|
17
19
|
clear(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookList/abstractions.js","sources":["../../../../src/admin/presentation/WebhookList/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IListViewModel } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\n\nexport interface IWebhookListViewModel {\n list: IListViewModel<Webhook>;\n permissions: {\n canRead: boolean;\n canCreate: boolean;\n canEdit: boolean;\n canDelete: boolean;\n };\n}\n\nexport interface IWebhookListPresenter {\n vm: IWebhookListViewModel;\n init(): void;\n search: { set(query: string): void; clear(): void };\n sort: { set(field: string, direction: \"ASC\" | \"DESC\"): void; toggle(field: string): void };\n filter: { set(key: string, value: unknown): void; clear(key: string): void; clearAll(): void };\n selection: {\n toggle(id: string): void;\n selectRangeTo(id: string): void;\n selectAll(): void;\n deselectAll(): void;\n selectRows(ids: string[]): void;\n isSelected(id: string): boolean;\n };\n loadMore(): Promise<void>;\n refresh(): Promise<void>;\n deleteWebhook(id: string): Promise<void>;\n triggerWebhook(id: string): Promise<void>;\n}\n\nexport const WebhookListPresenter =\n createAbstraction<IWebhookListPresenter>(\"WebhookListPresenter\");\n\nexport namespace WebhookListPresenter {\n export type Interface = IWebhookListPresenter;\n export type ViewModel = IWebhookListViewModel;\n}\n"],"names":["WebhookListPresenter","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookList/abstractions.js","sources":["../../../../src/admin/presentation/WebhookList/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IListViewModel } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\n\nexport interface IWebhookListViewModel {\n list: IListViewModel<Webhook>;\n permissions: {\n canRead: boolean;\n canCreate: boolean;\n canEdit: boolean;\n canDelete: boolean;\n };\n}\n\nexport interface IWebhookListPresenter {\n vm: IWebhookListViewModel;\n init(): void;\n /** Stops telling the assistant about the webhooks list. */\n dispose(): void;\n search: { set(query: string): void; clear(): void };\n sort: { set(field: string, direction: \"ASC\" | \"DESC\"): void; toggle(field: string): void };\n filter: { set(key: string, value: unknown): void; clear(key: string): void; clearAll(): void };\n selection: {\n toggle(id: string): void;\n selectRangeTo(id: string): void;\n selectAll(): void;\n deselectAll(): void;\n selectRows(ids: string[]): void;\n isSelected(id: string): boolean;\n };\n loadMore(): Promise<void>;\n refresh(): Promise<void>;\n deleteWebhook(id: string): Promise<void>;\n triggerWebhook(id: string): Promise<void>;\n}\n\nexport const WebhookListPresenter =\n createAbstraction<IWebhookListPresenter>(\"WebhookListPresenter\");\n\nexport namespace WebhookListPresenter {\n export type Interface = IWebhookListPresenter;\n export type ViewModel = IWebhookListViewModel;\n}\n"],"names":["WebhookListPresenter","createAbstraction"],"mappings":";AAoCO,MAAMA,uBACTC,kBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookList/components/WebhookListView.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListView.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature } from \"@webiny/app\";\nimport { Heading, Separator } from \"@webiny/admin-ui\";\nimport { WebhookListPresenterFeature } from \"../feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { TriggerWebhookFeature } from \"~/admin/features/triggerWebhook/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { WebhookListContent } from \"./WebhookListContent.js\";\nimport { WebhookDeliveriesButton } from \"~/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js\";\n\nconst WebhookListViewInner = observer(function WebhookListViewInner() {\n const { presenter } = useFeature(WebhookListPresenterFeature);\n\n useEffect(() => {\n presenter.init();\n }, [presenter]);\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}>Webhooks</Heading>\n <div className={\"flex gap-sm\"}>\n <WebhookDeliveriesButton />\n <CreateWebhookButton />\n </div>\n </div>\n <Separator />\n <WebhookListContent presenter={presenter} />\n </div>\n );\n});\n\nexport const WebhookListView = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhooksFeature.register(child);\n DeleteWebhookFeature.register(child);\n TriggerWebhookFeature.register(child);\n WebhookPermissionsFeature.register(child);\n WebhookListPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookListViewInner />\n </DiContainerProvider>\n );\n};\n"],"names":["WebhookListViewInner","observer","presenter","useFeature","WebhookListPresenterFeature","useEffect","Heading","WebhookDeliveriesButton","CreateWebhookButton","Separator","WebhookListContent","WebhookListView","container","useContainer","scopedContainer","useMemo","child","ListWebhooksFeature","DeleteWebhookFeature","TriggerWebhookFeature","WebhookPermissionsFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,uCAAuBC,SAAS;IAClC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjCC,UAAU;QACNH,UAAU,IAAI;
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookList/components/WebhookListView.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListView.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature } from \"@webiny/app\";\nimport { Heading, Separator } from \"@webiny/admin-ui\";\nimport { WebhookListPresenterFeature } from \"../feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { TriggerWebhookFeature } from \"~/admin/features/triggerWebhook/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { WebhookListContent } from \"./WebhookListContent.js\";\nimport { WebhookDeliveriesButton } from \"~/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js\";\n\nconst WebhookListViewInner = observer(function WebhookListViewInner() {\n const { presenter } = useFeature(WebhookListPresenterFeature);\n\n useEffect(() => {\n presenter.init();\n return () => presenter.dispose();\n }, [presenter]);\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}>Webhooks</Heading>\n <div className={\"flex gap-sm\"}>\n <WebhookDeliveriesButton />\n <CreateWebhookButton />\n </div>\n </div>\n <Separator />\n <WebhookListContent presenter={presenter} />\n </div>\n );\n});\n\nexport const WebhookListView = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhooksFeature.register(child);\n DeleteWebhookFeature.register(child);\n TriggerWebhookFeature.register(child);\n WebhookPermissionsFeature.register(child);\n WebhookListPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookListViewInner />\n </DiContainerProvider>\n );\n};\n"],"names":["WebhookListViewInner","observer","presenter","useFeature","WebhookListPresenterFeature","useEffect","Heading","WebhookDeliveriesButton","CreateWebhookButton","Separator","WebhookListContent","WebhookListView","container","useContainer","scopedContainer","useMemo","child","ListWebhooksFeature","DeleteWebhookFeature","TriggerWebhookFeature","WebhookPermissionsFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,uCAAuBC,SAAS;IAClC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IAEjCC,UAAU;QACNH,UAAU,IAAI;QACd,OAAO,IAAMA,UAAU,OAAO;IAClC,GAAG;QAACA;KAAU;IAEd,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACI,SAAOA;QAAC,OAAO;OAAG,2BACnB,oBAAC;QAAI,WAAW;qBACZ,oBAACC,yBAAuBA,OAAAA,WAAAA,GACxB,oBAACC,qBAAmBA,SAAAA,WAAAA,GAG5B,oBAACC,WAASA,OAAAA,WAAAA,GACV,oBAACC,oBAAkBA;QAAC,WAAWR;;AAG3C;AAEO,MAAMS,kBAAkB;IAC3B,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBC,QAAQ;QAC5B,MAAMC,QAAQJ,UAAU,oBAAoB;QAC5CK,oBAAoB,QAAQ,CAACD;QAC7BE,qBAAqB,QAAQ,CAACF;QAC9BG,sBAAsB,QAAQ,CAACH;QAC/BI,0BAA0B,QAAQ,CAACJ;QACnCZ,4BAA4B,QAAQ,CAACY;QACrC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACK,qBAAmBA;QAAC,WAAWP;qBAC5B,oBAACd,sCAAoBA;AAGjC"}
|
package/api/domain/errors.d.ts
CHANGED
|
@@ -26,6 +26,18 @@ export declare class WebhookPersistenceError extends BaseError<WebhookPersistenc
|
|
|
26
26
|
constructor(error: Error);
|
|
27
27
|
static from(error: unknown): WebhookPersistenceError;
|
|
28
28
|
}
|
|
29
|
+
interface WebhookDeliveryNotQueuedErrorData {
|
|
30
|
+
deliveryId: string;
|
|
31
|
+
markedFailed: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare class WebhookDeliveryNotQueuedError extends BaseError<WebhookDeliveryNotQueuedErrorData> {
|
|
34
|
+
readonly code: "WEBHOOK_DELIVERY_NOT_QUEUED";
|
|
35
|
+
constructor(params: {
|
|
36
|
+
message: string;
|
|
37
|
+
deliveryId: string;
|
|
38
|
+
markedFailed: boolean;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
29
41
|
export declare class WebhookModelNotFoundError extends BaseError {
|
|
30
42
|
readonly code: "WEBHOOK_MODEL_NOT_FOUND";
|
|
31
43
|
constructor(modelId: string);
|
package/api/domain/errors.js
CHANGED
|
@@ -57,6 +57,17 @@ class WebhookPersistenceError extends BaseError {
|
|
|
57
57
|
return new WebhookPersistenceError(new Error(String(error)));
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
class WebhookDeliveryNotQueuedError extends BaseError {
|
|
61
|
+
constructor(params){
|
|
62
|
+
super({
|
|
63
|
+
message: `Could not queue the webhook delivery: ${params.message}`,
|
|
64
|
+
data: {
|
|
65
|
+
deliveryId: params.deliveryId,
|
|
66
|
+
markedFailed: params.markedFailed
|
|
67
|
+
}
|
|
68
|
+
}), this.code = "WEBHOOK_DELIVERY_NOT_QUEUED";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
60
71
|
class WebhookModelNotFoundError extends BaseError {
|
|
61
72
|
constructor(modelId){
|
|
62
73
|
super({
|
|
@@ -78,6 +89,6 @@ class WebhookNotAuthorizedError extends BaseError {
|
|
|
78
89
|
}), this.code = "WEBHOOK_NOT_AUTHORIZED";
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
|
-
export { WebhookDeliveryNotFoundError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookNotFoundError, WebhookPersistenceError, WebhookValidationError, WebhookVerificationFailedError };
|
|
92
|
+
export { WebhookDeliveryNotFoundError, WebhookDeliveryNotQueuedError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookNotFoundError, WebhookPersistenceError, WebhookValidationError, WebhookVerificationFailedError };
|
|
82
93
|
|
|
83
94
|
//# sourceMappingURL=errors.js.map
|
package/api/domain/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/domain/errors.js","sources":["../../../src/api/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\nimport { parseZodError } from \"@webiny/utils\";\nimport type { ValidationIssue } from \"@webiny/utils\";\n\nexport class WebhookNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_NOT_FOUND\" as const;\n\n constructor(id: string) {\n super({ message: `Webhook \"${id}\" was not found.` });\n }\n}\n\nexport class WebhookDeliveryNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_DELIVERY_NOT_FOUND\" as const;\n\n constructor(id: string) {\n super({ message: `Webhook delivery \"${id}\" was not found.` });\n }\n}\n\ninterface WebhookValidationErrorData {\n issues: ValidationIssue[];\n}\n\nexport class WebhookValidationError extends BaseError<WebhookValidationErrorData> {\n override readonly code = \"WEBHOOK_VALIDATION_ERROR\" as const;\n\n constructor(error: string | ZodError) {\n if (typeof error === \"string\") {\n super({ message: error, data: { issues: [] } });\n } else {\n const issues = parseZodError(error);\n super({ message: \"Validation failed.\", data: { issues } });\n }\n }\n}\n\ninterface WebhookPersistenceErrorData {\n originalMessage: string;\n originalCode?: string;\n originalData?: unknown;\n}\n\nexport class WebhookPersistenceError extends BaseError<WebhookPersistenceErrorData> {\n override readonly code = \"WEBHOOK_PERSISTENCE_ERROR\" as const;\n\n constructor(error: Error) {\n super({ message: error.message, data: { originalMessage: error.message } });\n }\n\n static from(error: unknown): WebhookPersistenceError {\n if (error instanceof Error) {\n const instance = new WebhookPersistenceError(error);\n const data: WebhookPersistenceErrorData = {\n originalMessage: error.message,\n originalCode: (error as any).code,\n originalData: (error as any).data\n };\n (instance as any).data = data;\n instance.stack = error.stack;\n return instance;\n }\n\n return new WebhookPersistenceError(new Error(String(error)));\n }\n}\n\nexport class WebhookModelNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_MODEL_NOT_FOUND\" as const;\n\n constructor(modelId: string) {\n super({ message: `Webhook model \"${modelId}\" was not found.` });\n }\n}\n\nexport class WebhookVerificationFailedError extends BaseError {\n override readonly code = \"WEBHOOK_VERIFICATION_FAILED\" as const;\n\n constructor(message: string) {\n super({ message });\n }\n}\n\nexport class WebhookNotAuthorizedError extends BaseError {\n override readonly code = \"WEBHOOK_NOT_AUTHORIZED\" as const;\n\n constructor() {\n super({ message: \"Not authorized!\" });\n }\n}\n"],"names":["WebhookNotFoundError","BaseError","id","WebhookDeliveryNotFoundError","WebhookValidationError","error","issues","parseZodError","WebhookPersistenceError","Error","instance","data","String","WebhookModelNotFoundError","modelId","WebhookVerificationFailedError","message","WebhookNotAuthorizedError"],"mappings":";;AAKO,MAAMA,6BAA6BC;IAGtC,YAAYC,EAAU,CAAE;QACpB,KAAK,CAAC;YAAE,SAAS,CAAC,SAAS,EAAEA,GAAG,gBAAgB,CAAC;QAAC,SAHpC,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMC,qCAAqCF;IAG9C,YAAYC,EAAU,CAAE;QACpB,KAAK,CAAC;YAAE,SAAS,CAAC,kBAAkB,EAAEA,GAAG,gBAAgB,CAAC;QAAC,SAH7C,IAAI,GAAG;IAIzB;AACJ;AAMO,MAAME,+BAA+BH;IAGxC,YAAYI,KAAwB,CAAE;QAClC,IAAI,AAAiB,YAAjB,OAAOA,OACP,KAAK,CAAC;YAAE,SAASA;YAAO,MAAM;gBAAE,QAAQ,EAAE;YAAC;QAAE,SAJnC,IAAI,GAAG;aAKd;YACH,MAAMC,SAASC,cAAcF;YAC7B,KAAK,CAAC;gBAAE,SAAS;gBAAsB,MAAM;oBAAEC;gBAAO;YAAE,SAP9C,IAAI,GAAG;QAQrB;IACJ;AACJ;AAQO,MAAME,gCAAgCP;IAGzC,YAAYI,KAAY,CAAE;QACtB,KAAK,CAAC;YAAE,SAASA,MAAM,OAAO;YAAE,MAAM;gBAAE,iBAAiBA,MAAM,OAAO;YAAC;QAAE,SAH3D,IAAI,GAAG;IAIzB;IAEA,OAAO,KAAKA,KAAc,EAA2B;QACjD,IAAIA,iBAAiBI,OAAO;YACxB,MAAMC,WAAW,IAAIF,wBAAwBH;YAC7C,MAAMM,OAAoC;gBACtC,iBAAiBN,MAAM,OAAO;gBAC9B,cAAeA,MAAc,IAAI;gBACjC,cAAeA,MAAc,IAAI;YACrC;YACCK,SAAiB,IAAI,GAAGC;YACzBD,SAAS,KAAK,GAAGL,MAAM,KAAK;YAC5B,OAAOK;QACX;QAEA,OAAO,IAAIF,wBAAwB,IAAIC,MAAMG,OAAOP;IACxD;AACJ;
|
|
1
|
+
{"version":3,"file":"api/domain/errors.js","sources":["../../../src/api/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\nimport { parseZodError } from \"@webiny/utils\";\nimport type { ValidationIssue } from \"@webiny/utils\";\n\nexport class WebhookNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_NOT_FOUND\" as const;\n\n constructor(id: string) {\n super({ message: `Webhook \"${id}\" was not found.` });\n }\n}\n\nexport class WebhookDeliveryNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_DELIVERY_NOT_FOUND\" as const;\n\n constructor(id: string) {\n super({ message: `Webhook delivery \"${id}\" was not found.` });\n }\n}\n\ninterface WebhookValidationErrorData {\n issues: ValidationIssue[];\n}\n\nexport class WebhookValidationError extends BaseError<WebhookValidationErrorData> {\n override readonly code = \"WEBHOOK_VALIDATION_ERROR\" as const;\n\n constructor(error: string | ZodError) {\n if (typeof error === \"string\") {\n super({ message: error, data: { issues: [] } });\n } else {\n const issues = parseZodError(error);\n super({ message: \"Validation failed.\", data: { issues } });\n }\n }\n}\n\ninterface WebhookPersistenceErrorData {\n originalMessage: string;\n originalCode?: string;\n originalData?: unknown;\n}\n\nexport class WebhookPersistenceError extends BaseError<WebhookPersistenceErrorData> {\n override readonly code = \"WEBHOOK_PERSISTENCE_ERROR\" as const;\n\n constructor(error: Error) {\n super({ message: error.message, data: { originalMessage: error.message } });\n }\n\n static from(error: unknown): WebhookPersistenceError {\n if (error instanceof Error) {\n const instance = new WebhookPersistenceError(error);\n const data: WebhookPersistenceErrorData = {\n originalMessage: error.message,\n originalCode: (error as any).code,\n originalData: (error as any).data\n };\n (instance as any).data = data;\n instance.stack = error.stack;\n return instance;\n }\n\n return new WebhookPersistenceError(new Error(String(error)));\n }\n}\n\ninterface WebhookDeliveryNotQueuedErrorData {\n deliveryId: string;\n // False when the delivery could not be marked failed either, so it is still stored as pending.\n markedFailed: boolean;\n}\n\nexport class WebhookDeliveryNotQueuedError extends BaseError<WebhookDeliveryNotQueuedErrorData> {\n override readonly code = \"WEBHOOK_DELIVERY_NOT_QUEUED\" as const;\n\n constructor(params: { message: string; deliveryId: string; markedFailed: boolean }) {\n super({\n message: `Could not queue the webhook delivery: ${params.message}`,\n data: {\n deliveryId: params.deliveryId,\n markedFailed: params.markedFailed\n }\n });\n }\n}\n\nexport class WebhookModelNotFoundError extends BaseError {\n override readonly code = \"WEBHOOK_MODEL_NOT_FOUND\" as const;\n\n constructor(modelId: string) {\n super({ message: `Webhook model \"${modelId}\" was not found.` });\n }\n}\n\nexport class WebhookVerificationFailedError extends BaseError {\n override readonly code = \"WEBHOOK_VERIFICATION_FAILED\" as const;\n\n constructor(message: string) {\n super({ message });\n }\n}\n\nexport class WebhookNotAuthorizedError extends BaseError {\n override readonly code = \"WEBHOOK_NOT_AUTHORIZED\" as const;\n\n constructor() {\n super({ message: \"Not authorized!\" });\n }\n}\n"],"names":["WebhookNotFoundError","BaseError","id","WebhookDeliveryNotFoundError","WebhookValidationError","error","issues","parseZodError","WebhookPersistenceError","Error","instance","data","String","WebhookDeliveryNotQueuedError","params","WebhookModelNotFoundError","modelId","WebhookVerificationFailedError","message","WebhookNotAuthorizedError"],"mappings":";;AAKO,MAAMA,6BAA6BC;IAGtC,YAAYC,EAAU,CAAE;QACpB,KAAK,CAAC;YAAE,SAAS,CAAC,SAAS,EAAEA,GAAG,gBAAgB,CAAC;QAAC,SAHpC,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMC,qCAAqCF;IAG9C,YAAYC,EAAU,CAAE;QACpB,KAAK,CAAC;YAAE,SAAS,CAAC,kBAAkB,EAAEA,GAAG,gBAAgB,CAAC;QAAC,SAH7C,IAAI,GAAG;IAIzB;AACJ;AAMO,MAAME,+BAA+BH;IAGxC,YAAYI,KAAwB,CAAE;QAClC,IAAI,AAAiB,YAAjB,OAAOA,OACP,KAAK,CAAC;YAAE,SAASA;YAAO,MAAM;gBAAE,QAAQ,EAAE;YAAC;QAAE,SAJnC,IAAI,GAAG;aAKd;YACH,MAAMC,SAASC,cAAcF;YAC7B,KAAK,CAAC;gBAAE,SAAS;gBAAsB,MAAM;oBAAEC;gBAAO;YAAE,SAP9C,IAAI,GAAG;QAQrB;IACJ;AACJ;AAQO,MAAME,gCAAgCP;IAGzC,YAAYI,KAAY,CAAE;QACtB,KAAK,CAAC;YAAE,SAASA,MAAM,OAAO;YAAE,MAAM;gBAAE,iBAAiBA,MAAM,OAAO;YAAC;QAAE,SAH3D,IAAI,GAAG;IAIzB;IAEA,OAAO,KAAKA,KAAc,EAA2B;QACjD,IAAIA,iBAAiBI,OAAO;YACxB,MAAMC,WAAW,IAAIF,wBAAwBH;YAC7C,MAAMM,OAAoC;gBACtC,iBAAiBN,MAAM,OAAO;gBAC9B,cAAeA,MAAc,IAAI;gBACjC,cAAeA,MAAc,IAAI;YACrC;YACCK,SAAiB,IAAI,GAAGC;YACzBD,SAAS,KAAK,GAAGL,MAAM,KAAK;YAC5B,OAAOK;QACX;QAEA,OAAO,IAAIF,wBAAwB,IAAIC,MAAMG,OAAOP;IACxD;AACJ;AAQO,MAAMQ,sCAAsCZ;IAG/C,YAAYa,MAAsE,CAAE;QAChF,KAAK,CAAC;YACF,SAAS,CAAC,sCAAsC,EAAEA,OAAO,OAAO,EAAE;YAClE,MAAM;gBACF,YAAYA,OAAO,UAAU;gBAC7B,cAAcA,OAAO,YAAY;YACrC;QACJ,SATc,IAAI,GAAG;IAUzB;AACJ;AAEO,MAAMC,kCAAkCd;IAG3C,YAAYe,OAAe,CAAE;QACzB,KAAK,CAAC;YAAE,SAAS,CAAC,eAAe,EAAEA,QAAQ,gBAAgB,CAAC;QAAC,SAH/C,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMC,uCAAuChB;IAGhD,YAAYiB,OAAe,CAAE;QACzB,KAAK,CAAC;YAAEA;QAAQ,SAHF,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMC,kCAAkClB;IAG3C,aAAc;QACV,KAAK,CAAC;YAAE,SAAS;QAAkB,SAHrB,IAAI,GAAG;IAIzB;AACJ"}
|
|
@@ -4,7 +4,7 @@ const CreateWebhookInputSchema = z.object({
|
|
|
4
4
|
name: z.string().min(1, "Name is required."),
|
|
5
5
|
slug: z.string().optional(),
|
|
6
6
|
endpointUrl: z.string().refine(isValidEndpointUrl, {
|
|
7
|
-
message: "Endpoint URL must use HTTPS
|
|
7
|
+
message: "Endpoint URL must use HTTPS and must not point to a local or link-local address."
|
|
8
8
|
}),
|
|
9
9
|
description: z.string().optional(),
|
|
10
10
|
enabled: z.boolean().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/CreateWebhook/schema.js","sources":["../../../../src/api/features/CreateWebhook/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isValidEndpointUrl } from \"~/api/utils/isValidEndpointUrl.js\";\n\nexport const CreateWebhookInputSchema = z.object({\n name: z.string().min(1, \"Name is required.\"),\n slug: z.string().optional(),\n endpointUrl: z.string().refine(isValidEndpointUrl, {\n message: \"Endpoint URL must use HTTPS
|
|
1
|
+
{"version":3,"file":"api/features/CreateWebhook/schema.js","sources":["../../../../src/api/features/CreateWebhook/schema.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isValidEndpointUrl } from \"~/api/utils/isValidEndpointUrl.js\";\n\nexport const CreateWebhookInputSchema = z.object({\n name: z.string().min(1, \"Name is required.\"),\n slug: z.string().optional(),\n endpointUrl: z.string().refine(isValidEndpointUrl, {\n message: \"Endpoint URL must use HTTPS and must not point to a local or link-local address.\"\n }),\n description: z.string().optional(),\n enabled: z.boolean().optional(),\n events: z.array(z.string()).min(1, \"At least one event must be selected.\"),\n signingSecret: z.string().optional()\n});\n"],"names":["CreateWebhookInputSchema","z","isValidEndpointUrl"],"mappings":";;AAGO,MAAMA,2BAA2BC,EAAE,MAAM,CAAC;IAC7C,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG;IACxB,MAAMA,EAAE,MAAM,GAAG,QAAQ;IACzB,aAAaA,EAAE,MAAM,GAAG,MAAM,CAACC,oBAAoB;QAC/C,SAAS;IACb;IACA,aAAaD,EAAE,MAAM,GAAG,QAAQ;IAChC,SAASA,EAAE,OAAO,GAAG,QAAQ;IAC7B,QAAQA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,GAAG,CAAC,GAAG;IACnC,eAAeA,EAAE,MAAM,GAAG,QAAQ;AACtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetWebhookSettingsRepository, GetWebhookSettingsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
|
+
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
4
|
+
import type { IWebhookSettings } from "../../../api/domain/WebhookSettings.js";
|
|
5
|
+
declare class GetWebhookSettingsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
+
private readonly permissions;
|
|
7
|
+
private readonly repository;
|
|
8
|
+
constructor(permissions: WebhookPermissions.Interface, repository: GetWebhookSettingsRepository.Interface);
|
|
9
|
+
execute(): Promise<Result<IWebhookSettings, UseCaseAbstraction.Error>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const GetWebhookSettingsUseCase: typeof GetWebhookSettingsUseCaseImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetWebhookSettingsUseCase>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetWebhookSettingsRepository, GetWebhookSettingsUseCase } from "./abstractions.js";
|
|
3
|
+
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
4
|
+
import { WebhookNotAuthorizedError } from "../../domain/errors.js";
|
|
5
|
+
class GetWebhookSettingsUseCaseImpl {
|
|
6
|
+
constructor(permissions, repository){
|
|
7
|
+
this.permissions = permissions;
|
|
8
|
+
this.repository = repository;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
if (!await this.permissions.canEdit("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
12
|
+
return this.repository.execute();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const GetWebhookSettingsUseCase_GetWebhookSettingsUseCase = GetWebhookSettingsUseCase.createImplementation({
|
|
16
|
+
implementation: GetWebhookSettingsUseCaseImpl,
|
|
17
|
+
dependencies: [
|
|
18
|
+
WebhookPermissions,
|
|
19
|
+
GetWebhookSettingsRepository
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { GetWebhookSettingsUseCase_GetWebhookSettingsUseCase as GetWebhookSettingsUseCase };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=GetWebhookSettingsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/GetWebhookSettingsUseCase.js","sources":["../../../../src/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetWebhookSettingsRepository,\n GetWebhookSettingsUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError } from \"~/api/domain/errors.js\";\nimport type { IWebhookSettings } from \"~/api/domain/WebhookSettings.js\";\n\nclass GetWebhookSettingsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly repository: GetWebhookSettingsRepository.Interface\n ) {}\n\n async execute(): Promise<Result<IWebhookSettings, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canEdit(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n return this.repository.execute();\n }\n}\n\nexport const GetWebhookSettingsUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetWebhookSettingsUseCaseImpl,\n dependencies: [WebhookPermissions, GetWebhookSettingsRepository]\n});\n"],"names":["GetWebhookSettingsUseCaseImpl","permissions","repository","Result","WebhookNotAuthorizedError","GetWebhookSettingsUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookSettingsRepository"],"mappings":";;;;AASA,MAAMA;IACF,YACqBC,WAAyC,EACzCC,UAAkD,CACrE;aAFmBD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IAClB;IAEH,MAAM,UAAuE;QACzE,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YACjC,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;IAClC;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBN;IAChB,cAAc;QAACO;QAAoBC;KAA6B;AACpE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { IWebhookSettings } from "../../../api/domain/WebhookSettings.js";
|
|
3
|
-
import type { WebhookModelNotFoundError, WebhookPersistenceError } from "../../../api/domain/errors.js";
|
|
3
|
+
import type { WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookPersistenceError } from "../../../api/domain/errors.js";
|
|
4
4
|
type IError = WebhookModelNotFoundError | WebhookPersistenceError;
|
|
5
5
|
export interface IGetWebhookSettingsRepository {
|
|
6
6
|
execute(): Promise<Result<IWebhookSettings, IError>>;
|
|
@@ -10,4 +10,17 @@ export declare namespace GetWebhookSettingsRepository {
|
|
|
10
10
|
type Interface = IGetWebhookSettingsRepository;
|
|
11
11
|
type Error = IError;
|
|
12
12
|
}
|
|
13
|
+
type IUseCaseError = IError | WebhookNotAuthorizedError;
|
|
14
|
+
/**
|
|
15
|
+
* Settings hold the global signing secret, so reading them needs the same permission as
|
|
16
|
+
* changing them. Internal code that signs deliveries uses the repository directly.
|
|
17
|
+
*/
|
|
18
|
+
export interface IGetWebhookSettingsUseCase {
|
|
19
|
+
execute(): Promise<Result<IWebhookSettings, IUseCaseError>>;
|
|
20
|
+
}
|
|
21
|
+
export declare const GetWebhookSettingsUseCase: import("@webiny/di").Abstraction<IGetWebhookSettingsUseCase>;
|
|
22
|
+
export declare namespace GetWebhookSettingsUseCase {
|
|
23
|
+
type Interface = IGetWebhookSettingsUseCase;
|
|
24
|
+
type Error = IUseCaseError;
|
|
25
|
+
}
|
|
13
26
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
2
|
const GetWebhookSettingsRepository = createAbstraction("Webhooks/GetWebhookSettingsRepository");
|
|
3
|
-
|
|
3
|
+
const GetWebhookSettingsUseCase = createAbstraction("Webhooks/GetWebhookSettingsUseCase");
|
|
4
|
+
export { GetWebhookSettingsRepository, GetWebhookSettingsUseCase };
|
|
4
5
|
|
|
5
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhookSettings/abstractions.js","sources":["../../../../src/api/features/GetWebhookSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { IWebhookSettings } from \"~/api/domain/WebhookSettings.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/abstractions.js","sources":["../../../../src/api/features/GetWebhookSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type { IWebhookSettings } from \"~/api/domain/WebhookSettings.js\";\nimport type {\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookPersistenceError\n} from \"~/api/domain/errors.js\";\n\ntype IError = WebhookModelNotFoundError | WebhookPersistenceError;\n\nexport interface IGetWebhookSettingsRepository {\n execute(): Promise<Result<IWebhookSettings, IError>>;\n}\n\nexport const GetWebhookSettingsRepository = createAbstraction<IGetWebhookSettingsRepository>(\n \"Webhooks/GetWebhookSettingsRepository\"\n);\n\nexport namespace GetWebhookSettingsRepository {\n export type Interface = IGetWebhookSettingsRepository;\n export type Error = IError;\n}\n\ntype IUseCaseError = IError | WebhookNotAuthorizedError;\n\n/**\n * Settings hold the global signing secret, so reading them needs the same permission as\n * changing them. Internal code that signs deliveries uses the repository directly.\n */\nexport interface IGetWebhookSettingsUseCase {\n execute(): Promise<Result<IWebhookSettings, IUseCaseError>>;\n}\n\nexport const GetWebhookSettingsUseCase = createAbstraction<IGetWebhookSettingsUseCase>(\n \"Webhooks/GetWebhookSettingsUseCase\"\n);\n\nexport namespace GetWebhookSettingsUseCase {\n export type Interface = IGetWebhookSettingsUseCase;\n export type Error = IUseCaseError;\n}\n"],"names":["GetWebhookSettingsRepository","createAbstraction","GetWebhookSettingsUseCase"],"mappings":";AAcO,MAAMA,+BAA+BC,kBACxC;AAkBG,MAAMC,4BAA4BD,kBACrC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { GetWebhookSettingsRepository } from "./GetWebhookSettingsRepository.js";
|
|
3
|
+
import { GetWebhookSettingsUseCase } from "./GetWebhookSettingsUseCase.js";
|
|
3
4
|
const GetWebhookSettingsFeature = createFeature({
|
|
4
5
|
name: "GetWebhookSettings",
|
|
5
6
|
register (container) {
|
|
7
|
+
container.register(GetWebhookSettingsUseCase);
|
|
6
8
|
container.register(GetWebhookSettingsRepository).inSingletonScope();
|
|
7
9
|
}
|
|
8
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/GetWebhookSettings/feature.js","sources":["../../../../src/api/features/GetWebhookSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetWebhookSettingsRepository } from \"./GetWebhookSettingsRepository.js\";\n\nexport const GetWebhookSettingsFeature = createFeature({\n name: \"GetWebhookSettings\",\n register(container) {\n container.register(GetWebhookSettingsRepository).inSingletonScope();\n }\n});\n"],"names":["GetWebhookSettingsFeature","createFeature","container","GetWebhookSettingsRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/GetWebhookSettings/feature.js","sources":["../../../../src/api/features/GetWebhookSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetWebhookSettingsRepository } from \"./GetWebhookSettingsRepository.js\";\nimport { GetWebhookSettingsUseCase } from \"./GetWebhookSettingsUseCase.js\";\n\nexport const GetWebhookSettingsFeature = createFeature({\n name: \"GetWebhookSettings\",\n register(container) {\n container.register(GetWebhookSettingsUseCase);\n container.register(GetWebhookSettingsRepository).inSingletonScope();\n }\n});\n"],"names":["GetWebhookSettingsFeature","createFeature","container","GetWebhookSettingsUseCase","GetWebhookSettingsRepository"],"mappings":";;;AAIO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,8BAA8B,gBAAgB;IACrE;AACJ"}
|
|
@@ -3,6 +3,7 @@ import { ResendWebhookDeliveryUseCase as UseCaseAbstraction } from "./abstractio
|
|
|
3
3
|
import { GetWebhookDeliveryRepository } from "../../../api/features/GetWebhookDelivery/abstractions.js";
|
|
4
4
|
import { GetWebhookRepository } from "../../../api/features/GetWebhook/abstractions.js";
|
|
5
5
|
import { CreateWebhookDeliveryRepository } from "../../../api/features/CreateWebhookDelivery/abstractions.js";
|
|
6
|
+
import { UpdateWebhookDeliveryRepository } from "../../../api/features/UpdateWebhookDelivery/abstractions.js";
|
|
6
7
|
import { GetWebhookSettingsRepository } from "../../../api/features/GetWebhookSettings/abstractions.js";
|
|
7
8
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
8
9
|
import { TaskService } from "@webiny/api-core/exports/api/tasks.js";
|
|
@@ -13,7 +14,8 @@ declare class ResendWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Int
|
|
|
13
14
|
private readonly createDeliveryRepository;
|
|
14
15
|
private readonly taskService;
|
|
15
16
|
private readonly getSettingsRepository;
|
|
16
|
-
|
|
17
|
+
private readonly updateDeliveryRepository;
|
|
18
|
+
constructor(permissions: WebhookPermissions.Interface, getDeliveryRepository: GetWebhookDeliveryRepository.Interface, getWebhookRepository: GetWebhookRepository.Interface, createDeliveryRepository: CreateWebhookDeliveryRepository.Interface, taskService: TaskService.Interface, getSettingsRepository: GetWebhookSettingsRepository.Interface, updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface);
|
|
17
19
|
execute(deliveryId: string): Promise<Result<boolean, UseCaseAbstraction.Error>>;
|
|
18
20
|
}
|
|
19
21
|
export declare const ResendWebhookDeliveryUseCase: typeof ResendWebhookDeliveryUseCaseImpl & {
|
|
@@ -4,19 +4,21 @@ import { ResendWebhookDeliveryInputSchema } from "./schema.js";
|
|
|
4
4
|
import { GetWebhookDeliveryRepository } from "../GetWebhookDelivery/abstractions.js";
|
|
5
5
|
import { GetWebhookRepository } from "../GetWebhook/abstractions.js";
|
|
6
6
|
import { CreateWebhookDeliveryRepository } from "../CreateWebhookDelivery/abstractions.js";
|
|
7
|
+
import { UpdateWebhookDeliveryRepository } from "../UpdateWebhookDelivery/abstractions.js";
|
|
7
8
|
import { GetWebhookSettingsRepository } from "../GetWebhookSettings/abstractions.js";
|
|
8
9
|
import { WebhookPermissions } from "../WebhookPermissions/abstractions.js";
|
|
9
|
-
import { WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
10
|
+
import { WebhookDeliveryNotQueuedError, WebhookNotAuthorizedError, WebhookValidationError } from "../../domain/errors.js";
|
|
10
11
|
import { TaskService } from "@webiny/api-core/exports/api/tasks.js";
|
|
11
12
|
import { SEND_WEBHOOK_TASK, WEBHOOK_DELIVERY_MAX_RETENTION_DAYS } from "../../domain/constants.js";
|
|
12
13
|
class ResendWebhookDeliveryUseCaseImpl {
|
|
13
|
-
constructor(permissions, getDeliveryRepository, getWebhookRepository, createDeliveryRepository, taskService, getSettingsRepository){
|
|
14
|
+
constructor(permissions, getDeliveryRepository, getWebhookRepository, createDeliveryRepository, taskService, getSettingsRepository, updateDeliveryRepository){
|
|
14
15
|
this.permissions = permissions;
|
|
15
16
|
this.getDeliveryRepository = getDeliveryRepository;
|
|
16
17
|
this.getWebhookRepository = getWebhookRepository;
|
|
17
18
|
this.createDeliveryRepository = createDeliveryRepository;
|
|
18
19
|
this.taskService = taskService;
|
|
19
20
|
this.getSettingsRepository = getSettingsRepository;
|
|
21
|
+
this.updateDeliveryRepository = updateDeliveryRepository;
|
|
20
22
|
}
|
|
21
23
|
async execute(deliveryId) {
|
|
22
24
|
if (!await this.permissions.canEdit("webhook")) return Result.fail(new WebhookNotAuthorizedError());
|
|
@@ -33,7 +35,7 @@ class ResendWebhookDeliveryUseCaseImpl {
|
|
|
33
35
|
const data = originalPayload?.data ?? {};
|
|
34
36
|
const settingsResult = await this.getSettingsRepository.execute();
|
|
35
37
|
const retentionDays = settingsResult.isOk() ? settingsResult.value.deliveryRetentionDays ?? WEBHOOK_DELIVERY_MAX_RETENTION_DAYS : WEBHOOK_DELIVERY_MAX_RETENTION_DAYS;
|
|
36
|
-
const expiresAt = new Date(Date.now() + 24 * retentionDays *
|
|
38
|
+
const expiresAt = new Date(Date.now() + 24 * retentionDays * 60 * 60 * 1000);
|
|
37
39
|
const newDeliveryResult = await this.createDeliveryRepository.execute({
|
|
38
40
|
webhookId: delivery.webhookId,
|
|
39
41
|
eventType: delivery.eventType,
|
|
@@ -42,7 +44,7 @@ class ResendWebhookDeliveryUseCaseImpl {
|
|
|
42
44
|
expiresAt
|
|
43
45
|
});
|
|
44
46
|
if (newDeliveryResult.isFail()) return Result.fail(newDeliveryResult.error);
|
|
45
|
-
await this.taskService.trigger({
|
|
47
|
+
const triggered = await this.taskService.trigger({
|
|
46
48
|
definition: SEND_WEBHOOK_TASK,
|
|
47
49
|
name: `Resend webhook: ${delivery.eventType}`,
|
|
48
50
|
input: {
|
|
@@ -51,6 +53,16 @@ class ResendWebhookDeliveryUseCaseImpl {
|
|
|
51
53
|
deliveryId: newDeliveryResult.value.id
|
|
52
54
|
}
|
|
53
55
|
});
|
|
56
|
+
if (triggered.isFail()) {
|
|
57
|
+
const marked = await this.updateDeliveryRepository.execute(newDeliveryResult.value.id, {
|
|
58
|
+
status: "failed"
|
|
59
|
+
});
|
|
60
|
+
return Result.fail(new WebhookDeliveryNotQueuedError({
|
|
61
|
+
message: triggered.error.message,
|
|
62
|
+
deliveryId: newDeliveryResult.value.id,
|
|
63
|
+
markedFailed: marked.isOk()
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
54
66
|
return Result.ok(true);
|
|
55
67
|
}
|
|
56
68
|
}
|
|
@@ -62,7 +74,8 @@ const ResendWebhookDeliveryUseCase_ResendWebhookDeliveryUseCase = ResendWebhookD
|
|
|
62
74
|
GetWebhookRepository,
|
|
63
75
|
CreateWebhookDeliveryRepository,
|
|
64
76
|
TaskService,
|
|
65
|
-
GetWebhookSettingsRepository
|
|
77
|
+
GetWebhookSettingsRepository,
|
|
78
|
+
UpdateWebhookDeliveryRepository
|
|
66
79
|
]
|
|
67
80
|
});
|
|
68
81
|
export { ResendWebhookDeliveryUseCase_ResendWebhookDeliveryUseCase as ResendWebhookDeliveryUseCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js","sources":["../../../../src/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ResendWebhookDeliveryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ResendWebhookDeliveryInputSchema } from \"./schema.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { CreateWebhookDeliveryRepository } from \"~/api/features/CreateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport { TaskService } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { SEND_WEBHOOK_TASK, WEBHOOK_DELIVERY_MAX_RETENTION_DAYS } from \"~/api/domain/constants.js\";\nimport type { IWebhookPayload } from \"~/api/features/SendWebhookTask/types.js\";\n\nclass ResendWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly getDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly createDeliveryRepository: CreateWebhookDeliveryRepository.Interface,\n private readonly taskService: TaskService.Interface,\n private readonly getSettingsRepository: GetWebhookSettingsRepository.Interface\n ) {}\n\n async execute(deliveryId: string): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canEdit(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = ResendWebhookDeliveryInputSchema.safeParse({ deliveryId });\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n const deliveryResult = await this.getDeliveryRepository.execute(parsed.data.deliveryId);\n if (deliveryResult.isFail()) {\n return Result.fail(deliveryResult.error);\n }\n\n const delivery = deliveryResult.value;\n\n const webhookResult = await this.getWebhookRepository.execute(delivery.webhookId);\n if (webhookResult.isFail()) {\n return Result.fail(webhookResult.error);\n }\n\n const originalPayload = delivery.payload as IWebhookPayload | null;\n const data = originalPayload?.data ?? {};\n\n const settingsResult = await this.getSettingsRepository.execute();\n const retentionDays = settingsResult.isOk()\n ? (settingsResult.value.deliveryRetentionDays ?? WEBHOOK_DELIVERY_MAX_RETENTION_DAYS)\n : WEBHOOK_DELIVERY_MAX_RETENTION_DAYS;\n\n const expiresAt = new Date(Date.now() + retentionDays * 24 * 60 * 60 * 1000);\n\n const newDeliveryResult = await this.createDeliveryRepository.execute({\n webhookId: delivery.webhookId,\n eventType: delivery.eventType,\n status: \"pending\",\n payload: data as Record<string, unknown>,\n expiresAt\n });\n\n if (newDeliveryResult.isFail()) {\n return Result.fail(newDeliveryResult.error);\n }\n\n await this.taskService.trigger({\n definition: SEND_WEBHOOK_TASK,\n name: `Resend webhook: ${delivery.eventType}`,\n input: {\n webhookId: delivery.webhookId,\n eventName: delivery.eventType,\n deliveryId: newDeliveryResult.value.id\n }\n });\n\n return Result.ok(true);\n }\n}\n\nexport const ResendWebhookDeliveryUseCase = UseCaseAbstraction.createImplementation({\n implementation: ResendWebhookDeliveryUseCaseImpl,\n dependencies: [\n WebhookPermissions,\n GetWebhookDeliveryRepository,\n GetWebhookRepository,\n CreateWebhookDeliveryRepository,\n TaskService,\n GetWebhookSettingsRepository\n ]\n});\n"],"names":["ResendWebhookDeliveryUseCaseImpl","permissions","getDeliveryRepository","getWebhookRepository","createDeliveryRepository","taskService","getSettingsRepository","deliveryId","Result","WebhookNotAuthorizedError","parsed","ResendWebhookDeliveryInputSchema","WebhookValidationError","deliveryResult","delivery","webhookResult","originalPayload","data","settingsResult","retentionDays","WEBHOOK_DELIVERY_MAX_RETENTION_DAYS","expiresAt","Date","newDeliveryResult","SEND_WEBHOOK_TASK","ResendWebhookDeliveryUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookDeliveryRepository","GetWebhookRepository","CreateWebhookDeliveryRepository","TaskService","GetWebhookSettingsRepository"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js","sources":["../../../../src/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ResendWebhookDeliveryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ResendWebhookDeliveryInputSchema } from \"./schema.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { CreateWebhookDeliveryRepository } from \"~/api/features/CreateWebhookDelivery/abstractions.js\";\nimport { UpdateWebhookDeliveryRepository } from \"~/api/features/UpdateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookPermissions } from \"~/api/features/WebhookPermissions/abstractions.js\";\nimport { WebhookNotAuthorizedError, WebhookValidationError } from \"~/api/domain/errors.js\";\nimport { WebhookDeliveryNotQueuedError } from \"~/api/domain/errors.js\";\nimport { TaskService } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { SEND_WEBHOOK_TASK, WEBHOOK_DELIVERY_MAX_RETENTION_DAYS } from \"~/api/domain/constants.js\";\nimport type { IWebhookPayload } from \"~/api/features/SendWebhookTask/types.js\";\n\nclass ResendWebhookDeliveryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private readonly permissions: WebhookPermissions.Interface,\n private readonly getDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly createDeliveryRepository: CreateWebhookDeliveryRepository.Interface,\n private readonly taskService: TaskService.Interface,\n private readonly getSettingsRepository: GetWebhookSettingsRepository.Interface,\n private readonly updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface\n ) {}\n\n async execute(deliveryId: string): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n if (!(await this.permissions.canEdit(\"webhook\"))) {\n return Result.fail(new WebhookNotAuthorizedError());\n }\n\n const parsed = ResendWebhookDeliveryInputSchema.safeParse({ deliveryId });\n if (!parsed.success) {\n return Result.fail(new WebhookValidationError(parsed.error));\n }\n\n const deliveryResult = await this.getDeliveryRepository.execute(parsed.data.deliveryId);\n if (deliveryResult.isFail()) {\n return Result.fail(deliveryResult.error);\n }\n\n const delivery = deliveryResult.value;\n\n const webhookResult = await this.getWebhookRepository.execute(delivery.webhookId);\n if (webhookResult.isFail()) {\n return Result.fail(webhookResult.error);\n }\n\n const originalPayload = delivery.payload as IWebhookPayload | null;\n const data = originalPayload?.data ?? {};\n\n const settingsResult = await this.getSettingsRepository.execute();\n const retentionDays = settingsResult.isOk()\n ? (settingsResult.value.deliveryRetentionDays ?? WEBHOOK_DELIVERY_MAX_RETENTION_DAYS)\n : WEBHOOK_DELIVERY_MAX_RETENTION_DAYS;\n\n const expiresAt = new Date(Date.now() + retentionDays * 24 * 60 * 60 * 1000);\n\n const newDeliveryResult = await this.createDeliveryRepository.execute({\n webhookId: delivery.webhookId,\n eventType: delivery.eventType,\n status: \"pending\",\n payload: data as Record<string, unknown>,\n expiresAt\n });\n\n if (newDeliveryResult.isFail()) {\n return Result.fail(newDeliveryResult.error);\n }\n\n const triggered = await this.taskService.trigger({\n definition: SEND_WEBHOOK_TASK,\n name: `Resend webhook: ${delivery.eventType}`,\n input: {\n webhookId: delivery.webhookId,\n eventName: delivery.eventType,\n deliveryId: newDeliveryResult.value.id\n }\n });\n if (triggered.isFail()) {\n // Nothing will send this delivery, so it must not stay pending.\n const marked = await this.updateDeliveryRepository.execute(newDeliveryResult.value.id, {\n status: \"failed\"\n });\n return Result.fail(\n new WebhookDeliveryNotQueuedError({\n message: triggered.error.message,\n deliveryId: newDeliveryResult.value.id,\n markedFailed: marked.isOk()\n })\n );\n }\n\n return Result.ok(true);\n }\n}\n\nexport const ResendWebhookDeliveryUseCase = UseCaseAbstraction.createImplementation({\n implementation: ResendWebhookDeliveryUseCaseImpl,\n dependencies: [\n WebhookPermissions,\n GetWebhookDeliveryRepository,\n GetWebhookRepository,\n CreateWebhookDeliveryRepository,\n TaskService,\n GetWebhookSettingsRepository,\n UpdateWebhookDeliveryRepository\n ]\n});\n"],"names":["ResendWebhookDeliveryUseCaseImpl","permissions","getDeliveryRepository","getWebhookRepository","createDeliveryRepository","taskService","getSettingsRepository","updateDeliveryRepository","deliveryId","Result","WebhookNotAuthorizedError","parsed","ResendWebhookDeliveryInputSchema","WebhookValidationError","deliveryResult","delivery","webhookResult","originalPayload","data","settingsResult","retentionDays","WEBHOOK_DELIVERY_MAX_RETENTION_DAYS","expiresAt","Date","newDeliveryResult","triggered","SEND_WEBHOOK_TASK","marked","WebhookDeliveryNotQueuedError","ResendWebhookDeliveryUseCase","UseCaseAbstraction","WebhookPermissions","GetWebhookDeliveryRepository","GetWebhookRepository","CreateWebhookDeliveryRepository","TaskService","GetWebhookSettingsRepository","UpdateWebhookDeliveryRepository"],"mappings":";;;;;;;;;;;;AAeA,MAAMA;IACF,YACqBC,WAAyC,EAC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B,CAAC,OAAO,CAAC;YAClE,WAAWT,SAAS,SAAS;YAC7B,WAAWA,SAAS,SAAS;YAC7B,QAAQ;YACR,SAASG;YACTI;QACJ;QAEA,IAAIE,kBAAkB,MAAM,IACxB,OAAOf,OAAO,IAAI,CAACe,kBAAkB,KAAK;QAG9C,MAAMC,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YAC7C,YAAYC;YACZ,MAAM,CAAC,gBAAgB,EAAEX,SAAS,SAAS,EAAE;YAC7C,OAAO;gBACH,WAAWA,SAAS,SAAS;gBAC7B,WAAWA,SAAS,SAAS;gBAC7B,YAAYS,kBAAkB,KAAK,CAAC,EAAE;YAC1C;QACJ;QACA,IAAIC,UAAU,MAAM,IAAI;YAEpB,MAAME,SAAS,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACH,kBAAkB,KAAK,CAAC,EAAE,EAAE;gBACnF,QAAQ;YACZ;YACA,OAAOf,OAAO,IAAI,CACd,IAAImB,8BAA8B;gBAC9B,SAASH,UAAU,KAAK,CAAC,OAAO;gBAChC,YAAYD,kBAAkB,KAAK,CAAC,EAAE;gBACtC,cAAcG,OAAO,IAAI;YAC7B;QAER;QAEA,OAAOlB,OAAO,EAAE,CAAC;IACrB;AACJ;AAEO,MAAMoB,4DAA+BC,6BAAAA,oBAAuC,CAAC;IAChF,gBAAgB9B;IAChB,cAAc;QACV+B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Result } from "@webiny/feature/api";
|
|
2
2
|
import type { WebhookDeliveryNotFoundError, WebhookNotFoundError, WebhookPersistenceError, WebhookModelNotFoundError, WebhookNotAuthorizedError, WebhookValidationError } from "../../../api/domain/errors.js";
|
|
3
|
-
type
|
|
3
|
+
import type { WebhookDeliveryNotQueuedError } from "../../../api/domain/errors.js";
|
|
4
|
+
type IError = WebhookDeliveryNotFoundError | WebhookNotFoundError | WebhookPersistenceError | WebhookModelNotFoundError | WebhookNotAuthorizedError | WebhookValidationError | WebhookDeliveryNotQueuedError;
|
|
4
5
|
export interface IResendWebhookDeliveryUseCase {
|
|
5
6
|
execute(deliveryId: string): Promise<Result<boolean, IError>>;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/ResendWebhookDelivery/abstractions.js","sources":["../../../../src/api/features/ResendWebhookDelivery/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type {\n WebhookDeliveryNotFoundError,\n WebhookNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookDeliveryNotFoundError\n | WebhookNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError;\n\nexport interface IResendWebhookDeliveryUseCase {\n execute(deliveryId: string): Promise<Result<boolean, IError>>;\n}\n\nexport const ResendWebhookDeliveryUseCase = createAbstraction<IResendWebhookDeliveryUseCase>(\n \"Webhooks/ResendWebhookDeliveryUseCase\"\n);\n\nexport namespace ResendWebhookDeliveryUseCase {\n export type Interface = IResendWebhookDeliveryUseCase;\n export type Error = IError;\n}\n"],"names":["ResendWebhookDeliveryUseCase","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"api/features/ResendWebhookDelivery/abstractions.js","sources":["../../../../src/api/features/ResendWebhookDelivery/abstractions.ts"],"sourcesContent":["import { createAbstraction, type Result } from \"@webiny/feature/api\";\nimport type {\n WebhookDeliveryNotFoundError,\n WebhookNotFoundError,\n WebhookPersistenceError,\n WebhookModelNotFoundError,\n WebhookNotAuthorizedError,\n WebhookValidationError\n} from \"~/api/domain/errors.js\";\nimport type { WebhookDeliveryNotQueuedError } from \"~/api/domain/errors.js\";\n\ntype IError =\n | WebhookDeliveryNotFoundError\n | WebhookNotFoundError\n | WebhookPersistenceError\n | WebhookModelNotFoundError\n | WebhookNotAuthorizedError\n | WebhookValidationError\n | WebhookDeliveryNotQueuedError;\n\nexport interface IResendWebhookDeliveryUseCase {\n execute(deliveryId: string): Promise<Result<boolean, IError>>;\n}\n\nexport const ResendWebhookDeliveryUseCase = createAbstraction<IResendWebhookDeliveryUseCase>(\n \"Webhooks/ResendWebhookDeliveryUseCase\"\n);\n\nexport namespace ResendWebhookDeliveryUseCase {\n export type Interface = IResendWebhookDeliveryUseCase;\n export type Error = IError;\n}\n"],"names":["ResendWebhookDeliveryUseCase","createAbstraction"],"mappings":";AAwBO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "@webiny/background-tasks/api/types.js";
|
|
2
2
|
import { TaskDefinition, TaskHandler } from "@webiny/api-core/exports/api/tasks.js";
|
|
3
|
+
import { isValidEndpointUrl } from "../../utils/isValidEndpointUrl.js";
|
|
3
4
|
import { TenantContext } from "@webiny/api-core/exports/api/tenancy.js";
|
|
4
5
|
import { WebhookSignPayload } from "@webiny/api-core/features/webhooks/index.js";
|
|
5
6
|
import { GetWebhookRepository } from "../GetWebhook/abstractions.js";
|
|
@@ -8,6 +9,11 @@ import { UpdateWebhookDeliveryRepository } from "../UpdateWebhookDelivery/abstra
|
|
|
8
9
|
import { GetWebhookSettingsRepository } from "../GetWebhookSettings/abstractions.js";
|
|
9
10
|
import { WebhookDeliver } from "../WebhookDeliver/abstractions.js";
|
|
10
11
|
import { SEND_WEBHOOK_TASK } from "../../domain/constants.js";
|
|
12
|
+
const MAX_STORED_RESPONSE_BODY_LENGTH = 4096;
|
|
13
|
+
const truncateResponseBody = (body)=>{
|
|
14
|
+
if (!body || body.length <= MAX_STORED_RESPONSE_BODY_LENGTH) return body;
|
|
15
|
+
return `${body.slice(0, MAX_STORED_RESPONSE_BODY_LENGTH)}… (truncated)`;
|
|
16
|
+
};
|
|
11
17
|
class SendWebhookTaskHandlerImpl {
|
|
12
18
|
constructor(getWebhookRepository, getWebhookDeliveryRepository, updateDeliveryRepository, signPayload, tenantContext, getWebhookSettingsRepository, deliver){
|
|
13
19
|
this.getWebhookRepository = getWebhookRepository;
|
|
@@ -67,6 +73,14 @@ class SendWebhookTaskHandlerImpl {
|
|
|
67
73
|
"Content-Type": "application/json",
|
|
68
74
|
...signHeaders
|
|
69
75
|
};
|
|
76
|
+
if (!isValidEndpointUrl(webhook.endpointUrl)) {
|
|
77
|
+
await this.updateDeliveryRepository.execute(input.deliveryId, {
|
|
78
|
+
status: "failed"
|
|
79
|
+
});
|
|
80
|
+
return controller.response.error({
|
|
81
|
+
message: `Webhook endpoint URL is not allowed: ${webhook.endpointUrl}`
|
|
82
|
+
});
|
|
83
|
+
}
|
|
70
84
|
const result = await this.deliver.execute({
|
|
71
85
|
url: webhook.endpointUrl,
|
|
72
86
|
headers: requestHeaders,
|
|
@@ -81,7 +95,7 @@ class SendWebhookTaskHandlerImpl {
|
|
|
81
95
|
requestHeaders,
|
|
82
96
|
responseTime: result.responseTime,
|
|
83
97
|
responseStatus: result.status,
|
|
84
|
-
responseBody: result.body,
|
|
98
|
+
responseBody: truncateResponseBody(result.body),
|
|
85
99
|
status: result.status > 0 ? "delivered" : "failed"
|
|
86
100
|
});
|
|
87
101
|
return controller.response.done();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/features/SendWebhookTask/SendWebhookTask.js","sources":["../../../../src/api/features/SendWebhookTask/SendWebhookTask.ts"],"sourcesContent":["import \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition, TaskHandler } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { TenantContext } from \"@webiny/api-core/exports/api/tenancy.js\";\nimport { WebhookSignPayload } from \"@webiny/api-core/features/webhooks/index.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { UpdateWebhookDeliveryRepository } from \"~/api/features/UpdateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookDeliver } from \"~/api/features/WebhookDeliver/abstractions.js\";\nimport { SEND_WEBHOOK_TASK } from \"~/api/domain/constants.js\";\nimport type { ISendWebhookTaskInput, ISendWebhookTaskOutput, IWebhookPayload } from \"./types.js\";\nimport type { IWebhookSignPayloadHeaders } from \"@webiny/api-core/features/webhooks/WebhookSignPayload/abstractions.js\";\n\ntype IRunParams = TaskHandler.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;\n\nclass SendWebhookTaskHandlerImpl implements TaskHandler.Interface<\n ISendWebhookTaskInput,\n ISendWebhookTaskOutput\n> {\n public constructor(\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly getWebhookDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface,\n private readonly signPayload: WebhookSignPayload.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly getWebhookSettingsRepository: GetWebhookSettingsRepository.Interface,\n private readonly deliver: WebhookDeliver.Interface\n ) {}\n\n public async run(params: IRunParams) {\n const { input, controller } = params;\n const taskId = controller.state.getTask().id;\n\n const delivery = await this.getWebhookDeliveryRepository.execute(input.deliveryId);\n if (delivery.isFail()) {\n return controller.response.error(delivery.error);\n }\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n backgroundTaskId: taskId,\n status: \"delivering\"\n });\n\n const webhookResult = await this.getWebhookRepository.execute(input.webhookId);\n if (webhookResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(webhookResult.error);\n }\n const webhook = webhookResult.value;\n\n const now = new Date();\n const payload: IWebhookPayload = {\n id: taskId,\n event: input.eventName,\n timestamp: now.toISOString(),\n webhookId: input.webhookId,\n deliveryId: input.deliveryId,\n tenant: this.tenantContext.getTenant().id,\n data: delivery.value.payload\n };\n const rawBody = JSON.stringify(payload);\n let signHeaders: IWebhookSignPayloadHeaders;\n\n const settingsResult = await this.getWebhookSettingsRepository.execute();\n if (settingsResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(settingsResult.error);\n }\n const signingSecret = webhook.signingSecret || settingsResult.value.signingSecret || \"\";\n\n try {\n signHeaders = await this.signPayload.sign(taskId, now, rawBody, signingSecret);\n } catch (ex) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(ex);\n }\n\n const requestHeaders: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...signHeaders\n };\n\n const result = await this.deliver.execute({\n url: webhook.endpointUrl,\n headers: requestHeaders,\n body: rawBody,\n timeout: 600_000,\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30_000\n });\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n payload,\n requestHeaders,\n responseTime: result.responseTime,\n responseStatus: result.status,\n responseBody: result.body,\n status: result.status > 0 ? \"delivered\" : \"failed\"\n });\n\n return controller.response.done();\n }\n}\n\nconst SendWebhookTaskHandler = TaskHandler.createImplementation({\n implementation: SendWebhookTaskHandlerImpl,\n dependencies: [\n GetWebhookRepository,\n GetWebhookDeliveryRepository,\n UpdateWebhookDeliveryRepository,\n WebhookSignPayload,\n TenantContext,\n GetWebhookSettingsRepository,\n WebhookDeliver\n ]\n});\n\nclass SendWebhookTaskDefinition implements TaskDefinition.Interface {\n public readonly id = SEND_WEBHOOK_TASK;\n public readonly title = \"Send Webhook\";\n public readonly maxIterations = 1;\n public readonly isPrivate = true;\n public readonly databaseLogs = false;\n public readonly description =\n \"POST a signed event payload to a webhook endpoint and log the delivery.\";\n public readonly selfCleanup = \"always\";\n\n handler = SendWebhookTaskHandler;\n}\n\nexport const SendWebhookTask = TaskDefinition.createImplementation({\n implementation: SendWebhookTaskDefinition,\n dependencies: []\n});\n"],"names":["SendWebhookTaskHandlerImpl","getWebhookRepository","getWebhookDeliveryRepository","updateDeliveryRepository","signPayload","tenantContext","getWebhookSettingsRepository","deliver","params","input","controller","taskId","delivery","webhookResult","webhook","now","Date","payload","rawBody","JSON","signHeaders","settingsResult","signingSecret","ex","requestHeaders","result","SendWebhookTaskHandler","TaskHandler","GetWebhookRepository","GetWebhookDeliveryRepository","UpdateWebhookDeliveryRepository","WebhookSignPayload","TenantContext","GetWebhookSettingsRepository","WebhookDeliver","SendWebhookTaskDefinition","SEND_WEBHOOK_TASK","SendWebhookTask","TaskDefinition"],"mappings":";;;;;;;;;;AAeA,MAAMA;IAIF,YACqBC,oBAAoD,EACpDC,4BAAoE,EACpEC,wBAAmE,EACnEC,WAAyC,EACzCC,aAAsC,EACtCC,4BAAoE,EACpEC,OAAiC,CACpD;aAPmBN,oBAAoB,GAApBA;aACAC,4BAA4B,GAA5BA;aACAC,wBAAwB,GAAxBA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,4BAA4B,GAA5BA;aACAC,OAAO,GAAPA;IAClB;IAEH,MAAa,IAAIC,MAAkB,EAAE;QACjC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;QAC9B,MAAMG,SAASD,WAAW,KAAK,CAAC,OAAO,GAAG,EAAE;QAE5C,MAAME,WAAW,MAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAACH,MAAM,UAAU;QACjF,IAAIG,SAAS,MAAM,IACf,OAAOF,WAAW,QAAQ,CAAC,KAAK,CAACE,SAAS,KAAK;QAGnD,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACH,MAAM,UAAU,EAAE;YAC1D,kBAAkBE;YAClB,QAAQ;QACZ;QAEA,MAAME,gBAAgB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACJ,MAAM,SAAS;QAC7E,IAAII,cAAc,MAAM,IAAI;YACxB,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACJ,MAAM,UAAU,EAAE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AAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAACT,MAAM,UAAU,EAAE;YAC1DQ;YACAO;YACA,cAAcC,OAAO,YAAY;YACjC,gBAAgBA,OAAO,MAAM;YAC7B,cAAcA,OAAO,IAAI;YACzB,QAAQA,OAAO,MAAM,GAAG,IAAI,cAAc;QAC9C;QAEA,OAAOf,WAAW,QAAQ,CAAC,IAAI;IACnC;AACJ;AAEA,MAAMgB,yBAAyBC,YAAY,oBAAoB,CAAC;IAC5D,gBAAgB3B;IAChB,cAAc;QACV4B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,aAAa,GAAG;aAChB,SAAS,GAAG;aACZ,YAAY,GAAG;aACf,WAAW,GACvB;aACY,WAAW,GAAG;aAE9B,OAAO,GAAGV;;AACd;AAEO,MAAMW,kBAAkBC,eAAe,oBAAoB,CAAC;IAC/D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
1
|
+
{"version":3,"file":"api/features/SendWebhookTask/SendWebhookTask.js","sources":["../../../../src/api/features/SendWebhookTask/SendWebhookTask.ts"],"sourcesContent":["import \"@webiny/background-tasks/api/types.js\";\nimport { TaskDefinition, TaskHandler } from \"@webiny/api-core/exports/api/tasks.js\";\nimport { isValidEndpointUrl } from \"~/api/utils/isValidEndpointUrl.js\";\nimport { TenantContext } from \"@webiny/api-core/exports/api/tenancy.js\";\nimport { WebhookSignPayload } from \"@webiny/api-core/features/webhooks/index.js\";\nimport { GetWebhookRepository } from \"~/api/features/GetWebhook/abstractions.js\";\nimport { GetWebhookDeliveryRepository } from \"~/api/features/GetWebhookDelivery/abstractions.js\";\nimport { UpdateWebhookDeliveryRepository } from \"~/api/features/UpdateWebhookDelivery/abstractions.js\";\nimport { GetWebhookSettingsRepository } from \"~/api/features/GetWebhookSettings/abstractions.js\";\nimport { WebhookDeliver } from \"~/api/features/WebhookDeliver/abstractions.js\";\nimport { SEND_WEBHOOK_TASK } from \"~/api/domain/constants.js\";\nimport type { ISendWebhookTaskInput, ISendWebhookTaskOutput, IWebhookPayload } from \"./types.js\";\nimport type { IWebhookSignPayloadHeaders } from \"@webiny/api-core/features/webhooks/WebhookSignPayload/abstractions.js\";\n\ntype IRunParams = TaskHandler.RunParams<ISendWebhookTaskInput, ISendWebhookTaskOutput>;\n\n/* The delivery log only needs enough of the response to debug the receiver. */\nconst MAX_STORED_RESPONSE_BODY_LENGTH = 4096;\nconst truncateResponseBody = (body: string | undefined) => {\n if (!body || body.length <= MAX_STORED_RESPONSE_BODY_LENGTH) {\n return body;\n }\n return `${body.slice(0, MAX_STORED_RESPONSE_BODY_LENGTH)}… (truncated)`;\n};\n\nclass SendWebhookTaskHandlerImpl implements TaskHandler.Interface<\n ISendWebhookTaskInput,\n ISendWebhookTaskOutput\n> {\n public constructor(\n private readonly getWebhookRepository: GetWebhookRepository.Interface,\n private readonly getWebhookDeliveryRepository: GetWebhookDeliveryRepository.Interface,\n private readonly updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface,\n private readonly signPayload: WebhookSignPayload.Interface,\n private readonly tenantContext: TenantContext.Interface,\n private readonly getWebhookSettingsRepository: GetWebhookSettingsRepository.Interface,\n private readonly deliver: WebhookDeliver.Interface\n ) {}\n\n public async run(params: IRunParams) {\n const { input, controller } = params;\n const taskId = controller.state.getTask().id;\n\n const delivery = await this.getWebhookDeliveryRepository.execute(input.deliveryId);\n if (delivery.isFail()) {\n return controller.response.error(delivery.error);\n }\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n backgroundTaskId: taskId,\n status: \"delivering\"\n });\n\n const webhookResult = await this.getWebhookRepository.execute(input.webhookId);\n if (webhookResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(webhookResult.error);\n }\n const webhook = webhookResult.value;\n\n const now = new Date();\n const payload: IWebhookPayload = {\n id: taskId,\n event: input.eventName,\n timestamp: now.toISOString(),\n webhookId: input.webhookId,\n deliveryId: input.deliveryId,\n tenant: this.tenantContext.getTenant().id,\n data: delivery.value.payload\n };\n const rawBody = JSON.stringify(payload);\n let signHeaders: IWebhookSignPayloadHeaders;\n\n const settingsResult = await this.getWebhookSettingsRepository.execute();\n if (settingsResult.isFail()) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(settingsResult.error);\n }\n const signingSecret = webhook.signingSecret || settingsResult.value.signingSecret || \"\";\n\n try {\n signHeaders = await this.signPayload.sign(taskId, now, rawBody, signingSecret);\n } catch (ex) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error(ex);\n }\n\n const requestHeaders: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...signHeaders\n };\n\n // Webhooks stored before the endpoint rules were tightened may still point to a local address.\n if (!isValidEndpointUrl(webhook.endpointUrl)) {\n await this.updateDeliveryRepository.execute(input.deliveryId, { status: \"failed\" });\n return controller.response.error({\n message: `Webhook endpoint URL is not allowed: ${webhook.endpointUrl}`\n });\n }\n\n const result = await this.deliver.execute({\n url: webhook.endpointUrl,\n headers: requestHeaders,\n body: rawBody,\n timeout: 600_000,\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30_000\n });\n\n await this.updateDeliveryRepository.execute(input.deliveryId, {\n payload,\n requestHeaders,\n responseTime: result.responseTime,\n responseStatus: result.status,\n responseBody: truncateResponseBody(result.body),\n status: result.status > 0 ? \"delivered\" : \"failed\"\n });\n\n return controller.response.done();\n }\n}\n\nconst SendWebhookTaskHandler = TaskHandler.createImplementation({\n implementation: SendWebhookTaskHandlerImpl,\n dependencies: [\n GetWebhookRepository,\n GetWebhookDeliveryRepository,\n UpdateWebhookDeliveryRepository,\n WebhookSignPayload,\n TenantContext,\n GetWebhookSettingsRepository,\n WebhookDeliver\n ]\n});\n\nclass SendWebhookTaskDefinition implements TaskDefinition.Interface {\n public readonly id = SEND_WEBHOOK_TASK;\n public readonly title = \"Send Webhook\";\n public readonly maxIterations = 1;\n public readonly isPrivate = true;\n public readonly databaseLogs = false;\n public readonly description =\n \"POST a signed event payload to a webhook endpoint and log the delivery.\";\n public readonly selfCleanup = \"always\";\n\n handler = SendWebhookTaskHandler;\n}\n\nexport const SendWebhookTask = TaskDefinition.createImplementation({\n implementation: SendWebhookTaskDefinition,\n dependencies: []\n});\n"],"names":["MAX_STORED_RESPONSE_BODY_LENGTH","truncateResponseBody","body","SendWebhookTaskHandlerImpl","getWebhookRepository","getWebhookDeliveryRepository","updateDeliveryRepository","signPayload","tenantContext","getWebhookSettingsRepository","deliver","params","input","controller","taskId","delivery","webhookResult","webhook","now","Date","payload","rawBody","JSON","signHeaders","settingsResult","signingSecret","ex","requestHeaders","isValidEndpointUrl","result","SendWebhookTaskHandler","TaskHandler","GetWebhookRepository","GetWebhookDeliveryRepository","UpdateWebhookDeliveryRepository","WebhookSignPayload","TenantContext","GetWebhookSettingsRepository","WebhookDeliver","SendWebhookTaskDefinition","SEND_WEBHOOK_TASK","SendWebhookTask","TaskDefinition"],"mappings":";;;;;;;;;;;AAiBA,MAAMA,kCAAkC;AACxC,MAAMC,uBAAuB,CAACC;IAC1B,IAAI,CAACA,QAAQA,KAAK,MAAM,IAAIF,iCACxB,OAAOE;IAEX,OAAO,GAAGA,KAAK,KAAK,CAAC,GAAGF,iCAAiC,aAAa,CAAC;AAC3E;AAEA,MAAMG;IAIF,YACqBC,oBAAoD,EACpDC,4BAAoE,EACpEC,wBAAmE,EACnEC,WAAyC,EACzCC,aAAsC,EACtCC,4BAAoE,EACpEC,OAAiC,CACpD;aAPmBN,oBAAoB,GAApBA;aACAC,4BAA4B,GAA5BA;aACAC,wBAAwB,GAAxBA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,4BAA4B,GAA5BA;aACAC,OAAO,GAAPA;IAClB;IAEH,MAAa,IAAIC,MAAkB,EAAE;QACjC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,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GAAG;aACZ,YAAY,GAAG;aACf,WAAW,GACvB;aACY,WAAW,GAAG;aAE9B,OAAO,GAAGV;;AACd;AAEO,MAAMW,kBAAkBC,eAAe,oBAAoB,CAAC;IAC/D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -3,6 +3,7 @@ import { TaskService } from "@webiny/api-core/exports/api/tasks.js";
|
|
|
3
3
|
import { TriggerWebhookUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
4
|
import { GetWebhookRepository } from "../../../api/features/GetWebhook/abstractions.js";
|
|
5
5
|
import { CreateWebhookDeliveryRepository } from "../../../api/features/CreateWebhookDelivery/abstractions.js";
|
|
6
|
+
import { UpdateWebhookDeliveryRepository } from "../../../api/features/UpdateWebhookDelivery/abstractions.js";
|
|
6
7
|
import { GetWebhookSettingsRepository } from "../../../api/features/GetWebhookSettings/abstractions.js";
|
|
7
8
|
import { WebhookPermissions } from "../../../api/features/WebhookPermissions/abstractions.js";
|
|
8
9
|
import type { WebhookDelivery } from "../../../api/domain/WebhookDelivery.js";
|
|
@@ -12,7 +13,8 @@ declare class TriggerWebhookUseCaseImpl implements UseCaseAbstraction.Interface
|
|
|
12
13
|
private readonly createDeliveryRepository;
|
|
13
14
|
private readonly taskService;
|
|
14
15
|
private readonly getSettingsRepository;
|
|
15
|
-
|
|
16
|
+
private readonly updateDeliveryRepository;
|
|
17
|
+
constructor(permissions: WebhookPermissions.Interface, getWebhookRepository: GetWebhookRepository.Interface, createDeliveryRepository: CreateWebhookDeliveryRepository.Interface, taskService: TaskService.Interface, getSettingsRepository: GetWebhookSettingsRepository.Interface, updateDeliveryRepository: UpdateWebhookDeliveryRepository.Interface);
|
|
16
18
|
execute(webhookId: string, payload: Record<string, unknown>): Promise<Result<WebhookDelivery, UseCaseAbstraction.Error>>;
|
|
17
19
|
}
|
|
18
20
|
export declare const TriggerWebhookUseCase: typeof TriggerWebhookUseCaseImpl & {
|