Skip to content

chore(types): API responses use the owners' generated types (no casts) - #33

Merged
pushpsood merged 1 commit into
mainfrom
chore/typed-contract-responses
Nov 29, 2026
Merged

pushpsood merged 1 commit into
mainfrom
chore/typed-contract-responses

Conversation

@pushpsood

Copy link
Copy Markdown
Owner

Removes the casts that hid contract changes from tsc on API responses.

  • GraphQL subscriptions: 9 as unknown as {...} casts (7 in chat.ts, 2 in key-recovery.ts) replaced by one helper, subscribeToField. It is typed by the generated Subscription type from onehook-api-client/graphql.
  • GraphQL types: the hand-written chat and key-recovery types are now derived from the generated ones: MessageReaction, TypingIndicator, ScreenshotEvent, StarredMessageRecord, PresenceUpdate, ChatMessageExtended and KeyRecoverySession. Their comments said they were local only until the SDK caught up, and it has. Enums become string-literal types (\${MessageContentType}``), so existing literals like 'TEXT' keep working.
  • Moderation evidence: PresignResponse, CompleteResponse and PresignUpload alias the portal SDK's generated models, and the two result casts are gone.
  • Mr OneHook: the chat turn result carries ProductConnectionChatCommandOutput; the response and request-body casts are gone.

Checked by adding three deliberate mistakes temporarily; tsc rejects each one: a misspelled subscription field, a callback expecting a field the schema doesn't have, and a content type the schema doesn't define.

  • npx tsc --noEmit: clean
  • npm test: 102 files, 1263 tests passed
  • npm run build: OK

Casts that remain are not API contract issues: WebCrypto and byte buffers, and the SDK middleware's request headers.

@pushpsood
pushpsood merged commit 01d78b1 into main Nov 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant