Skip to content
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

realtime-api Chat/PubSub: remove updateToken and session.expiring #607

Merged
merged 4 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/friendly-teachers-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@signalwire/realtime-api': patch
---

remove `updateToken` and `session.expiring` event from realtime-api Chat and PubSub
1 change: 0 additions & 1 deletion internal/stack-tests/src/pubSub/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ async function run() {
tap.ok(pubSub.publish, 'pubSub.publish is defined')
tap.ok(pubSub.subscribe, 'pubSub.subscribe is defined')
tap.ok(pubSub.unsubscribe, 'pubSub.unsubscribe is defined')
tap.ok(pubSub.updateToken, 'pubSub.updateToken is defined')

process.exit(0)
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/pubSub/BasePubSub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export class BasePubSubConsumer<
})
}

// Currently only `js` supports this features and it's
// being ignored (filtered at the Proxy level) within
// `realtime-api`
updateToken(token: string): Promise<void> {
return new Promise((resolve, reject) => {
// @ts-expect-error
Expand Down
8 changes: 5 additions & 3 deletions packages/realtime-api/src/chat/ChatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
Chat as ChatNamespace,
} from '@signalwire/core'
import { clientConnect, setupClient, RealtimeClient } from '../client/index'
import type { RealTimeChatApiEventsHandlerMapping } from '../types/chat'

export interface ChatClientApiEvents extends ChatNamespace.BaseChatApiEvents {}
export interface ChatClientApiEvents
extends ChatNamespace.BaseChatApiEvents<RealTimeChatApiEventsHandlerMapping> {}

export interface ClientFullState extends ChatClient {}
interface ChatClient
extends Omit<ChatContract, 'getAllowedChannels'>,
extends Omit<ChatContract, 'getAllowedChannels' | 'updateToken'>,
Omit<ConsumerContract<ChatClientApiEvents, ClientFullState>, 'subscribe'> {
new (opts: ChatClientOptions): this

Expand All @@ -31,7 +33,7 @@ const INTERCEPTED_METHODS: ClientMethods[] = [
'getMemberState',
'setMemberState',
]
const UNSUPPORTED_METHODS = ['getAllowedChannels']
const UNSUPPORTED_METHODS = ['getAllowedChannels', 'updateToken']

/**
* You can use instances of this class to control the chat and subscribe to its
Expand Down
7 changes: 4 additions & 3 deletions packages/realtime-api/src/pubSub/PubSubClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
PubSubContract,
} from '@signalwire/core'
import { clientConnect, setupClient, RealtimeClient } from '../client/index'
import type { RealTimePubSubApiEventsHandlerMapping } from '../types/pubSub'

export interface PubSubClientApiEvents
extends PubSubNamespace.BasePubSubApiEvents {}
extends PubSubNamespace.BasePubSubApiEvents<RealTimePubSubApiEventsHandlerMapping> {}

export interface ClientFullState extends PubSubClient {}
interface PubSubClient
extends Omit<PubSubContract, 'getAllowedChannels'>,
extends Omit<PubSubContract, 'getAllowedChannels' | 'updateToken'>,
Omit<
ConsumerContract<PubSubClientApiEvents, ClientFullState>,
'subscribe'
Expand All @@ -29,7 +30,7 @@ interface PubSubClientOptions

type ClientMethods = Exclude<keyof PubSubClient, '_session'>
const INTERCEPTED_METHODS: ClientMethods[] = ['subscribe', 'publish']
const UNSUPPORTED_METHODS = ['getAllowedChannels']
const UNSUPPORTED_METHODS = ['getAllowedChannels', 'updateToken']
edolix marked this conversation as resolved.
Show resolved Hide resolved

/**
* Creates a new PubSub client.
Expand Down
12 changes: 12 additions & 0 deletions packages/realtime-api/src/types/chat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {
ChatMember,
ChatMemberEventNames,
ChatMessage,
ChatMessageEventName,
} from '@signalwire/core'

export type RealTimeChatApiEventsHandlerMapping = Record<
ChatMessageEventName,
(message: ChatMessage) => void
> &
Record<ChatMemberEventNames, (member: ChatMember) => void>
6 changes: 6 additions & 0 deletions packages/realtime-api/src/types/pubSub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { PubSubMessage, PubSubMessageEventName } from '@signalwire/core'

export type RealTimePubSubApiEventsHandlerMapping = Record<
PubSubMessageEventName,
(message: PubSubMessage) => void
>