@lark-sh/client 0.1.6 → 0.1.8

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.
package/dist/index.d.mts CHANGED
@@ -24,6 +24,7 @@ declare class OnDisconnect {
24
24
  cancel(): Promise<void>;
25
25
  /**
26
26
  * Set a value with priority when disconnected.
27
+ * Priority is injected as `.priority` into the value object.
27
28
  */
28
29
  setWithPriority(value: unknown, priority: number | string): Promise<void>;
29
30
  }
@@ -88,6 +89,9 @@ declare class DatabaseReference {
88
89
  child(path: string): DatabaseReference;
89
90
  /**
90
91
  * Set the data at this location, overwriting any existing data.
92
+ *
93
+ * For volatile paths (high-frequency updates), this is fire-and-forget
94
+ * and resolves immediately without waiting for server confirmation.
91
95
  */
92
96
  set(value: unknown): Promise<void>;
93
97
  /**
@@ -112,6 +116,8 @@ declare class DatabaseReference {
112
116
  update(values: Record<string, unknown>): Promise<void>;
113
117
  /**
114
118
  * Remove the data at this location.
119
+ *
120
+ * For volatile paths, this is fire-and-forget.
115
121
  */
116
122
  remove(): Promise<void>;
117
123
  /**
@@ -126,10 +132,12 @@ declare class DatabaseReference {
126
132
  push(value?: unknown): DatabaseReference | Promise<DatabaseReference>;
127
133
  /**
128
134
  * Set the data with a priority value for ordering.
135
+ * Priority is injected as `.priority` into the value object.
129
136
  */
130
137
  setWithPriority(value: unknown, priority: number | string): Promise<void>;
131
138
  /**
132
139
  * Set the priority of the data at this location.
140
+ * Fetches current value and sets it with the new priority.
133
141
  */
134
142
  setPriority(priority: number | string): Promise<void>;
135
143
  /**
@@ -224,6 +232,12 @@ declare class DatabaseReference {
224
232
  /**
225
233
  * DataSnapshot - an immutable snapshot of data at a location.
226
234
  * Received in event callbacks and from once() operations.
235
+ *
236
+ * Priority Handling:
237
+ * - Priority is stored as a regular child value `.priority` in the data
238
+ * - val() strips `.priority` from returned objects (so app code doesn't see it)
239
+ * - getPriority() reads from the data's `.priority` field
240
+ * - This matches Firebase behavior where priority is metadata, not user data
227
241
  */
228
242
 
229
243
  declare class DataSnapshot {
@@ -231,11 +245,9 @@ declare class DataSnapshot {
231
245
  private readonly _path;
232
246
  private readonly _db;
233
247
  private readonly _volatile;
234
- private readonly _priority;
235
248
  private readonly _serverTimestamp;
236
249
  constructor(data: unknown, path: string, db: LarkDatabase, options?: {
237
250
  volatile?: boolean;
238
- priority?: number | string | null;
239
251
  serverTimestamp?: number | null;
240
252
  });
241
253
  /**
@@ -247,7 +259,8 @@ declare class DataSnapshot {
247
259
  */
248
260
  get key(): string | null;
249
261
  /**
250
- * Get the raw data value.
262
+ * Get the data value, with `.priority` stripped if present.
263
+ * Priority is internal metadata and should not be visible to app code.
251
264
  */
252
265
  val(): unknown;
253
266
  /**
@@ -276,6 +289,7 @@ declare class DataSnapshot {
276
289
  forEach(callback: (child: DataSnapshot) => boolean | void): void;
277
290
  /**
278
291
  * Get the priority of the data at this location.
292
+ * Priority is stored as `.priority` in the data object.
279
293
  */
280
294
  getPriority(): number | string | null;
281
295
  /**
@@ -328,19 +342,21 @@ interface TxConditionOp {
328
342
  v: unknown;
329
343
  }
330
344
  type TxOperation = TxSetOp | TxUpdateOp | TxDeleteOp | TxConditionOp;
331
- interface MoveEntry {
332
- k: string;
333
- ak: string;
334
- }
335
345
 
336
346
  /**
337
- * SubscriptionManager - tracks active subscriptions and routes events to callbacks.
347
+ * View - represents a client's subscription to a database path.
338
348
  *
339
- * Handles the new delta-based protocol where server sends 'put' and 'patch' events.
340
- * Client generates child_added, child_changed, child_removed, child_moved events locally.
349
+ * Each View encapsulates all state for a single subscription:
350
+ * - Path and query parameters
351
+ * - Event callbacks by type
352
+ * - Ordered children (keys in sorted order, sorted by client)
353
+ * - Local cache of visible data
341
354
  *
342
- * Supports ordered queries: tracks child order from server's `k` (orderedKeys) and `ak` (afterKey)
343
- * fields, and fires child_moved when positions change via `mv` (moves) array.
355
+ * This mirrors the server's View concept, enabling:
356
+ * - Per-View caching (no shared global cache)
357
+ * - Client-side sorting (ignores server's ak/mv hints)
358
+ * - Local-first writes (future)
359
+ * - Independent reconnection per View
344
360
  */
345
361
 
346
362
  type SnapshotCallback = (snapshot: DataSnapshot, previousChildKey?: string | null) => void;
@@ -389,12 +405,18 @@ interface TransactionConditionOp {
389
405
  type TransactionOp = TransactionSetOp | TransactionUpdateOp | TransactionDeleteOp | TransactionConditionOp;
390
406
  /** Object syntax for transactions: path -> value (null = delete) */
391
407
  type TransactionObject = Record<string, unknown>;
408
+ type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
392
409
  declare class LarkDatabase {
393
410
  private _state;
394
411
  private _auth;
395
412
  private _databaseId;
396
413
  private _coordinatorUrl;
397
414
  private _volatilePaths;
415
+ private _connectionId;
416
+ private _connectOptions;
417
+ private _intentionalDisconnect;
418
+ private _reconnectAttempt;
419
+ private _reconnectTimer;
398
420
  private ws;
399
421
  private messageQueue;
400
422
  private subscriptionManager;
@@ -402,11 +424,20 @@ declare class LarkDatabase {
402
424
  private connectCallbacks;
403
425
  private disconnectCallbacks;
404
426
  private errorCallbacks;
427
+ private reconnectingCallbacks;
405
428
  constructor();
406
429
  /**
407
430
  * Whether the database is currently connected.
408
431
  */
409
432
  get connected(): boolean;
433
+ /**
434
+ * Whether the database is currently attempting to reconnect.
435
+ */
436
+ get reconnecting(): boolean;
437
+ /**
438
+ * Current connection state.
439
+ */
440
+ get state(): ConnectionState;
410
441
  /**
411
442
  * Current auth info, or null if not connected.
412
443
  */
@@ -442,15 +473,41 @@ declare class LarkDatabase {
442
473
  * @param options - Connection options (token, anonymous, coordinator URL)
443
474
  */
444
475
  connect(databaseId: string, options?: ConnectOptions): Promise<void>;
476
+ /**
477
+ * Internal connect implementation used by both initial connect and reconnect.
478
+ */
479
+ private performConnect;
445
480
  /**
446
481
  * Disconnect from the database.
447
482
  * This triggers onDisconnect hooks on the server.
448
483
  */
449
484
  disconnect(): Promise<void>;
450
485
  /**
451
- * Clean up connection state.
486
+ * Full cleanup - clears all state including subscriptions.
487
+ * Used for intentional disconnect.
488
+ */
489
+ private cleanupFull;
490
+ /**
491
+ * Partial cleanup - preserves state needed for reconnect.
492
+ * Used for unexpected disconnect.
493
+ */
494
+ private cleanupForReconnect;
495
+ /**
496
+ * Schedule a reconnection attempt with exponential backoff.
497
+ */
498
+ private scheduleReconnect;
499
+ /**
500
+ * Attempt to reconnect to the database.
452
501
  */
453
- private cleanup;
502
+ private attemptReconnect;
503
+ /**
504
+ * Restore subscriptions and retry pending writes after reconnect.
505
+ */
506
+ private restoreAfterReconnect;
507
+ /**
508
+ * Retry all pending writes after reconnect.
509
+ */
510
+ private retryPendingWrites;
454
511
  /**
455
512
  * Get a reference to a path in the database.
456
513
  */
@@ -512,14 +569,21 @@ declare class LarkDatabase {
512
569
  * Returns an unsubscribe function.
513
570
  */
514
571
  onError(callback: (error: Error) => void): () => void;
572
+ /**
573
+ * Register a callback for when reconnection attempts begin.
574
+ * This fires when an unexpected disconnect occurs and auto-reconnect starts.
575
+ * Returns an unsubscribe function.
576
+ */
577
+ onReconnecting(callback: () => void): () => void;
515
578
  private handleMessage;
516
579
  private handleClose;
517
580
  private handleError;
518
581
  private send;
519
582
  /**
520
583
  * @internal Send a set operation.
584
+ * Note: Priority is now part of the value (as .priority), not a separate field.
521
585
  */
522
- _sendSet(path: string, value: unknown, priority?: number | string): Promise<void>;
586
+ _sendSet(path: string, value: unknown): Promise<void>;
523
587
  /**
524
588
  * @internal Send an update operation.
525
589
  */
@@ -529,9 +593,30 @@ declare class LarkDatabase {
529
593
  */
530
594
  _sendDelete(path: string): Promise<void>;
531
595
  /**
532
- * @internal Send a push operation. Returns the generated key.
596
+ * @internal Send a volatile set operation (fire-and-forget).
597
+ *
598
+ * Volatile writes skip:
599
+ * - Recovery checks (volatile paths don't participate in recovery)
600
+ * - Request ID generation (no ack expected)
601
+ * - Pending write tracking (no retry on reconnect)
602
+ * - pw field (no dependency tracking)
603
+ *
604
+ * The write is applied optimistically to local cache for UI feedback,
605
+ * but we don't await server confirmation.
606
+ */
607
+ _sendVolatileSet(path: string, value: unknown): void;
608
+ /**
609
+ * @internal Send a volatile update operation (fire-and-forget).
610
+ */
611
+ _sendVolatileUpdate(path: string, values: Record<string, unknown>): void;
612
+ /**
613
+ * @internal Send a volatile delete operation (fire-and-forget).
614
+ */
615
+ _sendVolatileDelete(path: string): void;
616
+ /**
617
+ * Check if a path is a volatile path (high-frequency, fire-and-forget).
533
618
  */
534
- _sendPush(path: string, value: unknown): Promise<string>;
619
+ isVolatilePath(path: string): boolean;
535
620
  /**
536
621
  * @internal Send a once (read) operation.
537
622
  *
@@ -548,7 +633,7 @@ declare class LarkDatabase {
548
633
  /**
549
634
  * @internal Send an onDisconnect operation.
550
635
  */
551
- _sendOnDisconnect(path: string, action: string, value?: unknown, priority?: number | string): Promise<void>;
636
+ _sendOnDisconnect(path: string, action: string, value?: unknown): Promise<void>;
552
637
  /**
553
638
  * @internal Send a subscribe message to server.
554
639
  */
@@ -577,6 +662,18 @@ declare class LarkDatabase {
577
662
 
578
663
  /**
579
664
  * LarkError - custom error class for Lark operations.
665
+ *
666
+ * Standard error codes:
667
+ * - `permission_denied` - Security rules rejected operation
668
+ * - `invalid_data` - Malformed data
669
+ * - `not_found` - Path doesn't exist
670
+ * - `invalid_path` - Invalid path format
671
+ * - `timeout` - Request timed out
672
+ * - `not_connected` - Operation attempted while disconnected
673
+ * - `condition_failed` - Transaction condition check failed (CAS mismatch)
674
+ * - `max_retries_exceeded` - Optimistic transaction exceeded retry limit
675
+ * - `write_tainted` - Write rejected locally because it depended on a failed write
676
+ * - `view_recovering` - Write rejected because View is recovering from failed write
580
677
  */
581
678
  declare class LarkError extends Error {
582
679
  readonly code: string;
@@ -590,7 +687,7 @@ declare class LarkError extends Error {
590
687
  * pending writes until they are acknowledged by the server. On reconnect, pending
591
688
  * writes can be retried to ensure data consistency.
592
689
  */
593
- type WriteOperation = 'set' | 'update' | 'delete' | 'push' | 'transaction';
690
+ type WriteOperation = 'set' | 'update' | 'delete' | 'transaction';
594
691
  interface PendingWrite {
595
692
  oid: string;
596
693
  operation: WriteOperation;
@@ -659,20 +756,21 @@ declare function generatePushId(): string;
659
756
  * Volatile path matching utilities.
660
757
  *
661
758
  * Volatile paths are patterns where a wildcard matches exactly one path segment.
662
- * These paths use unreliable transport for better performance (UDP when available).
759
+ * These paths use unreliable transport for better performance (WebTransport datagrams when available).
663
760
  */
664
761
  /**
665
762
  * Check if a path matches any of the volatile path patterns.
666
763
  *
667
764
  * Pattern matching rules:
668
- * - Wildcard matches exactly one path segment (not zero, not multiple)
765
+ * - Wildcard matches exactly one path segment
669
766
  * - Patterns and paths are compared segment by segment
670
- * - Path must have the same number of segments as the pattern
767
+ * - If pattern is exhausted before path, it's still a match (descendant rule)
768
+ * - If path is exhausted before pattern, no match
671
769
  *
672
- * @param path - The path to check (e.g., "/players/abc/position")
770
+ * @param path - The path to check
673
771
  * @param patterns - Array of volatile patterns with wildcards
674
772
  * @returns true if the path matches any pattern
675
773
  */
676
774
  declare function isVolatilePath(path: string, patterns: string[] | null | undefined): boolean;
677
775
 
678
- export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, type MoveEntry, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };
776
+ export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ declare class OnDisconnect {
24
24
  cancel(): Promise<void>;
25
25
  /**
26
26
  * Set a value with priority when disconnected.
27
+ * Priority is injected as `.priority` into the value object.
27
28
  */
28
29
  setWithPriority(value: unknown, priority: number | string): Promise<void>;
29
30
  }
@@ -88,6 +89,9 @@ declare class DatabaseReference {
88
89
  child(path: string): DatabaseReference;
89
90
  /**
90
91
  * Set the data at this location, overwriting any existing data.
92
+ *
93
+ * For volatile paths (high-frequency updates), this is fire-and-forget
94
+ * and resolves immediately without waiting for server confirmation.
91
95
  */
92
96
  set(value: unknown): Promise<void>;
93
97
  /**
@@ -112,6 +116,8 @@ declare class DatabaseReference {
112
116
  update(values: Record<string, unknown>): Promise<void>;
113
117
  /**
114
118
  * Remove the data at this location.
119
+ *
120
+ * For volatile paths, this is fire-and-forget.
115
121
  */
116
122
  remove(): Promise<void>;
117
123
  /**
@@ -126,10 +132,12 @@ declare class DatabaseReference {
126
132
  push(value?: unknown): DatabaseReference | Promise<DatabaseReference>;
127
133
  /**
128
134
  * Set the data with a priority value for ordering.
135
+ * Priority is injected as `.priority` into the value object.
129
136
  */
130
137
  setWithPriority(value: unknown, priority: number | string): Promise<void>;
131
138
  /**
132
139
  * Set the priority of the data at this location.
140
+ * Fetches current value and sets it with the new priority.
133
141
  */
134
142
  setPriority(priority: number | string): Promise<void>;
135
143
  /**
@@ -224,6 +232,12 @@ declare class DatabaseReference {
224
232
  /**
225
233
  * DataSnapshot - an immutable snapshot of data at a location.
226
234
  * Received in event callbacks and from once() operations.
235
+ *
236
+ * Priority Handling:
237
+ * - Priority is stored as a regular child value `.priority` in the data
238
+ * - val() strips `.priority` from returned objects (so app code doesn't see it)
239
+ * - getPriority() reads from the data's `.priority` field
240
+ * - This matches Firebase behavior where priority is metadata, not user data
227
241
  */
228
242
 
229
243
  declare class DataSnapshot {
@@ -231,11 +245,9 @@ declare class DataSnapshot {
231
245
  private readonly _path;
232
246
  private readonly _db;
233
247
  private readonly _volatile;
234
- private readonly _priority;
235
248
  private readonly _serverTimestamp;
236
249
  constructor(data: unknown, path: string, db: LarkDatabase, options?: {
237
250
  volatile?: boolean;
238
- priority?: number | string | null;
239
251
  serverTimestamp?: number | null;
240
252
  });
241
253
  /**
@@ -247,7 +259,8 @@ declare class DataSnapshot {
247
259
  */
248
260
  get key(): string | null;
249
261
  /**
250
- * Get the raw data value.
262
+ * Get the data value, with `.priority` stripped if present.
263
+ * Priority is internal metadata and should not be visible to app code.
251
264
  */
252
265
  val(): unknown;
253
266
  /**
@@ -276,6 +289,7 @@ declare class DataSnapshot {
276
289
  forEach(callback: (child: DataSnapshot) => boolean | void): void;
277
290
  /**
278
291
  * Get the priority of the data at this location.
292
+ * Priority is stored as `.priority` in the data object.
279
293
  */
280
294
  getPriority(): number | string | null;
281
295
  /**
@@ -328,19 +342,21 @@ interface TxConditionOp {
328
342
  v: unknown;
329
343
  }
330
344
  type TxOperation = TxSetOp | TxUpdateOp | TxDeleteOp | TxConditionOp;
331
- interface MoveEntry {
332
- k: string;
333
- ak: string;
334
- }
335
345
 
336
346
  /**
337
- * SubscriptionManager - tracks active subscriptions and routes events to callbacks.
347
+ * View - represents a client's subscription to a database path.
338
348
  *
339
- * Handles the new delta-based protocol where server sends 'put' and 'patch' events.
340
- * Client generates child_added, child_changed, child_removed, child_moved events locally.
349
+ * Each View encapsulates all state for a single subscription:
350
+ * - Path and query parameters
351
+ * - Event callbacks by type
352
+ * - Ordered children (keys in sorted order, sorted by client)
353
+ * - Local cache of visible data
341
354
  *
342
- * Supports ordered queries: tracks child order from server's `k` (orderedKeys) and `ak` (afterKey)
343
- * fields, and fires child_moved when positions change via `mv` (moves) array.
355
+ * This mirrors the server's View concept, enabling:
356
+ * - Per-View caching (no shared global cache)
357
+ * - Client-side sorting (ignores server's ak/mv hints)
358
+ * - Local-first writes (future)
359
+ * - Independent reconnection per View
344
360
  */
345
361
 
346
362
  type SnapshotCallback = (snapshot: DataSnapshot, previousChildKey?: string | null) => void;
@@ -389,12 +405,18 @@ interface TransactionConditionOp {
389
405
  type TransactionOp = TransactionSetOp | TransactionUpdateOp | TransactionDeleteOp | TransactionConditionOp;
390
406
  /** Object syntax for transactions: path -> value (null = delete) */
391
407
  type TransactionObject = Record<string, unknown>;
408
+ type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
392
409
  declare class LarkDatabase {
393
410
  private _state;
394
411
  private _auth;
395
412
  private _databaseId;
396
413
  private _coordinatorUrl;
397
414
  private _volatilePaths;
415
+ private _connectionId;
416
+ private _connectOptions;
417
+ private _intentionalDisconnect;
418
+ private _reconnectAttempt;
419
+ private _reconnectTimer;
398
420
  private ws;
399
421
  private messageQueue;
400
422
  private subscriptionManager;
@@ -402,11 +424,20 @@ declare class LarkDatabase {
402
424
  private connectCallbacks;
403
425
  private disconnectCallbacks;
404
426
  private errorCallbacks;
427
+ private reconnectingCallbacks;
405
428
  constructor();
406
429
  /**
407
430
  * Whether the database is currently connected.
408
431
  */
409
432
  get connected(): boolean;
433
+ /**
434
+ * Whether the database is currently attempting to reconnect.
435
+ */
436
+ get reconnecting(): boolean;
437
+ /**
438
+ * Current connection state.
439
+ */
440
+ get state(): ConnectionState;
410
441
  /**
411
442
  * Current auth info, or null if not connected.
412
443
  */
@@ -442,15 +473,41 @@ declare class LarkDatabase {
442
473
  * @param options - Connection options (token, anonymous, coordinator URL)
443
474
  */
444
475
  connect(databaseId: string, options?: ConnectOptions): Promise<void>;
476
+ /**
477
+ * Internal connect implementation used by both initial connect and reconnect.
478
+ */
479
+ private performConnect;
445
480
  /**
446
481
  * Disconnect from the database.
447
482
  * This triggers onDisconnect hooks on the server.
448
483
  */
449
484
  disconnect(): Promise<void>;
450
485
  /**
451
- * Clean up connection state.
486
+ * Full cleanup - clears all state including subscriptions.
487
+ * Used for intentional disconnect.
488
+ */
489
+ private cleanupFull;
490
+ /**
491
+ * Partial cleanup - preserves state needed for reconnect.
492
+ * Used for unexpected disconnect.
493
+ */
494
+ private cleanupForReconnect;
495
+ /**
496
+ * Schedule a reconnection attempt with exponential backoff.
497
+ */
498
+ private scheduleReconnect;
499
+ /**
500
+ * Attempt to reconnect to the database.
452
501
  */
453
- private cleanup;
502
+ private attemptReconnect;
503
+ /**
504
+ * Restore subscriptions and retry pending writes after reconnect.
505
+ */
506
+ private restoreAfterReconnect;
507
+ /**
508
+ * Retry all pending writes after reconnect.
509
+ */
510
+ private retryPendingWrites;
454
511
  /**
455
512
  * Get a reference to a path in the database.
456
513
  */
@@ -512,14 +569,21 @@ declare class LarkDatabase {
512
569
  * Returns an unsubscribe function.
513
570
  */
514
571
  onError(callback: (error: Error) => void): () => void;
572
+ /**
573
+ * Register a callback for when reconnection attempts begin.
574
+ * This fires when an unexpected disconnect occurs and auto-reconnect starts.
575
+ * Returns an unsubscribe function.
576
+ */
577
+ onReconnecting(callback: () => void): () => void;
515
578
  private handleMessage;
516
579
  private handleClose;
517
580
  private handleError;
518
581
  private send;
519
582
  /**
520
583
  * @internal Send a set operation.
584
+ * Note: Priority is now part of the value (as .priority), not a separate field.
521
585
  */
522
- _sendSet(path: string, value: unknown, priority?: number | string): Promise<void>;
586
+ _sendSet(path: string, value: unknown): Promise<void>;
523
587
  /**
524
588
  * @internal Send an update operation.
525
589
  */
@@ -529,9 +593,30 @@ declare class LarkDatabase {
529
593
  */
530
594
  _sendDelete(path: string): Promise<void>;
531
595
  /**
532
- * @internal Send a push operation. Returns the generated key.
596
+ * @internal Send a volatile set operation (fire-and-forget).
597
+ *
598
+ * Volatile writes skip:
599
+ * - Recovery checks (volatile paths don't participate in recovery)
600
+ * - Request ID generation (no ack expected)
601
+ * - Pending write tracking (no retry on reconnect)
602
+ * - pw field (no dependency tracking)
603
+ *
604
+ * The write is applied optimistically to local cache for UI feedback,
605
+ * but we don't await server confirmation.
606
+ */
607
+ _sendVolatileSet(path: string, value: unknown): void;
608
+ /**
609
+ * @internal Send a volatile update operation (fire-and-forget).
610
+ */
611
+ _sendVolatileUpdate(path: string, values: Record<string, unknown>): void;
612
+ /**
613
+ * @internal Send a volatile delete operation (fire-and-forget).
614
+ */
615
+ _sendVolatileDelete(path: string): void;
616
+ /**
617
+ * Check if a path is a volatile path (high-frequency, fire-and-forget).
533
618
  */
534
- _sendPush(path: string, value: unknown): Promise<string>;
619
+ isVolatilePath(path: string): boolean;
535
620
  /**
536
621
  * @internal Send a once (read) operation.
537
622
  *
@@ -548,7 +633,7 @@ declare class LarkDatabase {
548
633
  /**
549
634
  * @internal Send an onDisconnect operation.
550
635
  */
551
- _sendOnDisconnect(path: string, action: string, value?: unknown, priority?: number | string): Promise<void>;
636
+ _sendOnDisconnect(path: string, action: string, value?: unknown): Promise<void>;
552
637
  /**
553
638
  * @internal Send a subscribe message to server.
554
639
  */
@@ -577,6 +662,18 @@ declare class LarkDatabase {
577
662
 
578
663
  /**
579
664
  * LarkError - custom error class for Lark operations.
665
+ *
666
+ * Standard error codes:
667
+ * - `permission_denied` - Security rules rejected operation
668
+ * - `invalid_data` - Malformed data
669
+ * - `not_found` - Path doesn't exist
670
+ * - `invalid_path` - Invalid path format
671
+ * - `timeout` - Request timed out
672
+ * - `not_connected` - Operation attempted while disconnected
673
+ * - `condition_failed` - Transaction condition check failed (CAS mismatch)
674
+ * - `max_retries_exceeded` - Optimistic transaction exceeded retry limit
675
+ * - `write_tainted` - Write rejected locally because it depended on a failed write
676
+ * - `view_recovering` - Write rejected because View is recovering from failed write
580
677
  */
581
678
  declare class LarkError extends Error {
582
679
  readonly code: string;
@@ -590,7 +687,7 @@ declare class LarkError extends Error {
590
687
  * pending writes until they are acknowledged by the server. On reconnect, pending
591
688
  * writes can be retried to ensure data consistency.
592
689
  */
593
- type WriteOperation = 'set' | 'update' | 'delete' | 'push' | 'transaction';
690
+ type WriteOperation = 'set' | 'update' | 'delete' | 'transaction';
594
691
  interface PendingWrite {
595
692
  oid: string;
596
693
  operation: WriteOperation;
@@ -659,20 +756,21 @@ declare function generatePushId(): string;
659
756
  * Volatile path matching utilities.
660
757
  *
661
758
  * Volatile paths are patterns where a wildcard matches exactly one path segment.
662
- * These paths use unreliable transport for better performance (UDP when available).
759
+ * These paths use unreliable transport for better performance (WebTransport datagrams when available).
663
760
  */
664
761
  /**
665
762
  * Check if a path matches any of the volatile path patterns.
666
763
  *
667
764
  * Pattern matching rules:
668
- * - Wildcard matches exactly one path segment (not zero, not multiple)
765
+ * - Wildcard matches exactly one path segment
669
766
  * - Patterns and paths are compared segment by segment
670
- * - Path must have the same number of segments as the pattern
767
+ * - If pattern is exhausted before path, it's still a match (descendant rule)
768
+ * - If path is exhausted before pattern, no match
671
769
  *
672
- * @param path - The path to check (e.g., "/players/abc/position")
770
+ * @param path - The path to check
673
771
  * @param patterns - Array of volatile patterns with wildcards
674
772
  * @returns true if the path matches any pattern
675
773
  */
676
774
  declare function isVolatilePath(path: string, patterns: string[] | null | undefined): boolean;
677
775
 
678
- export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, type MoveEntry, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };
776
+ export { type AuthInfo, type ConnectOptions, DataSnapshot, DatabaseReference, type EventType, LarkDatabase, LarkError, OnDisconnect, type PendingWrite, PendingWriteManager, type QueryParams, type QueryState, type SnapshotCallback$1 as SnapshotCallback, type TransactionConditionOp, type TransactionDeleteOp, type TransactionObject, type TransactionOp, type TransactionResult, type TransactionSetOp, type TransactionUpdateOp, type WriteOperation, generatePushId, isVolatilePath };