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

Fix typings for RealtimeChannel.modes #1955

Merged
merged 1 commit into from
Jan 27, 2025
Merged
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
49 changes: 43 additions & 6 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,30 +853,67 @@ declare namespace ChannelModes {
/**
lawrence-forooghian marked this conversation as resolved.
Show resolved Hide resolved
* The client can publish messages.
*/
type PUBLISH = 'PUBLISH';
type PUBLISH = 'PUBLISH' | 'publish';
/**
* The client can subscribe to messages.
*/
type SUBSCRIBE = 'SUBSCRIBE';
type SUBSCRIBE = 'SUBSCRIBE' | 'subscribe';
/**
* The client can enter the presence set.
*/
type PRESENCE = 'PRESENCE';
type PRESENCE = 'PRESENCE' | 'presence';
/**
* The client can receive presence messages.
*/
type PRESENCE_SUBSCRIBE = 'PRESENCE_SUBSCRIBE';
type PRESENCE_SUBSCRIBE = 'PRESENCE_SUBSCRIBE' | 'presence_subscribe';
}

/**
* Describes the possible flags used to configure client capabilities, using {@link ChannelOptions}.
*
* **Note:** This type admits uppercase or lowercase values for reasons of backwards compatibility. In the next major release of this SDK, it will be merged with {@link ResolvedChannelMode} and only admit lowercase values; see [this GitHub issue](https://github.com/ably/ably-js/issues/1954).
*/
export type ChannelMode =
| ChannelModes.PUBLISH
| ChannelModes.SUBSCRIBE
| ChannelModes.PRESENCE
| ChannelModes.PRESENCE_SUBSCRIBE;

/**
* The `ResolvedChannelModes` namespace describes the possible values of the {@link ResolvedChannelMode} type.
*/
declare namespace ResolvedChannelModes {
/**
* The client can publish messages.
*/
type PUBLISH = 'publish';
/**
* The client can subscribe to messages.
*/
type SUBSCRIBE = 'subscribe';
/**
* The client can enter the presence set.
*/
type PRESENCE = 'presence';
/**
* The client can receive presence messages.
*/
type PRESENCE_SUBSCRIBE = 'presence_subscribe';
}

/**
* Describes the configuration that a {@link RealtimeChannel} is using, as returned by {@link RealtimeChannel.modes}.
*
* This type is the same as the {@link ChannelMode} type but with all of the values lowercased.
*
* **Note:** This type exists for reasons of backwards compatibility. In the next major release of this SDK, it will be merged with {@link ChannelMode}; see [this GitHub issue](https://github.com/ably/ably-js/issues/1954).
*/
export type ResolvedChannelMode =
| ResolvedChannelModes.PUBLISH
| ResolvedChannelModes.SUBSCRIBE
| ResolvedChannelModes.PRESENCE
| ResolvedChannelModes.PRESENCE_SUBSCRIBE;

/**
* Passes additional properties to a {@link Channel} or {@link RealtimeChannel} object, such as encryption, {@link ChannelMode} and channel parameters.
*/
Expand Down Expand Up @@ -2090,9 +2127,9 @@ export declare interface RealtimeChannel extends EventEmitter<channelEventCallba
*/
params: ChannelParams;
/**
* An array of {@link ChannelMode} objects.
* An array of {@link ResolvedChannelMode} objects.
*/
modes: ChannelMode[];
modes: ResolvedChannelMode[];
/**
* Deregisters the given listener for the specified event name. This removes an earlier event-specific subscription.
*
Expand Down
Loading