Skip to content

js-bao-wss-client


js-bao-wss-client / MeAPI

Interface: MeAPI ​

Sub-API for the current user (client.me.*): read and update the caller's profile (cache-aware), upload an avatar, and list the documents they own and the documents shared with them.

Methods ​

cacheInfo() ​

cacheInfo(): Promise<{ ageMs?: number; updatedAt?: string; }>

Returns cache metadata for the current user's profile entry.

Returns ​

Promise<{ ageMs?: number; updatedAt?: string; }>

Object with optional updatedAt timestamp and ageMs since last refresh


clearCache() ​

clearCache(): Promise<void>

Clears the cached profile so the next get() fetches fresh data from the server.

Returns ​

Promise<void>


get() ​

get(options?): Promise<UserProfile | null>

Retrieves the current user's profile, using the cache when available.

Parameters ​

options? ​

GetMeOptions

Controls caching and loading behavior

Returns ​

Promise<UserProfile | null>


ownedDocuments() ​

Call Signature ​

ownedDocuments(options): Promise<DocumentListPage>

List documents the current user owns.

Returns docs where the caller's DocumentPermission.permission === "owner". Mirrors MeAPI.sharedDocuments for parallel structure ("owned-by-me" vs "shared-with-me").

Returns the current owner set (not creators) — ownership transfer updates DocumentPermission.permission without changing Document.createdBy, so this method tracks live ownership.

Offline-first / cache-aware: the owner filter is applied across the local cache, the network response, and the merged result. The response is cached additively (authoritative: false) — cached non-owner rows are NOT evicted; ownership-revocation lag is accepted as an eventual-consistency tradeoff, and the connect-time scope walk is what evicts.

Cursor format is raw JSON, NOT base64url.

Parameters ​
options ​

OwnedDocumentsOptions & object

Returns ​

Promise<DocumentListPage>

Call Signature ​

ownedDocuments(options?): Promise<DocumentInfo<unknown>[]>

List documents the current user owns.

Returns docs where the caller's DocumentPermission.permission === "owner". Mirrors MeAPI.sharedDocuments for parallel structure ("owned-by-me" vs "shared-with-me").

Returns the current owner set (not creators) — ownership transfer updates DocumentPermission.permission without changing Document.createdBy, so this method tracks live ownership.

Offline-first / cache-aware: the owner filter is applied across the local cache, the network response, and the merged result. The response is cached additively (authoritative: false) — cached non-owner rows are NOT evicted; ownership-revocation lag is accepted as an eventual-consistency tradeoff, and the connect-time scope walk is what evicts.

Cursor format is raw JSON, NOT base64url.

Parameters ​
options? ​

OwnedDocumentsOptions

Returns ​

Promise<DocumentInfo<unknown>[]>


sharedDocuments() ​

sharedDocuments(options?): Promise<SharedDocumentListResult>

List documents shared with the current user: the documents they hold a direct non-owner DocumentPermission on. Pass tag to filter by a document tag.

Returns the unified { items, cursor } envelope (was { documents, nextCursor }) with a raw-JSON cursor (was base64url), matching MeAPI.ownedDocuments. Each row carries the base Document fields plus the shared extras (source/grantedBy).

Parameters ​

options? ​

SharedDocumentsOptions

Returns ​

Promise<SharedDocumentListResult>


update() ​

update(params): Promise<UserProfile>

Update the current user's profile (name and/or external avatar URL).

Parameters ​

params ​

UpdateMeParams

Fields to update on the profile

Returns ​

Promise<UserProfile>


uploadAvatar() ​

uploadAvatar(imageData, contentType): Promise<{ avatarUrl: string; }>

Uploads an avatar image for the current user and returns the new avatar URL.

Parameters ​

imageData ​

ArrayBuffer | File | Blob

The raw image binary to upload

contentType ​

"image/png" | "image/jpeg" | "image/gif" | "image/webp"

MIME type of the image (must be png, jpeg, gif, or webp)

Returns ​

Promise<{ avatarUrl: string; }>

Object with the new avatarUrl

Documentation validated against js-bao-wss-client 3.4.0 · js-bao 0.11.0 · primitive-admin 1.0.62 · primitive-app 3.1.0 — 2026-09-30