Skip to content

Follow Up to addressing #1258 comments #1260

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
merged 10 commits into from
Jul 21, 2025
Merged

Conversation

jpsantosbh
Copy link
Collaborator

Description

Follow Up to addressing #1258 comments

Type of change

  • Internal refactoring
  • Bug fix (bugfix - non-breaking)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Code snippets

In case of new feature or breaking changes, please include code snippets.

Copy link

changeset-bot bot commented Jul 18, 2025

⚠️ No Changeset found

Latest commit: d70452f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jpsantosbh jpsantosbh requested a review from iAmmar7 July 18, 2025 20:48
@iAmmar7
Copy link
Member

iAmmar7 commented Jul 21, 2025

Check this comment as well: https://github.com/signalwire/signalwire-js/pull/1258/files#r2216451899

I am not sure if you understood the comment.

Since you have defined two different params, it means the ConversationEvent can have two different set of payloads: ConversationMessageEvent OR ConversationChatMessageEvent

Let me know if you have any questions.

@jpsantosbh
Copy link
Collaborator Author

Check this comment as well: https://github.com/signalwire/signalwire-js/pull/1258/files#r2216451899

I am not sure if you understood the comment.

Since you have defined two different params, it means the ConversationEvent can have two different set of payloads: ConversationMessageEvent OR ConversationChatMessageEvent

Let me know if you have any questions.

Yes, but a ConversationMessageEvent is a super set.

Developer are not required to use the convenience chat methods the receive chat events since a ConversationMessageEvent can be both. There is no need for saying that a ConversationEvent = ConversationMessageEvent | ConversationChatMessageEvent

But we they use the chat methods they only get ConversationChatMessageEvent

@jpsantosbh jpsantosbh requested a review from iAmmar7 July 21, 2025 13:50
@iAmmar7 iAmmar7 requested a review from LittorWired July 21, 2025 14:15
Copy link
Member

@iAmmar7 iAmmar7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Just highlighting this:

export interface ConversationMessageEvent extends SwEvent {
  event_type: ConversationMessageEventName
  params: ConversationMessageEventParams | ConversationChatMessageEventParams
}

export type ConversationEventParams = ConversationMessageEventParams | ConversationChatMessageEventParams

If you tell the TS that the conversation event can have params with two types, you would be able to avoid using unknown in the type guard:

const isConversationChatEventParams = (
  event: unknown // this can be replaced with ConversationEventParams
): event is ConversationChatEventParams => {
  return (
    typeof event === 'object' &&
    event !== null &&
    'subtype' in event &&
    event.subtype === 'chat' &&
    'user_name' in event &&
    'text' in event
  )
}

@jpsantosbh jpsantosbh merged commit ffaedf9 into main Jul 21, 2025
24 of 31 checks passed
@jpsantosbh jpsantosbh deleted the joao/use_camel_case_in_param branch July 21, 2025 16:06
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.

3 participants