Skip to content

Commit

Permalink
Add support for Metafields to webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rsperko committed Jan 7, 2025
1 parent 30464f0 commit f3135a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/app/src/cli/models/app/app.test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export async function testSingleWebhookSubscriptionExtension({
topic,
api_version: '2024-01',
uri: 'https://my-app.com/webhooks',
metafields: [{namespace: 'custom', key: 'test'}],
},
}: {
emptyConfig?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ describe('webhooks', () => {
{
topics: ['orders/create'],
uri: 'https://example.com/webhooks/orders',
metafields: [{namespace: 'custom', key: 'test'}],
},
{
topics: ['products/create'],
uri: 'https://example.com/webhooks/products',
metafields: [{namespace: 'custom', key: 'test'}],
},
],
},
Expand All @@ -41,10 +43,12 @@ describe('webhooks', () => {
{
topic: 'orders/create',
uri: 'https://example.com/webhooks/orders',
metafields: [{namespace: 'custom', key: 'test'}],
},
{
topic: 'products/create',
uri: 'https://example.com/webhooks/products',
metafields: [{namespace: 'custom', key: 'test'}],
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ 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(),
metafields: zod
.array(
zod.object({
namespace: zod.string({invalid_type_error: 'Metafield namespace must be a string'}),
key: zod.string({invalid_type_error: 'Metafield key must be a string'}),
}),
{invalid_type_error: 'Metafields must be an array of objects with namespace and key'},
)
.optional(),
compliance_topics: zod
.array(
zod.enum([ComplianceTopic.CustomersRedact, ComplianceTopic.CustomersDataRequest, ComplianceTopic.ShopRedact]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export interface WebhookSubscription {
compliance_topics?: string[]
include_fields?: string[]
filter?: string
metafields?: {
namespace: string
key: string
}[]
}

interface PrivacyComplianceConfig {
Expand Down

0 comments on commit f3135a3

Please sign in to comment.