diff --git a/.changeset/spotty-buckets-join.md b/.changeset/spotty-buckets-join.md new file mode 100644 index 00000000000..1782d860b09 --- /dev/null +++ b/.changeset/spotty-buckets-join.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': minor +--- + +Add support for an optional name field for webhook subscriptions in shopify.app.toml diff --git a/packages/app/src/cli/models/app/loader.test.ts b/packages/app/src/cli/models/app/loader.test.ts index 273acacc2cb..624a2d02b81 100644 --- a/packages/app/src/cli/models/app/loader.test.ts +++ b/packages/app/src/cli/models/app/loader.test.ts @@ -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', diff --git a/packages/app/src/cli/models/extensions/specifications/app_config_webhook_schemas/webhook_subscription_schema.ts b/packages/app/src/cli/models/extensions/specifications/app_config_webhook_schemas/webhook_subscription_schema.ts index 1f33206e5cd..7c22dd007d2 100644 --- a/packages/app/src/cli/models/extensions/specifications/app_config_webhook_schemas/webhook_subscription_schema.ts +++ b/packages/app/src/cli/models/extensions/specifications/app_config_webhook_schemas/webhook_subscription_schema.ts @@ -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( diff --git a/packages/app/src/cli/models/extensions/specifications/app_config_webhook_subscription.ts b/packages/app/src/cli/models/extensions/specifications/app_config_webhook_subscription.ts index 0b6034f8da9..c1cffad42b7 100644 --- a/packages/app/src/cli/models/extensions/specifications/app_config_webhook_subscription.ts +++ b/packages/app/src/cli/models/extensions/specifications/app_config_webhook_subscription.ts @@ -16,6 +16,7 @@ interface TransformedWebhookSubscription { include_fields?: string[] filter?: string payload_query?: string + name?: string } export const SingleWebhookSubscriptionSchema = zod.object({ @@ -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 diff --git a/packages/app/src/cli/models/extensions/specifications/types/app_config_webhook.ts b/packages/app/src/cli/models/extensions/specifications/types/app_config_webhook.ts index c9f5f16f6cd..51982bb7a09 100644 --- a/packages/app/src/cli/models/extensions/specifications/types/app_config_webhook.ts +++ b/packages/app/src/cli/models/extensions/specifications/types/app_config_webhook.ts @@ -6,6 +6,7 @@ export interface WebhookSubscription { include_fields?: string[] filter?: string payload_query?: string + name?: string } interface PrivacyComplianceConfig {