Change webhook configuration to subscription

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-02-13 16:54:46 +01:00
parent 6de906d0a9
commit 60538ef2bb
24 changed files with 915 additions and 885 deletions

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<18c0948adc229a75b1d980e64730b423>> * @generated SignedSource<<164efe490915ac140a48e42cbd17e915>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -17,7 +17,7 @@ export type WebhooksSettingsPageQuery$data = {
readonly organization: { readonly organization: {
readonly __typename: "Organization"; readonly __typename: "Organization";
readonly id: string; readonly id: string;
readonly webhookConfigurations: { readonly webhookSubscriptions: {
readonly edges: ReadonlyArray<{ readonly edges: ReadonlyArray<{
readonly node: { readonly node: {
readonly endpointUrl: string; readonly endpointUrl: string;
@@ -73,7 +73,7 @@ v4 = [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "WebhookConfigurationEdge", "concreteType": "WebhookSubscriptionEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "edges", "name": "edges",
"plural": true, "plural": true,
@@ -81,7 +81,7 @@ v4 = [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "WebhookConfiguration", "concreteType": "WebhookSubscription",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -195,11 +195,11 @@ return {
"selections": [ "selections": [
(v3/*: any*/), (v3/*: any*/),
{ {
"alias": "webhookConfigurations", "alias": "webhookSubscriptions",
"args": null, "args": null,
"concreteType": "WebhookConfigurationConnection", "concreteType": "WebhookSubscriptionConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "__WebhooksSettingsPage_webhookConfigurations_connection", "name": "__WebhooksSettingsPage_webhookSubscriptions_connection",
"plural": false, "plural": false,
"selections": (v4/*: any*/), "selections": (v4/*: any*/),
"storageKey": null "storageKey": null
@@ -239,21 +239,21 @@ return {
{ {
"alias": null, "alias": null,
"args": (v5/*: any*/), "args": (v5/*: any*/),
"concreteType": "WebhookConfigurationConnection", "concreteType": "WebhookSubscriptionConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "webhookConfigurations", "name": "webhookSubscriptions",
"plural": false, "plural": false,
"selections": (v4/*: any*/), "selections": (v4/*: any*/),
"storageKey": "webhookConfigurations(first:50)" "storageKey": "webhookSubscriptions(first:50)"
}, },
{ {
"alias": null, "alias": null,
"args": (v5/*: any*/), "args": (v5/*: any*/),
"filters": null, "filters": null,
"handle": "connection", "handle": "connection",
"key": "WebhooksSettingsPage_webhookConfigurations", "key": "WebhooksSettingsPage_webhookSubscriptions",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "webhookConfigurations" "name": "webhookSubscriptions"
} }
], ],
"type": "Organization", "type": "Organization",
@@ -265,7 +265,7 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "b5ca3cf4d05d2cb81c744e760433cb94", "cacheID": "eeb9eda2a1b1d205fadba357fc20077c",
"id": null, "id": null,
"metadata": { "metadata": {
"connection": [ "connection": [
@@ -275,18 +275,18 @@ return {
"direction": "forward", "direction": "forward",
"path": [ "path": [
"organization", "organization",
"webhookConfigurations" "webhookSubscriptions"
] ]
} }
] ]
}, },
"name": "WebhooksSettingsPageQuery", "name": "WebhooksSettingsPageQuery",
"operationKind": "query", "operationKind": "query",
"text": "query WebhooksSettingsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n webhookConfigurations(first: 50) {\n edges {\n node {\n id\n endpointUrl\n selectedEvents\n events(first: 0) {\n totalCount\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n" "text": "query WebhooksSettingsPageQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n webhookSubscriptions(first: 50) {\n edges {\n node {\n id\n endpointUrl\n selectedEvents\n events(first: 0) {\n totalCount\n }\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "bac1812903d6f495d15bb0e70ce5ed48"; (node as any).hash = "2d08ddd621d3e5880367b83a70d2f168";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<56bfc2d1746edae72b0da44526fab12f>> * @generated SignedSource<<d3e3309eefb502b19d48c61f9f162d18>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -10,20 +10,23 @@
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type WebhookEventType = "MEETING_CREATED" | "MEETING_DELETED" | "MEETING_UPDATED" | "VENDOR_CREATED" | "VENDOR_DELETED" | "VENDOR_UPDATED"; export type WebhookEventType = "MEETING_CREATED" | "MEETING_DELETED" | "MEETING_UPDATED" | "VENDOR_CREATED" | "VENDOR_DELETED" | "VENDOR_UPDATED";
export type CreateWebhookConfigurationInput = { export type CreateWebhookSubscriptionInput = {
endpointUrl: string; endpointUrl: string;
organizationId: string; organizationId: string;
selectedEvents: ReadonlyArray<WebhookEventType>; selectedEvents: ReadonlyArray<WebhookEventType>;
}; };
export type WebhooksSettingsPage_createMutation$variables = { export type WebhooksSettingsPage_createMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: CreateWebhookConfigurationInput; input: CreateWebhookSubscriptionInput;
}; };
export type WebhooksSettingsPage_createMutation$data = { export type WebhooksSettingsPage_createMutation$data = {
readonly createWebhookConfiguration: { readonly createWebhookSubscription: {
readonly webhookConfigurationEdge: { readonly webhookSubscriptionEdge: {
readonly node: { readonly node: {
readonly endpointUrl: string; readonly endpointUrl: string;
readonly events: {
readonly totalCount: number;
};
readonly id: string; readonly id: string;
readonly selectedEvents: ReadonlyArray<WebhookEventType>; readonly selectedEvents: ReadonlyArray<WebhookEventType>;
}; };
@@ -56,15 +59,15 @@ v2 = [
v3 = { v3 = {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "WebhookConfigurationEdge", "concreteType": "WebhookSubscriptionEdge",
"kind": "LinkedField", "kind": "LinkedField",
"name": "webhookConfigurationEdge", "name": "webhookSubscriptionEdge",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "WebhookConfiguration", "concreteType": "WebhookSubscription",
"kind": "LinkedField", "kind": "LinkedField",
"name": "node", "name": "node",
"plural": false, "plural": false,
@@ -89,6 +92,30 @@ v3 = {
"kind": "ScalarField", "kind": "ScalarField",
"name": "selectedEvents", "name": "selectedEvents",
"storageKey": null "storageKey": null
},
{
"alias": null,
"args": [
{
"kind": "Literal",
"name": "first",
"value": 0
}
],
"concreteType": "WebhookEventConnection",
"kind": "LinkedField",
"name": "events",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "totalCount",
"storageKey": null
}
],
"storageKey": "events(first:0)"
} }
], ],
"storageKey": null "storageKey": null
@@ -109,9 +136,9 @@ return {
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "CreateWebhookConfigurationPayload", "concreteType": "CreateWebhookSubscriptionPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "createWebhookConfiguration", "name": "createWebhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/) (v3/*: any*/)
@@ -134,9 +161,9 @@ return {
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "CreateWebhookConfigurationPayload", "concreteType": "CreateWebhookSubscriptionPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "createWebhookConfiguration", "name": "createWebhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/), (v3/*: any*/),
@@ -147,7 +174,7 @@ return {
"handle": "prependEdge", "handle": "prependEdge",
"key": "", "key": "",
"kind": "LinkedHandle", "kind": "LinkedHandle",
"name": "webhookConfigurationEdge", "name": "webhookSubscriptionEdge",
"handleArgs": [ "handleArgs": [
{ {
"kind": "Variable", "kind": "Variable",
@@ -162,16 +189,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "0e88932f635b8f16e41f730abf9e05ff", "cacheID": "478c002a1f98dd87f23c6af0269ea2c6",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "WebhooksSettingsPage_createMutation", "name": "WebhooksSettingsPage_createMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation WebhooksSettingsPage_createMutation(\n $input: CreateWebhookConfigurationInput!\n) {\n createWebhookConfiguration(input: $input) {\n webhookConfigurationEdge {\n node {\n id\n endpointUrl\n selectedEvents\n }\n }\n }\n}\n" "text": "mutation WebhooksSettingsPage_createMutation(\n $input: CreateWebhookSubscriptionInput!\n) {\n createWebhookSubscription(input: $input) {\n webhookSubscriptionEdge {\n node {\n id\n endpointUrl\n selectedEvents\n events(first: 0) {\n totalCount\n }\n }\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "4e1a7692c83c4dda0c2fc557f15d669d"; (node as any).hash = "f47b849f8cad710922bf62eb6aebdd93";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<86d94ecf595a0048971276541e185905>> * @generated SignedSource<<bbbb8700958f1bee82226fdbf53189b3>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -9,16 +9,16 @@
// @ts-nocheck // @ts-nocheck
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type DeleteWebhookConfigurationInput = { export type DeleteWebhookSubscriptionInput = {
webhookConfigurationId: string; webhookSubscriptionId: string;
}; };
export type WebhooksSettingsPage_deleteMutation$variables = { export type WebhooksSettingsPage_deleteMutation$variables = {
connections: ReadonlyArray<string>; connections: ReadonlyArray<string>;
input: DeleteWebhookConfigurationInput; input: DeleteWebhookSubscriptionInput;
}; };
export type WebhooksSettingsPage_deleteMutation$data = { export type WebhooksSettingsPage_deleteMutation$data = {
readonly deleteWebhookConfiguration: { readonly deleteWebhookSubscription: {
readonly deletedWebhookConfigurationId: string; readonly deletedWebhookSubscriptionId: string;
}; };
}; };
export type WebhooksSettingsPage_deleteMutation = { export type WebhooksSettingsPage_deleteMutation = {
@@ -48,7 +48,7 @@ v3 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "deletedWebhookConfigurationId", "name": "deletedWebhookSubscriptionId",
"storageKey": null "storageKey": null
}; };
return { return {
@@ -64,9 +64,9 @@ return {
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "DeleteWebhookConfigurationPayload", "concreteType": "DeleteWebhookSubscriptionPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "deleteWebhookConfiguration", "name": "deleteWebhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/) (v3/*: any*/)
@@ -89,9 +89,9 @@ return {
{ {
"alias": null, "alias": null,
"args": (v2/*: any*/), "args": (v2/*: any*/),
"concreteType": "DeleteWebhookConfigurationPayload", "concreteType": "DeleteWebhookSubscriptionPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "deleteWebhookConfiguration", "name": "deleteWebhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
(v3/*: any*/), (v3/*: any*/),
@@ -102,7 +102,7 @@ return {
"handle": "deleteEdge", "handle": "deleteEdge",
"key": "", "key": "",
"kind": "ScalarHandle", "kind": "ScalarHandle",
"name": "deletedWebhookConfigurationId", "name": "deletedWebhookSubscriptionId",
"handleArgs": [ "handleArgs": [
{ {
"kind": "Variable", "kind": "Variable",
@@ -117,16 +117,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "ae53fa4e16e4491720c1fdfc52301c09", "cacheID": "c1bab418b14488e982f2c444b8693919",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "WebhooksSettingsPage_deleteMutation", "name": "WebhooksSettingsPage_deleteMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation WebhooksSettingsPage_deleteMutation(\n $input: DeleteWebhookConfigurationInput!\n) {\n deleteWebhookConfiguration(input: $input) {\n deletedWebhookConfigurationId\n }\n}\n" "text": "mutation WebhooksSettingsPage_deleteMutation(\n $input: DeleteWebhookSubscriptionInput!\n) {\n deleteWebhookSubscription(input: $input) {\n deletedWebhookSubscriptionId\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "632fce2d89360bed2d857dd3feb90b9d"; (node as any).hash = "794d73fc91d4332f5e65a070ea11d27d";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<7427d67b4f9b27376c782cbe0601a5ec>> * @generated SignedSource<<6973a312c85bf6bed33ceda2600b989d>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -13,7 +13,7 @@ export type WebhookEventStatus = "FAILED" | "PENDING" | "SUCCEEDED";
export type WebhooksSettingsPage_eventsQuery$variables = { export type WebhooksSettingsPage_eventsQuery$variables = {
after?: string | null | undefined; after?: string | null | undefined;
first?: number | null | undefined; first?: number | null | undefined;
webhookConfigurationId: string; webhookSubscriptionId: string;
}; };
export type WebhooksSettingsPage_eventsQuery$data = { export type WebhooksSettingsPage_eventsQuery$data = {
readonly node: { readonly node: {
@@ -53,13 +53,13 @@ v1 = {
v2 = { v2 = {
"defaultValue": null, "defaultValue": null,
"kind": "LocalArgument", "kind": "LocalArgument",
"name": "webhookConfigurationId" "name": "webhookSubscriptionId"
}, },
v3 = [ v3 = [
{ {
"kind": "Variable", "kind": "Variable",
"name": "id", "name": "id",
"variableName": "webhookConfigurationId" "variableName": "webhookSubscriptionId"
} }
], ],
v4 = { v4 = {
@@ -171,7 +171,7 @@ v5 = {
"storageKey": null "storageKey": null
} }
], ],
"type": "WebhookConfiguration", "type": "WebhookSubscription",
"abstractKey": null "abstractKey": null
}; };
return { return {
@@ -234,16 +234,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "4593e2ef5dabf3cef70959eb8d2e4b01", "cacheID": "e74fa0d64dfc6bb54856386970bf4b68",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "WebhooksSettingsPage_eventsQuery", "name": "WebhooksSettingsPage_eventsQuery",
"operationKind": "query", "operationKind": "query",
"text": "query WebhooksSettingsPage_eventsQuery(\n $webhookConfigurationId: ID!\n $first: Int\n $after: CursorKey\n) {\n node(id: $webhookConfigurationId) {\n __typename\n ... on WebhookConfiguration {\n events(first: $first, after: $after) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n id\n status\n createdAt\n response\n }\n }\n }\n }\n id\n }\n}\n" "text": "query WebhooksSettingsPage_eventsQuery(\n $webhookSubscriptionId: ID!\n $first: Int\n $after: CursorKey\n) {\n node(id: $webhookSubscriptionId) {\n __typename\n ... on WebhookSubscription {\n events(first: $first, after: $after) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n id\n status\n createdAt\n response\n }\n }\n }\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "16da5d0681f767c57e3f352d4956eefe"; (node as any).hash = "75d3f1df0526526656b065b6d9be8b65";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<af555c91779a2fbceaae3666d5bae667>> * @generated SignedSource<<d341340b571530212b3cdc8722d694f1>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -10,7 +10,7 @@
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type WebhooksSettingsPage_signingSecretQuery$variables = { export type WebhooksSettingsPage_signingSecretQuery$variables = {
webhookConfigurationId: string; webhookSubscriptionId: string;
}; };
export type WebhooksSettingsPage_signingSecretQuery$data = { export type WebhooksSettingsPage_signingSecretQuery$data = {
readonly node: { readonly node: {
@@ -27,14 +27,14 @@ var v0 = [
{ {
"defaultValue": null, "defaultValue": null,
"kind": "LocalArgument", "kind": "LocalArgument",
"name": "webhookConfigurationId" "name": "webhookSubscriptionId"
} }
], ],
v1 = [ v1 = [
{ {
"kind": "Variable", "kind": "Variable",
"name": "id", "name": "id",
"variableName": "webhookConfigurationId" "variableName": "webhookSubscriptionId"
} }
], ],
v2 = { v2 = {
@@ -48,7 +48,7 @@ v2 = {
"storageKey": null "storageKey": null
} }
], ],
"type": "WebhookConfiguration", "type": "WebhookSubscription",
"abstractKey": null "abstractKey": null
}; };
return { return {
@@ -109,16 +109,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "266c1519da14eb09ed28e26cc6394f23", "cacheID": "df35742c680c055e5b820401cfb05271",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "WebhooksSettingsPage_signingSecretQuery", "name": "WebhooksSettingsPage_signingSecretQuery",
"operationKind": "query", "operationKind": "query",
"text": "query WebhooksSettingsPage_signingSecretQuery(\n $webhookConfigurationId: ID!\n) {\n node(id: $webhookConfigurationId) {\n __typename\n ... on WebhookConfiguration {\n signingSecret\n }\n id\n }\n}\n" "text": "query WebhooksSettingsPage_signingSecretQuery(\n $webhookSubscriptionId: ID!\n) {\n node(id: $webhookSubscriptionId) {\n __typename\n ... on WebhookSubscription {\n signingSecret\n }\n id\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "9d981d1a353a82f234e7ce79edb6d5d9"; (node as any).hash = "2d895bf4be96e0ef2c767af8149c8533";
export default node; export default node;

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<3331839e2cc81d14ac1b2fcfe3fd84f1>> * @generated SignedSource<<864603efd6135475b827a1234b128b7c>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -10,17 +10,17 @@
import { ConcreteRequest } from 'relay-runtime'; import { ConcreteRequest } from 'relay-runtime';
export type WebhookEventType = "MEETING_CREATED" | "MEETING_DELETED" | "MEETING_UPDATED" | "VENDOR_CREATED" | "VENDOR_DELETED" | "VENDOR_UPDATED"; export type WebhookEventType = "MEETING_CREATED" | "MEETING_DELETED" | "MEETING_UPDATED" | "VENDOR_CREATED" | "VENDOR_DELETED" | "VENDOR_UPDATED";
export type UpdateWebhookConfigurationInput = { export type UpdateWebhookSubscriptionInput = {
endpointUrl?: string | null | undefined; endpointUrl?: string | null | undefined;
id: string; id: string;
selectedEvents?: ReadonlyArray<WebhookEventType> | null | undefined; selectedEvents?: ReadonlyArray<WebhookEventType> | null | undefined;
}; };
export type WebhooksSettingsPage_updateMutation$variables = { export type WebhooksSettingsPage_updateMutation$variables = {
input: UpdateWebhookConfigurationInput; input: UpdateWebhookSubscriptionInput;
}; };
export type WebhooksSettingsPage_updateMutation$data = { export type WebhooksSettingsPage_updateMutation$data = {
readonly updateWebhookConfiguration: { readonly updateWebhookSubscription: {
readonly webhookConfiguration: { readonly webhookSubscription: {
readonly endpointUrl: string; readonly endpointUrl: string;
readonly id: string; readonly id: string;
readonly selectedEvents: ReadonlyArray<WebhookEventType>; readonly selectedEvents: ReadonlyArray<WebhookEventType>;
@@ -51,17 +51,17 @@ v1 = [
"variableName": "input" "variableName": "input"
} }
], ],
"concreteType": "UpdateWebhookConfigurationPayload", "concreteType": "UpdateWebhookSubscriptionPayload",
"kind": "LinkedField", "kind": "LinkedField",
"name": "updateWebhookConfiguration", "name": "updateWebhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
"alias": null, "alias": null,
"args": null, "args": null,
"concreteType": "WebhookConfiguration", "concreteType": "WebhookSubscription",
"kind": "LinkedField", "kind": "LinkedField",
"name": "webhookConfiguration", "name": "webhookSubscription",
"plural": false, "plural": false,
"selections": [ "selections": [
{ {
@@ -117,16 +117,16 @@ return {
"selections": (v1/*: any*/) "selections": (v1/*: any*/)
}, },
"params": { "params": {
"cacheID": "399a35c005f10dd321784a7533fb4f80", "cacheID": "e12790e2de3f89c6606b50a597acb244",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "WebhooksSettingsPage_updateMutation", "name": "WebhooksSettingsPage_updateMutation",
"operationKind": "mutation", "operationKind": "mutation",
"text": "mutation WebhooksSettingsPage_updateMutation(\n $input: UpdateWebhookConfigurationInput!\n) {\n updateWebhookConfiguration(input: $input) {\n webhookConfiguration {\n id\n endpointUrl\n selectedEvents\n updatedAt\n }\n }\n}\n" "text": "mutation WebhooksSettingsPage_updateMutation(\n $input: UpdateWebhookSubscriptionInput!\n) {\n updateWebhookSubscription(input: $input) {\n webhookSubscription {\n id\n endpointUrl\n selectedEvents\n updatedAt\n }\n }\n}\n"
} }
}; };
})(); })();
(node as any).hash = "f974aae43d0ad8b5fe3cab60bd07a3ff"; (node as any).hash = "f4c0f7667d77b64c41e436a7b5df6df5";
export default node; export default node;

View File

@@ -38,8 +38,8 @@ export const webhooksSettingsPageQuery = graphql`
__typename __typename
... on Organization { ... on Organization {
id id
webhookConfigurations(first: 50) webhookSubscriptions(first: 50)
@connection(key: "WebhooksSettingsPage_webhookConfigurations") { @connection(key: "WebhooksSettingsPage_webhookSubscriptions") {
edges { edges {
node { node {
id id
@@ -56,29 +56,32 @@ export const webhooksSettingsPageQuery = graphql`
} }
`; `;
const createWebhookConfigurationMutation = graphql` const createWebhookSubscriptionMutation = graphql`
mutation WebhooksSettingsPage_createMutation( mutation WebhooksSettingsPage_createMutation(
$input: CreateWebhookConfigurationInput! $input: CreateWebhookSubscriptionInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
createWebhookConfiguration(input: $input) { createWebhookSubscription(input: $input) {
webhookConfigurationEdge @prependEdge(connections: $connections) { webhookSubscriptionEdge @prependEdge(connections: $connections) {
node { node {
id id
endpointUrl endpointUrl
selectedEvents selectedEvents
events(first: 0) {
totalCount
}
} }
} }
} }
} }
`; `;
const updateWebhookConfigurationMutation = graphql` const updateWebhookSubscriptionMutation = graphql`
mutation WebhooksSettingsPage_updateMutation( mutation WebhooksSettingsPage_updateMutation(
$input: UpdateWebhookConfigurationInput! $input: UpdateWebhookSubscriptionInput!
) { ) {
updateWebhookConfiguration(input: $input) { updateWebhookSubscription(input: $input) {
webhookConfiguration { webhookSubscription {
id id
endpointUrl endpointUrl
selectedEvents selectedEvents
@@ -89,9 +92,9 @@ const updateWebhookConfigurationMutation = graphql`
`; `;
const signingSecretQuery = graphql` const signingSecretQuery = graphql`
query WebhooksSettingsPage_signingSecretQuery($webhookConfigurationId: ID!) { query WebhooksSettingsPage_signingSecretQuery($webhookSubscriptionId: ID!) {
node(id: $webhookConfigurationId) { node(id: $webhookSubscriptionId) {
... on WebhookConfiguration { ... on WebhookSubscription {
signingSecret signingSecret
} }
} }
@@ -100,12 +103,12 @@ const signingSecretQuery = graphql`
const webhookEventsQuery = graphql` const webhookEventsQuery = graphql`
query WebhooksSettingsPage_eventsQuery( query WebhooksSettingsPage_eventsQuery(
$webhookConfigurationId: ID! $webhookSubscriptionId: ID!
$first: Int $first: Int
$after: CursorKey $after: CursorKey
) { ) {
node(id: $webhookConfigurationId) { node(id: $webhookSubscriptionId) {
... on WebhookConfiguration { ... on WebhookSubscription {
events(first: $first, after: $after) { events(first: $first, after: $after) {
totalCount totalCount
pageInfo { pageInfo {
@@ -126,13 +129,13 @@ const webhookEventsQuery = graphql`
} }
`; `;
const deleteWebhookConfigurationMutation = graphql` const deleteWebhookSubscriptionMutation = graphql`
mutation WebhooksSettingsPage_deleteMutation( mutation WebhooksSettingsPage_deleteMutation(
$input: DeleteWebhookConfigurationInput! $input: DeleteWebhookSubscriptionInput!
$connections: [ID!]! $connections: [ID!]!
) { ) {
deleteWebhookConfiguration(input: $input) { deleteWebhookSubscription(input: $input) {
deletedWebhookConfigurationId @deleteEdge(connections: $connections) deletedWebhookSubscriptionId @deleteEdge(connections: $connections)
} }
} }
`; `;
@@ -221,8 +224,8 @@ function WebhookFormDialog({
trigger={trigger} trigger={trigger}
title={ title={
mode === "create" mode === "create"
? __("Add Webhook Configuration") ? __("Add Webhook Subscription")
: __("Edit Webhook Configuration") : __("Edit Webhook Subscription")
} }
className="max-w-lg" className="max-w-lg"
> >
@@ -300,11 +303,11 @@ function formatDate(iso: string) {
} }
function WebhookEventsDialog({ function WebhookEventsDialog({
webhookConfigurationId, webhookSubscriptionId,
endpointUrl, endpointUrl,
onClose, onClose,
}: { }: {
webhookConfigurationId: string; webhookSubscriptionId: string;
endpointUrl: string; endpointUrl: string;
onClose: () => void; onClose: () => void;
}) { }) {
@@ -329,7 +332,7 @@ function WebhookEventsDialog({
environment, environment,
webhookEventsQuery, webhookEventsQuery,
{ {
webhookConfigurationId, webhookSubscriptionId,
first: PAGE_SIZE, first: PAGE_SIZE,
after: after ?? null, after: after ?? null,
}, },
@@ -353,7 +356,7 @@ function WebhookEventsDialog({
setLoading(false); setLoading(false);
} }
}, },
[environment, webhookConfigurationId, toast, __], [environment, webhookSubscriptionId, toast, __],
); );
useEffect(() => { useEffect(() => {
@@ -450,24 +453,24 @@ export function WebhooksSettingsPage(props: {
const [viewingEventsId, setViewingEventsId] = useState<string | null>(null); const [viewingEventsId, setViewingEventsId] = useState<string | null>(null);
const fetchSigningSecret = useCallback( const fetchSigningSecret = useCallback(
async (webhookConfigurationId: string): Promise<string | null> => { async (webhookSubscriptionId: string): Promise<string | null> => {
// Return cached secret if already fetched // Return cached secret if already fetched
if (revealedSecrets[webhookConfigurationId]) { if (revealedSecrets[webhookSubscriptionId]) {
return revealedSecrets[webhookConfigurationId]; return revealedSecrets[webhookSubscriptionId];
} }
setLoadingSecrets(prev => new Set(prev).add(webhookConfigurationId)); setLoadingSecrets(prev => new Set(prev).add(webhookSubscriptionId));
try { try {
const data = await fetchQuery<WebhooksSettingsPage_signingSecretQuery>( const data = await fetchQuery<WebhooksSettingsPage_signingSecretQuery>(
environment, environment,
signingSecretQuery, signingSecretQuery,
{ webhookConfigurationId }, { webhookSubscriptionId },
).toPromise(); ).toPromise();
const secret = data?.node?.signingSecret; const secret = data?.node?.signingSecret;
if (secret) { if (secret) {
setRevealedSecrets(prev => ({ ...prev, [webhookConfigurationId]: secret })); setRevealedSecrets(prev => ({ ...prev, [webhookSubscriptionId]: secret }));
return secret; return secret;
} }
return null; return null;
@@ -481,7 +484,7 @@ export function WebhooksSettingsPage(props: {
} finally { } finally {
setLoadingSecrets((prev) => { setLoadingSecrets((prev) => {
const next = new Set(prev); const next = new Set(prev);
next.delete(webhookConfigurationId); next.delete(webhookSubscriptionId);
return next; return next;
}); });
} }
@@ -501,8 +504,8 @@ export function WebhooksSettingsPage(props: {
} }
}; };
const copyToClipboard = async (webhookConfigurationId: string, label: string) => { const copyToClipboard = async (webhookSubscriptionId: string, label: string) => {
const secret = await fetchSigningSecret(webhookConfigurationId); const secret = await fetchSigningSecret(webhookSubscriptionId);
if (secret) { if (secret) {
void navigator.clipboard.writeText(secret); void navigator.clipboard.writeText(secret);
toast({ toast({
@@ -523,7 +526,7 @@ export function WebhooksSettingsPage(props: {
const [createWebhook, isCreating] const [createWebhook, isCreating]
= useMutationWithToasts<WebhooksSettingsPage_createMutation>( = useMutationWithToasts<WebhooksSettingsPage_createMutation>(
createWebhookConfigurationMutation, createWebhookSubscriptionMutation,
{ {
successMessage: __("Webhook created successfully"), successMessage: __("Webhook created successfully"),
errorMessage: __("Failed to create webhook"), errorMessage: __("Failed to create webhook"),
@@ -532,7 +535,7 @@ export function WebhooksSettingsPage(props: {
const [updateWebhook, isUpdating] const [updateWebhook, isUpdating]
= useMutationWithToasts<WebhooksSettingsPage_updateMutation>( = useMutationWithToasts<WebhooksSettingsPage_updateMutation>(
updateWebhookConfigurationMutation, updateWebhookSubscriptionMutation,
{ {
successMessage: __("Webhook updated successfully"), successMessage: __("Webhook updated successfully"),
errorMessage: __("Failed to update webhook"), errorMessage: __("Failed to update webhook"),
@@ -541,21 +544,21 @@ export function WebhooksSettingsPage(props: {
const [deleteWebhook, isDeleting] const [deleteWebhook, isDeleting]
= useMutationWithToasts<WebhooksSettingsPage_deleteMutation>( = useMutationWithToasts<WebhooksSettingsPage_deleteMutation>(
deleteWebhookConfigurationMutation, deleteWebhookSubscriptionMutation,
{ {
successMessage: __("Webhook deleted successfully"), successMessage: __("Webhook deleted successfully"),
errorMessage: __("Failed to delete webhook"), errorMessage: __("Failed to delete webhook"),
}, },
); );
const webhooks = organization.webhookConfigurations?.edges ?? []; const webhooks = organization.webhookSubscriptions?.edges ?? [];
const viewingEventsWebhook = viewingEventsId const viewingEventsWebhook = viewingEventsId
? webhooks.find(e => e.node.id === viewingEventsId)?.node ?? null ? webhooks.find(e => e.node.id === viewingEventsId)?.node ?? null
: null; : null;
const connectionId = ConnectionHandler.getConnectionID( const connectionId = ConnectionHandler.getConnectionID(
organization.id, organization.id,
"WebhooksSettingsPage_webhookConfigurations", "WebhooksSettingsPage_webhookSubscriptions",
); );
const handleCreate = (values: WebhookFormData) => { const handleCreate = (values: WebhookFormData) => {
@@ -587,7 +590,7 @@ export function WebhooksSettingsPage(props: {
void deleteWebhook({ void deleteWebhook({
variables: { variables: {
input: { input: {
webhookConfigurationId: id, webhookSubscriptionId: id,
}, },
connections: [connectionId], connections: [connectionId],
}, },
@@ -602,7 +605,7 @@ export function WebhooksSettingsPage(props: {
<div className="space-y-4"> <div className="space-y-4">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div> <div>
<h2 className="text-base font-medium">{__("Webhook Configurations")}</h2> <h2 className="text-base font-medium">{__("Webhook Subscriptions")}</h2>
<p className="text-sm text-txt-tertiary"> <p className="text-sm text-txt-tertiary">
{__( {__(
"Configure webhooks to receive notifications when events occur in your organization.", "Configure webhooks to receive notifications when events occur in your organization.",
@@ -615,7 +618,7 @@ export function WebhooksSettingsPage(props: {
isSubmitting={isCreating} isSubmitting={isCreating}
trigger={( trigger={(
<Button icon={IconPlusLarge}> <Button icon={IconPlusLarge}>
{__("Add Webhook Configuration")} {__("Add Webhook Subscription")}
</Button> </Button>
)} )}
/> />
@@ -626,7 +629,7 @@ export function WebhooksSettingsPage(props: {
<Card padded> <Card padded>
<div className="text-center py-8"> <div className="text-center py-8">
<p className="text-sm text-txt-tertiary"> <p className="text-sm text-txt-tertiary">
{__("No webhook configurations yet. Add one to get started.")} {__("No webhook subscriptions yet. Add one to get started.")}
</p> </p>
</div> </div>
</Card> </Card>
@@ -737,7 +740,7 @@ export function WebhooksSettingsPage(props: {
<DialogContent padded> <DialogContent padded>
<p className="text-txt-secondary"> <p className="text-txt-secondary">
{__( {__(
"Are you sure you want to delete this webhook configuration?", "Are you sure you want to delete this webhook subscription?",
)} )}
</p> </p>
<p className="text-txt-secondary mt-2"> <p className="text-txt-secondary mt-2">
@@ -766,7 +769,7 @@ export function WebhooksSettingsPage(props: {
{viewingEventsWebhook && viewingEventsId && ( {viewingEventsWebhook && viewingEventsId && (
<WebhookEventsDialog <WebhookEventsDialog
webhookConfigurationId={viewingEventsId} webhookSubscriptionId={viewingEventsId}
endpointUrl={viewingEventsWebhook.endpointUrl} endpointUrl={viewingEventsWebhook.endpointUrl}
onClose={() => setViewingEventsId(null)} onClose={() => setViewingEventsId(null)}
/> />

View File

@@ -79,7 +79,7 @@ const (
SCIMEventEntityType uint16 = 53 SCIMEventEntityType uint16 = 53
TokenEntityType uint16 = 54 TokenEntityType uint16 = 54
SCIMBridgeEntityType uint16 = 55 SCIMBridgeEntityType uint16 = 55
WebhookConfigurationEntityType uint16 = 56 WebhookSubscriptionEntityType uint16 = 56
WebhookDataEntityType uint16 = 57 WebhookDataEntityType uint16 = 57
WebhookEventEntityType uint16 = 58 WebhookEventEntityType uint16 = 58
) )
@@ -194,8 +194,8 @@ func NewEntityFromID(id gid.GID) (any, bool) {
return &Token{ID: id}, true return &Token{ID: id}, true
case SCIMBridgeEntityType: case SCIMBridgeEntityType:
return &SCIMBridge{ID: id}, true return &SCIMBridge{ID: id}, true
case WebhookConfigurationEntityType: case WebhookSubscriptionEntityType:
return &WebhookConfiguration{ID: id}, true return &WebhookSubscription{ID: id}, true
case WebhookDataEntityType: case WebhookDataEntityType:
return &WebhookData{ID: id}, true return &WebhookData{ID: id}, true
case WebhookEventEntityType: case WebhookEventEntityType:

View File

@@ -7,7 +7,7 @@ CREATE TYPE webhook_event_type AS ENUM (
'vendor:deleted' 'vendor:deleted'
); );
CREATE TABLE webhook_configurations ( CREATE TABLE webhook_subscriptions (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL, tenant_id TEXT NOT NULL,
organization_id TEXT NOT NULL REFERENCES organizations(id) ON UPDATE CASCADE ON DELETE CASCADE, organization_id TEXT NOT NULL REFERENCES organizations(id) ON UPDATE CASCADE ON DELETE CASCADE,
@@ -38,7 +38,7 @@ CREATE TABLE webhook_events (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
tenant_id TEXT NOT NULL, tenant_id TEXT NOT NULL,
webhook_data_id TEXT NOT NULL REFERENCES webhook_data(id) ON UPDATE CASCADE ON DELETE CASCADE, webhook_data_id TEXT NOT NULL REFERENCES webhook_data(id) ON UPDATE CASCADE ON DELETE CASCADE,
webhook_configuration_id TEXT NOT NULL REFERENCES webhook_configurations(id) ON UPDATE CASCADE ON DELETE CASCADE, webhook_subscription_id TEXT NOT NULL REFERENCES webhook_subscriptions(id) ON UPDATE CASCADE ON DELETE CASCADE,
status webhook_event_status NOT NULL, status webhook_event_status NOT NULL,
response JSONB, response JSONB,
created_at TIMESTAMP WITH TIME ZONE NOT NULL created_at TIMESTAMP WITH TIME ZONE NOT NULL

View File

@@ -31,7 +31,7 @@ type (
WebhookEvent struct { WebhookEvent struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
WebhookDataID gid.GID `db:"webhook_data_id"` WebhookDataID gid.GID `db:"webhook_data_id"`
WebhookConfigurationID gid.GID `db:"webhook_configuration_id"` WebhookSubscriptionID gid.GID `db:"webhook_subscription_id"`
Status WebhookEventStatus `db:"status"` Status WebhookEventStatus `db:"status"`
Response json.RawMessage `db:"response"` Response json.RawMessage `db:"response"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
@@ -49,18 +49,18 @@ func (w WebhookEvent) CursorKey(orderBy WebhookEventOrderField) page.CursorKey {
panic(fmt.Sprintf("unsupported order by: %s", orderBy)) panic(fmt.Sprintf("unsupported order by: %s", orderBy))
} }
func (w *WebhookEvents) LoadByConfigurationID( func (w *WebhookEvents) LoadBySubscriptionID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
cursor *page.Cursor[WebhookEventOrderField], cursor *page.Cursor[WebhookEventOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
id, id,
webhook_data_id, webhook_data_id,
webhook_configuration_id, webhook_subscription_id,
status, status,
response, response,
created_at created_at
@@ -68,12 +68,12 @@ FROM
webhook_events webhook_events
WHERE WHERE
%s %s
AND webhook_configuration_id = @webhook_configuration_id AND webhook_subscription_id = @webhook_subscription_id
AND %s AND %s
` `
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
args := pgx.NamedArgs{"webhook_configuration_id": webhookConfigurationID} args := pgx.NamedArgs{"webhook_subscription_id": webhookSubscriptionID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
maps.Copy(args, cursor.SQLArguments()) maps.Copy(args, cursor.SQLArguments())
@@ -91,21 +91,21 @@ WHERE
return nil return nil
} }
func (w *WebhookEvents) CountByConfigurationID( func (w *WebhookEvents) CountBySubscriptionID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) (int, error) { ) (int, error) {
q := ` q := `
SELECT COUNT(*) SELECT COUNT(*)
FROM webhook_events FROM webhook_events
WHERE %s WHERE %s
AND webhook_configuration_id = @webhook_configuration_id AND webhook_subscription_id = @webhook_subscription_id
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"webhook_configuration_id": webhookConfigurationID} args := pgx.StrictNamedArgs{"webhook_subscription_id": webhookSubscriptionID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
var count int var count int
@@ -126,7 +126,7 @@ INSERT INTO webhook_events (
id, id,
tenant_id, tenant_id,
webhook_data_id, webhook_data_id,
webhook_configuration_id, webhook_subscription_id,
status, status,
response, response,
created_at created_at
@@ -135,7 +135,7 @@ VALUES (
@id, @id,
@tenant_id, @tenant_id,
@webhook_data_id, @webhook_data_id,
@webhook_configuration_id, @webhook_subscription_id,
@status, @status,
@response, @response,
@created_at @created_at
@@ -146,7 +146,7 @@ VALUES (
"id": w.ID, "id": w.ID,
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"webhook_data_id": w.WebhookDataID, "webhook_data_id": w.WebhookDataID,
"webhook_configuration_id": w.WebhookConfigurationID, "webhook_subscription_id": w.WebhookSubscriptionID,
"status": w.Status, "status": w.Status,
"response": w.Response, "response": w.Response,
"created_at": w.CreatedAt, "created_at": w.CreatedAt,

View File

@@ -31,7 +31,7 @@ import (
) )
type ( type (
WebhookConfiguration struct { WebhookSubscription struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
EndpointURL string `db:"endpoint_url"` EndpointURL string `db:"endpoint_url"`
@@ -41,10 +41,10 @@ type (
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
} }
WebhookConfigurations []*WebhookConfiguration WebhookSubscriptions []*WebhookSubscription
) )
func (w *WebhookConfiguration) GenerateSigningSecret(encryptionKey cipher.EncryptionKey) (string, error) { func (w *WebhookSubscription) GenerateSigningSecret(encryptionKey cipher.EncryptionKey) (string, error) {
secret := make([]byte, 32) secret := make([]byte, 32)
if _, err := rand.Read(secret); err != nil { if _, err := rand.Read(secret); err != nil {
return "", fmt.Errorf("cannot generate signing secret: %w", err) return "", fmt.Errorf("cannot generate signing secret: %w", err)
@@ -62,7 +62,7 @@ func (w *WebhookConfiguration) GenerateSigningSecret(encryptionKey cipher.Encryp
return signingSecret, nil return signingSecret, nil
} }
func (w *WebhookConfiguration) DecryptSigningSecret(encryptionKey cipher.EncryptionKey) (string, error) { func (w *WebhookSubscription) DecryptSigningSecret(encryptionKey cipher.EncryptionKey) (string, error) {
if len(w.EncryptedSigningSecret) == 0 { if len(w.EncryptedSigningSecret) == 0 {
return "", fmt.Errorf("no encrypted signing secret") return "", fmt.Errorf("no encrypted signing secret")
} }
@@ -75,9 +75,9 @@ func (w *WebhookConfiguration) DecryptSigningSecret(encryptionKey cipher.Encrypt
return string(plaintext), nil return string(plaintext), nil
} }
func (w WebhookConfiguration) CursorKey(orderBy WebhookConfigurationOrderField) page.CursorKey { func (w WebhookSubscription) CursorKey(orderBy WebhookSubscriptionOrderField) page.CursorKey {
switch orderBy { switch orderBy {
case WebhookConfigurationOrderFieldCreatedAt: case WebhookSubscriptionOrderFieldCreatedAt:
return page.NewCursorKey(w.ID, w.CreatedAt) return page.NewCursorKey(w.ID, w.CreatedAt)
} }
@@ -85,25 +85,25 @@ func (w WebhookConfiguration) CursorKey(orderBy WebhookConfigurationOrderField)
} }
// AuthorizationAttributes returns the authorization attributes for policy evaluation. // AuthorizationAttributes returns the authorization attributes for policy evaluation.
func (w *WebhookConfiguration) AuthorizationAttributes(ctx context.Context, conn pg.Conn) (map[string]string, error) { func (w *WebhookSubscription) AuthorizationAttributes(ctx context.Context, conn pg.Conn) (map[string]string, error) {
q := `SELECT organization_id FROM webhook_configurations WHERE id = $1 LIMIT 1;` q := `SELECT organization_id FROM webhook_subscriptions WHERE id = $1 LIMIT 1;`
var organizationID gid.GID var organizationID gid.GID
if err := conn.QueryRow(ctx, q, w.ID).Scan(&organizationID); err != nil { if err := conn.QueryRow(ctx, q, w.ID).Scan(&organizationID); err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound return nil, ErrResourceNotFound
} }
return nil, fmt.Errorf("cannot query webhook configuration authorization attributes: %w", err) return nil, fmt.Errorf("cannot query webhook subscription authorization attributes: %w", err)
} }
return map[string]string{"organization_id": organizationID.String()}, nil return map[string]string{"organization_id": organizationID.String()}, nil
} }
func (w *WebhookConfiguration) LoadByID( func (w *WebhookSubscription) LoadByID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -115,42 +115,42 @@ SELECT
created_at, created_at,
updated_at updated_at
FROM FROM
webhook_configurations webhook_subscriptions
WHERE WHERE
%s %s
AND id = @webhook_configuration_id AND id = @webhook_subscription_id
LIMIT 1; LIMIT 1;
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"webhook_configuration_id": webhookConfigurationID} args := pgx.StrictNamedArgs{"webhook_subscription_id": webhookSubscriptionID}
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query webhook configurations: %w", err) return fmt.Errorf("cannot query webhook subscriptions: %w", err)
} }
wc, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[WebhookConfiguration]) wc, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[WebhookSubscription])
if err != nil { if err != nil {
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound return ErrResourceNotFound
} }
return fmt.Errorf("cannot collect webhook configuration: %w", err) return fmt.Errorf("cannot collect webhook subscription: %w", err)
} }
*w = wc *w = wc
return nil return nil
} }
func (w *WebhookConfigurations) LoadByOrganizationID( func (w *WebhookSubscriptions) LoadByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
organizationID gid.GID, organizationID gid.GID,
cursor *page.Cursor[WebhookConfigurationOrderField], cursor *page.Cursor[WebhookSubscriptionOrderField],
) error { ) error {
q := ` q := `
SELECT SELECT
@@ -162,7 +162,7 @@ SELECT
created_at, created_at,
updated_at updated_at
FROM FROM
webhook_configurations webhook_subscriptions
WHERE WHERE
%s %s
AND organization_id = @organization_id AND organization_id = @organization_id
@@ -176,19 +176,19 @@ WHERE
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query webhook configurations: %w", err) return fmt.Errorf("cannot query webhook subscriptions: %w", err)
} }
configurations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[WebhookConfiguration]) subscriptions, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[WebhookSubscription])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect webhook configurations: %w", err) return fmt.Errorf("cannot collect webhook subscriptions: %w", err)
} }
*w = configurations *w = subscriptions
return nil return nil
} }
func (w *WebhookConfigurations) CountByOrganizationID( func (w *WebhookSubscriptions) CountByOrganizationID(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
@@ -198,7 +198,7 @@ func (w *WebhookConfigurations) CountByOrganizationID(
SELECT SELECT
COUNT(*) COUNT(*)
FROM FROM
webhook_configurations webhook_subscriptions
WHERE WHERE
%s %s
AND organization_id = @organization_id AND organization_id = @organization_id
@@ -213,13 +213,13 @@ WHERE
row := conn.QueryRow(ctx, q, args) row := conn.QueryRow(ctx, q, args)
var count int var count int
if err := row.Scan(&count); err != nil { if err := row.Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count webhook configurations: %w", err) return 0, fmt.Errorf("cannot count webhook subscriptions: %w", err)
} }
return count, nil return count, nil
} }
func (w *WebhookConfigurations) ExistsByOrganizationIDAndEventType( func (w *WebhookSubscriptions) ExistsByOrganizationIDAndEventType(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
@@ -229,7 +229,7 @@ func (w *WebhookConfigurations) ExistsByOrganizationIDAndEventType(
q := ` q := `
SELECT EXISTS ( SELECT EXISTS (
SELECT 1 SELECT 1
FROM webhook_configurations FROM webhook_subscriptions
WHERE %s WHERE %s
AND organization_id = @organization_id AND organization_id = @organization_id
AND @event_type = ANY(selected_events) AND @event_type = ANY(selected_events)
@@ -245,20 +245,20 @@ SELECT EXISTS (
var exists bool var exists bool
if err := conn.QueryRow(ctx, q, args).Scan(&exists); err != nil { if err := conn.QueryRow(ctx, q, args).Scan(&exists); err != nil {
return false, fmt.Errorf("cannot check webhook configuration existence: %w", err) return false, fmt.Errorf("cannot check webhook subscription existence: %w", err)
} }
return exists, nil return exists, nil
} }
func (w *WebhookConfiguration) Insert( func (w *WebhookSubscription) Insert(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
INSERT INTO INSERT INTO
webhook_configurations ( webhook_subscriptions (
tenant_id, tenant_id,
id, id,
organization_id, organization_id,
@@ -270,7 +270,7 @@ INSERT INTO
) )
VALUES ( VALUES (
@tenant_id, @tenant_id,
@webhook_configuration_id, @webhook_subscription_id,
@organization_id, @organization_id,
@endpoint_url, @endpoint_url,
@selected_events, @selected_events,
@@ -281,52 +281,52 @@ VALUES (
` `
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"tenant_id": scope.GetTenantID(), "tenant_id": scope.GetTenantID(),
"webhook_configuration_id": w.ID, "webhook_subscription_id": w.ID,
"organization_id": w.OrganizationID, "organization_id": w.OrganizationID,
"endpoint_url": w.EndpointURL, "endpoint_url": w.EndpointURL,
"selected_events": w.SelectedEvents, "selected_events": w.SelectedEvents,
"encrypted_signing_secret": w.EncryptedSigningSecret, "encrypted_signing_secret": w.EncryptedSigningSecret,
"created_at": w.CreatedAt, "created_at": w.CreatedAt,
"updated_at": w.UpdatedAt, "updated_at": w.UpdatedAt,
} }
_, err := conn.Exec(ctx, q, args) _, err := conn.Exec(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot insert webhook configuration: %w", err) return fmt.Errorf("cannot insert webhook subscription: %w", err)
} }
return nil return nil
} }
func (w *WebhookConfiguration) Update( func (w *WebhookSubscription) Update(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
UPDATE webhook_configurations UPDATE webhook_subscriptions
SET SET
endpoint_url = @endpoint_url, endpoint_url = @endpoint_url,
selected_events = @selected_events, selected_events = @selected_events,
updated_at = @updated_at updated_at = @updated_at
WHERE %s WHERE %s
AND id = @webhook_configuration_id AND id = @webhook_subscription_id
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"webhook_configuration_id": w.ID, "webhook_subscription_id": w.ID,
"endpoint_url": w.EndpointURL, "endpoint_url": w.EndpointURL,
"selected_events": w.SelectedEvents, "selected_events": w.SelectedEvents,
"updated_at": w.UpdatedAt, "updated_at": w.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args) result, err := conn.Exec(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot update webhook configuration: %w", err) return fmt.Errorf("cannot update webhook subscription: %w", err)
} }
if result.RowsAffected() == 0 { if result.RowsAffected() == 0 {
@@ -336,7 +336,7 @@ WHERE %s
return nil return nil
} }
func (w *WebhookConfigurations) LoadMatchingByOrganizationIDAndEventType( func (w *WebhookSubscriptions) LoadMatchingByOrganizationIDAndEventType(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
@@ -353,7 +353,7 @@ SELECT
created_at, created_at,
updated_at updated_at
FROM FROM
webhook_configurations webhook_subscriptions
WHERE WHERE
%s %s
AND organization_id = @organization_id AND organization_id = @organization_id
@@ -369,38 +369,38 @@ WHERE
rows, err := conn.Query(ctx, q, args) rows, err := conn.Query(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot query matching webhook configurations: %w", err) return fmt.Errorf("cannot query matching webhook subscriptions: %w", err)
} }
configurations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[WebhookConfiguration]) subscriptions, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[WebhookSubscription])
if err != nil { if err != nil {
return fmt.Errorf("cannot collect matching webhook configurations: %w", err) return fmt.Errorf("cannot collect matching webhook subscriptions: %w", err)
} }
*w = configurations *w = subscriptions
return nil return nil
} }
func (w *WebhookConfiguration) Delete( func (w *WebhookSubscription) Delete(
ctx context.Context, ctx context.Context,
conn pg.Conn, conn pg.Conn,
scope Scoper, scope Scoper,
) error { ) error {
q := ` q := `
DELETE FROM webhook_configurations DELETE FROM webhook_subscriptions
WHERE %s WHERE %s
AND id = @webhook_configuration_id AND id = @webhook_subscription_id
` `
q = fmt.Sprintf(q, scope.SQLFragment()) q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{ args := pgx.StrictNamedArgs{
"webhook_configuration_id": w.ID, "webhook_subscription_id": w.ID,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args) result, err := conn.Exec(ctx, q, args)
if err != nil { if err != nil {
return fmt.Errorf("cannot delete webhook configuration: %w", err) return fmt.Errorf("cannot delete webhook subscription: %w", err)
} }
if result.RowsAffected() == 0 { if result.RowsAffected() == 0 {

View File

@@ -19,37 +19,37 @@ import (
) )
type ( type (
WebhookConfigurationOrderField string WebhookSubscriptionOrderField string
) )
const ( const (
WebhookConfigurationOrderFieldCreatedAt WebhookConfigurationOrderField = "CREATED_AT" WebhookSubscriptionOrderFieldCreatedAt WebhookSubscriptionOrderField = "CREATED_AT"
) )
func (p WebhookConfigurationOrderField) Column() string { func (p WebhookSubscriptionOrderField) Column() string {
return string(p) return string(p)
} }
func (p WebhookConfigurationOrderField) String() string { func (p WebhookSubscriptionOrderField) String() string {
return string(p) return string(p)
} }
func (p WebhookConfigurationOrderField) IsValid() bool { func (p WebhookSubscriptionOrderField) IsValid() bool {
switch p { switch p {
case WebhookConfigurationOrderFieldCreatedAt: case WebhookSubscriptionOrderFieldCreatedAt:
return true return true
} }
return false return false
} }
func (p WebhookConfigurationOrderField) MarshalText() ([]byte, error) { func (p WebhookSubscriptionOrderField) MarshalText() ([]byte, error) {
return []byte(p.String()), nil return []byte(p.String()), nil
} }
func (p *WebhookConfigurationOrderField) UnmarshalText(text []byte) error { func (p *WebhookSubscriptionOrderField) UnmarshalText(text []byte) error {
*p = WebhookConfigurationOrderField(text) *p = WebhookSubscriptionOrderField(text)
if !p.IsValid() { if !p.IsValid() {
return fmt.Errorf("%s is not a valid WebhookConfigurationOrderField", string(text)) return fmt.Errorf("%s is not a valid WebhookSubscriptionOrderField", string(text))
} }
return nil return nil
} }

View File

@@ -317,10 +317,10 @@ const (
ActionApplicabilityStatementUpdate = "core:applicability-statement:update" ActionApplicabilityStatementUpdate = "core:applicability-statement:update"
ActionApplicabilityStatementDelete = "core:applicability-statement:delete" ActionApplicabilityStatementDelete = "core:applicability-statement:delete"
// WebhookConfiguration actions // WebhookSubscription actions
ActionWebhookConfigurationList = "core:webhook-configuration:list" ActionWebhookSubscriptionList = "core:webhook-subscription:list"
ActionWebhookConfigurationGet = "core:webhook-configuration:get" ActionWebhookSubscriptionGet = "core:webhook-subscription:get"
ActionWebhookConfigurationCreate = "core:webhook-configuration:create" ActionWebhookSubscriptionCreate = "core:webhook-subscription:create"
ActionWebhookConfigurationUpdate = "core:webhook-configuration:update" ActionWebhookSubscriptionUpdate = "core:webhook-subscription:update"
ActionWebhookConfigurationDelete = "core:webhook-configuration:delete" ActionWebhookSubscriptionDelete = "core:webhook-subscription:delete"
) )

View File

@@ -79,7 +79,7 @@ var ViewerPolicy = policy.NewPolicy(
ActionRightsRequestGet, ActionRightsRequestList, ActionRightsRequestGet, ActionRightsRequestList,
ActionStateOfApplicabilityGet, ActionStateOfApplicabilityList, ActionStateOfApplicabilityGet, ActionStateOfApplicabilityList,
ActionApplicabilityStatementGet, ActionApplicabilityStatementList, ActionApplicabilityStatementGet, ActionApplicabilityStatementList,
ActionWebhookConfigurationGet, ActionWebhookConfigurationList, ActionWebhookSubscriptionGet, ActionWebhookSubscriptionList,
).WithSID("entity-read-access").When(organizationCondition), ).WithSID("entity-read-access").When(organizationCondition),
policy.Allow( policy.Allow(

View File

@@ -92,7 +92,7 @@ type (
Data *DatumService Data *DatumService
Audits *AuditService Audits *AuditService
Meetings *MeetingService Meetings *MeetingService
WebhookConfigurations *WebhookConfigurationService WebhookSubscriptions *WebhookSubscriptionService
Reports *ReportService Reports *ReportService
TrustCenters *TrustCenterService TrustCenters *TrustCenterService
TrustCenterAccesses *TrustCenterAccessService TrustCenterAccesses *TrustCenterAccessService
@@ -214,7 +214,7 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
tenantService.Data = &DatumService{svc: tenantService} tenantService.Data = &DatumService{svc: tenantService}
tenantService.Audits = &AuditService{svc: tenantService} tenantService.Audits = &AuditService{svc: tenantService}
tenantService.Meetings = &MeetingService{svc: tenantService} tenantService.Meetings = &MeetingService{svc: tenantService}
tenantService.WebhookConfigurations = &WebhookConfigurationService{svc: tenantService} tenantService.WebhookSubscriptions = &WebhookSubscriptionService{svc: tenantService}
tenantService.Reports = &ReportService{svc: tenantService} tenantService.Reports = &ReportService{svc: tenantService}
tenantService.TrustCenters = &TrustCenterService{svc: tenantService} tenantService.TrustCenters = &TrustCenterService{svc: tenantService}
tenantService.TrustCenterAccesses = &TrustCenterAccessService{svc: tenantService} tenantService.TrustCenterAccesses = &TrustCenterAccessService{svc: tenantService}

View File

@@ -26,25 +26,25 @@ import (
"go.probo.inc/probo/pkg/validator" "go.probo.inc/probo/pkg/validator"
) )
type WebhookConfigurationService struct { type WebhookSubscriptionService struct {
svc *TenantService svc *TenantService
} }
type ( type (
CreateWebhookConfigurationRequest struct { CreateWebhookSubscriptionRequest struct {
OrganizationID gid.GID OrganizationID gid.GID
EndpointURL string EndpointURL string
SelectedEvents []coredata.WebhookEventType SelectedEvents []coredata.WebhookEventType
} }
UpdateWebhookConfigurationRequest struct { UpdateWebhookSubscriptionRequest struct {
WebhookConfigurationID gid.GID WebhookSubscriptionID gid.GID
EndpointURL *string EndpointURL *string
SelectedEvents []coredata.WebhookEventType SelectedEvents []coredata.WebhookEventType
} }
) )
func (r *CreateWebhookConfigurationRequest) Validate() error { func (r *CreateWebhookSubscriptionRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(r.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType)) v.Check(r.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
@@ -53,21 +53,21 @@ func (r *CreateWebhookConfigurationRequest) Validate() error {
return v.Error() return v.Error()
} }
func (r *UpdateWebhookConfigurationRequest) Validate() error { func (r *UpdateWebhookSubscriptionRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(r.WebhookConfigurationID, "webhook_configuration_id", validator.Required(), validator.GID(coredata.WebhookConfigurationEntityType)) v.Check(r.WebhookSubscriptionID, "webhook_subscription_id", validator.Required(), validator.GID(coredata.WebhookSubscriptionEntityType))
v.Check(r.EndpointURL, "endpoint_url", validator.NotEmpty(), validator.HTTPSUrl()) v.Check(r.EndpointURL, "endpoint_url", validator.NotEmpty(), validator.HTTPSUrl())
return v.Error() return v.Error()
} }
func (s WebhookConfigurationService) ListForOrganizationID( func (s WebhookSubscriptionService) ListForOrganizationID(
ctx context.Context, ctx context.Context,
organizationID gid.GID, organizationID gid.GID,
cursor *page.Cursor[coredata.WebhookConfigurationOrderField], cursor *page.Cursor[coredata.WebhookSubscriptionOrderField],
) (*page.Page[*coredata.WebhookConfiguration, coredata.WebhookConfigurationOrderField], error) { ) (*page.Page[*coredata.WebhookSubscription, coredata.WebhookSubscriptionOrderField], error) {
var configurations coredata.WebhookConfigurations var subscriptions coredata.WebhookSubscriptions
organization := &coredata.Organization{} organization := &coredata.Organization{}
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
@@ -77,7 +77,7 @@ func (s WebhookConfigurationService) ListForOrganizationID(
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
err := configurations.LoadByOrganizationID( err := subscriptions.LoadByOrganizationID(
ctx, ctx,
conn, conn,
s.svc.scope, s.svc.scope,
@@ -85,7 +85,7 @@ func (s WebhookConfigurationService) ListForOrganizationID(
cursor, cursor,
) )
if err != nil { if err != nil {
return fmt.Errorf("cannot load webhook configurations: %w", err) return fmt.Errorf("cannot load webhook subscriptions: %w", err)
} }
return nil return nil
@@ -96,10 +96,10 @@ func (s WebhookConfigurationService) ListForOrganizationID(
return nil, err return nil, err
} }
return page.NewPage(configurations, cursor), nil return page.NewPage(subscriptions, cursor), nil
} }
func (s WebhookConfigurationService) CountForOrganizationID( func (s WebhookSubscriptionService) CountForOrganizationID(
ctx context.Context, ctx context.Context,
organizationID gid.GID, organizationID gid.GID,
) (int, error) { ) (int, error) {
@@ -108,10 +108,10 @@ func (s WebhookConfigurationService) CountForOrganizationID(
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) (err error) { func(conn pg.Conn) (err error) {
configurations := &coredata.WebhookConfigurations{} subscriptions := &coredata.WebhookSubscriptions{}
count, err = configurations.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID) count, err = subscriptions.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
if err != nil { if err != nil {
return fmt.Errorf("cannot count webhook configurations: %w", err) return fmt.Errorf("cannot count webhook subscriptions: %w", err)
} }
return nil return nil
@@ -125,17 +125,17 @@ func (s WebhookConfigurationService) CountForOrganizationID(
return count, nil return count, nil
} }
func (s WebhookConfigurationService) Get( func (s WebhookSubscriptionService) Get(
ctx context.Context, ctx context.Context,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) (*coredata.WebhookConfiguration, error) { ) (*coredata.WebhookSubscription, error) {
wc := &coredata.WebhookConfiguration{} wc := &coredata.WebhookSubscription{}
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookConfigurationID); err != nil { if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookSubscriptionID); err != nil {
return fmt.Errorf("cannot load webhook configuration: %w", err) return fmt.Errorf("cannot load webhook subscription: %w", err)
} }
return nil return nil
@@ -149,16 +149,16 @@ func (s WebhookConfigurationService) Get(
return wc, nil return wc, nil
} }
func (s WebhookConfigurationService) Create( func (s WebhookSubscriptionService) Create(
ctx context.Context, ctx context.Context,
req CreateWebhookConfigurationRequest, req CreateWebhookSubscriptionRequest,
) (*coredata.WebhookConfiguration, error) { ) (*coredata.WebhookSubscription, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
now := time.Now() now := time.Now()
var wc *coredata.WebhookConfiguration var wc *coredata.WebhookSubscription
organization := &coredata.Organization{} organization := &coredata.Organization{}
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
@@ -168,8 +168,8 @@ func (s WebhookConfigurationService) Create(
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
wc = &coredata.WebhookConfiguration{ wc = &coredata.WebhookSubscription{
ID: gid.New(organization.ID.TenantID(), coredata.WebhookConfigurationEntityType), ID: gid.New(organization.ID.TenantID(), coredata.WebhookSubscriptionEntityType),
OrganizationID: organization.ID, OrganizationID: organization.ID,
EndpointURL: req.EndpointURL, EndpointURL: req.EndpointURL,
SelectedEvents: req.SelectedEvents, SelectedEvents: req.SelectedEvents,
@@ -182,7 +182,7 @@ func (s WebhookConfigurationService) Create(
} }
if err := wc.Insert(ctx, conn, s.svc.scope); err != nil { if err := wc.Insert(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert webhook configuration: %w", err) return fmt.Errorf("cannot insert webhook subscription: %w", err)
} }
return nil return nil
@@ -196,21 +196,21 @@ func (s WebhookConfigurationService) Create(
return wc, nil return wc, nil
} }
func (s WebhookConfigurationService) Update( func (s WebhookSubscriptionService) Update(
ctx context.Context, ctx context.Context,
req UpdateWebhookConfigurationRequest, req UpdateWebhookSubscriptionRequest,
) (*coredata.WebhookConfiguration, error) { ) (*coredata.WebhookSubscription, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
wc := &coredata.WebhookConfiguration{} wc := &coredata.WebhookSubscription{}
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := wc.LoadByID(ctx, conn, s.svc.scope, req.WebhookConfigurationID); err != nil { if err := wc.LoadByID(ctx, conn, s.svc.scope, req.WebhookSubscriptionID); err != nil {
return fmt.Errorf("cannot load webhook configuration: %w", err) return fmt.Errorf("cannot load webhook subscription: %w", err)
} }
if req.EndpointURL != nil { if req.EndpointURL != nil {
@@ -223,7 +223,7 @@ func (s WebhookConfigurationService) Update(
wc.UpdatedAt = time.Now() wc.UpdatedAt = time.Now()
if err := wc.Update(ctx, conn, s.svc.scope); err != nil { if err := wc.Update(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot update webhook configuration: %w", err) return fmt.Errorf("cannot update webhook subscription: %w", err)
} }
return nil return nil
@@ -237,17 +237,17 @@ func (s WebhookConfigurationService) Update(
return wc, nil return wc, nil
} }
func (s WebhookConfigurationService) GetSigningSecret( func (s WebhookSubscriptionService) GetSigningSecret(
ctx context.Context, ctx context.Context,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) (string, error) { ) (string, error) {
wc := &coredata.WebhookConfiguration{} wc := &coredata.WebhookSubscription{}
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookConfigurationID); err != nil { if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookSubscriptionID); err != nil {
return fmt.Errorf("cannot load webhook configuration: %w", err) return fmt.Errorf("cannot load webhook subscription: %w", err)
} }
return nil return nil
@@ -261,9 +261,9 @@ func (s WebhookConfigurationService) GetSigningSecret(
return wc.DecryptSigningSecret(s.svc.encryptionKey) return wc.DecryptSigningSecret(s.svc.encryptionKey)
} }
func (s WebhookConfigurationService) ListEventsForConfigurationID( func (s WebhookSubscriptionService) ListEventsForSubscriptionID(
ctx context.Context, ctx context.Context,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
cursor *page.Cursor[coredata.WebhookEventOrderField], cursor *page.Cursor[coredata.WebhookEventOrderField],
) (*page.Page[*coredata.WebhookEvent, coredata.WebhookEventOrderField], error) { ) (*page.Page[*coredata.WebhookEvent, coredata.WebhookEventOrderField], error) {
var events coredata.WebhookEvents var events coredata.WebhookEvents
@@ -271,7 +271,7 @@ func (s WebhookConfigurationService) ListEventsForConfigurationID(
err := s.svc.pg.WithConn( err := s.svc.pg.WithConn(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := events.LoadByConfigurationID(ctx, conn, s.svc.scope, webhookConfigurationID, cursor); err != nil { if err := events.LoadBySubscriptionID(ctx, conn, s.svc.scope, webhookSubscriptionID, cursor); err != nil {
return fmt.Errorf("cannot load webhook events: %w", err) return fmt.Errorf("cannot load webhook events: %w", err)
} }
@@ -286,9 +286,9 @@ func (s WebhookConfigurationService) ListEventsForConfigurationID(
return page.NewPage(events, cursor), nil return page.NewPage(events, cursor), nil
} }
func (s WebhookConfigurationService) CountEventsForConfigurationID( func (s WebhookSubscriptionService) CountEventsForSubscriptionID(
ctx context.Context, ctx context.Context,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) (int, error) { ) (int, error) {
var count int var count int
@@ -296,7 +296,7 @@ func (s WebhookConfigurationService) CountEventsForConfigurationID(
ctx, ctx,
func(conn pg.Conn) (err error) { func(conn pg.Conn) (err error) {
events := &coredata.WebhookEvents{} events := &coredata.WebhookEvents{}
count, err = events.CountByConfigurationID(ctx, conn, s.svc.scope, webhookConfigurationID) count, err = events.CountBySubscriptionID(ctx, conn, s.svc.scope, webhookSubscriptionID)
if err != nil { if err != nil {
return fmt.Errorf("cannot count webhook events: %w", err) return fmt.Errorf("cannot count webhook events: %w", err)
@@ -313,21 +313,21 @@ func (s WebhookConfigurationService) CountEventsForConfigurationID(
return count, nil return count, nil
} }
func (s WebhookConfigurationService) Delete( func (s WebhookSubscriptionService) Delete(
ctx context.Context, ctx context.Context,
webhookConfigurationID gid.GID, webhookSubscriptionID gid.GID,
) error { ) error {
wc := &coredata.WebhookConfiguration{ID: webhookConfigurationID} wc := &coredata.WebhookSubscription{ID: webhookSubscriptionID}
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
ctx, ctx,
func(conn pg.Conn) error { func(conn pg.Conn) error {
if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookConfigurationID); err != nil { if err := wc.LoadByID(ctx, conn, s.svc.scope, webhookSubscriptionID); err != nil {
return fmt.Errorf("cannot load webhook configuration: %w", err) return fmt.Errorf("cannot load webhook subscription: %w", err)
} }
if err := wc.Delete(ctx, conn, s.svc.scope); err != nil { if err := wc.Delete(ctx, conn, s.svc.scope); err != nil {
return fmt.Errorf("cannot delete webhook configuration: %w", err) return fmt.Errorf("cannot delete webhook subscription: %w", err)
} }
return nil return nil

View File

@@ -488,13 +488,13 @@ enum MeetingOrderField
) )
} }
enum WebhookConfigurationOrderField enum WebhookSubscriptionOrderField
@goModel( @goModel(
model: "go.probo.inc/probo/pkg/coredata.WebhookConfigurationOrderField" model: "go.probo.inc/probo/pkg/coredata.WebhookSubscriptionOrderField"
) { ) {
CREATED_AT CREATED_AT
@goEnum( @goEnum(
value: "go.probo.inc/probo/pkg/coredata.WebhookConfigurationOrderFieldCreatedAt" value: "go.probo.inc/probo/pkg/coredata.WebhookSubscriptionOrderFieldCreatedAt"
) )
} }
@@ -1355,12 +1355,12 @@ input MeetingOrder
field: MeetingOrderField! field: MeetingOrderField!
} }
input WebhookConfigurationOrder input WebhookSubscriptionOrder
@goModel( @goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookConfigurationOrderBy" model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookSubscriptionOrderBy"
) { ) {
direction: OrderDirection! direction: OrderDirection!
field: WebhookConfigurationOrderField! field: WebhookSubscriptionOrderField!
} }
input RiskOrder input RiskOrder
@@ -1835,13 +1835,13 @@ type Organization implements Node {
customDomain: CustomDomain @goField(forceResolver: true) customDomain: CustomDomain @goField(forceResolver: true)
webhookConfigurations( webhookSubscriptions(
first: Int first: Int
after: CursorKey after: CursorKey
last: Int last: Int
before: CursorKey before: CursorKey
orderBy: WebhookConfigurationOrder orderBy: WebhookSubscriptionOrder
): WebhookConfigurationConnection! @goField(forceResolver: true) ): WebhookSubscriptionConnection! @goField(forceResolver: true)
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
@@ -2284,7 +2284,7 @@ enum WebhookEventType
@goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeVendorDeleted") @goEnum(value: "go.probo.inc/probo/pkg/coredata.WebhookEventTypeVendorDeleted")
} }
type WebhookConfiguration implements Node { type WebhookSubscription implements Node {
id: ID! id: ID!
organization: Organization @goField(forceResolver: true) organization: Organization @goField(forceResolver: true)
endpointUrl: String! endpointUrl: String!
@@ -2304,18 +2304,18 @@ type WebhookConfiguration implements Node {
permission(action: String!): Boolean! @goField(forceResolver: true) permission(action: String!): Boolean! @goField(forceResolver: true)
} }
type WebhookConfigurationConnection type WebhookSubscriptionConnection
@goModel( @goModel(
model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookConfigurationConnection" model: "go.probo.inc/probo/pkg/server/api/console/v1/types.WebhookSubscriptionConnection"
) { ) {
edges: [WebhookConfigurationEdge!]! edges: [WebhookSubscriptionEdge!]!
pageInfo: PageInfo! pageInfo: PageInfo!
totalCount: Int! @goField(forceResolver: true) totalCount: Int! @goField(forceResolver: true)
} }
type WebhookConfigurationEdge { type WebhookSubscriptionEdge {
cursor: CursorKey! cursor: CursorKey!
node: WebhookConfiguration! node: WebhookSubscription!
} }
enum WebhookEventStatus enum WebhookEventStatus
@@ -2348,7 +2348,7 @@ input WebhookEventOrder
type WebhookEvent implements Node { type WebhookEvent implements Node {
id: ID! id: ID!
webhookConfigurationId: ID! webhookSubscriptionId: ID!
status: WebhookEventStatus! status: WebhookEventStatus!
response: String response: String
createdAt: Datetime! createdAt: Datetime!
@@ -3396,16 +3396,16 @@ type Mutation {
createMeeting(input: CreateMeetingInput!): CreateMeetingPayload! createMeeting(input: CreateMeetingInput!): CreateMeetingPayload!
updateMeeting(input: UpdateMeetingInput!): UpdateMeetingPayload! updateMeeting(input: UpdateMeetingInput!): UpdateMeetingPayload!
deleteMeeting(input: DeleteMeetingInput!): DeleteMeetingPayload! deleteMeeting(input: DeleteMeetingInput!): DeleteMeetingPayload!
# WebhookConfiguration mutations # WebhookSubscription mutations
createWebhookConfiguration( createWebhookSubscription(
input: CreateWebhookConfigurationInput! input: CreateWebhookSubscriptionInput!
): CreateWebhookConfigurationPayload! ): CreateWebhookSubscriptionPayload!
updateWebhookConfiguration( updateWebhookSubscription(
input: UpdateWebhookConfigurationInput! input: UpdateWebhookSubscriptionInput!
): UpdateWebhookConfigurationPayload! ): UpdateWebhookSubscriptionPayload!
deleteWebhookConfiguration( deleteWebhookSubscription(
input: DeleteWebhookConfigurationInput! input: DeleteWebhookSubscriptionInput!
): DeleteWebhookConfigurationPayload! ): DeleteWebhookSubscriptionPayload!
# StateOfApplicability mutations # StateOfApplicability mutations
createStateOfApplicability( createStateOfApplicability(
input: CreateStateOfApplicabilityInput! input: CreateStateOfApplicabilityInput!
@@ -4757,32 +4757,32 @@ type DeleteMeetingPayload {
deletedMeetingId: ID! deletedMeetingId: ID!
} }
input CreateWebhookConfigurationInput { input CreateWebhookSubscriptionInput {
organizationId: ID! organizationId: ID!
endpointUrl: String! endpointUrl: String!
selectedEvents: [WebhookEventType!]! selectedEvents: [WebhookEventType!]!
} }
input UpdateWebhookConfigurationInput { input UpdateWebhookSubscriptionInput {
id: ID! id: ID!
endpointUrl: String endpointUrl: String
selectedEvents: [WebhookEventType!] selectedEvents: [WebhookEventType!]
} }
input DeleteWebhookConfigurationInput { input DeleteWebhookSubscriptionInput {
webhookConfigurationId: ID! webhookSubscriptionId: ID!
} }
type CreateWebhookConfigurationPayload { type CreateWebhookSubscriptionPayload {
webhookConfigurationEdge: WebhookConfigurationEdge! webhookSubscriptionEdge: WebhookSubscriptionEdge!
} }
type UpdateWebhookConfigurationPayload { type UpdateWebhookSubscriptionPayload {
webhookConfiguration: WebhookConfiguration! webhookSubscription: WebhookSubscription!
} }
type DeleteWebhookConfigurationPayload { type DeleteWebhookSubscriptionPayload {
deletedWebhookConfigurationId: ID! deletedWebhookSubscriptionId: ID!
} }
type CreateStateOfApplicabilityPayload { type CreateStateOfApplicabilityPayload {

File diff suppressed because it is too large Load Diff

View File

@@ -693,14 +693,14 @@ type CreateVendorServicePayload struct {
VendorServiceEdge *VendorServiceEdge `json:"vendorServiceEdge"` VendorServiceEdge *VendorServiceEdge `json:"vendorServiceEdge"`
} }
type CreateWebhookConfigurationInput struct { type CreateWebhookSubscriptionInput struct {
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
EndpointURL string `json:"endpointUrl"` EndpointURL string `json:"endpointUrl"`
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents"` SelectedEvents []coredata.WebhookEventType `json:"selectedEvents"`
} }
type CreateWebhookConfigurationPayload struct { type CreateWebhookSubscriptionPayload struct {
WebhookConfigurationEdge *WebhookConfigurationEdge `json:"webhookConfigurationEdge"` WebhookSubscriptionEdge *WebhookSubscriptionEdge `json:"webhookSubscriptionEdge"`
} }
type CustomDomain struct { type CustomDomain struct {
@@ -1113,12 +1113,12 @@ type DeleteVendorServicePayload struct {
DeletedVendorServiceID gid.GID `json:"deletedVendorServiceId"` DeletedVendorServiceID gid.GID `json:"deletedVendorServiceId"`
} }
type DeleteWebhookConfigurationInput struct { type DeleteWebhookSubscriptionInput struct {
WebhookConfigurationID gid.GID `json:"webhookConfigurationId"` WebhookSubscriptionID gid.GID `json:"webhookSubscriptionId"`
} }
type DeleteWebhookConfigurationPayload struct { type DeleteWebhookSubscriptionPayload struct {
DeletedWebhookConfigurationID gid.GID `json:"deletedWebhookConfigurationId"` DeletedWebhookSubscriptionID gid.GID `json:"deletedWebhookSubscriptionId"`
} }
type Document struct { type Document struct {
@@ -1517,7 +1517,7 @@ type Organization struct {
TrustCenterFiles *TrustCenterFileConnection `json:"trustCenterFiles"` TrustCenterFiles *TrustCenterFileConnection `json:"trustCenterFiles"`
TrustCenter *TrustCenter `json:"trustCenter,omitempty"` TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
CustomDomain *CustomDomain `json:"customDomain,omitempty"` CustomDomain *CustomDomain `json:"customDomain,omitempty"`
WebhookConfigurations *WebhookConfigurationConnection `json:"webhookConfigurations"` WebhookSubscriptions *WebhookSubscriptionConnection `json:"webhookSubscriptions"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
Permission bool `json:"permission"` Permission bool `json:"permission"`
@@ -2361,14 +2361,14 @@ type UpdateVendorServicePayload struct {
VendorService *VendorService `json:"vendorService"` VendorService *VendorService `json:"vendorService"`
} }
type UpdateWebhookConfigurationInput struct { type UpdateWebhookSubscriptionInput struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
EndpointURL *string `json:"endpointUrl,omitempty"` EndpointURL *string `json:"endpointUrl,omitempty"`
SelectedEvents []coredata.WebhookEventType `json:"selectedEvents,omitempty"` SelectedEvents []coredata.WebhookEventType `json:"selectedEvents,omitempty"`
} }
type UpdateWebhookConfigurationPayload struct { type UpdateWebhookSubscriptionPayload struct {
WebhookConfiguration *WebhookConfiguration `json:"webhookConfiguration"` WebhookSubscription *WebhookSubscription `json:"webhookSubscription"`
} }
type UploadAuditReportInput struct { type UploadAuditReportInput struct {
@@ -2623,7 +2623,7 @@ type Viewer struct {
SignableDocument *SignableDocument `json:"signableDocument,omitempty"` SignableDocument *SignableDocument `json:"signableDocument,omitempty"`
} }
type WebhookConfiguration struct { type WebhookSubscription struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Organization *Organization `json:"organization,omitempty"` Organization *Organization `json:"organization,omitempty"`
EndpointURL string `json:"endpointUrl"` EndpointURL string `json:"endpointUrl"`
@@ -2635,17 +2635,17 @@ type WebhookConfiguration struct {
Permission bool `json:"permission"` Permission bool `json:"permission"`
} }
func (WebhookConfiguration) IsNode() {} func (WebhookSubscription) IsNode() {}
func (this WebhookConfiguration) GetID() gid.GID { return this.ID } func (this WebhookSubscription) GetID() gid.GID { return this.ID }
type WebhookConfigurationEdge struct { type WebhookSubscriptionEdge struct {
Cursor page.CursorKey `json:"cursor"` Cursor page.CursorKey `json:"cursor"`
Node *WebhookConfiguration `json:"node"` Node *WebhookSubscription `json:"node"`
} }
type WebhookEvent struct { type WebhookEvent struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
WebhookConfigurationID gid.GID `json:"webhookConfigurationId"` WebhookSubscriptionID gid.GID `json:"webhookSubscriptionId"`
Status coredata.WebhookEventStatus `json:"status"` Status coredata.WebhookEventStatus `json:"status"`
Response *string `json:"response,omitempty"` Response *string `json:"response,omitempty"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`

View File

@@ -69,7 +69,7 @@ func NewWebhookEvent(we *coredata.WebhookEvent) *WebhookEvent {
return &WebhookEvent{ return &WebhookEvent{
ID: we.ID, ID: we.ID,
WebhookConfigurationID: we.WebhookConfigurationID, WebhookSubscriptionID: we.WebhookSubscriptionID,
Status: we.Status, Status: we.Status,
Response: response, Response: response,
CreatedAt: we.CreatedAt, CreatedAt: we.CreatedAt,

View File

@@ -21,11 +21,11 @@ import (
) )
type ( type (
WebhookConfigurationOrderBy OrderBy[coredata.WebhookConfigurationOrderField] WebhookSubscriptionOrderBy OrderBy[coredata.WebhookSubscriptionOrderField]
WebhookConfigurationConnection struct { WebhookSubscriptionConnection struct {
TotalCount int TotalCount int
Edges []*WebhookConfigurationEdge Edges []*WebhookSubscriptionEdge
PageInfo PageInfo PageInfo PageInfo
Resolver any Resolver any
@@ -33,18 +33,18 @@ type (
} }
) )
func NewWebhookConfigurationConnection( func NewWebhookSubscriptionConnection(
p *page.Page[*coredata.WebhookConfiguration, coredata.WebhookConfigurationOrderField], p *page.Page[*coredata.WebhookSubscription, coredata.WebhookSubscriptionOrderField],
parentType any, parentType any,
parentID gid.GID, parentID gid.GID,
) *WebhookConfigurationConnection { ) *WebhookSubscriptionConnection {
var edges = make([]*WebhookConfigurationEdge, len(p.Data)) var edges = make([]*WebhookSubscriptionEdge, len(p.Data))
for i := range edges { for i := range edges {
edges[i] = NewWebhookConfigurationEdge(p.Data[i], p.Cursor.OrderBy.Field) edges[i] = NewWebhookSubscriptionEdge(p.Data[i], p.Cursor.OrderBy.Field)
} }
return &WebhookConfigurationConnection{ return &WebhookSubscriptionConnection{
Edges: edges, Edges: edges,
PageInfo: *NewPageInfo(p), PageInfo: *NewPageInfo(p),
@@ -53,15 +53,15 @@ func NewWebhookConfigurationConnection(
} }
} }
func NewWebhookConfigurationEdge(wc *coredata.WebhookConfiguration, orderBy coredata.WebhookConfigurationOrderField) *WebhookConfigurationEdge { func NewWebhookSubscriptionEdge(wc *coredata.WebhookSubscription, orderBy coredata.WebhookSubscriptionOrderField) *WebhookSubscriptionEdge {
return &WebhookConfigurationEdge{ return &WebhookSubscriptionEdge{
Cursor: wc.CursorKey(orderBy), Cursor: wc.CursorKey(orderBy),
Node: NewWebhookConfiguration(wc), Node: NewWebhookSubscription(wc),
} }
} }
func NewWebhookConfiguration(wc *coredata.WebhookConfiguration) *WebhookConfiguration { func NewWebhookSubscription(wc *coredata.WebhookSubscription) *WebhookSubscription {
return &WebhookConfiguration{ return &WebhookSubscription{
ID: wc.ID, ID: wc.ID,
Organization: &Organization{ Organization: &Organization{
ID: wc.OrganizationID, ID: wc.OrganizationID,

View File

@@ -3678,74 +3678,74 @@ func (r *mutationResolver) DeleteMeeting(ctx context.Context, input types.Delete
}, nil }, nil
} }
// CreateWebhookConfiguration is the resolver for the createWebhookConfiguration field. // CreateWebhookSubscription is the resolver for the createWebhookSubscription field.
func (r *mutationResolver) CreateWebhookConfiguration(ctx context.Context, input types.CreateWebhookConfigurationInput) (*types.CreateWebhookConfigurationPayload, error) { func (r *mutationResolver) CreateWebhookSubscription(ctx context.Context, input types.CreateWebhookSubscriptionInput) (*types.CreateWebhookSubscriptionPayload, error) {
if err := r.authorize(ctx, input.OrganizationID, probo.ActionWebhookConfigurationCreate); err != nil { if err := r.authorize(ctx, input.OrganizationID, probo.ActionWebhookSubscriptionCreate); err != nil {
return nil, err return nil, err
} }
prb := r.ProboService(ctx, input.OrganizationID.TenantID()) prb := r.ProboService(ctx, input.OrganizationID.TenantID())
wc, err := prb.WebhookConfigurations.Create( wc, err := prb.WebhookSubscriptions.Create(
ctx, ctx,
probo.CreateWebhookConfigurationRequest{ probo.CreateWebhookSubscriptionRequest{
OrganizationID: input.OrganizationID, OrganizationID: input.OrganizationID,
EndpointURL: input.EndpointURL, EndpointURL: input.EndpointURL,
SelectedEvents: input.SelectedEvents, SelectedEvents: input.SelectedEvents,
}, },
) )
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot create webhook configuration", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot create webhook subscription", log.Error(err))
return nil, gqlutils.Internal(ctx) return nil, gqlutils.Internal(ctx)
} }
return &types.CreateWebhookConfigurationPayload{ return &types.CreateWebhookSubscriptionPayload{
WebhookConfigurationEdge: types.NewWebhookConfigurationEdge(wc, coredata.WebhookConfigurationOrderFieldCreatedAt), WebhookSubscriptionEdge: types.NewWebhookSubscriptionEdge(wc, coredata.WebhookSubscriptionOrderFieldCreatedAt),
}, nil }, nil
} }
// UpdateWebhookConfiguration is the resolver for the updateWebhookConfiguration field. // UpdateWebhookSubscription is the resolver for the updateWebhookSubscription field.
func (r *mutationResolver) UpdateWebhookConfiguration(ctx context.Context, input types.UpdateWebhookConfigurationInput) (*types.UpdateWebhookConfigurationPayload, error) { func (r *mutationResolver) UpdateWebhookSubscription(ctx context.Context, input types.UpdateWebhookSubscriptionInput) (*types.UpdateWebhookSubscriptionPayload, error) {
if err := r.authorize(ctx, input.ID, probo.ActionWebhookConfigurationUpdate); err != nil { if err := r.authorize(ctx, input.ID, probo.ActionWebhookSubscriptionUpdate); err != nil {
return nil, err return nil, err
} }
prb := r.ProboService(ctx, input.ID.TenantID()) prb := r.ProboService(ctx, input.ID.TenantID())
wc, err := prb.WebhookConfigurations.Update( wc, err := prb.WebhookSubscriptions.Update(
ctx, ctx,
probo.UpdateWebhookConfigurationRequest{ probo.UpdateWebhookSubscriptionRequest{
WebhookConfigurationID: input.ID, WebhookSubscriptionID: input.ID,
EndpointURL: input.EndpointURL, EndpointURL: input.EndpointURL,
SelectedEvents: input.SelectedEvents, SelectedEvents: input.SelectedEvents,
}, },
) )
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot update webhook configuration", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot update webhook subscription", log.Error(err))
return nil, gqlutils.Internal(ctx) return nil, gqlutils.Internal(ctx)
} }
return &types.UpdateWebhookConfigurationPayload{ return &types.UpdateWebhookSubscriptionPayload{
WebhookConfiguration: types.NewWebhookConfiguration(wc), WebhookSubscription: types.NewWebhookSubscription(wc),
}, nil }, nil
} }
// DeleteWebhookConfiguration is the resolver for the deleteWebhookConfiguration field. // DeleteWebhookSubscription is the resolver for the deleteWebhookSubscription field.
func (r *mutationResolver) DeleteWebhookConfiguration(ctx context.Context, input types.DeleteWebhookConfigurationInput) (*types.DeleteWebhookConfigurationPayload, error) { func (r *mutationResolver) DeleteWebhookSubscription(ctx context.Context, input types.DeleteWebhookSubscriptionInput) (*types.DeleteWebhookSubscriptionPayload, error) {
if err := r.authorize(ctx, input.WebhookConfigurationID, probo.ActionWebhookConfigurationDelete); err != nil { if err := r.authorize(ctx, input.WebhookSubscriptionID, probo.ActionWebhookSubscriptionDelete); err != nil {
return nil, err return nil, err
} }
prb := r.ProboService(ctx, input.WebhookConfigurationID.TenantID()) prb := r.ProboService(ctx, input.WebhookSubscriptionID.TenantID())
err := prb.WebhookConfigurations.Delete(ctx, input.WebhookConfigurationID) err := prb.WebhookSubscriptions.Delete(ctx, input.WebhookSubscriptionID)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot delete webhook configuration", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot delete webhook subscription", log.Error(err))
return nil, gqlutils.Internal(ctx) return nil, gqlutils.Internal(ctx)
} }
return &types.DeleteWebhookConfigurationPayload{ return &types.DeleteWebhookSubscriptionPayload{
DeletedWebhookConfigurationID: input.WebhookConfigurationID, DeletedWebhookSubscriptionID: input.WebhookSubscriptionID,
}, nil }, nil
} }
@@ -6384,20 +6384,20 @@ func (r *organizationResolver) CustomDomain(ctx context.Context, obj *types.Orga
return types.NewCustomDomain(domain, r.customDomainCname), nil return types.NewCustomDomain(domain, r.customDomainCname), nil
} }
// WebhookConfigurations is the resolver for the webhookConfigurations field. // WebhookSubscriptions is the resolver for the webhookSubscriptions field.
func (r *organizationResolver) WebhookConfigurations(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookConfigurationOrderBy) (*types.WebhookConfigurationConnection, error) { func (r *organizationResolver) WebhookSubscriptions(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookSubscriptionOrderBy) (*types.WebhookSubscriptionConnection, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationList); err != nil { if err := r.authorize(ctx, obj.ID, probo.ActionWebhookSubscriptionList); err != nil {
return nil, err return nil, err
} }
prb := r.ProboService(ctx, obj.ID.TenantID()) prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.WebhookConfigurationOrderField]{ pageOrderBy := page.OrderBy[coredata.WebhookSubscriptionOrderField]{
Field: coredata.WebhookConfigurationOrderFieldCreatedAt, Field: coredata.WebhookSubscriptionOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc, Direction: page.OrderDirectionDesc,
} }
if orderBy != nil { if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.WebhookConfigurationOrderField]{ pageOrderBy = page.OrderBy[coredata.WebhookSubscriptionOrderField]{
Field: orderBy.Field, Field: orderBy.Field,
Direction: orderBy.Direction, Direction: orderBy.Direction,
} }
@@ -6405,13 +6405,13 @@ func (r *organizationResolver) WebhookConfigurations(ctx context.Context, obj *t
cursor := types.NewCursor(first, after, last, before, pageOrderBy) cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.WebhookConfigurations.ListForOrganizationID(ctx, obj.ID, cursor) page, err := prb.WebhookSubscriptions.ListForOrganizationID(ctx, obj.ID, cursor)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot list organization webhook configurations", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot list organization webhook subscriptions", log.Error(err))
return nil, gqlutils.Internal(ctx) return nil, gqlutils.Internal(ctx)
} }
return types.NewWebhookConfigurationConnection(page, r, obj.ID), nil return types.NewWebhookSubscriptionConnection(page, r, obj.ID), nil
} }
// Permission is the resolver for the permission field. // Permission is the resolver for the permission field.
@@ -6862,14 +6862,14 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
} }
return types.NewStateOfApplicability(stateOfApplicability), nil return types.NewStateOfApplicability(stateOfApplicability), nil
} }
case coredata.WebhookConfigurationEntityType: case coredata.WebhookSubscriptionEntityType:
action = probo.ActionWebhookConfigurationGet action = probo.ActionWebhookSubscriptionGet
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
wc, err := prb.WebhookConfigurations.Get(ctx, id) wc, err := prb.WebhookSubscriptions.Get(ctx, id)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return types.NewWebhookConfiguration(wc), nil return types.NewWebhookSubscription(wc), nil
} }
default: default:
} }
@@ -8560,7 +8560,7 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
} }
// Organization is the resolver for the organization field. // Organization is the resolver for the organization field.
func (r *webhookConfigurationResolver) Organization(ctx context.Context, obj *types.WebhookConfiguration) (*types.Organization, error) { func (r *webhookSubscriptionResolver) Organization(ctx context.Context, obj *types.WebhookSubscription) (*types.Organization, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet); err != nil { if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet); err != nil {
return nil, err return nil, err
} }
@@ -8581,14 +8581,14 @@ func (r *webhookConfigurationResolver) Organization(ctx context.Context, obj *ty
} }
// SigningSecret is the resolver for the signingSecret field. // SigningSecret is the resolver for the signingSecret field.
func (r *webhookConfigurationResolver) SigningSecret(ctx context.Context, obj *types.WebhookConfiguration) (string, error) { func (r *webhookSubscriptionResolver) SigningSecret(ctx context.Context, obj *types.WebhookSubscription) (string, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationUpdate); err != nil { if err := r.authorize(ctx, obj.ID, probo.ActionWebhookSubscriptionUpdate); err != nil {
return "", err return "", err
} }
prb := r.ProboService(ctx, obj.ID.TenantID()) prb := r.ProboService(ctx, obj.ID.TenantID())
signingSecret, err := prb.WebhookConfigurations.GetSigningSecret(ctx, obj.ID) signingSecret, err := prb.WebhookSubscriptions.GetSigningSecret(ctx, obj.ID)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot get signing secret", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot get signing secret", log.Error(err))
return "", gqlutils.Internal(ctx) return "", gqlutils.Internal(ctx)
@@ -8598,8 +8598,8 @@ func (r *webhookConfigurationResolver) SigningSecret(ctx context.Context, obj *t
} }
// Events is the resolver for the events field. // Events is the resolver for the events field.
func (r *webhookConfigurationResolver) Events(ctx context.Context, obj *types.WebhookConfiguration, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookEventOrderBy) (*types.WebhookEventConnection, error) { func (r *webhookSubscriptionResolver) Events(ctx context.Context, obj *types.WebhookSubscription, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.WebhookEventOrderBy) (*types.WebhookEventConnection, error) {
if err := r.authorize(ctx, obj.ID, probo.ActionWebhookConfigurationGet); err != nil { if err := r.authorize(ctx, obj.ID, probo.ActionWebhookSubscriptionGet); err != nil {
return nil, err return nil, err
} }
@@ -8618,7 +8618,7 @@ func (r *webhookConfigurationResolver) Events(ctx context.Context, obj *types.We
cursor := types.NewCursor(first, after, last, before, pageOrderBy) cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.WebhookConfigurations.ListEventsForConfigurationID(ctx, obj.ID, cursor) page, err := prb.WebhookSubscriptions.ListEventsForSubscriptionID(ctx, obj.ID, cursor)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot list webhook events", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot list webhook events", log.Error(err))
return nil, gqlutils.Internal(ctx) return nil, gqlutils.Internal(ctx)
@@ -8628,13 +8628,13 @@ func (r *webhookConfigurationResolver) Events(ctx context.Context, obj *types.We
} }
// Permission is the resolver for the permission field. // Permission is the resolver for the permission field.
func (r *webhookConfigurationResolver) Permission(ctx context.Context, obj *types.WebhookConfiguration, action string) (bool, error) { func (r *webhookSubscriptionResolver) Permission(ctx context.Context, obj *types.WebhookSubscription, action string) (bool, error) {
return r.Resolver.Permission(ctx, obj, action) return r.Resolver.Permission(ctx, obj, action)
} }
// TotalCount is the resolver for the totalCount field. // TotalCount is the resolver for the totalCount field.
func (r *webhookConfigurationConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookConfigurationConnection) (int, error) { func (r *webhookSubscriptionConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookSubscriptionConnection) (int, error) {
if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookConfigurationList); err != nil { if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookSubscriptionList); err != nil {
return 0, err return 0, err
} }
@@ -8642,27 +8642,27 @@ func (r *webhookConfigurationConnectionResolver) TotalCount(ctx context.Context,
switch obj.Resolver.(type) { switch obj.Resolver.(type) {
case *organizationResolver: case *organizationResolver:
count, err := prb.WebhookConfigurations.CountForOrganizationID(ctx, obj.ParentID) count, err := prb.WebhookSubscriptions.CountForOrganizationID(ctx, obj.ParentID)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot count webhook configurations", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot count webhook subscriptions", log.Error(err))
return 0, gqlutils.Internal(ctx) return 0, gqlutils.Internal(ctx)
} }
return count, nil return count, nil
} }
r.logger.ErrorCtx(ctx, "unsupported resolver for webhook configuration connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver))) r.logger.ErrorCtx(ctx, "unsupported resolver for webhook subscription connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
return 0, gqlutils.Internal(ctx) return 0, gqlutils.Internal(ctx)
} }
// TotalCount is the resolver for the totalCount field. // TotalCount is the resolver for the totalCount field.
func (r *webhookEventConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookEventConnection) (int, error) { func (r *webhookEventConnectionResolver) TotalCount(ctx context.Context, obj *types.WebhookEventConnection) (int, error) {
if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookConfigurationGet); err != nil { if err := r.authorize(ctx, obj.ParentID, probo.ActionWebhookSubscriptionGet); err != nil {
return 0, err return 0, err
} }
prb := r.ProboService(ctx, obj.ParentID.TenantID()) prb := r.ProboService(ctx, obj.ParentID.TenantID())
count, err := prb.WebhookConfigurations.CountEventsForConfigurationID(ctx, obj.ParentID) count, err := prb.WebhookSubscriptions.CountEventsForSubscriptionID(ctx, obj.ParentID)
if err != nil { if err != nil {
r.logger.ErrorCtx(ctx, "cannot count webhook events", log.Error(err)) r.logger.ErrorCtx(ctx, "cannot count webhook events", log.Error(err))
return 0, gqlutils.Internal(ctx) return 0, gqlutils.Internal(ctx)
@@ -8973,14 +8973,14 @@ func (r *Resolver) VendorService() schema.VendorServiceResolver { return &vendor
// Viewer returns schema.ViewerResolver implementation. // Viewer returns schema.ViewerResolver implementation.
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} } func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
// WebhookConfiguration returns schema.WebhookConfigurationResolver implementation. // WebhookSubscription returns schema.WebhookSubscriptionResolver implementation.
func (r *Resolver) WebhookConfiguration() schema.WebhookConfigurationResolver { func (r *Resolver) WebhookSubscription() schema.WebhookSubscriptionResolver {
return &webhookConfigurationResolver{r} return &webhookSubscriptionResolver{r}
} }
// WebhookConfigurationConnection returns schema.WebhookConfigurationConnectionResolver implementation. // WebhookSubscriptionConnection returns schema.WebhookSubscriptionConnectionResolver implementation.
func (r *Resolver) WebhookConfigurationConnection() schema.WebhookConfigurationConnectionResolver { func (r *Resolver) WebhookSubscriptionConnection() schema.WebhookSubscriptionConnectionResolver {
return &webhookConfigurationConnectionResolver{r} return &webhookSubscriptionConnectionResolver{r}
} }
// WebhookEventConnection returns schema.WebhookEventConnectionResolver implementation. // WebhookEventConnection returns schema.WebhookEventConnectionResolver implementation.
@@ -9060,6 +9060,6 @@ type vendorDataPrivacyAgreementResolver struct{ *Resolver }
type vendorRiskAssessmentResolver struct{ *Resolver } type vendorRiskAssessmentResolver struct{ *Resolver }
type vendorServiceResolver struct{ *Resolver } type vendorServiceResolver struct{ *Resolver }
type viewerResolver struct{ *Resolver } type viewerResolver struct{ *Resolver }
type webhookConfigurationResolver struct{ *Resolver } type webhookSubscriptionResolver struct{ *Resolver }
type webhookConfigurationConnectionResolver struct{ *Resolver } type webhookSubscriptionConnectionResolver struct{ *Resolver }
type webhookEventConnectionResolver struct{ *Resolver } type webhookEventConnectionResolver struct{ *Resolver }

View File

@@ -33,10 +33,10 @@ func InsertEvent(
eventType coredata.WebhookEventType, eventType coredata.WebhookEventType,
data any, data any,
) error { ) error {
var configs coredata.WebhookConfigurations var configs coredata.WebhookSubscriptions
exists, err := configs.ExistsByOrganizationIDAndEventType(ctx, conn, scope, organizationID, eventType) exists, err := configs.ExistsByOrganizationIDAndEventType(ctx, conn, scope, organizationID, eventType)
if err != nil { if err != nil {
return fmt.Errorf("cannot check webhook configurations: %w", err) return fmt.Errorf("cannot check webhook subscriptions: %w", err)
} }
if !exists { if !exists {

View File

@@ -64,7 +64,7 @@ type (
pendingDelivery struct { pendingDelivery struct {
Event *coredata.WebhookEvent Event *coredata.WebhookEvent
Config *coredata.WebhookConfiguration Config *coredata.WebhookSubscription
} }
) )
@@ -138,22 +138,22 @@ func (s *Sender) claimNextWebhookData(ctx context.Context) (*coredata.WebhookDat
scope := coredata.NewScopeFromObjectID(webhookData.ID) scope := coredata.NewScopeFromObjectID(webhookData.ID)
var configs coredata.WebhookConfigurations var configs coredata.WebhookSubscriptions
if err := configs.LoadMatchingByOrganizationIDAndEventType( if err := configs.LoadMatchingByOrganizationIDAndEventType(
ctx, tx, scope, webhookData.OrganizationID, webhookData.EventType, ctx, tx, scope, webhookData.OrganizationID, webhookData.EventType,
); err != nil { ); err != nil {
return fmt.Errorf("cannot load matching webhook configurations: %w", err) return fmt.Errorf("cannot load matching webhook subscriptions: %w", err)
} }
now := time.Now() now := time.Now()
for _, config := range configs { for _, config := range configs {
event := &coredata.WebhookEvent{ event := &coredata.WebhookEvent{
ID: gid.New(webhookData.ID.TenantID(), coredata.WebhookEventEntityType), ID: gid.New(webhookData.ID.TenantID(), coredata.WebhookEventEntityType),
WebhookDataID: webhookData.ID, WebhookDataID: webhookData.ID,
WebhookConfigurationID: config.ID, WebhookSubscriptionID: config.ID,
Status: coredata.WebhookEventStatusPending, Status: coredata.WebhookEventStatusPending,
CreatedAt: now, CreatedAt: now,
} }
if err := event.Insert(ctx, tx, scope); err != nil { if err := event.Insert(ctx, tx, scope); err != nil {
@@ -195,7 +195,7 @@ func (s *Sender) deliver(ctx context.Context, webhookData *coredata.WebhookData,
s.logger.ErrorCtx(ctx, "cannot get signing secret", s.logger.ErrorCtx(ctx, "cannot get signing secret",
log.Error(err), log.Error(err),
log.String("webhook_data_id", webhookData.ID.String()), log.String("webhook_data_id", webhookData.ID.String()),
log.String("configuration_id", d.Config.ID.String()), log.String("subscription_id", d.Config.ID.String()),
) )
s.updateEventStatus(ctx, d.Event, scope, coredata.WebhookEventStatusFailed, nil) s.updateEventStatus(ctx, d.Event, scope, coredata.WebhookEventStatusFailed, nil)
return return
@@ -238,8 +238,8 @@ func (s *Sender) updateEventStatus(
} }
} }
func (s *Sender) getSigningSecret(webhookConfigurationID string, encryptedSigningSecret []byte) (string, error) { func (s *Sender) getSigningSecret(webhookSubscriptionID string, encryptedSigningSecret []byte) (string, error) {
if cached, ok := s.cache.Load(webhookConfigurationID); ok { if cached, ok := s.cache.Load(webhookSubscriptionID); ok {
entry := cached.(*cachedSecret) entry := cached.(*cachedSecret)
if bytes.Equal(entry.encryptedSecret, encryptedSigningSecret) { if bytes.Equal(entry.encryptedSecret, encryptedSigningSecret) {
return entry.plaintext, nil return entry.plaintext, nil
@@ -252,7 +252,7 @@ func (s *Sender) getSigningSecret(webhookConfigurationID string, encryptedSignin
} }
signingSecret := string(plaintext) signingSecret := string(plaintext)
s.cache.Store(webhookConfigurationID, &cachedSecret{ s.cache.Store(webhookSubscriptionID, &cachedSecret{
encryptedSecret: encryptedSigningSecret, encryptedSecret: encryptedSigningSecret,
plaintext: signingSecret, plaintext: signingSecret,
}) })
@@ -265,16 +265,16 @@ func (s *Sender) doHTTPCall(
eventID gid.GID, eventID gid.GID,
endpointURL string, endpointURL string,
webhookData *coredata.WebhookData, webhookData *coredata.WebhookData,
configurationID gid.GID, subscriptionID gid.GID,
signingSecret string, signingSecret string,
) (json.RawMessage, error) { ) (json.RawMessage, error) {
payload := map[string]any{ payload := map[string]any{
"eventId": eventID.String(), "eventId": eventID.String(),
"configurationId": configurationID.String(), "subscriptionId": subscriptionID.String(),
"organizationId": webhookData.OrganizationID.String(), "organizationId": webhookData.OrganizationID.String(),
"eventType": webhookData.EventType.String(), "eventType": webhookData.EventType.String(),
"createdAt": webhookData.CreatedAt, "createdAt": webhookData.CreatedAt,
"data": webhookData.Data, "data": webhookData.Data,
} }
body, err := json.Marshal(payload) body, err := json.Marshal(payload)
if err != nil { if err != nil {