From 0720621c2ea291441c285bc37b252fe3d59b5841 Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Sun, 4 Oct 2026 22:25:23 +0100 Subject: [PATCH 1/3] feat(channels): support default audience request flag --- CHANGELOG.md | 6 +++ src/clients/channels-client.test.ts | 65 +++++++++++++++++++++++++++++ src/types/requests.ts | 2 + 3 files changed, 73 insertions(+) create mode 100644 src/clients/channels-client.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b66c0b2..df426eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Features + +* **channels:** support `useDefaultRecipients` in create and update requests + ## [3.3.0](https://github.com/Doist/comms-sdk-typescript/compare/v3.2.0...v3.3.0) (2026-10-01) ### Features diff --git a/src/clients/channels-client.test.ts b/src/clients/channels-client.test.ts new file mode 100644 index 0000000..00a3d62 --- /dev/null +++ b/src/clients/channels-client.test.ts @@ -0,0 +1,65 @@ +import { http, HttpResponse } from 'msw' +import { describe, expect, it } from 'vitest' +import { CommsApi } from '../comms-api' +import { server } from '../testUtils/msw-setup' +import { + TEST_API_BASE_URL as BASE, + TEST_API_TOKEN, + TEST_CHANNEL_ID, +} from '../testUtils/test-defaults' + +const CHANNEL_RESPONSE = { + id: TEST_CHANNEL_ID, + name: 'General', + creator: 1, + public: true, + workspace_id: 1, + archived: false, + created_ts: 1_609_459_200, + version: 1, +} + +describe('ChannelsClient — wire serialization', () => { + it.each([ + ['createChannel', 'add', true], + ['createChannel', 'add', false], + ['updateChannel', 'update', true], + ['updateChannel', 'update', false], + ] as const)( + '%s sends use_default_recipients: %s and empty default audience arrays', + async (method, suffix, useDefaultRecipients) => { + let body: Record | undefined + server.use( + http.post(`${BASE}/channels/${suffix}`, async ({ request }) => { + body = (await request.json()) as Record + return HttpResponse.json(CHANNEL_RESPONSE) + }), + ) + + const api = new CommsApi(TEST_API_TOKEN) + if (method === 'createChannel') { + await api.channels.createChannel({ + workspaceId: 1, + name: 'General', + useDefaultRecipients, + defaultGroups: [], + defaultRecipients: [], + }) + } else { + await api.channels.updateChannel({ + id: TEST_CHANNEL_ID, + name: 'General', + useDefaultRecipients, + defaultGroups: [], + defaultRecipients: [], + }) + } + + expect(body).toMatchObject({ + use_default_recipients: useDefaultRecipients, + default_groups: [], + default_recipients: [], + }) + }, + ) +}) diff --git a/src/types/requests.ts b/src/types/requests.ts index 9a41a39..0081b59 100644 --- a/src/types/requests.ts +++ b/src/types/requests.ts @@ -18,6 +18,7 @@ export const CreateChannelArgsSchema = z.object({ color: z.number().nullable().optional(), public: z.boolean().nullable().optional(), description: z.string().nullable().optional(), + useDefaultRecipients: z.boolean().nullable().optional(), defaultGroups: z.array(z.string()).nullable().optional(), defaultRecipients: z.array(z.number()).nullable().optional(), isFavorited: z.boolean().nullable().optional(), @@ -32,6 +33,7 @@ export const UpdateChannelArgsSchema = z.object({ color: z.number().nullable().optional(), public: z.boolean().nullable().optional(), description: z.string().nullable().optional(), + useDefaultRecipients: z.boolean().nullable().optional(), defaultGroups: z.array(z.string()).nullable().optional(), defaultRecipients: z.array(z.number()).nullable().optional(), isFavorited: z.boolean().nullable().optional(), From 94064e04c5557de3213c3304a7e6d8132298db6d Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Tue, 6 Oct 2026 15:38:27 +0100 Subject: [PATCH 2/3] test(channels): derive endpoint from method --- src/clients/channels-client.test.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/clients/channels-client.test.ts b/src/clients/channels-client.test.ts index 00a3d62..02370c0 100644 --- a/src/clients/channels-client.test.ts +++ b/src/clients/channels-client.test.ts @@ -21,13 +21,14 @@ const CHANNEL_RESPONSE = { describe('ChannelsClient — wire serialization', () => { it.each([ - ['createChannel', 'add', true], - ['createChannel', 'add', false], - ['updateChannel', 'update', true], - ['updateChannel', 'update', false], + ['createChannel', true], + ['createChannel', false], + ['updateChannel', true], + ['updateChannel', false], ] as const)( '%s sends use_default_recipients: %s and empty default audience arrays', - async (method, suffix, useDefaultRecipients) => { + async (method, useDefaultRecipients) => { + const suffix = method === 'createChannel' ? 'add' : 'update' let body: Record | undefined server.use( http.post(`${BASE}/channels/${suffix}`, async ({ request }) => { From 2a4f52d3c049c4dc95b4afafcf414fe18a4e6cbf Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Fri, 23 Oct 2026 16:43:50 +0100 Subject: [PATCH 3/3] chore: leave changelog generation to release automation --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e93da..b22aea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,3 @@ -## Unreleased - -### Features - -* **channels:** support `useDefaultRecipients` in create and update requests - ## [3.8.1](https://github.com/Doist/comms-sdk-typescript/compare/v3.8.0...v3.8.1) (2026-10-21) ### Bug Fixes