Skip to content

Commit 0a14d27

Browse files
committed
docs(repo): added missing drscriptions
1 parent ce9dad8 commit 0a14d27

File tree

8 files changed

+90
-9
lines changed

8 files changed

+90
-9
lines changed

packages/core/realtime-js/src/RealtimeChannel.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ export default class RealtimeChannel {
182182
private: boolean
183183

184184
/**
185+
* Creates a channel that can broadcast messages, sync presence, and listen to Postgres changes.
186+
*
187+
* The topic determines which realtime stream you are subscribing to. Config options let you
188+
* enable acknowledgement for broadcasts, presence tracking, or private channels.
189+
*
185190
* @example
186191
* ```ts
187192
* import RealtimeClient from '@supabase/realtime-js'
@@ -364,10 +369,20 @@ export default class RealtimeChannel {
364369
return this
365370
}
366371

372+
/**
373+
* Returns the current presence state for this channel.
374+
*
375+
* The shape is a map keyed by presence key (for example a user id) where each entry contains the
376+
* tracked metadata for that user.
377+
*/
367378
presenceState<T extends { [key: string]: any } = {}>(): RealtimePresenceState<T> {
368379
return this.presence.state as RealtimePresenceState<T>
369380
}
370381

382+
/**
383+
* Sends the supplied payload to the presence tracker so other subscribers can see that this
384+
* client is online. Use `untrack` to stop broadcasting presence for the same key.
385+
*/
371386
async track(
372387
payload: { [key: string]: any },
373388
opts: { [key: string]: any } = {}
@@ -382,6 +397,9 @@ export default class RealtimeChannel {
382397
)
383398
}
384399

400+
/**
401+
* Removes the current presence state for this client.
402+
*/
385403
async untrack(opts: { [key: string]: any } = {}): Promise<RealtimeChannelSendResponse> {
386404
return await this.send(
387405
{
@@ -658,6 +676,10 @@ export default class RealtimeChannel {
658676
}
659677
}
660678

679+
/**
680+
* Updates the payload that will be sent the next time the channel joins (reconnects).
681+
* Useful for rotating access tokens or updating config without re-creating the channel.
682+
*/
661683
updateJoinPayload(payload: { [key: string]: any }): void {
662684
this.joinPush.updatePayload(payload)
663685
}

packages/core/realtime-js/src/RealtimeClient.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const CONNECTION_TIMEOUTS = {
5555
const RECONNECT_INTERVALS = [1000, 2000, 5000, 10000] as const
5656
const DEFAULT_RECONNECT_FALLBACK = 10000
5757

58+
/**
59+
* Minimal WebSocket constructor interface that RealtimeClient can work with.
60+
* Supply a compatible implementation (native WebSocket, `ws`, etc) when running outside the browser.
61+
*/
5862
export interface WebSocketLikeConstructor {
5963
new (address: string | URL, subprotocols?: string | string[] | undefined): WebSocketLike
6064
// Allow additional properties that may exist on WebSocket constructors
@@ -364,6 +368,13 @@ export default class RealtimeClient {
364368
return this._connectionState === 'disconnecting'
365369
}
366370

371+
/**
372+
* Creates (or reuses) a {@link RealtimeChannel} for the provided topic.
373+
*
374+
* Topics are automatically prefixed with `realtime:` to match the Realtime service.
375+
* If a channel with the same topic already exists it will be returned instead of creating
376+
* a duplicate connection.
377+
*/
367378
channel(topic: string, params: RealtimeChannelOptions = { config: {} }): RealtimeChannel {
368379
const realtimeTopic = `realtime:${topic}`
369380
const exists = this.getChannels().find((c: RealtimeChannel) => c.topic === realtimeTopic)
@@ -467,6 +478,10 @@ export default class RealtimeClient {
467478
this._setAuthSafely('heartbeat')
468479
}
469480

481+
/**
482+
* Sets a callback that receives lifecycle events for internal heartbeat messages.
483+
* Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).
484+
*/
470485
onHeartbeat(callback: (status: HeartbeatStatus) => void): void {
471486
this.heartbeatCallback = callback
472487
}

packages/core/realtime-js/src/RealtimePresence.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ export default class RealtimePresence {
7272
}
7373

7474
/**
75-
* Initializes the Presence.
75+
* Creates a Presence helper that keeps the local presence state in sync with the server.
76+
*
77+
* @param channel - The realtime channel to bind to.
78+
* @param opts - Optional custom event names, e.g. `{ events: { state: 'state', diff: 'diff' } }`.
7679
*
77-
* @param channel - The RealtimeChannel
78-
* @param opts - The options,
79-
* for example `{events: {state: 'state', diff: 'diff'}}`
80-
*/
81-
/**
8280
* @example
8381
* ```ts
8482
* const presence = new RealtimePresence(channel)

packages/core/realtime-js/src/lib/websocket-factory.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@ export interface WebSocketLike {
77
readonly url: string
88
readonly protocol: string
99

10+
/**
11+
* Closes the socket, optionally providing a close code and reason.
12+
*/
1013
close(code?: number, reason?: string): void
14+
/**
15+
* Sends data through the socket using the underlying implementation.
16+
*/
1117
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
1218

1319
onopen: ((this: any, ev: Event) => any) | null
1420
onmessage: ((this: any, ev: MessageEvent) => any) | null
1521
onclose: ((this: any, ev: CloseEvent) => any) | null
1622
onerror: ((this: any, ev: Event) => any) | null
1723

24+
/**
25+
* Registers an event listener on the socket (compatible with browser WebSocket API).
26+
*/
1827
addEventListener(type: string, listener: EventListener): void
28+
/**
29+
* Removes a previously registered event listener.
30+
*/
1931
removeEventListener(type: string, listener: EventListener): void
2032

2133
// Add additional properties that may exist on WebSocket implementations
@@ -36,6 +48,10 @@ export interface WebSocketEnvironment {
3648
* Utilities for creating WebSocket instances across runtimes.
3749
*/
3850
export class WebSocketFactory {
51+
/**
52+
* Static-only utility – prevent instantiation.
53+
*/
54+
private constructor() {}
3955
private static detectEnvironment(): WebSocketEnvironment {
4056
if (typeof WebSocket !== 'undefined') {
4157
return { type: 'native', constructor: WebSocket }

packages/core/storage-js/src/lib/vectors/StorageVectorsClient.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ export interface StorageVectorsClientOptions {
8282
* ```
8383
*/
8484
export class StorageVectorsClient extends VectorBucketApi {
85+
/**
86+
* Creates a StorageVectorsClient that can manage buckets, indexes, and vectors.
87+
*
88+
* @param url - Base URL of the Storage Vectors REST API.
89+
* @param options.headers - Optional headers (for example `Authorization`) applied to every request.
90+
* @param options.fetch - Optional custom `fetch` implementation for non-browser runtimes.
91+
*/
8592
constructor(url: string, options: StorageVectorsClientOptions = {}) {
8693
super(url, options.headers || {}, options.fetch)
8794
}
@@ -121,6 +128,9 @@ export class StorageVectorsClient extends VectorBucketApi {
121128
export class VectorBucketScope extends VectorIndexApi {
122129
private vectorBucketName: string
123130

131+
/**
132+
* Creates a helper that automatically scopes all index operations to the provided bucket.
133+
*/
124134
constructor(
125135
url: string,
126136
headers: { [key: string]: string },
@@ -258,6 +268,9 @@ export class VectorIndexScope extends VectorDataApi {
258268
private vectorBucketName: string
259269
private indexName: string
260270

271+
/**
272+
* Creates a helper that automatically scopes all vector operations to the provided bucket/index names.
273+
*/
261274
constructor(
262275
url: string,
263276
headers: { [key: string]: string },

packages/core/storage-js/src/lib/vectors/VectorBucketApi.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export default class VectorBucketApi {
2424
* @param url - The base URL for the storage vectors API
2525
* @param headers - HTTP headers to include in requests
2626
* @param fetch - Optional custom fetch implementation
27+
*
28+
* @example
29+
* ```typescript
30+
* const client = new VectorBucketApi(url, headers)
31+
* ```
2732
*/
2833
constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) {
2934
this.url = url.replace(/\/$/, '')
@@ -107,9 +112,7 @@ export default class VectorBucketApi {
107112
* }
108113
* ```
109114
*/
110-
async getBucket(
111-
vectorBucketName: string
112-
): Promise<ApiResponse<{ vectorBucket: VectorBucket }>> {
115+
async getBucket(vectorBucketName: string): Promise<ApiResponse<{ vectorBucket: VectorBucket }>> {
113116
try {
114117
const data = await post(
115118
this.fetch,

packages/core/storage-js/src/lib/vectors/VectorDataApi.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export default class VectorDataApi {
2424
protected fetch: Fetch
2525
protected shouldThrowOnError = false
2626

27+
/**
28+
* Creates a VectorDataApi bound to a Storage Vectors deployment.
29+
*
30+
* @param url - Base URL for the Storage Vectors API.
31+
* @param headers - Default headers (for example authentication tokens).
32+
* @param fetch - Optional custom `fetch` implementation for non-browser runtimes.
33+
*/
2734
constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) {
2835
this.url = url.replace(/\/$/, '')
2936
this.headers = { ...DEFAULT_HEADERS, ...headers }

packages/core/storage-js/src/lib/vectors/VectorIndexApi.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export default class VectorIndexApi {
3434
protected fetch: Fetch
3535
protected shouldThrowOnError = false
3636

37+
/**
38+
* Creates an API client for managing vector indexes.
39+
*
40+
* @param url - Base URL for the Storage Vectors API.
41+
* @param headers - Default headers sent with each request.
42+
* @param fetch - Optional custom `fetch` implementation for non-browser runtimes.
43+
*/
3744
constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) {
3845
this.url = url.replace(/\/$/, '')
3946
this.headers = { ...DEFAULT_HEADERS, ...headers }

0 commit comments

Comments
 (0)