-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: remove legacy Twist/migration framing #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
amix
merged 4 commits into
amix/ft.bootstrap-comms-sdk
from
amix/remove-legacy-references
May 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
431191d
refactor: remove legacy Twist/migration framing
amix 480fd0f
review: address Doistbot findings on PR #1
amix 0124291
fix(test): use array capture so CI tsc emit succeeds
amix 88c5283
fix: schema mismatches found smoke-testing against staging
amix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,5 @@ dist | |
| *.tgz | ||
| .claude/settings.local.json | ||
| scratch.ts | ||
| .vscode/launch.json | ||
| scratch-*.ts | ||
| .vscode/launch.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { TEST_API_TOKEN, TEST_THREAD_ID } from '../testUtils/test-defaults' | ||
| import { EVERYONE, EVERYONE_IN_THREAD } from '../types/enums' | ||
| import { addCommentRequest } from './add-comment-helper' | ||
|
|
||
| const ctx = { baseUri: 'https://comms.todoist.com/api/v3/', apiToken: TEST_API_TOKEN } | ||
|
|
||
| describe('addCommentRequest — reserved broadcast marker validation', () => { | ||
| it('throws when a marker is passed in `groups`', () => { | ||
| expect(() => | ||
| addCommentRequest(ctx, { | ||
| threadId: TEST_THREAD_ID, | ||
| content: 'hello', | ||
| groups: [EVERYONE], | ||
| }), | ||
| ).toThrow(/`groups` contains EVERYONE/) | ||
| }) | ||
|
|
||
| it('throws when a marker is passed in `directGroupMentions`', () => { | ||
| expect(() => | ||
| addCommentRequest(ctx, { | ||
| threadId: TEST_THREAD_ID, | ||
| content: 'hello', | ||
| directGroupMentions: [EVERYONE_IN_THREAD], | ||
| }), | ||
| ).toThrow(/`directGroupMentions` contains EVERYONE_IN_THREAD/) | ||
| }) | ||
|
|
||
| it('reports both fields in one error when markers appear in both', () => { | ||
| let caught: Error | null = null | ||
| try { | ||
| addCommentRequest(ctx, { | ||
| threadId: TEST_THREAD_ID, | ||
| content: 'hello', | ||
| groups: [EVERYONE], | ||
| directGroupMentions: [EVERYONE_IN_THREAD], | ||
| }) | ||
| } catch (e) { | ||
| caught = e as Error | ||
| } | ||
| expect(caught).not.toBeNull() | ||
| expect(caught?.message).toMatch(/`groups` contains EVERYONE/) | ||
| expect(caught?.message).toMatch(/`directGroupMentions` contains EVERYONE_IN_THREAD/) | ||
| expect(caught?.message).toMatch(/notifyAudience/) | ||
| }) | ||
|
|
||
| it('translates notifyAudience: channel into the EVERYONE marker', () => { | ||
| const descriptor = addCommentRequest( | ||
| ctx, | ||
| { threadId: TEST_THREAD_ID, content: 'hello', notifyAudience: 'channel' }, | ||
| { batch: true }, | ||
| ) | ||
| expect('params' in descriptor).toBe(true) | ||
| if (!('params' in descriptor)) return | ||
| const groups = (descriptor.params as Record<string, unknown>)?.groups as string[] | ||
| expect(groups).toEqual([EVERYONE]) | ||
| }) | ||
|
|
||
| it('translates notifyAudience: thread into the EVERYONE_IN_THREAD marker', () => { | ||
| const descriptor = addCommentRequest( | ||
| ctx, | ||
| { threadId: TEST_THREAD_ID, content: 'hello', notifyAudience: 'thread' }, | ||
| { batch: true }, | ||
| ) | ||
| if (!('params' in descriptor)) return | ||
| const groups = (descriptor.params as Record<string, unknown>)?.groups as string[] | ||
| expect(groups).toEqual([EVERYONE_IN_THREAD]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| 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_TOKEN, TEST_COMMENT_ID, TEST_THREAD_ID } from '../testUtils/test-defaults' | ||
|
|
||
| const BASE = 'https://comms.todoist.com/api/v3' | ||
|
|
||
| // These tests pin the wire shape of `comments-client` — every camelCase | ||
| // field on the args side ends up snake_case on the wire (via | ||
| // `snakeCaseKeys` in the transport layer). The simplify pass dropped | ||
| // hand-rolled snake-casing inside the client, so this is the only thing | ||
| // that catches a casing regression locally. | ||
|
|
||
| describe('CommentsClient — wire serialization', () => { | ||
| it('getComments sends thread_id / newer_than_ts / older_than_ts on the URL', async () => { | ||
| const capturedUrls: URL[] = [] | ||
| server.use( | ||
| http.get(`${BASE}/comments/get`, ({ request }) => { | ||
| capturedUrls.push(new URL(request.url)) | ||
| return HttpResponse.json([]) | ||
| }), | ||
| ) | ||
|
|
||
| const api = new CommsApi(TEST_API_TOKEN) | ||
| await api.comments.getComments({ | ||
| threadId: TEST_THREAD_ID, | ||
| newerThan: new Date('2026-01-01T00:00:00Z'), | ||
| olderThan: new Date('2026-02-01T00:00:00Z'), | ||
| limit: 50, | ||
| }) | ||
|
|
||
| expect(capturedUrls).toHaveLength(1) | ||
| const params = (capturedUrls[0] as URL).searchParams | ||
| expect(params.get('thread_id')).toBe(TEST_THREAD_ID) | ||
| expect(params.get('newer_than_ts')).toBe( | ||
| String(Math.floor(new Date('2026-01-01T00:00:00Z').getTime() / 1000)), | ||
| ) | ||
| expect(params.get('older_than_ts')).toBe( | ||
| String(Math.floor(new Date('2026-02-01T00:00:00Z').getTime() / 1000)), | ||
| ) | ||
| expect(params.get('limit')).toBe('50') | ||
| }) | ||
|
|
||
| it('markPosition POSTs thread_id and comment_id as snake_case', async () => { | ||
| let capturedBody: Record<string, unknown> | null = null | ||
| server.use( | ||
| http.post(`${BASE}/comments/mark_position`, async ({ request }) => { | ||
| capturedBody = (await request.json()) as Record<string, unknown> | ||
| return HttpResponse.json({ status: 'ok' }) | ||
| }), | ||
| ) | ||
|
|
||
| const api = new CommsApi(TEST_API_TOKEN) | ||
| await api.comments.markPosition({ | ||
| threadId: TEST_THREAD_ID, | ||
| commentId: TEST_COMMENT_ID, | ||
| }) | ||
|
|
||
| expect(capturedBody).toEqual({ | ||
| thread_id: TEST_THREAD_ID, | ||
| comment_id: TEST_COMMENT_ID, | ||
| }) | ||
| }) | ||
|
|
||
| it('batch descriptors carry camelCase params (transport snake-cases on send)', () => { | ||
| const api = new CommsApi(TEST_API_TOKEN) | ||
| const descriptor = api.comments.getComments( | ||
| { | ||
| threadId: TEST_THREAD_ID, | ||
| newerThan: new Date('2026-01-01T00:00:00Z'), | ||
| limit: 10, | ||
| }, | ||
| { batch: true }, | ||
| ) | ||
| if (!('params' in descriptor) || !descriptor.params) { | ||
| throw new Error('expected batch descriptor with params') | ||
| } | ||
| expect(descriptor.params).toMatchObject({ | ||
| threadId: TEST_THREAD_ID, | ||
| limit: 10, | ||
| }) | ||
| expect(descriptor.params.newerThanTs).toBeTypeOf('number') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.