js-bao-wss-client 1.3.7 → 1.3.9
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/JsBaoClient.d.ts +550 -45
- package/dist/JsBaoClient.d.ts.map +1 -1
- package/dist/JsBaoClient.js +455 -18
- package/dist/JsBaoClient.js.map +1 -1
- package/dist/api/cacheFacade.d.ts +38 -0
- package/dist/api/cacheFacade.d.ts.map +1 -1
- package/dist/api/cacheFacade.js +9 -0
- package/dist/api/cacheFacade.js.map +1 -1
- package/dist/api/collectionsApi.d.ts +102 -17
- package/dist/api/collectionsApi.d.ts.map +1 -1
- package/dist/api/collectionsApi.js +72 -5
- package/dist/api/collectionsApi.js.map +1 -1
- package/dist/api/databasesApi.d.ts +171 -34
- package/dist/api/databasesApi.d.ts.map +1 -1
- package/dist/api/databasesApi.js +109 -7
- package/dist/api/databasesApi.js.map +1 -1
- package/dist/api/documentsApi.d.ts +445 -66
- package/dist/api/documentsApi.d.ts.map +1 -1
- package/dist/api/documentsApi.js +331 -22
- package/dist/api/documentsApi.js.map +1 -1
- package/dist/api/geminiApi.d.ts +30 -0
- package/dist/api/geminiApi.d.ts.map +1 -1
- package/dist/api/geminiApi.js +30 -0
- package/dist/api/geminiApi.js.map +1 -1
- package/dist/api/groupTypeConfigsApi.d.ts +34 -9
- package/dist/api/groupTypeConfigsApi.d.ts.map +1 -1
- package/dist/api/groupTypeConfigsApi.js +18 -0
- package/dist/api/groupTypeConfigsApi.js.map +1 -1
- package/dist/api/groupsApi.d.ts +91 -20
- package/dist/api/groupsApi.d.ts.map +1 -1
- package/dist/api/groupsApi.js +58 -1
- package/dist/api/groupsApi.js.map +1 -1
- package/dist/api/llmApi.d.ts +17 -0
- package/dist/api/llmApi.d.ts.map +1 -1
- package/dist/api/llmApi.js +17 -0
- package/dist/api/llmApi.js.map +1 -1
- package/dist/api/meApi.d.ts +31 -14
- package/dist/api/meApi.d.ts.map +1 -1
- package/dist/api/meApi.js +13 -4
- package/dist/api/meApi.js.map +1 -1
- package/dist/api/ruleSetsApi.d.ts +101 -44
- package/dist/api/ruleSetsApi.d.ts.map +1 -1
- package/dist/api/ruleSetsApi.js +31 -0
- package/dist/api/ruleSetsApi.js.map +1 -1
- package/dist/api/sessionApi.d.ts +1 -0
- package/dist/api/sessionApi.d.ts.map +1 -1
- package/dist/api/sessionApi.js +1 -0
- package/dist/api/sessionApi.js.map +1 -1
- package/dist/api/usersApi.d.ts +19 -6
- package/dist/api/usersApi.d.ts.map +1 -1
- package/dist/api/usersApi.js +5 -0
- package/dist/api/usersApi.js.map +1 -1
- package/dist/browser.umd.js +1157 -58
- package/dist/browser.umd.js.map +1 -1
- package/dist/internal/analyticsQueue.d.ts +7 -1
- package/dist/internal/analyticsQueue.d.ts.map +1 -1
- package/dist/internal/analyticsQueue.js +9 -2
- package/dist/internal/analyticsQueue.js.map +1 -1
- package/dist/internal/blobManager.d.ts +76 -16
- package/dist/internal/blobManager.d.ts.map +1 -1
- package/dist/internal/blobManager.js.map +1 -1
- package/package.json +1 -1
package/dist/JsBaoClient.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { BlobManager } from "./internal/blobManager";
|
|
|
8
8
|
import { type AnalyticsEventInput } from "./internal/analyticsQueue";
|
|
9
9
|
import { type RequestOptions } from "./internal/httpClient";
|
|
10
10
|
import { type DocumentPermission as DocumentAccessLevel, type LocalDocumentEntry, type LocalMetadataEntry, type DocumentDebugSnapshot } from "./internal/documentManager";
|
|
11
|
-
import { DocumentsAPI, DocumentContext, type DocumentInfo, type ResolveAliasParams } from "./api/documentsApi";
|
|
11
|
+
import { DocumentsAPI, DocumentContext, type DocumentInfo, type ResolveAliasParams, type CreateDocumentOptions } from "./api/documentsApi";
|
|
12
12
|
import { type CacheFacade } from "./api/cacheFacade";
|
|
13
13
|
import { MeAPI } from "./api/meApi";
|
|
14
14
|
import { SessionAPI } from "./api/sessionApi";
|
|
@@ -24,12 +24,12 @@ export { JsBaoError, isJsBaoError } from "./errors";
|
|
|
24
24
|
export type { JsBaoErrorCode } from "./errors";
|
|
25
25
|
export { AuthError, AUTH_CODES } from "./internal/authController";
|
|
26
26
|
export type { AuthCode } from "./internal/authController";
|
|
27
|
-
export type { DocumentInfo, DocumentPermissionEntry, DocumentInvitation, DocumentInvitationResponse, DocumentAccessResult, DocumentGroupPermissionEntry, } from "./api/documentsApi";
|
|
27
|
+
export type { DocumentInfo, DocumentPermissionEntry, DocumentInvitation, DocumentInvitationResponse, DocumentAccessResult, DocumentGroupPermissionEntry, DocumentAliasInfo, DocumentAliasScope, } from "./api/documentsApi";
|
|
28
28
|
export type { UserProfile } from "./api/meApi";
|
|
29
29
|
export type { SessionInfo } from "./api/sessionApi";
|
|
30
30
|
export type { BasicUserInfo } from "./api/usersApi";
|
|
31
31
|
export type { DatabaseInfo, DatabasePermissionEntry, DatabaseOwnershipTransferResult, DatabaseOperationInfo, CsvImportOptions, CsvImportProgress, CsvImportResult, } from "./api/databasesApi";
|
|
32
|
-
export type { GroupInfo, GroupMemberInfo, GroupMembershipInfo, GroupDocumentInfo, } from "./api/groupsApi";
|
|
32
|
+
export type { GroupInfo, GroupMemberInfo, GroupMembershipInfo, GroupDocumentInfo, PaginatedResult, } from "./api/groupsApi";
|
|
33
33
|
export type { CollectionInfo, CollectionDocumentInfo, CollectionGroupPermissionInfo, CollectionMemberInfo, CollectionAccessInfo, DocumentCollectionInfo, } from "./api/collectionsApi";
|
|
34
34
|
export type { RuleSetInfo, RuleSetSchema, RuleSetTestResult, RuleSetDebugResult, TraceEntry, TriggerDefInfo, ModelRulesInfo, } from "./api/ruleSetsApi";
|
|
35
35
|
export type { GroupTypeConfigInfo } from "./api/groupTypeConfigsApi";
|
|
@@ -37,6 +37,19 @@ export type { DoDb, DOClientEngine, ModelIdentifier, ModelFieldInfo } from "js-b
|
|
|
37
37
|
export type { CacheFacade } from "./api/cacheFacade";
|
|
38
38
|
export type { ReasoningOptions, LlmChatOptions } from "./api/llmApi";
|
|
39
39
|
export type { AnalyticsEventInput } from "./internal/analyticsQueue";
|
|
40
|
+
export { ANALYTICS_UNAUTHENTICATED_USER } from "./internal/analyticsQueue";
|
|
41
|
+
export type { DocumentBlobContext, BlobUploadSourceOptions, BlobUploadResult, BlobListResult, BlobUploadStatus, BlobReadOptions, BlobPrefetchOptions, BlobProxyUrlOptions, BlobDisposition, } from "./internal/blobManager";
|
|
42
|
+
export type { DocumentsAPI, DocumentContext, DocumentAliasesAPI } from "./api/documentsApi";
|
|
43
|
+
export type { DatabasesAPI } from "./api/databasesApi";
|
|
44
|
+
export type { CollectionsAPI } from "./api/collectionsApi";
|
|
45
|
+
export type { GeminiAPI } from "./api/geminiApi";
|
|
46
|
+
export type { LlmAPI } from "./api/llmApi";
|
|
47
|
+
export type { MeAPI } from "./api/meApi";
|
|
48
|
+
export type { SessionAPI } from "./api/sessionApi";
|
|
49
|
+
export type { UsersAPI } from "./api/usersApi";
|
|
50
|
+
export type { GroupsAPI } from "./api/groupsApi";
|
|
51
|
+
export type { RuleSetsAPI } from "./api/ruleSetsApi";
|
|
52
|
+
export type { GroupTypeConfigsAPI } from "./api/groupTypeConfigsApi";
|
|
40
53
|
export interface AnalyticsAutoEventsOptions {
|
|
41
54
|
dailyAuth?: boolean;
|
|
42
55
|
returnActive?: boolean;
|
|
@@ -518,6 +531,67 @@ export interface WorkflowDefineOptions {
|
|
|
518
531
|
/** Handler to apply workflow results to the document. Called automatically when this workflow completes with needsApply. */
|
|
519
532
|
onApply: WorkflowApplyHandler;
|
|
520
533
|
}
|
|
534
|
+
/** Options for {@link JsBaoClient.waitForUserId}. */
|
|
535
|
+
export interface WaitForUserIdOptions {
|
|
536
|
+
/** Maximum time to wait before rejecting (ms). */
|
|
537
|
+
timeoutMs?: number;
|
|
538
|
+
}
|
|
539
|
+
/** Options for {@link JsBaoClient.waitForAuthReady}. */
|
|
540
|
+
export interface WaitForAuthReadyOptions {
|
|
541
|
+
/** Maximum time to wait before rejecting (ms). */
|
|
542
|
+
timeoutMs?: number;
|
|
543
|
+
}
|
|
544
|
+
/** Options for {@link JsBaoClient.enableOfflineAccess}. */
|
|
545
|
+
export interface EnableOfflineAccessOptions {
|
|
546
|
+
/** If true, attempts passkey-based largeBlob storage before falling back to PIN. */
|
|
547
|
+
preferBiometric?: boolean;
|
|
548
|
+
/** If true, falls back to PIN-based offline access when passkey largeBlob is unavailable. */
|
|
549
|
+
allowPinFallback?: boolean;
|
|
550
|
+
/** Number of days the offline grant remains valid before requiring online re-authentication. */
|
|
551
|
+
ttlDays?: number;
|
|
552
|
+
/** Controls whether offline data survives sign-out. */
|
|
553
|
+
retention?: {
|
|
554
|
+
/** If true, keeps offline data when the user logs out. */
|
|
555
|
+
preserveOnSignOut?: boolean;
|
|
556
|
+
};
|
|
557
|
+
/** Async function that prompts the user for a PIN and returns it. */
|
|
558
|
+
pinProvider?: () => Promise<string>;
|
|
559
|
+
}
|
|
560
|
+
/** Options for {@link JsBaoClient.revokeOfflineGrant}. */
|
|
561
|
+
export interface RevokeOfflineGrantOptions {
|
|
562
|
+
/** If true, also deletes all locally stored document data. */
|
|
563
|
+
wipeLocal?: boolean;
|
|
564
|
+
}
|
|
565
|
+
/** Options for {@link JsBaoClient.logout}. */
|
|
566
|
+
export interface LogoutOptions {
|
|
567
|
+
/** URL to navigate to after logout completes (browser only). */
|
|
568
|
+
redirectTo?: string;
|
|
569
|
+
/** If true, deletes all locally cached document data and KV cache. */
|
|
570
|
+
wipeLocal?: boolean;
|
|
571
|
+
/** If true, revokes the stored offline access grant. */
|
|
572
|
+
revokeOffline?: boolean;
|
|
573
|
+
/** If false, preserves the in-memory offline identity after logout (default true). */
|
|
574
|
+
clearOfflineIdentity?: boolean;
|
|
575
|
+
/** If true, awaits WebSocket disconnection before resolving; set to false to avoid blocking UI (default false). */
|
|
576
|
+
waitForDisconnect?: boolean;
|
|
577
|
+
}
|
|
578
|
+
/** Options for {@link JsBaoClient.goOffline}. */
|
|
579
|
+
export interface GoOfflineOptions {
|
|
580
|
+
/** Human-readable reason for going offline (stored in network status). */
|
|
581
|
+
reason?: string;
|
|
582
|
+
}
|
|
583
|
+
/** Options for {@link JsBaoClient.listLocalDocumentsUnified}. */
|
|
584
|
+
export interface ListLocalDocumentsOptions {
|
|
585
|
+
/** If true, includes the user's root document in the results. */
|
|
586
|
+
includeRoot?: boolean;
|
|
587
|
+
/** If true, only returns documents that have local data stored. */
|
|
588
|
+
onlyWithLocalData?: boolean;
|
|
589
|
+
}
|
|
590
|
+
/** Options for {@link JsBaoClient.evictAllLocal}. */
|
|
591
|
+
export interface EvictAllLocalOptions {
|
|
592
|
+
/** If true, only evicts documents that are fully synced with the server. */
|
|
593
|
+
onlySynced?: boolean;
|
|
594
|
+
}
|
|
521
595
|
export interface JsBaoEvents {
|
|
522
596
|
error: {
|
|
523
597
|
error: any;
|
|
@@ -574,6 +648,7 @@ export interface JsBaoEvents {
|
|
|
574
648
|
}
|
|
575
649
|
export interface AnalyticsClient {
|
|
576
650
|
logEvent(event: AnalyticsEventInput): void;
|
|
651
|
+
logSnapshot(context?: Record<string, any>): void;
|
|
577
652
|
flush(): void;
|
|
578
653
|
setPlanOverride(plan: string | null | undefined): void;
|
|
579
654
|
setAppVersionOverride(version: string | null | undefined): void;
|
|
@@ -624,6 +699,8 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
624
699
|
private lastOnlineAt;
|
|
625
700
|
private lastConnectionError;
|
|
626
701
|
private lastEmittedPermission;
|
|
702
|
+
/** Analytics client for tracking events and metrics.
|
|
703
|
+
* @group Sub-APIs */
|
|
627
704
|
readonly analytics: AnalyticsClient;
|
|
628
705
|
private analyticsQueue;
|
|
629
706
|
private analyticsCleanup?;
|
|
@@ -652,6 +729,8 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
652
729
|
private buildLogged;
|
|
653
730
|
private retentionPolicy;
|
|
654
731
|
private kvCache;
|
|
732
|
+
/** Key-value cache facade backed by IndexedDB.
|
|
733
|
+
* @group Sub-APIs */
|
|
655
734
|
cache: CacheFacade;
|
|
656
735
|
private authPersistEnabled;
|
|
657
736
|
private authStorageNamespace;
|
|
@@ -689,20 +768,51 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
689
768
|
private serviceWorkerBridgeLastToken;
|
|
690
769
|
private pendingSelfRemovalDocs;
|
|
691
770
|
private pendingSelfRemovalTimers;
|
|
771
|
+
/** Sub-API for managing documents (list, create, get, delete, share).
|
|
772
|
+
* @group Sub-APIs */
|
|
692
773
|
documents: DocumentsAPI;
|
|
774
|
+
/** Get a scoped API for a specific document
|
|
775
|
+
* @param documentId - The document to scope operations to
|
|
776
|
+
* @group Documents */
|
|
693
777
|
document(documentId: string): DocumentContext;
|
|
778
|
+
/** Sub-API for the current authenticated user's profile and preferences.
|
|
779
|
+
* @group Sub-APIs */
|
|
694
780
|
me: MeAPI;
|
|
781
|
+
/** Sub-API for session management (sign in, sign out, token refresh).
|
|
782
|
+
* @group Sub-APIs */
|
|
695
783
|
session: SessionAPI;
|
|
784
|
+
/** Sub-API for LLM (large language model) operations.
|
|
785
|
+
* @group Sub-APIs */
|
|
696
786
|
llm: LlmAPI;
|
|
787
|
+
/** Sub-API for Gemini model operations.
|
|
788
|
+
* @group Sub-APIs */
|
|
697
789
|
gemini: GeminiAPI;
|
|
790
|
+
/** Sub-API for managing app users.
|
|
791
|
+
* @group Sub-APIs */
|
|
698
792
|
users: UsersAPI;
|
|
793
|
+
/** Sub-API for managing databases.
|
|
794
|
+
* @group Sub-APIs */
|
|
699
795
|
databases: DatabasesAPI;
|
|
796
|
+
/** Sub-API for managing groups and memberships.
|
|
797
|
+
* @group Sub-APIs */
|
|
700
798
|
groups: GroupsAPI;
|
|
799
|
+
/** Sub-API for managing document collections.
|
|
800
|
+
* @group Sub-APIs */
|
|
701
801
|
collections: CollectionsAPI;
|
|
802
|
+
/** Sub-API for managing rule sets.
|
|
803
|
+
* @group Sub-APIs */
|
|
702
804
|
ruleSets: RuleSetsAPI;
|
|
805
|
+
/** Sub-API for managing group type configurations.
|
|
806
|
+
* @group Sub-APIs */
|
|
703
807
|
groupTypeConfigs: GroupTypeConfigsAPI;
|
|
808
|
+
/** Sub-API for managing third-party integrations.
|
|
809
|
+
* @group Sub-APIs */
|
|
704
810
|
integrations: IntegrationsAPI;
|
|
811
|
+
/** Sub-API for managing and executing workflows.
|
|
812
|
+
* @group Sub-APIs */
|
|
705
813
|
workflows: WorkflowsAPI;
|
|
814
|
+
/** Sub-API for managing and executing prompts.
|
|
815
|
+
* @group Sub-APIs */
|
|
706
816
|
prompts: PromptsAPI;
|
|
707
817
|
private workflowApplyHandlers;
|
|
708
818
|
private httpClient;
|
|
@@ -710,7 +820,13 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
710
820
|
private controllerPreviousToken;
|
|
711
821
|
private controllerTokenCause;
|
|
712
822
|
private normalizeRefreshProxyOption;
|
|
823
|
+
/** Mark a document as pending self-removal to suppress duplicate server delete events.
|
|
824
|
+
* @param documentId - The document being removed by the current user
|
|
825
|
+
* @group Documents */
|
|
713
826
|
markSelfRemovalPending(documentId: string): void;
|
|
827
|
+
/** Clear the self-removal pending flag for a document.
|
|
828
|
+
* @param documentId - The document to clear the pending self-removal flag for
|
|
829
|
+
* @group Documents */
|
|
714
830
|
clearSelfRemovalPending(documentId: string): void;
|
|
715
831
|
private normalizeProxyBase;
|
|
716
832
|
private detectInitialOfflineState;
|
|
@@ -728,14 +844,34 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
728
844
|
private get wsLastCloseInitiator();
|
|
729
845
|
private set wsLastCloseInitiator(value);
|
|
730
846
|
constructor(options: JsBaoClientOptions);
|
|
847
|
+
/** Subscribe to a client event.
|
|
848
|
+
* @param type - The event name to listen for
|
|
849
|
+
* @param f - Callback invoked when the event fires
|
|
850
|
+
* @group Events */
|
|
731
851
|
on<K extends keyof JsBaoEvents>(type: K, f: (payload: JsBaoEvents[K]) => void): void;
|
|
852
|
+
/** Unsubscribe from a client event.
|
|
853
|
+
* @param type - The event name to stop listening for
|
|
854
|
+
* @param f - The callback to remove
|
|
855
|
+
* @group Events */
|
|
732
856
|
off<K extends keyof JsBaoEvents>(type: K, f: (payload: JsBaoEvents[K]) => void): void;
|
|
857
|
+
/** Emit a client event.
|
|
858
|
+
* @param type - The event name to emit
|
|
859
|
+
* @param args - The event payload wrapped in an array
|
|
860
|
+
* @group Events */
|
|
733
861
|
emit<K extends keyof JsBaoEvents>(type: K, args: [JsBaoEvents[K]]): void;
|
|
734
862
|
private isWebSocketOpen;
|
|
735
863
|
private _logWsState;
|
|
736
864
|
private _closeWs;
|
|
737
865
|
/**
|
|
738
866
|
* Exchange an OAuth authorization code for an access token without constructing a client instance.
|
|
867
|
+
* @param params - OAuth exchange parameters
|
|
868
|
+
* @param params.apiUrl - The API server base URL
|
|
869
|
+
* @param params.appId - The application ID
|
|
870
|
+
* @param params.code - The authorization code received from the OAuth provider
|
|
871
|
+
* @param params.state - The state parameter for CSRF verification
|
|
872
|
+
* @param params.refreshProxyBaseUrl - Optional proxy URL for refresh token cookie handling
|
|
873
|
+
* @param params.refreshProxyCookieMaxAgeSeconds - Max age in seconds for the refresh proxy cookie
|
|
874
|
+
* @group Authentication
|
|
739
875
|
*/
|
|
740
876
|
static exchangeOAuthCode(params: {
|
|
741
877
|
apiUrl: string;
|
|
@@ -746,13 +882,34 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
746
882
|
refreshProxyCookieMaxAgeSeconds?: number;
|
|
747
883
|
}): Promise<string>;
|
|
748
884
|
private _buildServerDocumentsContext;
|
|
885
|
+
/** Sync document metadata with the server.
|
|
886
|
+
* @param options - Controls the scope and behavior of the metadata sync
|
|
887
|
+
* @group Offline & Sync */
|
|
749
888
|
syncMetadata(options?: SyncMetadataOptions): Promise<void>;
|
|
889
|
+
/** Sync metadata for a specific document.
|
|
890
|
+
* @param documentId - The document whose metadata to sync
|
|
891
|
+
* @param options - Optional sync behavior controls
|
|
892
|
+
* @param options.payload - Pre-fetched metadata payload to merge instead of fetching from server
|
|
893
|
+
* @param options.payloadType - Whether the payload contains full metadata objects or just IDs
|
|
894
|
+
* @param options.background - If true, silently swallows errors instead of throwing
|
|
895
|
+
* @param options.shouldRetain - Predicate controlling which documents are kept in the local cache
|
|
896
|
+
* @group Offline & Sync */
|
|
750
897
|
syncMetadataForDocument(documentId: string, options?: {
|
|
751
898
|
payload?: any;
|
|
752
899
|
payloadType?: "full" | "ids";
|
|
753
900
|
background?: boolean;
|
|
754
901
|
shouldRetain?: (docId: string) => boolean;
|
|
755
902
|
}): Promise<void>;
|
|
903
|
+
/** Update local metadata cache with server document data.
|
|
904
|
+
* @param items - Array of server document records to merge into the local cache
|
|
905
|
+
* @param options - Controls how the merge is performed
|
|
906
|
+
* @param options.scope - Whether to replace all metadata or merge a single document
|
|
907
|
+
* @param options.payloadType - Whether items contain full metadata or just document IDs
|
|
908
|
+
* @param options.authoritative - If true, evicts local entries not present in the server list
|
|
909
|
+
* @param options.retainIds - Document IDs to keep locally even if missing from the server list
|
|
910
|
+
* @param options.targetDocumentId - Specific document ID to update when scope is "single"
|
|
911
|
+
* @param options.shouldRetain - Predicate controlling which documents are kept during eviction
|
|
912
|
+
* @group Offline & Sync */
|
|
756
913
|
upsertServerDocuments(items: Array<{
|
|
757
914
|
documentId: string;
|
|
758
915
|
title?: string;
|
|
@@ -767,13 +924,32 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
767
924
|
targetDocumentId?: string;
|
|
768
925
|
shouldRetain?: (documentId: string) => boolean;
|
|
769
926
|
}): void;
|
|
927
|
+
/** Get the API base URL.
|
|
928
|
+
* @group Configuration */
|
|
770
929
|
getApiUrl(): string;
|
|
930
|
+
/** Get the app ID.
|
|
931
|
+
* @group Configuration */
|
|
771
932
|
getAppId(): string;
|
|
933
|
+
/** Get the blob manager for direct blob operations.
|
|
934
|
+
* @group Blobs */
|
|
772
935
|
getBlobManager(): BlobManager;
|
|
936
|
+
/** Set the maximum number of concurrent blob uploads.
|
|
937
|
+
* @param value - Maximum number of blob uploads that can run in parallel
|
|
938
|
+
* @group Blobs */
|
|
773
939
|
setBlobUploadConcurrency(value: number): void;
|
|
940
|
+
/** Get the current blob upload concurrency limit.
|
|
941
|
+
* @group Blobs */
|
|
774
942
|
getBlobUploadConcurrency(): number;
|
|
943
|
+
/** Mark a document's metadata as deleted locally.
|
|
944
|
+
* @param documentId - The document to mark as deleted
|
|
945
|
+
* @group Documents */
|
|
775
946
|
markMetadataDeleted(documentId: string): number | undefined;
|
|
947
|
+
/** Check if a document's metadata has been marked as deleted.
|
|
948
|
+
* @param documentId - The document to check
|
|
949
|
+
* @group Documents */
|
|
776
950
|
isMetadataDeleted(documentId: string): boolean;
|
|
951
|
+
/** Get the global admin app ID.
|
|
952
|
+
* @group Configuration */
|
|
777
953
|
getGlobalAdminAppId(): string;
|
|
778
954
|
private initializeJsBao;
|
|
779
955
|
private _syncKvUserId;
|
|
@@ -791,8 +967,18 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
791
967
|
private initializeStorageProvider;
|
|
792
968
|
private _doInitializeStorageProvider;
|
|
793
969
|
private runAuthBootstrap;
|
|
970
|
+
/**
|
|
971
|
+
* Wait for the initial authentication bootstrap to complete (token refresh, offline unlock, etc.).
|
|
972
|
+
* @group Authentication
|
|
973
|
+
*/
|
|
794
974
|
waitForAuthBootstrap(): Promise<void>;
|
|
795
975
|
private initialize;
|
|
976
|
+
/** Make an authenticated HTTP request to the API server.
|
|
977
|
+
* @param method - HTTP method (GET, POST, PUT, DELETE, etc.)
|
|
978
|
+
* @param path - API endpoint path relative to the app base URL
|
|
979
|
+
* @param data - Request body payload (sent as JSON)
|
|
980
|
+
* @param options - Additional request options (headers, timeout, etc.)
|
|
981
|
+
* @group Connection */
|
|
796
982
|
makeRequest(method: string, path: string, data?: any, options?: RequestOptions): Promise<any>;
|
|
797
983
|
private makeRawRequest;
|
|
798
984
|
private callIntegration;
|
|
@@ -810,29 +996,67 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
810
996
|
private defineWorkflow;
|
|
811
997
|
private handleWorkflowApply;
|
|
812
998
|
private executePrompt;
|
|
999
|
+
/** Check if the current user has read-only access to a document.
|
|
1000
|
+
* @param documentId - The document to check
|
|
1001
|
+
* @group Documents */
|
|
813
1002
|
isDocumentReadOnly(documentId: string): boolean;
|
|
1003
|
+
/** Get the current user's permission level for a document.
|
|
1004
|
+
* @param documentId - The document to check permissions for
|
|
1005
|
+
* @group Documents */
|
|
814
1006
|
getDocumentPermission(documentId: string): DocumentAccessLevel | null;
|
|
1007
|
+
/**
|
|
1008
|
+
* Get the root document ID for the authenticated user.
|
|
1009
|
+
* @group Authentication
|
|
1010
|
+
*/
|
|
815
1011
|
getRootDocId(): string | null;
|
|
1012
|
+
/**
|
|
1013
|
+
* Get the current authenticated user's ID.
|
|
1014
|
+
* @group Authentication
|
|
1015
|
+
*/
|
|
816
1016
|
getUserId(): string | null;
|
|
1017
|
+
/**
|
|
1018
|
+
* Get the current authentication state including mode (online/offline/none) and user ID.
|
|
1019
|
+
* @returns Object with `authenticated` flag, current auth `mode`, and optional `userId`
|
|
1020
|
+
* @group Authentication
|
|
1021
|
+
*/
|
|
817
1022
|
getAuthState(): {
|
|
818
1023
|
authenticated: boolean;
|
|
819
1024
|
mode: "online" | "offline" | "none";
|
|
820
1025
|
userId?: string;
|
|
821
1026
|
};
|
|
1027
|
+
/**
|
|
1028
|
+
* Check if the client is currently authenticated.
|
|
1029
|
+
* @group Authentication
|
|
1030
|
+
*/
|
|
822
1031
|
isAuthenticated(): boolean;
|
|
1032
|
+
/**
|
|
1033
|
+
* Get info about how auth tokens are persisted (memory vs storage).
|
|
1034
|
+
* @returns Object with persistence `mode` ("memory" or "persisted") and whether the stored token has been `hydrated`
|
|
1035
|
+
* @group Authentication
|
|
1036
|
+
*/
|
|
823
1037
|
getAuthPersistenceInfo(): {
|
|
824
1038
|
mode: "memory" | "persisted";
|
|
825
1039
|
hydrated: boolean;
|
|
826
1040
|
};
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1041
|
+
/**
|
|
1042
|
+
* Wait until a user ID is available (authenticated).
|
|
1043
|
+
* @param options - Optional configuration
|
|
1044
|
+
* @group Authentication
|
|
1045
|
+
*/
|
|
1046
|
+
waitForUserId(options?: WaitForUserIdOptions): Promise<string>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Wait until the client is authenticated and return the auth mode and user ID.
|
|
1049
|
+
* @param options - Optional configuration
|
|
1050
|
+
* @returns The authenticated `userId` and auth `mode` ("online" or "offline")
|
|
1051
|
+
* @group Authentication
|
|
1052
|
+
*/
|
|
1053
|
+
waitForAuthReady(options?: WaitForAuthReadyOptions): Promise<{
|
|
833
1054
|
userId: string;
|
|
834
1055
|
mode: "online" | "offline";
|
|
835
1056
|
}>;
|
|
1057
|
+
/** Check if a document is the user's root document.
|
|
1058
|
+
* @param documentId - The document to check
|
|
1059
|
+
* @group Documents */
|
|
836
1060
|
isRootDocument(documentId: string): boolean;
|
|
837
1061
|
private syncBlobManagerIdentity;
|
|
838
1062
|
private initServiceWorkerBridge;
|
|
@@ -868,23 +1092,46 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
868
1092
|
private logServiceWorkerControl;
|
|
869
1093
|
private logServiceWorkerTokenUpdate;
|
|
870
1094
|
private logSessionEndEvent;
|
|
1095
|
+
/** Get the analytics context for LLM operations.
|
|
1096
|
+
* @group Configuration */
|
|
871
1097
|
getLlmAnalyticsContext(): {
|
|
872
|
-
logEvent: (event: AnalyticsEventInput) => void;
|
|
1098
|
+
logEvent: (event: Omit<AnalyticsEventInput, "user_ulid">) => void;
|
|
873
1099
|
isEnabled: (phase?: "start" | "success" | "failure") => boolean;
|
|
874
1100
|
} | null;
|
|
1101
|
+
/** Get the analytics context for Gemini operations.
|
|
1102
|
+
* @group Configuration */
|
|
875
1103
|
getGeminiAnalyticsContext(): {
|
|
876
|
-
logEvent: (event: AnalyticsEventInput) => void;
|
|
1104
|
+
logEvent: (event: Omit<AnalyticsEventInput, "user_ulid">) => void;
|
|
877
1105
|
isEnabled: (phase?: "start" | "success" | "failure") => boolean;
|
|
878
1106
|
} | null;
|
|
879
1107
|
private sanitizeOverride;
|
|
880
1108
|
private readEnvNumber;
|
|
1109
|
+
/** Check if a document is synced with the server.
|
|
1110
|
+
* @param documentId - The document to check sync status for
|
|
1111
|
+
* @group Offline & Sync */
|
|
881
1112
|
isSynced(documentId: string): boolean;
|
|
1113
|
+
/** Set the local user's awareness state for a document (e.g., cursor position, selection).
|
|
1114
|
+
* @param documentId - The document to set awareness for
|
|
1115
|
+
* @param state - Arbitrary awareness data (cursor, selection, user info) to broadcast to collaborators
|
|
1116
|
+
* @group Awareness */
|
|
882
1117
|
setAwareness(documentId: string, state: any): void;
|
|
883
1118
|
private getIndexedDbNames;
|
|
884
1119
|
private doesIndexedDbExist;
|
|
1120
|
+
/** Check if a document has IndexedDB persistence.
|
|
1121
|
+
* @param documentId - The document to check for local persistence
|
|
1122
|
+
* @group Offline & Sync */
|
|
885
1123
|
hasIndexedDbPersistence(documentId: string): Promise<boolean>;
|
|
1124
|
+
/** Update the local snapshot flag for a document.
|
|
1125
|
+
* @param documentId - The document to update the snapshot flag for
|
|
1126
|
+
* @param hasSnapshot - Whether the document has a local IndexedDB snapshot
|
|
1127
|
+
* @group Offline & Sync */
|
|
886
1128
|
updateLocalSnapshotFlag(documentId: string, hasSnapshot: boolean): Promise<void>;
|
|
887
1129
|
private sendAwarenessState;
|
|
1130
|
+
/** Remove awareness states for specific clients.
|
|
1131
|
+
* @param documentId - The document to remove awareness from
|
|
1132
|
+
* @param clientIds - Array of client IDs whose awareness states should be removed
|
|
1133
|
+
* @param _reason - Optional reason for removal (used for logging)
|
|
1134
|
+
* @group Awareness */
|
|
888
1135
|
removeAwareness(documentId: string, clientIds: string[], _reason?: string): void;
|
|
889
1136
|
private updateHandler;
|
|
890
1137
|
private enqueueLocalUpdate;
|
|
@@ -901,6 +1148,9 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
901
1148
|
private clearSyncWatchdog;
|
|
902
1149
|
private clearAllSyncWatchdogs;
|
|
903
1150
|
private handleSyncWatchdogTimeout;
|
|
1151
|
+
/** Compute a hash of the document's current state.
|
|
1152
|
+
* @param documentId - The document to hash
|
|
1153
|
+
* @group Documents */
|
|
904
1154
|
getDocHash(documentId: string): Promise<string>;
|
|
905
1155
|
/**
|
|
906
1156
|
* Reset the y-indexeddb persistence for a document and re-sync from server.
|
|
@@ -936,20 +1186,49 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
936
1186
|
private handleOfflineAuthMessage;
|
|
937
1187
|
private handleUploadUrlResponse;
|
|
938
1188
|
private handleLlmMessage;
|
|
1189
|
+
/** Connect to the WebSocket server.
|
|
1190
|
+
* @group Connection */
|
|
939
1191
|
connect(): void;
|
|
1192
|
+
/** Force a WebSocket reconnection.
|
|
1193
|
+
* @group Connection */
|
|
940
1194
|
forceReconnect(): void;
|
|
1195
|
+
/** Get the unique ID for this client connection.
|
|
1196
|
+
* @group Connection */
|
|
941
1197
|
getConnectionId(): string;
|
|
1198
|
+
/** Disconnect from the WebSocket server.
|
|
1199
|
+
* @group Connection */
|
|
942
1200
|
disconnect(): Promise<void>;
|
|
1201
|
+
/** Destroy the client, disconnecting and cleaning up all resources.
|
|
1202
|
+
* @group Connection */
|
|
943
1203
|
destroy(): Promise<void>;
|
|
1204
|
+
/** Set whether the client should maintain a WebSocket connection.
|
|
1205
|
+
* @param shouldConnect - If true, the client will connect and auto-reconnect; if false, it disconnects and stays disconnected
|
|
1206
|
+
* @group Connection */
|
|
944
1207
|
setShouldConnect(shouldConnect: boolean): Promise<void>;
|
|
945
1208
|
private _updateStatus;
|
|
946
1209
|
private safeGetNetworkStatus;
|
|
947
1210
|
private _emitPermission;
|
|
1211
|
+
/** Update a document's locally stored metadata (title, tags).
|
|
1212
|
+
* @param documentId - The document to update metadata for
|
|
1213
|
+
* @param updates - Fields to update in the local metadata cache
|
|
1214
|
+
* @param updates.title - New document title
|
|
1215
|
+
* @param updates.tags - New document tags
|
|
1216
|
+
* @group Documents */
|
|
948
1217
|
updateLocalMetadata(documentId: string, updates: {
|
|
949
1218
|
title?: string;
|
|
950
1219
|
tags?: string[];
|
|
951
1220
|
}): Promise<void>;
|
|
952
1221
|
private _updateSynced;
|
|
1222
|
+
/** Open a document for real-time collaboration and sync.
|
|
1223
|
+
* @param documentId - The document to open
|
|
1224
|
+
* @param options - Controls how the document is loaded and synced
|
|
1225
|
+
* @param options.waitForLoad - Controls when the returned promise resolves: "local" for local data only, "network" to wait for server sync, "localIfAvailableElseNetwork" to prefer local but fall back to network
|
|
1226
|
+
* @param options.enableNetworkSync - If false, opens the document without subscribing to server updates (default true)
|
|
1227
|
+
* @param options.retainLocal - If true, persists the document data locally for offline access (default true)
|
|
1228
|
+
* @param options.availabilityWaitMs - How long to wait for initial data before resolving with an empty doc (ms, default 30000)
|
|
1229
|
+
* @param options.deferNetworkSync - If true, opens locally without starting server sync until startNetworkSync() is called
|
|
1230
|
+
* @param options.requestSyncPerf - If true, requests sync performance timings from the server
|
|
1231
|
+
* @group Documents */
|
|
953
1232
|
openDocument(documentId: string, options?: {
|
|
954
1233
|
waitForLoad?: "local" | "network" | "localIfAvailableElseNetwork";
|
|
955
1234
|
enableNetworkSync?: boolean;
|
|
@@ -958,6 +1237,14 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
958
1237
|
deferNetworkSync?: boolean;
|
|
959
1238
|
requestSyncPerf?: boolean;
|
|
960
1239
|
}): Promise<Y.Doc>;
|
|
1240
|
+
/** Resolve a document alias and open the document.
|
|
1241
|
+
* @param alias - Alias parameters identifying the document (scope, aliasKey, optional userId)
|
|
1242
|
+
* @param options - Controls how the resolved document is loaded and synced
|
|
1243
|
+
* @param options.waitForLoad - Controls when the returned promise resolves: "local", "network", or "localIfAvailableElseNetwork"
|
|
1244
|
+
* @param options.enableNetworkSync - If false, opens the document without subscribing to server updates
|
|
1245
|
+
* @param options.retainLocal - If true, persists the document data locally for offline access
|
|
1246
|
+
* @param options.availabilityWaitMs - How long to wait for initial data before resolving with an empty doc (ms)
|
|
1247
|
+
* @group Documents */
|
|
961
1248
|
openDocumentByAlias(alias: ResolveAliasParams, options?: {
|
|
962
1249
|
waitForLoad?: "local" | "network" | "localIfAvailableElseNetwork";
|
|
963
1250
|
enableNetworkSync?: boolean;
|
|
@@ -967,15 +1254,41 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
967
1254
|
doc: Y.Doc;
|
|
968
1255
|
metadata: LocalMetadataEntry | null;
|
|
969
1256
|
}>;
|
|
1257
|
+
/** Close an open document and stop syncing.
|
|
1258
|
+
* @param documentId - The document to close
|
|
1259
|
+
* @param options - Optional close behavior
|
|
1260
|
+
* @param options.evictLocal - If true, removes the document's local data from storage on close
|
|
1261
|
+
* @group Documents */
|
|
970
1262
|
closeDocument(documentId: string, options?: {
|
|
971
1263
|
evictLocal?: boolean;
|
|
972
1264
|
}): Promise<void>;
|
|
1265
|
+
/** Map a js-bao model name to a specific document ID.
|
|
1266
|
+
* @param modelName - The model class name to map
|
|
1267
|
+
* @param documentId - The document that should store instances of this model
|
|
1268
|
+
* @group Documents */
|
|
973
1269
|
addDocumentModelMapping(modelName: string, documentId: string): void;
|
|
1270
|
+
/** Remove a model-to-document mapping.
|
|
1271
|
+
* @param modelName - The model class name to unmap
|
|
1272
|
+
* @group Documents */
|
|
974
1273
|
clearDocumentModelMapping(modelName: string): void;
|
|
1274
|
+
/** Get the document ID mapped to a model name.
|
|
1275
|
+
* @param modelName - The model class name to look up
|
|
1276
|
+
* @group Documents */
|
|
975
1277
|
getDocumentModelMapping(modelName: string): string | null;
|
|
1278
|
+
/** Set the default document ID used by js-bao models when no explicit mapping exists.
|
|
1279
|
+
* @param documentId - The document to use as the default for all unmapped models
|
|
1280
|
+
* @group Documents */
|
|
976
1281
|
setDefaultDocumentId(documentId: string): void;
|
|
1282
|
+
/** Clear the default document ID.
|
|
1283
|
+
* @group Documents */
|
|
977
1284
|
clearDefaultDocumentId(): void;
|
|
1285
|
+
/** Get the current default document ID.
|
|
1286
|
+
* @group Documents */
|
|
978
1287
|
getDefaultDocumentId(): string | null;
|
|
1288
|
+
/** Get offline status information for a document.
|
|
1289
|
+
* @param documentId - The document to get offline info for
|
|
1290
|
+
* @returns Object with `offlineEnabled`, `hasPersistence`, `isIdbSyncing` flags, optional `updatesStoreSize`, and `hasUnsyncedLocalChanges`
|
|
1291
|
+
* @group Offline & Sync */
|
|
979
1292
|
getOfflineInfo(documentId: string): {
|
|
980
1293
|
offlineEnabled: boolean;
|
|
981
1294
|
hasPersistence: boolean;
|
|
@@ -983,33 +1296,50 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
983
1296
|
updatesStoreSize?: number;
|
|
984
1297
|
hasUnsyncedLocalChanges?: boolean;
|
|
985
1298
|
};
|
|
1299
|
+
/** Check if a document has local data available.
|
|
1300
|
+
* @param documentId - The document to check for local data
|
|
1301
|
+
* @group Offline & Sync */
|
|
986
1302
|
hasLocalCopy(documentId: string): boolean;
|
|
1303
|
+
/** Set the client's log verbosity level.
|
|
1304
|
+
* @param level - The minimum log level to output (e.g. "debug", "warn", "error")
|
|
1305
|
+
* @group Configuration */
|
|
987
1306
|
setLogLevel(level: LogLevel): void;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
preserveOnSignOut?: boolean;
|
|
994
|
-
};
|
|
995
|
-
pinProvider?: () => Promise<string>;
|
|
996
|
-
}): Promise<{
|
|
1307
|
+
/** Enable offline access using passkey or PIN authentication.
|
|
1308
|
+
* @param options - Controls how offline credentials are created and stored
|
|
1309
|
+
* @returns Object with `enabled` flag, the `method` used (largeBlob, pin, or signed), and an optional `reason` if not enabled
|
|
1310
|
+
* @group Offline & Sync */
|
|
1311
|
+
enableOfflineAccess(options?: EnableOfflineAccessOptions): Promise<{
|
|
997
1312
|
enabled: boolean;
|
|
998
1313
|
method?: "largeBlob" | "pin" | "signed";
|
|
999
1314
|
reason?: string;
|
|
1000
1315
|
}>;
|
|
1316
|
+
/** Unlock offline access using stored credentials.
|
|
1317
|
+
* @param pinProvider - Async function that prompts the user for a PIN; required when the offline grant uses PIN-based storage
|
|
1318
|
+
* @group Offline & Sync */
|
|
1001
1319
|
unlockOffline(pinProvider?: () => Promise<string>): Promise<boolean>;
|
|
1320
|
+
/** Check if an offline access grant is currently active.
|
|
1321
|
+
* @group Offline & Sync */
|
|
1002
1322
|
isOfflineGrantAvailable(): boolean;
|
|
1323
|
+
/** Get detailed status of the offline access grant.
|
|
1324
|
+
* @returns Object with `available` flag, optional `expiresAt` timestamp, `daysLeft` until expiry, and storage `method`
|
|
1325
|
+
* @group Offline & Sync */
|
|
1003
1326
|
getOfflineGrantStatus(): {
|
|
1004
1327
|
available: boolean;
|
|
1005
1328
|
expiresAt?: string;
|
|
1006
1329
|
daysLeft?: number;
|
|
1007
1330
|
method?: "largeBlob" | "pin" | "signed";
|
|
1008
1331
|
};
|
|
1332
|
+
/** Renew the offline access grant while online.
|
|
1333
|
+
* @param pinProvider - Async function that prompts for a PIN; required for PIN-based grants
|
|
1334
|
+
* @group Offline & Sync */
|
|
1009
1335
|
renewOfflineGrantOnline(pinProvider?: () => Promise<string>): Promise<boolean>;
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1336
|
+
/** Revoke the offline access grant.
|
|
1337
|
+
* @param opts - Optional revocation behavior
|
|
1338
|
+
* @group Offline & Sync */
|
|
1339
|
+
revokeOfflineGrant(opts?: RevokeOfflineGrantOptions): Promise<void>;
|
|
1340
|
+
/** Get the offline identity (user info available when offline).
|
|
1341
|
+
* @returns The offline user identity with `userId`, `appId`, `rootDocId`, and optional `email`/`name`, or null if unavailable
|
|
1342
|
+
* @group Offline & Sync */
|
|
1013
1343
|
getOfflineIdentity(): {
|
|
1014
1344
|
userId: string;
|
|
1015
1345
|
appId: string;
|
|
@@ -1019,27 +1349,74 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1019
1349
|
} | null;
|
|
1020
1350
|
private buildCommitRetryContext;
|
|
1021
1351
|
private ensureAuthReadyForRequest;
|
|
1352
|
+
/** Check if an offline grant is stored locally.
|
|
1353
|
+
* @group Offline & Sync */
|
|
1022
1354
|
hasOfflineGrantStored(): Promise<boolean>;
|
|
1023
1355
|
private unsubscribeFromDocument;
|
|
1356
|
+
/** Get the raw Yjs Doc instance for a document.
|
|
1357
|
+
* @param documentId - The document to retrieve
|
|
1358
|
+
* @group Documents */
|
|
1024
1359
|
getDoc(documentId: string): Y.Doc | undefined;
|
|
1360
|
+
/** Run a function as a local Yjs transaction (batches updates).
|
|
1361
|
+
* @param documentId - The document to transact against
|
|
1362
|
+
* @param fn - Function to execute within the transaction; all Yjs mutations inside are batched into a single update
|
|
1363
|
+
* @group Documents */
|
|
1025
1364
|
runLocalTransaction(documentId: string, fn: () => void): void;
|
|
1365
|
+
/** Check if a document is currently open.
|
|
1366
|
+
* @param documentId - The document to check
|
|
1367
|
+
* @group Documents */
|
|
1026
1368
|
isDocOpen(documentId: string): boolean;
|
|
1369
|
+
/** Check if the WebSocket is currently connected.
|
|
1370
|
+
* @group Connection */
|
|
1027
1371
|
isConnected(): boolean;
|
|
1372
|
+
/** Check if a document's data is synced with the server.
|
|
1373
|
+
* @param documentId - The document to check sync status for
|
|
1374
|
+
* @group Offline & Sync */
|
|
1028
1375
|
isDocumentSynced(documentId: string): boolean;
|
|
1376
|
+
/** Wait until a document is synced with the server.
|
|
1377
|
+
* @param documentId - The document to wait for
|
|
1378
|
+
* @param timeoutMs - Maximum time to wait before rejecting (ms, default 30000)
|
|
1379
|
+
* @group Offline & Sync */
|
|
1029
1380
|
waitForSync(documentId: string, timeoutMs?: number): Promise<void>;
|
|
1030
1381
|
private requestUploadUrl;
|
|
1031
1382
|
private handleAwarenessRefresh;
|
|
1032
1383
|
private handleAwarenessMessage;
|
|
1033
1384
|
private _emitAwarenessChange;
|
|
1034
1385
|
private _broadcastAwareness;
|
|
1386
|
+
/** Set the local awareness state for a document.
|
|
1387
|
+
* @param documentId - The document to set awareness for
|
|
1388
|
+
* @param state - Arbitrary awareness data (cursor, selection, user info) to broadcast to collaborators
|
|
1389
|
+
* @group Awareness */
|
|
1035
1390
|
setLocalAwarenessState(documentId: string, state: any): void;
|
|
1391
|
+
/** Get the local user's current awareness state for a document.
|
|
1392
|
+
* @param documentId - The document to get local awareness for
|
|
1393
|
+
* @group Awareness */
|
|
1036
1394
|
getLocalAwarenessState(documentId: string): any | null;
|
|
1395
|
+
/** Get all users' awareness states for a document.
|
|
1396
|
+
* @param documentId - The document to get awareness states for
|
|
1397
|
+
* @group Awareness */
|
|
1037
1398
|
getAwarenessStates(documentId: string): Map<string, any>;
|
|
1399
|
+
/** Remove awareness states for specific clients and broadcast the removal to the server.
|
|
1400
|
+
* @param documentId - The document to remove awareness from
|
|
1401
|
+
* @param clientIds - Array of client IDs whose awareness states should be removed
|
|
1402
|
+
* @param _reason - Optional reason for removal (used for logging)
|
|
1403
|
+
* @group Awareness */
|
|
1038
1404
|
removeAwarenessStates(documentId: string, clientIds: string[], _reason?: string): void;
|
|
1039
1405
|
private applyTokenFromController;
|
|
1040
1406
|
private applyTokenEffects;
|
|
1041
1407
|
private pushAuthTokenToSocket;
|
|
1408
|
+
/**
|
|
1409
|
+
* Get the current JWT auth token.
|
|
1410
|
+
* @group Authentication
|
|
1411
|
+
*/
|
|
1042
1412
|
getToken(): string | null;
|
|
1413
|
+
/**
|
|
1414
|
+
* Manually set the JWT auth token.
|
|
1415
|
+
* @param token - The JWT token to use for authentication, or null to clear
|
|
1416
|
+
* @param options - Optional metadata
|
|
1417
|
+
* @param options.cause - Reason for the token change (used in event payloads and logging)
|
|
1418
|
+
* @group Authentication
|
|
1419
|
+
*/
|
|
1043
1420
|
setToken(token: string | null, options?: {
|
|
1044
1421
|
cause?: string;
|
|
1045
1422
|
}): void;
|
|
@@ -1047,25 +1424,39 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1047
1424
|
* Logout: best-effort server cookie clear, shutdown networking, clear auth state, and optional local eviction.
|
|
1048
1425
|
* - Preserves stored offline grant by default (does not delete it)
|
|
1049
1426
|
* - Clears in-memory offline identity so the client is not considered authenticated
|
|
1427
|
+
* @param options - Controls logout behavior
|
|
1428
|
+
* @group Authentication
|
|
1429
|
+
*/
|
|
1430
|
+
logout(options?: LogoutOptions): Promise<void>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Check if OAuth authentication is available for this app.
|
|
1433
|
+
* @group Authentication
|
|
1050
1434
|
*/
|
|
1051
|
-
logout(options?: {
|
|
1052
|
-
redirectTo?: string;
|
|
1053
|
-
wipeLocal?: boolean;
|
|
1054
|
-
revokeOffline?: boolean;
|
|
1055
|
-
clearOfflineIdentity?: boolean;
|
|
1056
|
-
waitForDisconnect?: boolean;
|
|
1057
|
-
}): Promise<void>;
|
|
1058
1435
|
checkOAuthAvailable(): Promise<boolean>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Start the OAuth authentication flow by redirecting to the OAuth provider.
|
|
1438
|
+
* @param continueUrl - URL to return to after the OAuth flow completes
|
|
1439
|
+
* @param options - Additional flow options
|
|
1440
|
+
* @param options.waitlist - If provided, enrolls the user in the app's waitlist with optional source and note
|
|
1441
|
+
* @group Authentication
|
|
1442
|
+
*/
|
|
1059
1443
|
startOAuthFlow(continueUrl?: string, options?: {
|
|
1060
1444
|
waitlist?: {
|
|
1061
1445
|
source?: string | null;
|
|
1062
1446
|
note?: string | null;
|
|
1063
1447
|
};
|
|
1064
1448
|
}): Promise<void>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Handle the OAuth callback after the user completes the OAuth flow.
|
|
1451
|
+
* @param code - The authorization code from the OAuth provider
|
|
1452
|
+
* @param state - The state parameter for CSRF verification
|
|
1453
|
+
* @group Authentication
|
|
1454
|
+
*/
|
|
1065
1455
|
handleOAuthCallback(code: string, state: string): Promise<void>;
|
|
1066
1456
|
/**
|
|
1067
1457
|
* Get the app's authentication configuration.
|
|
1068
1458
|
* Useful for checking what auth methods are available before showing login UI.
|
|
1459
|
+
* @group Authentication
|
|
1069
1460
|
*/
|
|
1070
1461
|
getAppConfig(): Promise<{
|
|
1071
1462
|
appId: string;
|
|
@@ -1076,11 +1467,23 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1076
1467
|
hasPasskey: boolean;
|
|
1077
1468
|
magicLinkEnabled: boolean;
|
|
1078
1469
|
}>;
|
|
1470
|
+
/**
|
|
1471
|
+
* Request a magic link email for passwordless authentication.
|
|
1472
|
+
* @param email - The email address to send the magic link to
|
|
1473
|
+
* @param options - Optional configuration
|
|
1474
|
+
* @param options.redirectUri - Override the default OAuth redirect URI for the magic link callback
|
|
1475
|
+
* @group Authentication
|
|
1476
|
+
*/
|
|
1079
1477
|
magicLinkRequest(email: string, options?: {
|
|
1080
1478
|
redirectUri?: string;
|
|
1081
1479
|
}): Promise<{
|
|
1082
1480
|
success: boolean;
|
|
1083
1481
|
}>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Verify a magic link token and authenticate the user.
|
|
1484
|
+
* @param token - The magic link token from the email URL
|
|
1485
|
+
* @group Authentication
|
|
1486
|
+
*/
|
|
1084
1487
|
magicLinkVerify(token: string): Promise<{
|
|
1085
1488
|
user: {
|
|
1086
1489
|
userId: string;
|
|
@@ -1093,6 +1496,8 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1093
1496
|
/**
|
|
1094
1497
|
* Request a one-time password (OTP) code to be sent to the specified email.
|
|
1095
1498
|
* The code can be verified using `otpVerify()`.
|
|
1499
|
+
* @param email - The email address to send the OTP code to
|
|
1500
|
+
* @group Authentication
|
|
1096
1501
|
*/
|
|
1097
1502
|
otpRequest(email: string): Promise<{
|
|
1098
1503
|
success: boolean;
|
|
@@ -1100,6 +1505,9 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1100
1505
|
/**
|
|
1101
1506
|
* Verify a one-time password (OTP) code and authenticate the user.
|
|
1102
1507
|
* On success, the client will be authenticated and connected.
|
|
1508
|
+
* @param email - The email address the OTP was sent to
|
|
1509
|
+
* @param code - The OTP code entered by the user
|
|
1510
|
+
* @group Authentication
|
|
1103
1511
|
*/
|
|
1104
1512
|
otpVerify(email: string, code: string): Promise<{
|
|
1105
1513
|
user: {
|
|
@@ -1109,10 +1517,20 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1109
1517
|
};
|
|
1110
1518
|
isNewUser?: boolean;
|
|
1111
1519
|
}>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Start the passkey authentication flow, returns challenge options for the browser.
|
|
1522
|
+
* @group Authentication
|
|
1523
|
+
*/
|
|
1112
1524
|
passkeyAuthStart(): Promise<{
|
|
1113
1525
|
options: any;
|
|
1114
1526
|
challengeToken: string;
|
|
1115
1527
|
}>;
|
|
1528
|
+
/**
|
|
1529
|
+
* Complete passkey authentication with the browser's credential response.
|
|
1530
|
+
* @param credential - The credential response from the browser's WebAuthn API
|
|
1531
|
+
* @param challengeToken - The challenge token returned by passkeyAuthStart()
|
|
1532
|
+
* @group Authentication
|
|
1533
|
+
*/
|
|
1116
1534
|
passkeyAuthFinish(credential: any, challengeToken: string): Promise<{
|
|
1117
1535
|
user: {
|
|
1118
1536
|
userId: string;
|
|
@@ -1121,13 +1539,28 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1121
1539
|
};
|
|
1122
1540
|
isNewUser?: boolean;
|
|
1123
1541
|
}>;
|
|
1542
|
+
/**
|
|
1543
|
+
* Start registering a new passkey for the current user.
|
|
1544
|
+
* @group Authentication
|
|
1545
|
+
*/
|
|
1124
1546
|
passkeyRegisterStart(): Promise<{
|
|
1125
1547
|
options: any;
|
|
1126
1548
|
challengeToken: string;
|
|
1127
1549
|
}>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Complete passkey registration with the browser's credential response.
|
|
1552
|
+
* @param credential - The credential response from the browser's WebAuthn API
|
|
1553
|
+
* @param challengeToken - The challenge token returned by passkeyRegisterStart()
|
|
1554
|
+
* @param deviceName - Optional human-readable name for this passkey (e.g. "MacBook Pro")
|
|
1555
|
+
* @group Authentication
|
|
1556
|
+
*/
|
|
1128
1557
|
passkeyRegisterFinish(credential: any, challengeToken: string, deviceName?: string): Promise<{
|
|
1129
1558
|
success: boolean;
|
|
1130
1559
|
}>;
|
|
1560
|
+
/**
|
|
1561
|
+
* List all passkeys registered for the current user.
|
|
1562
|
+
* @group Authentication
|
|
1563
|
+
*/
|
|
1131
1564
|
passkeyList(): Promise<{
|
|
1132
1565
|
passkeys: Array<{
|
|
1133
1566
|
passkeyId: string;
|
|
@@ -1136,9 +1569,21 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1136
1569
|
lastUsedAt?: string;
|
|
1137
1570
|
}>;
|
|
1138
1571
|
}>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Delete a registered passkey by ID.
|
|
1574
|
+
* @param passkeyId - The ID of the passkey to delete
|
|
1575
|
+
* @group Authentication
|
|
1576
|
+
*/
|
|
1139
1577
|
passkeyDelete(passkeyId: string): Promise<{
|
|
1140
1578
|
success: boolean;
|
|
1141
1579
|
}>;
|
|
1580
|
+
/**
|
|
1581
|
+
* Update a passkey's metadata such as its device name.
|
|
1582
|
+
* @param passkeyId - The ID of the passkey to update
|
|
1583
|
+
* @param params - Fields to update
|
|
1584
|
+
* @param params.deviceName - New human-readable name for the passkey
|
|
1585
|
+
* @group Authentication
|
|
1586
|
+
*/
|
|
1142
1587
|
passkeyUpdate(passkeyId: string, params: {
|
|
1143
1588
|
deviceName: string;
|
|
1144
1589
|
}): Promise<{
|
|
@@ -1149,6 +1594,10 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1149
1594
|
lastUsedAt?: string;
|
|
1150
1595
|
};
|
|
1151
1596
|
}>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Get detailed authentication configuration including enabled providers and passkey settings.
|
|
1599
|
+
* @group Authentication
|
|
1600
|
+
*/
|
|
1152
1601
|
getAuthConfig(): Promise<{
|
|
1153
1602
|
appId: string;
|
|
1154
1603
|
name: string;
|
|
@@ -1172,6 +1621,9 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1172
1621
|
private _putMetadataToIdb;
|
|
1173
1622
|
private _deleteMetadataFromIdb;
|
|
1174
1623
|
private _enforceRetentionPolicy;
|
|
1624
|
+
/** Get the current network status including connectivity and transport state.
|
|
1625
|
+
* @returns Object with network `mode`, WebSocket `transport` state, `isOnline` flag, and optional `lastOnlineAt`/`lastError`
|
|
1626
|
+
* @group Network */
|
|
1175
1627
|
getNetworkStatus(): {
|
|
1176
1628
|
mode: "auto" | "online" | "offline";
|
|
1177
1629
|
transport: "connected" | "connecting" | "disconnected";
|
|
@@ -1180,27 +1632,60 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1180
1632
|
lastOnlineAt?: string;
|
|
1181
1633
|
lastError?: string;
|
|
1182
1634
|
};
|
|
1635
|
+
/** Check if the client is currently online.
|
|
1636
|
+
* @group Network */
|
|
1183
1637
|
isOnline(): boolean;
|
|
1638
|
+
/** Set the network mode (auto, online, or offline).
|
|
1639
|
+
* @param mode - "auto" to connect/disconnect based on connectivity, "online" to force connection, "offline" to force disconnection
|
|
1640
|
+
* @group Network */
|
|
1184
1641
|
setNetworkMode(mode: "auto" | "online" | "offline"): Promise<void>;
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1642
|
+
/** Switch the client to offline mode.
|
|
1643
|
+
* @param opts - Optional configuration
|
|
1644
|
+
* @group Network */
|
|
1645
|
+
goOffline(opts?: GoOfflineOptions): Promise<void>;
|
|
1646
|
+
/** Switch the client back to online mode.
|
|
1647
|
+
* @group Network */
|
|
1188
1648
|
goOnline(): Promise<void>;
|
|
1649
|
+
/** Start network syncing for a document that was opened with deferred sync.
|
|
1650
|
+
* @param documentId - The document to begin syncing with the server
|
|
1651
|
+
* @group Offline & Sync */
|
|
1189
1652
|
startNetworkSync(documentId: string): Promise<void>;
|
|
1653
|
+
/** List IDs of all currently open documents.
|
|
1654
|
+
* @group Documents */
|
|
1190
1655
|
listOpenDocuments(): string[];
|
|
1656
|
+
/** List all documents stored locally.
|
|
1657
|
+
* @group Offline & Sync */
|
|
1191
1658
|
listLocalDocuments(): Promise<LocalDocumentEntry[]>;
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1659
|
+
/** List documents with merged local and server metadata.
|
|
1660
|
+
* @param options - Optional filters
|
|
1661
|
+
* @group Offline & Sync */
|
|
1662
|
+
listLocalDocumentsUnified(options?: ListLocalDocumentsOptions): Promise<DocumentInfo[]>;
|
|
1663
|
+
/** Get locally stored metadata for a document.
|
|
1664
|
+
* @param documentId - The document to get metadata for
|
|
1665
|
+
* @group Offline & Sync */
|
|
1196
1666
|
getLocalMetadata(documentId: string): Promise<LocalMetadataEntry | null>;
|
|
1667
|
+
/** Remove a document's local data from storage.
|
|
1668
|
+
* @param documentId - The document to evict
|
|
1669
|
+
* @param opts - Optional eviction behavior
|
|
1670
|
+
* @param opts.force - If true, evicts even if the document has unsynced local changes
|
|
1671
|
+
* @param opts.suppressMetadataEvent - If true, does not emit a documentMetadataChanged event
|
|
1672
|
+
* @group Offline & Sync */
|
|
1197
1673
|
evictLocalDocument(documentId: string, opts?: {
|
|
1198
1674
|
force?: boolean;
|
|
1199
1675
|
suppressMetadataEvent?: boolean;
|
|
1200
1676
|
}): Promise<void>;
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1677
|
+
/** Remove all locally stored document data.
|
|
1678
|
+
* @param opts - Optional eviction behavior
|
|
1679
|
+
* @group Offline & Sync */
|
|
1680
|
+
evictAllLocal(opts?: EvictAllLocalOptions): Promise<void>;
|
|
1681
|
+
/** Configure the local document retention policy.
|
|
1682
|
+
* @param opts - Retention policy settings
|
|
1683
|
+
* @param opts.default - Default retention mode: "persist" keeps documents across sessions, "session" evicts on sign-out
|
|
1684
|
+
* @param opts.maxDocs - Maximum number of documents to keep locally; oldest are evicted first
|
|
1685
|
+
* @param opts.maxBytes - Maximum total bytes of local document data; oldest documents evicted when exceeded
|
|
1686
|
+
* @param opts.ttlMs - Time-to-live in milliseconds; documents older than this are evicted
|
|
1687
|
+
* @param opts.preserveOnSignOut - If true, retains local data even when the user signs out
|
|
1688
|
+
* @group Offline & Sync */
|
|
1204
1689
|
setRetentionPolicy(opts: {
|
|
1205
1690
|
default: "persist" | "session";
|
|
1206
1691
|
maxDocs?: number;
|
|
@@ -1208,16 +1693,23 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1208
1693
|
ttlMs?: number;
|
|
1209
1694
|
preserveOnSignOut?: boolean;
|
|
1210
1695
|
}): void;
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
}): Promise<{
|
|
1696
|
+
/** Create a new document, optionally local-only for offline-first creation.
|
|
1697
|
+
* @param options - Document creation options
|
|
1698
|
+
* @group Documents */
|
|
1699
|
+
createDocument(options: CreateDocumentOptions): Promise<{
|
|
1216
1700
|
metadata: any;
|
|
1217
1701
|
}>;
|
|
1702
|
+
/** Retry committing a pending offline-created document to the server.
|
|
1703
|
+
* @param documentId - The pending document to retry committing
|
|
1704
|
+
* @group Documents */
|
|
1218
1705
|
retryCommit(documentId: string): Promise<{
|
|
1219
1706
|
created: boolean;
|
|
1220
1707
|
} | null>;
|
|
1708
|
+
/** Commit a locally created document to the server.
|
|
1709
|
+
* @param documentId - The locally created document to commit
|
|
1710
|
+
* @param opts - Optional commit behavior
|
|
1711
|
+
* @param opts.onExists - What to do if the document already exists on the server: "link" adopts the existing document, "fail" throws an error
|
|
1712
|
+
* @group Documents */
|
|
1221
1713
|
commitOfflineCreate(documentId: string, opts?: {
|
|
1222
1714
|
onExists?: "link" | "fail";
|
|
1223
1715
|
}): Promise<{
|
|
@@ -1225,15 +1717,28 @@ export declare class JsBaoClient extends Observable<any> {
|
|
|
1225
1717
|
linked?: boolean;
|
|
1226
1718
|
reason?: string;
|
|
1227
1719
|
}>;
|
|
1720
|
+
/** List all documents pending server creation.
|
|
1721
|
+
* @group Documents */
|
|
1228
1722
|
listPendingCreates(): Promise<Array<{
|
|
1229
1723
|
documentId: string;
|
|
1230
1724
|
title?: string;
|
|
1231
1725
|
createdAt: string;
|
|
1232
1726
|
}>>;
|
|
1727
|
+
/** Check if a document is pending server creation.
|
|
1728
|
+
* @param documentId - The document to check
|
|
1729
|
+
* @group Documents */
|
|
1233
1730
|
isPendingCreate(documentId: string): boolean;
|
|
1731
|
+
/** Cancel a pending offline document creation.
|
|
1732
|
+
* @param documentId - The pending document to cancel
|
|
1733
|
+
* @param opts - Optional cleanup behavior
|
|
1734
|
+
* @param opts.evictLocal - If true, also removes the document's local data from storage
|
|
1735
|
+
* @group Documents */
|
|
1234
1736
|
cancelPendingCreate(documentId: string, opts?: {
|
|
1235
1737
|
evictLocal?: boolean;
|
|
1236
1738
|
}): Promise<void>;
|
|
1739
|
+
/** Get debug information about a document's internal state.
|
|
1740
|
+
* @param documentId - The document to inspect
|
|
1741
|
+
* @group Documents */
|
|
1237
1742
|
getDocDebug(documentId: string): DocumentDebugSnapshot;
|
|
1238
1743
|
}
|
|
1239
1744
|
export declare function initializeClient(options: JsBaoClientOptions, waitOptions?: {
|