Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-buckets-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': minor
---

Add support for an optional name field for webhook subscriptions in shopify.app.toml
16 changes: 16 additions & 0 deletions packages/app/src/cli/models/app/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3441,6 +3441,22 @@ describe('WebhooksSchema', () => {
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
})

test('accepts webhook subscription with name', async () => {
const webhookConfig: WebhooksConfig = {
api_version: '2024-01',
subscriptions: [
{
topics: ['products/create'],
uri: 'https://example.com/webhooks',
name: 'products/create',
},
],
}
const {abortOrReport, parsedConfiguration} = await setupParsing({}, webhookConfig)
expect(abortOrReport).not.toHaveBeenCalled()
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
})

test('accepts webhook subscription with actions', async () => {
const webhookConfig: WebhooksConfig = {
api_version: '2024-01',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const WebhookSubscriptionSchema = zod.object({
include_fields: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
filter: zod.string({invalid_type_error: 'Value must be a string'}).optional(),
payload_query: zod.string({invalid_type_error: 'Value must be a string'}).trim().min(1).optional(),
name: zod.string({invalid_type_error: 'Value must be a string'}).trim().min(1).max(50).optional(),

compliance_topics: zod
.array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface TransformedWebhookSubscription {
include_fields?: string[]
filter?: string
payload_query?: string
name?: string
}

export const SingleWebhookSubscriptionSchema = zod.object({
Expand All @@ -28,6 +29,7 @@ export const SingleWebhookSubscriptionSchema = zod.object({
include_fields: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
filter: zod.string({invalid_type_error: 'Value must be a string'}).optional(),
payload_query: zod.string({invalid_type_error: 'Value must be a string'}).trim().min(1).optional(),
name: zod.string({invalid_type_error: 'Value must be a string'}).min(1).max(50).optional(),
})

/* this transforms webhooks remotely to be accepted by the TOML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface WebhookSubscription {
include_fields?: string[]
filter?: string
payload_query?: string
name?: string
}

interface PrivacyComplianceConfig {
Expand Down
Loading