Skip to content

Commit 8f9a503

Browse files
authored
Merge pull request #6576 from Shopify/add-webhook-name-field
added a name field to webhook subscriptions
2 parents 2f001d7 + 833d751 commit 8f9a503

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

.changeset/spotty-buckets-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/app': minor
3+
---
4+
5+
Add support for an optional name field for webhook subscriptions in shopify.app.toml

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

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

3444+
test('accepts webhook subscription with name', async () => {
3445+
const webhookConfig: WebhooksConfig = {
3446+
api_version: '2024-01',
3447+
subscriptions: [
3448+
{
3449+
topics: ['products/create'],
3450+
uri: 'https://example.com/webhooks',
3451+
name: 'products/create',
3452+
},
3453+
],
3454+
}
3455+
const {abortOrReport, parsedConfiguration} = await setupParsing({}, webhookConfig)
3456+
expect(abortOrReport).not.toHaveBeenCalled()
3457+
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
3458+
})
3459+
34443460
test('accepts webhook subscription with actions', async () => {
34453461
const webhookConfig: WebhooksConfig = {
34463462
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'}).trim().min(1).max(50).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).max(50).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)