Skip to content

Commit

Permalink
realtime-api Chat/PubSub: remove updateToken and `session.expirin…
Browse files Browse the repository at this point in the history
…g` (#607)

* remove the updateToken method from realtime chat and pubSub

* remove session.expiring from realtime-api chat and pubSub

* add changeset

* remove unused
  • Loading branch information
framini authored Aug 8, 2022
1 parent 24e956a commit f421f92
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
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']

/**
* 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
>

0 comments on commit f421f92

Please sign in to comment.