Skip to content

Commit bc77918

Browse files
Introduce webhook v2 (#17456)
Migrate webhook to v2 entity
1 parent 27e5b97 commit bc77918

File tree

83 files changed

+1574
-975
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1574
-975
lines changed

packages/twenty-front/src/generated-metadata/graphql.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ export enum AllMetadataName {
207207
viewField = 'viewField',
208208
viewFilter = 'viewFilter',
209209
viewFilterGroup = 'viewFilterGroup',
210-
viewGroup = 'viewGroup'
210+
viewGroup = 'viewGroup',
211+
webhook = 'webhook'
211212
}
212213

213214
export type Analytics = {
@@ -1148,6 +1149,7 @@ export type CreateViewSortInput = {
11481149

11491150
export type CreateWebhookInput = {
11501151
description?: InputMaybe<Scalars['String']>;
1152+
id?: InputMaybe<Scalars['UUID']>;
11511153
operations: Array<Scalars['String']>;
11521154
secret?: InputMaybe<Scalars['String']>;
11531155
targetUrl: Scalars['String'];
@@ -1287,10 +1289,6 @@ export type DeleteViewGroupInput = {
12871289
id: Scalars['UUID'];
12881290
};
12891291

1290-
export type DeleteWebhookInput = {
1291-
id: Scalars['UUID'];
1292-
};
1293-
12941292
export type DeleteWorkflowVersionStepInput = {
12951293
/** Step to delete ID */
12961294
stepId: Scalars['String'];
@@ -1691,10 +1689,6 @@ export type GetServerlessFunctionSourceCodeInput = {
16911689
version?: Scalars['String'];
16921690
};
16931691

1694-
export type GetWebhookInput = {
1695-
id: Scalars['UUID'];
1696-
};
1697-
16981692
/** Order by options for graph widgets */
16991693
export enum GraphOrderBy {
17001694
FIELD_ASC = 'FIELD_ASC',
@@ -2075,7 +2069,7 @@ export type Mutation = {
20752069
deleteTwoFactorAuthenticationMethod: DeleteTwoFactorAuthenticationMethodOutput;
20762070
deleteUser: User;
20772071
deleteUserFromWorkspace: UserWorkspace;
2078-
deleteWebhook: Scalars['Boolean'];
2072+
deleteWebhook: Webhook;
20792073
deleteWorkflowVersionEdge: WorkflowVersionStepChanges;
20802074
deleteWorkflowVersionStep: WorkflowVersionStepChanges;
20812075
deleteWorkspaceInvitation: Scalars['String'];
@@ -2165,7 +2159,7 @@ export type Mutation = {
21652159
updatePasswordViaResetToken: InvalidatePasswordOutput;
21662160
updateSkill: Skill;
21672161
updateUserEmail: Scalars['Boolean'];
2168-
updateWebhook?: Maybe<Webhook>;
2162+
updateWebhook: Webhook;
21692163
updateWorkflowRunStep: WorkflowAction;
21702164
updateWorkflowVersionPositions: Scalars['Boolean'];
21712165
updateWorkflowVersionStep: WorkflowAction;
@@ -2592,7 +2586,7 @@ export type MutationDeleteUserFromWorkspaceArgs = {
25922586

25932587

25942588
export type MutationDeleteWebhookArgs = {
2595-
input: DeleteWebhookInput;
2589+
id: Scalars['UUID'];
25962590
};
25972591

25982592

@@ -4017,7 +4011,7 @@ export type QueryValidatePasswordResetTokenArgs = {
40174011

40184012

40194013
export type QueryWebhookArgs = {
4020-
input: GetWebhookInput;
4014+
id: Scalars['UUID'];
40214015
};
40224016

40234017
export type QueueJob = {
@@ -5001,8 +4995,14 @@ export type UpdateViewSortInput = {
50014995
};
50024996

50034997
export type UpdateWebhookInput = {
5004-
description?: InputMaybe<Scalars['String']>;
4998+
/** The id of the webhook to update */
50054999
id: Scalars['UUID'];
5000+
/** The webhook fields to update */
5001+
update: UpdateWebhookInputUpdates;
5002+
};
5003+
5004+
export type UpdateWebhookInputUpdates = {
5005+
description?: InputMaybe<Scalars['String']>;
50065006
operations?: InputMaybe<Array<Scalars['String']>>;
50075007
secret?: InputMaybe<Scalars['String']>;
50085008
targetUrl?: InputMaybe<Scalars['String']>;
@@ -5246,6 +5246,7 @@ export enum ViewVisibility {
52465246

52475247
export type Webhook = {
52485248
__typename?: 'Webhook';
5249+
applicationId: Scalars['UUID'];
52495250
createdAt: Scalars['DateTime'];
52505251
deletedAt?: Maybe<Scalars['DateTime']>;
52515252
description?: Maybe<Scalars['String']>;
@@ -6345,11 +6346,11 @@ export type CreateWebhookMutationVariables = Exact<{
63456346
export type CreateWebhookMutation = { __typename?: 'Mutation', createWebhook: { __typename?: 'Webhook', id: string, targetUrl: string, operations: Array<string>, description?: string | null, secret: string } };
63466347

63476348
export type DeleteWebhookMutationVariables = Exact<{
6348-
input: DeleteWebhookInput;
6349+
id: Scalars['UUID'];
63496350
}>;
63506351

63516352

6352-
export type DeleteWebhookMutation = { __typename?: 'Mutation', deleteWebhook: boolean };
6353+
export type DeleteWebhookMutation = { __typename?: 'Mutation', deleteWebhook: { __typename?: 'Webhook', id: string, targetUrl: string, operations: Array<string>, description?: string | null, secret: string } };
63536354

63546355
export type RevokeApiKeyMutationVariables = Exact<{
63556356
input: RevokeApiKeyInput;
@@ -6370,7 +6371,7 @@ export type UpdateWebhookMutationVariables = Exact<{
63706371
}>;
63716372

63726373

6373-
export type UpdateWebhookMutation = { __typename?: 'Mutation', updateWebhook?: { __typename?: 'Webhook', id: string, targetUrl: string, operations: Array<string>, description?: string | null, secret: string } | null };
6374+
export type UpdateWebhookMutation = { __typename?: 'Mutation', updateWebhook: { __typename?: 'Webhook', id: string, targetUrl: string, operations: Array<string>, description?: string | null, secret: string } };
63746375

63756376
export type GetApiKeyQueryVariables = Exact<{
63766377
input: GetApiKeyInput;
@@ -6385,7 +6386,7 @@ export type GetApiKeysQueryVariables = Exact<{ [key: string]: never; }>;
63856386
export type GetApiKeysQuery = { __typename?: 'Query', apiKeys: Array<{ __typename?: 'ApiKey', id: string, name: string, expiresAt: string, revokedAt?: string | null, role: { __typename?: 'Role', id: string, label: string, icon?: string | null } }> };
63866387

63876388
export type GetWebhookQueryVariables = Exact<{
6388-
input: GetWebhookInput;
6389+
id: Scalars['UUID'];
63896390
}>;
63906391

63916392

@@ -11989,10 +11990,12 @@ export type CreateWebhookMutationHookResult = ReturnType<typeof useCreateWebhook
1198911990
export type CreateWebhookMutationResult = Apollo.MutationResult<CreateWebhookMutation>;
1199011991
export type CreateWebhookMutationOptions = Apollo.BaseMutationOptions<CreateWebhookMutation, CreateWebhookMutationVariables>;
1199111992
export const DeleteWebhookDocument = gql`
11992-
mutation DeleteWebhook($input: DeleteWebhookInput!) {
11993-
deleteWebhook(input: $input)
11993+
mutation DeleteWebhook($id: UUID!) {
11994+
deleteWebhook(id: $id) {
11995+
...WebhookFragment
11996+
}
1199411997
}
11995-
`;
11998+
${WebhookFragmentFragmentDoc}`;
1199611999
export type DeleteWebhookMutationFn = Apollo.MutationFunction<DeleteWebhookMutation, DeleteWebhookMutationVariables>;
1199712000

1199812001
/**
@@ -12008,7 +12011,7 @@ export type DeleteWebhookMutationFn = Apollo.MutationFunction<DeleteWebhookMutat
1200812011
* @example
1200912012
* const [deleteWebhookMutation, { data, loading, error }] = useDeleteWebhookMutation({
1201012013
* variables: {
12011-
* input: // value for 'input'
12014+
* id: // value for 'id'
1201212015
* },
1201312016
* });
1201412017
*/
@@ -12189,8 +12192,8 @@ export type GetApiKeysQueryHookResult = ReturnType<typeof useGetApiKeysQuery>;
1218912192
export type GetApiKeysLazyQueryHookResult = ReturnType<typeof useGetApiKeysLazyQuery>;
1219012193
export type GetApiKeysQueryResult = Apollo.QueryResult<GetApiKeysQuery, GetApiKeysQueryVariables>;
1219112194
export const GetWebhookDocument = gql`
12192-
query GetWebhook($input: GetWebhookInput!) {
12193-
webhook(input: $input) {
12195+
query GetWebhook($id: UUID!) {
12196+
webhook(id: $id) {
1219412197
...WebhookFragment
1219512198
}
1219612199
}
@@ -12208,7 +12211,7 @@ export const GetWebhookDocument = gql`
1220812211
* @example
1220912212
* const { data, loading, error } = useGetWebhookQuery({
1221012213
* variables: {
12211-
* input: // value for 'input'
12214+
* id: // value for 'id'
1221212215
* },
1221312216
* });
1221412217
*/

packages/twenty-front/src/generated/graphql.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ export enum AllMetadataName {
207207
viewField = 'viewField',
208208
viewFilter = 'viewFilter',
209209
viewFilterGroup = 'viewFilterGroup',
210-
viewGroup = 'viewGroup'
210+
viewGroup = 'viewGroup',
211+
webhook = 'webhook'
211212
}
212213

213214
export type Analytics = {
@@ -1115,6 +1116,7 @@ export type CreateViewSortInput = {
11151116

11161117
export type CreateWebhookInput = {
11171118
description?: InputMaybe<Scalars['String']>;
1119+
id?: InputMaybe<Scalars['UUID']>;
11181120
operations: Array<Scalars['String']>;
11191121
secret?: InputMaybe<Scalars['String']>;
11201122
targetUrl: Scalars['String'];
@@ -1254,10 +1256,6 @@ export type DeleteViewGroupInput = {
12541256
id: Scalars['UUID'];
12551257
};
12561258

1257-
export type DeleteWebhookInput = {
1258-
id: Scalars['UUID'];
1259-
};
1260-
12611259
export type DeleteWorkflowVersionStepInput = {
12621260
/** Step to delete ID */
12631261
stepId: Scalars['String'];
@@ -1658,10 +1656,6 @@ export type GetServerlessFunctionSourceCodeInput = {
16581656
version?: Scalars['String'];
16591657
};
16601658

1661-
export type GetWebhookInput = {
1662-
id: Scalars['UUID'];
1663-
};
1664-
16651659
/** Order by options for graph widgets */
16661660
export enum GraphOrderBy {
16671661
FIELD_ASC = 'FIELD_ASC',
@@ -2033,7 +2027,7 @@ export type Mutation = {
20332027
deleteTwoFactorAuthenticationMethod: DeleteTwoFactorAuthenticationMethodOutput;
20342028
deleteUser: User;
20352029
deleteUserFromWorkspace: UserWorkspace;
2036-
deleteWebhook: Scalars['Boolean'];
2030+
deleteWebhook: Webhook;
20372031
deleteWorkflowVersionEdge: WorkflowVersionStepChanges;
20382032
deleteWorkflowVersionStep: WorkflowVersionStepChanges;
20392033
deleteWorkspaceInvitation: Scalars['String'];
@@ -2118,7 +2112,7 @@ export type Mutation = {
21182112
updatePageLayoutWithTabsAndWidgets: PageLayout;
21192113
updatePasswordViaResetToken: InvalidatePasswordOutput;
21202114
updateUserEmail: Scalars['Boolean'];
2121-
updateWebhook?: Maybe<Webhook>;
2115+
updateWebhook: Webhook;
21222116
updateWorkflowRunStep: WorkflowAction;
21232117
updateWorkflowVersionPositions: Scalars['Boolean'];
21242118
updateWorkflowVersionStep: WorkflowAction;
@@ -2500,7 +2494,7 @@ export type MutationDeleteUserFromWorkspaceArgs = {
25002494

25012495

25022496
export type MutationDeleteWebhookArgs = {
2503-
input: DeleteWebhookInput;
2497+
id: Scalars['UUID'];
25042498
};
25052499

25062500

@@ -3820,7 +3814,7 @@ export type QueryValidatePasswordResetTokenArgs = {
38203814

38213815

38223816
export type QueryWebhookArgs = {
3823-
input: GetWebhookInput;
3817+
id: Scalars['UUID'];
38243818
};
38253819

38263820
export type QueueJob = {
@@ -4770,8 +4764,14 @@ export type UpdateViewSortInput = {
47704764
};
47714765

47724766
export type UpdateWebhookInput = {
4773-
description?: InputMaybe<Scalars['String']>;
4767+
/** The id of the webhook to update */
47744768
id: Scalars['UUID'];
4769+
/** The webhook fields to update */
4770+
update: UpdateWebhookInputUpdates;
4771+
};
4772+
4773+
export type UpdateWebhookInputUpdates = {
4774+
description?: InputMaybe<Scalars['String']>;
47754775
operations?: InputMaybe<Array<Scalars['String']>>;
47764776
secret?: InputMaybe<Scalars['String']>;
47774777
targetUrl?: InputMaybe<Scalars['String']>;
@@ -5015,6 +5015,7 @@ export enum ViewVisibility {
50155015

50165016
export type Webhook = {
50175017
__typename?: 'Webhook';
5018+
applicationId: Scalars['UUID'];
50185019
createdAt: Scalars['DateTime'];
50195020
deletedAt?: Maybe<Scalars['DateTime']>;
50205021
description?: Maybe<Scalars['String']>;

packages/twenty-front/src/modules/metadata-error-handler/hooks/useMetadataErrorHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const useMetadataErrorHandler = () => {
4545
commandMenuItem: t`command menu item`,
4646
frontComponent: t`front component`,
4747
navigationMenuItem: t`navigation menu item`,
48+
webhook: t`webhook`,
4849
} as const satisfies Record<AllMetadataName, string>;
4950

5051
const handleMetadataError = (
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import gql from 'graphql-tag';
2+
import { WEBHOOK_FRAGMENT } from '@/settings/developers/graphql/fragments/webhookFragment';
23

34
export const DELETE_WEBHOOK = gql`
4-
mutation DeleteWebhook($input: DeleteWebhookInput!) {
5-
deleteWebhook(input: $input)
5+
mutation DeleteWebhook($id: UUID!) {
6+
deleteWebhook(id: $id) {
7+
...WebhookFragment
8+
}
69
}
10+
${WEBHOOK_FRAGMENT}
711
`;

packages/twenty-front/src/modules/settings/developers/graphql/queries/getWebhook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import gql from 'graphql-tag';
22
import { WEBHOOK_FRAGMENT } from '@/settings/developers/graphql/fragments/webhookFragment';
33

44
export const GET_WEBHOOK = gql`
5-
query GetWebhook($input: GetWebhookInput!) {
6-
webhook(input: $input) {
5+
query GetWebhook($id: UUID!) {
6+
webhook(id: $id) {
77
...WebhookFragment
88
}
99
}

packages/twenty-front/src/modules/settings/developers/hooks/__tests__/useWebhookForm.test.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ const createSuccessfulUpdateMock = (webhookId: string, webhookData = {}) => ({
6161
variables: {
6262
input: {
6363
id: webhookId,
64-
targetUrl: 'https://updated.com/webhook',
65-
operations: ['person.updated'],
66-
description: 'Updated webhook',
67-
secret: 'updated-secret',
68-
...webhookData,
64+
update: {
65+
targetUrl: 'https://updated.com/webhook',
66+
operations: ['person.updated'],
67+
description: 'Updated webhook',
68+
secret: 'updated-secret',
69+
...webhookData,
70+
},
6971
},
7072
},
7173
},
@@ -87,16 +89,12 @@ const createSuccessfulDeleteMock = (webhookId: string) => ({
8789
request: {
8890
query: DELETE_WEBHOOK,
8991
variables: {
90-
input: {
91-
id: webhookId,
92-
},
92+
id: webhookId,
9393
},
9494
},
9595
result: {
9696
data: {
97-
deleteWebhook: {
98-
id: webhookId,
99-
},
97+
deleteWebhook: createMockWebhookData({ id: webhookId }),
10098
},
10199
},
102100
});
@@ -105,9 +103,7 @@ const createGetWebhookMock = (webhookId: string, webhookData = {}) => ({
105103
request: {
106104
query: GET_WEBHOOK,
107105
variables: {
108-
input: {
109-
id: webhookId,
110-
},
106+
id: webhookId,
111107
},
112108
},
113109
result: {
@@ -329,10 +325,12 @@ describe('useWebhookForm', () => {
329325
variables: {
330326
input: {
331327
id: webhookId,
332-
targetUrl: 'https://test.com/webhook',
333-
operations: ['person.created'],
334-
description: 'Test webhook',
335-
secret: 'test-secret',
328+
update: {
329+
targetUrl: 'https://test.com/webhook',
330+
operations: ['person.created'],
331+
description: 'Test webhook',
332+
secret: 'test-secret',
333+
},
336334
},
337335
},
338336
},
@@ -464,9 +462,7 @@ describe('useWebhookForm', () => {
464462
request: {
465463
query: DELETE_WEBHOOK,
466464
variables: {
467-
input: {
468-
id: webhookId,
469-
},
465+
id: webhookId,
470466
},
471467
},
472468
error: new Error('Deletion failed'),

0 commit comments

Comments
 (0)