Skip to content

Commit 0d6b5c0

Browse files
committed
Add support for webhook actions attribute
1 parent 1565cbc commit 0d6b5c0

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
@@ -3303,6 +3303,22 @@ describe('WebhooksSchema', () => {
33033303
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
33043304
})
33053305

3306+
test('accepts webhook subscription with actions', async () => {
3307+
const webhookConfig: WebhooksConfig = {
3308+
api_version: '2024-01',
3309+
subscriptions: [
3310+
{
3311+
topics: ['products/create'],
3312+
uri: 'https://example.com/webhooks',
3313+
actions: ['create'],
3314+
},
3315+
],
3316+
}
3317+
const {abortOrReport, parsedConfiguration} = await setupParsing({}, webhookConfig)
3318+
expect(abortOrReport).not.toHaveBeenCalled()
3319+
expect(parsedConfiguration.webhooks).toMatchObject(webhookConfig)
3320+
})
3321+
33063322
async function setupParsing(errorObj: zod.ZodIssue | {}, webhookConfigOverrides: WebhooksConfig) {
33073323
const err = Array.isArray(errorObj) ? errorObj : [errorObj]
33083324
const expectedFormatted = outputContent`\n${outputToken.errorText(

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
@@ -13,6 +13,7 @@ export const WebhookSubscriptionSchema = zod.object({
1313
invalid_type_error: 'Value must be string[]',
1414
})
1515
.optional(),
16+
actions: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
1617
uri: zod.preprocess((arg) => removeTrailingSlash(arg as string), WebhookSubscriptionUriValidation, {
1718
required_error: 'Missing value at',
1819
}),

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
@@ -11,6 +11,7 @@ interface TransformedWebhookSubscription {
1111
api_version: string
1212
uri: string
1313
topic: string
14+
actions: string[]
1415
compliance_topics?: string[]
1516
include_fields?: string[]
1617
filter?: string
@@ -19,6 +20,7 @@ interface TransformedWebhookSubscription {
1920

2021
export const SingleWebhookSubscriptionSchema = zod.object({
2122
topic: zod.string(),
23+
actions: zod.array(zod.string({invalid_type_error: 'Value must be a string'})).optional(),
2224
api_version: zod.string(),
2325
uri: zod.preprocess(removeTrailingSlash as (arg: unknown) => unknown, WebhookSubscriptionUriValidation, {
2426
required_error: 'Missing value at',

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
@@ -1,6 +1,7 @@
11
export interface WebhookSubscription {
22
uri: string
33
topics?: string[]
4+
actions?: string[]
45
compliance_topics?: string[]
56
include_fields?: string[]
67
filter?: string

0 commit comments

Comments
 (0)