Commit f148816
authored
fix(types): align with backend response schema (#1727)
## Summary
Fixes the scheduled `Type test` workflow, which has been failing for 4
consecutive Mondays (Apr 6, 13, 20, 27) because the live Stream backend
has drifted from the SDK's TypeScript types. Each field added below is
cross-referenced against the canonical
[`GetStream/protocol/openapi/chat-openapi.yaml`](https://github.com/GetStream/protocol/blob/main/openapi/chat-openapi.yaml).
### Changes to `src/types.ts`
| Type | Field | Source |
|---|---|---|
| `MessageResponseBase` | `mentioned_here?: boolean` | spec: "Whether
the message mentioned online users with @here tag" |
| `MessageResponseBase` | `mentioned_roles?: string[]` | spec: list of
roles mentioned (admin, channel_moderator, custom roles). **Proactive**
— in spec, not yet returned by backend, but will be the next drift the
moment it ships |
| `ReactionGroupResponse` | `latest_reactions_by?:
ReactionGroupUserResponse[]` | spec: required field, "The most recent
users who reacted with this type, ordered by most recent first" |
| **new** `ReactionGroupUserResponse` | `{ created_at: string; user_id:
string; user?: UserResponse }` | spec: required = `[user_id,
created_at]` |
| `ChannelConfigFields` | `push_level?: 'all' \| 'all_mentions' \|
'direct_mentions' \| 'mentions' \| 'none' \| ''` | spec enum (5 values);
`''` added to absorb empty-string responses observed in live
`getAppSettings` data |
| `AppSettingsAPIResponse.app.channel_configs` (inline) | same
`push_level` | this inline type duplicates `ChannelConfigFields` and
didn't share it — same drift, two locations |
| `AppSettingsAPIResponse.app` |
`moderation_audio_call_moderation_enabled?: boolean`,
`moderation_video_call_moderation_enabled?: boolean` | spec: both
`boolean`. Marked optional to match the existing pattern of every other
`moderation_*` field on `app` |
| `LocalMessage` | `error?: ... \| null`, `quoted_message?: ... \| null`
| live responses return explicit `null` (not just `undefined`) |
### Notes for reviewers
1. **`push_level: ''`** — the OpenAPI enum doesn't include `''`, but the
live backend currently returns it for unset channel-type configs
(visible in the captured `data.ts` from `getAppSettings`). Tightening
the union to spec would re-break the test. Worth flagging upstream as a
backend/spec discrepancy, but in the SDK we should match reality.
2. **`moderation_*_call_moderation_enabled`** — the spec lists both as
`required` on `App`. I declared them `?:` to stay consistent with every
other `moderation_*` field on the SDK's `app` object (all currently
optional). Tightening these alone would be an inconsistent half-measure;
aligning everything to spec would be a separate sweep PR.
3. **Inline duplication** — `AppSettingsAPIResponse.app.channel_configs`
redeclares `ChannelConfigFields` inline rather than reusing the named
type. That's why this drift surfaced in two places. A small follow-up to
dedupe would prevent the next round of two-edits-for-one-field. Not in
scope here.
## Test plan
Verified locally against the live Stream backend:
- [x] `yarn build` — clean
- [x] `yarn test-types` — 0 tsc errors after fixes (all 100+ live API
calls return ✅)
- [x] `yarn types` (SDK noEmit type-check) — clean
- [x] `yarn lint` — clean
- [x] `yarn vitest run` — 2767 passed, 1 skipped, 0 failed
The next scheduled `Type test` run on Monday should turn green.1 parent 63c45a6 commit f148816
1 file changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| |||
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
| 164 | + | |
157 | 165 | | |
158 | 166 | | |
159 | 167 | | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
535 | 544 | | |
536 | 545 | | |
537 | 546 | | |
538 | | - | |
539 | | - | |
| 547 | + | |
| 548 | + | |
540 | 549 | | |
541 | 550 | | |
542 | 551 | | |
| |||
744 | 753 | | |
745 | 754 | | |
746 | 755 | | |
| 756 | + | |
| 757 | + | |
747 | 758 | | |
748 | 759 | | |
749 | 760 | | |
| |||
770 | 781 | | |
771 | 782 | | |
772 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
773 | 791 | | |
774 | 792 | | |
775 | 793 | | |
| |||
2500 | 2518 | | |
2501 | 2519 | | |
2502 | 2520 | | |
| 2521 | + | |
2503 | 2522 | | |
2504 | 2523 | | |
2505 | 2524 | | |
| |||
0 commit comments