Skip to content

Commit f3a4122

Browse files
George LiGeorge Li
authored andcommitted
added a name field to webhook subscriptions
1 parent 3b79871 commit f3a4122

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

packages/app/src/cli/models/app/loader.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3411,6 +3411,22 @@ describe('WebhooksSchema', () => {
34113411
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
34123412
})
34133413

3414+
test('accepts webhook subscription with name', async () => {
3415+
const webhookConfig: WebhooksConfig = {
3416+
api_version: '2024-01',
3417+
subscriptions: [
3418+
{
3419+
topics: ['products/create'],
3420+
uri: 'https://example.com/webhooks',
3421+
name: 'products/create',
3422+
},
3423+
],
3424+
}
3425+
const {abortOrReport, parsedConfiguration} = await setupParsing({}, webhookConfig)
3426+
expect(abortOrReport).not.toHaveBeenCalled()
3427+
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
3428+
})
3429+
34143430
test('accepts webhook subscription with actions', async () => {
34153431
const webhookConfig: WebhooksConfig = {
34163432
api_version: '2024-01',

packages/app/src/cli/models/extensions/specifications/app_config_webhook_schemas/webhook_subscription_schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const WebhookSubscriptionSchema = zod.object({
2020
include_fields: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
2121
filter: zod.string({invalid_type_error: 'Value must be a string'}).optional(),
2222
payload_query: zod.string({invalid_type_error: 'Value must be a string'}).trim().min(1).optional(),
23+
name: zod.string({invalid_type_error: 'Value must be a string'}).min(1).optional(),
2324

2425
compliance_topics: zod
2526
.array(

packages/app/src/cli/models/extensions/specifications/app_config_webhook_subscription.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface TransformedWebhookSubscription {
1616
include_fields?: string[]
1717
filter?: string
1818
payload_query?: string
19+
name?: string
1920
}
2021

2122
export const SingleWebhookSubscriptionSchema = zod.object({
@@ -28,6 +29,7 @@ export const SingleWebhookSubscriptionSchema = zod.object({
2829
include_fields: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
2930
filter: zod.string({invalid_type_error: 'Value must be a string'}).optional(),
3031
payload_query: zod.string({invalid_type_error: 'Value must be a string'}).trim().min(1).optional(),
32+
name: zod.string({invalid_type_error: 'Value must be a string'}).min(1).optional(),
3133
})
3234

3335
/* this transforms webhooks remotely to be accepted by the TOML

packages/app/src/cli/models/extensions/specifications/types/app_config_webhook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface WebhookSubscription {
66
include_fields?: string[]
77
filter?: string
88
payload_query?: string
9+
name?: string
910
}
1011

1112
interface PrivacyComplianceConfig {

0 commit comments

Comments
 (0)