@yorkie-js/sdk 0.7.8 → 0.7.10-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,9 +106,10 @@ export declare interface AttachChannelOptions {
106
106
  */
107
107
  syncMode?: SyncMode;
108
108
  /**
109
- * `channelHeartbeatInterval` overrides the heartbeat interval (ms) for this
110
- * attachment. If unset, mode-specific defaults apply: Polling=3000,
111
- * Realtime=30000.
109
+ * `channelHeartbeatInterval` overrides the heartbeat interval (ms) for
110
+ * this attachment. If unset, the client-level default
111
+ * (`ClientOptions.channelHeartbeatInterval`, default 5000 ms) applies
112
+ * to both Realtime and Polling modes.
112
113
  */
113
114
  channelHeartbeatInterval?: number;
114
115
  }
@@ -801,6 +802,12 @@ export declare class Channel implements Observable_2<ChannelEvent>, Attachable {
801
802
  * The callback will be called when an authentication error occurs.
802
803
  */
803
804
  subscribe(type: 'auth-error', next: ChannelEventCallbackMap['auth-error']): Unsubscribe;
805
+ /**
806
+ * `subscribe` registers a callback to subscribe to non-recoverable sync
807
+ * (RefreshChannel) errors. Subsequent successful events on the channel
808
+ * imply recovery — there is no separate "recovered" event.
809
+ */
810
+ subscribe(type: 'sync-error', next: ChannelEventCallbackMap['sync-error']): Unsubscribe;
804
811
  /**
805
812
  * `subscribe` registers a callback to subscribe to presence events on the channel.
806
813
  * The callback will be called when the presence count changes.
@@ -834,7 +841,7 @@ export declare class Channel implements Observable_2<ChannelEvent>, Attachable {
834
841
  /**
835
842
  * `ChannelEvent` represents an event that occurs in the channel.
836
843
  */
837
- export declare type ChannelEvent = PresenceEvent_3 | BroadcastEvent | LocalBroadcastEvent | AuthErrorEvent_3;
844
+ export declare type ChannelEvent = PresenceEvent_3 | BroadcastEvent | LocalBroadcastEvent | AuthErrorEvent_3 | SyncErrorEvent;
838
845
 
839
846
  /**
840
847
  * `ChannelEventCallbackMap` represents a map of event types to callbacks.
@@ -843,6 +850,7 @@ declare type ChannelEventCallbackMap = {
843
850
  broadcast: NextFn<BroadcastEvent>;
844
851
  'local-broadcast': NextFn<LocalBroadcastEvent>;
845
852
  'auth-error': NextFn<AuthErrorEvent_3>;
853
+ 'sync-error': NextFn<SyncErrorEvent>;
846
854
  presence: NextFn<PresenceEvent_3>;
847
855
  all: NextFn<ChannelEvent>;
848
856
  };
@@ -870,7 +878,15 @@ export declare enum ChannelEventType {
870
878
  /**
871
879
  * `AuthError` means that an authentication error has occurred.
872
880
  */
873
- AuthError = "auth-error"
881
+ AuthError = "auth-error",
882
+ /**
883
+ * `SyncError` means that a non-recoverable sync (RefreshChannel) error
884
+ * occurred. Subscribers can use this to render an error state in the UI
885
+ * without polling internal SDK state. The SDK still retries via its sync
886
+ * loop, so subsequent successful events (PresenceChanged/Initialized) can
887
+ * be treated as recovery.
888
+ */
889
+ SyncError = "sync-error"
874
890
  }
875
891
 
876
892
  /**
@@ -1010,8 +1026,9 @@ export declare class Client {
1010
1026
  */
1011
1027
  attach<R, P extends Indexable>(resource: Document_2<R, P>, opts?: AttachOptions<R, P>): Promise<Document_2<R, P>>;
1012
1028
  /**
1013
- * `attach` attaches the given channel to this client. It tells the server that
1014
- * this client will track the channel.
1029
+ * `attach` attaches the given channel to this client. The channel is
1030
+ * registered locally and the server is notified on the next RefreshChannel
1031
+ * heartbeat.
1015
1032
  */
1016
1033
  attach(resource: Channel, opts?: AttachChannelOptions): Promise<Channel>;
1017
1034
  /**
@@ -1027,8 +1044,9 @@ export declare class Client {
1027
1044
  keepalive?: boolean;
1028
1045
  }): Promise<Document_2<R, P>>;
1029
1046
  /**
1030
- * `detach` detaches the given channel from this client.
1031
- * It tells the server that this client will no longer track the channel.
1047
+ * `detach` detaches the given channel from this client. The detach is a
1048
+ * local cleanup; the server reclaims the session via TTL when heartbeats
1049
+ * stop.
1032
1050
  */
1033
1051
  detach(resource: Channel): Promise<Channel>;
1034
1052
  /**
@@ -1041,13 +1059,15 @@ export declare class Client {
1041
1059
  */
1042
1060
  private detachDocument;
1043
1061
  /**
1044
- * `attach` attaches the given channel to this client.
1045
- * It tells the server that this client will track the channel.
1062
+ * `attachChannel` attaches the given channel to this client. The channel is
1063
+ * registered locally and the server is notified on the next RefreshChannel
1064
+ * heartbeat.
1046
1065
  */
1047
1066
  attachChannel(channel: Channel, opts?: AttachChannelOptions): Promise<Channel>;
1048
1067
  /**
1049
- * `detachChannel` detaches the given channel from this client.
1050
- * It tells the server that this client will no longer track the channel.
1068
+ * `detachChannel` detaches the given channel from this client. The detach
1069
+ * is a local cleanup; the server reclaims the session via TTL when
1070
+ * heartbeats stop.
1051
1071
  */
1052
1072
  detachChannel(channel: Channel): Promise<Channel>;
1053
1073
  /**
@@ -1122,6 +1142,17 @@ export declare class Client {
1122
1142
  * `restoreRevision` restores the document to the given revision.
1123
1143
  */
1124
1144
  restoreRevision<R, P extends Indexable>(doc: Document_2<R, P>, revisionId: string): Promise<void>;
1145
+ /**
1146
+ * `peekChannel` reads the current session count of a channel without
1147
+ * creating a session on the server. Use this when the caller only needs
1148
+ * to display the count (e.g. "N people writing") without contributing to
1149
+ * it and without receiving broadcasts.
1150
+ *
1151
+ * Unlike `attach({ readOnly: true })`, this does not occupy a `Session`
1152
+ * entry on the server, does not generate heartbeat RPCs, and does not
1153
+ * subscribe to channel events. Polling is the caller's responsibility.
1154
+ */
1155
+ peekChannel(channelKey: string): Promise<number>;
1125
1156
  /**
1126
1157
  * `broadcast` broadcasts the given payload to the given topic.
1127
1158
  */
@@ -1230,9 +1261,11 @@ export declare interface ClientOptions {
1230
1261
  */
1231
1262
  reconnectStreamDelay?: number;
1232
1263
  /**
1233
- * `channelHeartbeatInterval` is the interval of the channel heartbeat.
1234
- * The client sends a heartbeat to the server to refresh the channel TTL.
1235
- * The default value is `30000`(ms).
1264
+ * `channelHeartbeatInterval` is the interval of the channel heartbeat (ms).
1265
+ * The client sends a `RefreshChannel` heartbeat to refresh the channel
1266
+ * session TTL. The default value is `5000` (ms) — co-tuned to the server's
1267
+ * `ChannelSessionTTL` (15 s) at TTL/3. Values larger than the server TTL
1268
+ * risk premature session expiry.
1236
1269
  */
1237
1270
  channelHeartbeatInterval?: number;
1238
1271
  /**
@@ -6051,6 +6084,26 @@ declare interface SubscribeFn<T> {
6051
6084
  (observer: Observer<T>): Unsubscribe;
6052
6085
  }
6053
6086
 
6087
+ /**
6088
+ * `SyncErrorEvent` represents a non-recoverable sync (RefreshChannel) error.
6089
+ * It carries the underlying error object so subscribers can inspect codes
6090
+ * (e.g. via `isErrorCode`) without losing the original Error.
6091
+ */
6092
+ declare interface SyncErrorEvent {
6093
+ /**
6094
+ * `type` is the type of the event.
6095
+ */
6096
+ type: ChannelEventType.SyncError;
6097
+ /**
6098
+ * `error` is the underlying error thrown by the RPC call.
6099
+ */
6100
+ error: unknown;
6101
+ /**
6102
+ * `method` is the RPC method that failed (e.g. `RefreshChannel`).
6103
+ */
6104
+ method: string;
6105
+ }
6106
+
6054
6107
  /**
6055
6108
  * `SyncMode` defines synchronization modes for the PushPullChanges API
6056
6109
  * (documents) and the RefreshChannel heartbeat (channels).