Skip to content

js-bao-wss-client


js-bao-wss-client / GroupsAPI

Interface: GroupsAPI ​

Client API for groups — named sets of users used to grant shared access to documents, databases, and collections. Accessed as client.groups.

Methods ​

addMember() ​

addMember(groupType, groupId, params): Promise<GroupAddMemberResult>

Adds a user to a group by user ID or email address.

Returns a discriminated union based on whether the target is an existing app user (direct add) or a yet-to-sign-up email (deferred add):

  • { status: "added", userId, addedAt, addedBy, ... } — new membership.
  • { status: "already_member", userId, addedAt, addedBy, ... } — the user was already a member (no error; addedAt/addedBy reflect the pre-existing row). Replaces the previous HTTP 409 on duplicate.
  • { status: "pending_signup", email, deferredId, expiresAt, ... } — email not yet in the app; a DeferredGroupAdd row has been created (or an existing unresolved one is returned idempotently).

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

params ​

AddGroupMemberParams

User identifier (provide either userId or email, not both)

Returns ​

Promise<GroupAddMemberResult>


create() ​

create(params): Promise<GroupInfo>

Creates a new group with the specified type, ID, and name.

Parameters ​

params ​

CreateGroupParams

Configuration for the new group

Returns ​

Promise<GroupInfo>


delete() ​

delete(groupType, groupId): Promise<{ success: boolean; }>

Deletes a group by its type and ID.

Parameters ​

groupType ​

string

The type category of the group to delete

groupId ​

string

The unique identifier of the group within its type

Returns ​

Promise<{ success: boolean; }>


get() ​

get(groupType, groupId): Promise<GroupInfo>

Retrieves a single group by its type and ID.

Parameters ​

groupType ​

string

The type category of the group to retrieve

groupId ​

string

The unique identifier of the group within its type

Returns ​

Promise<GroupInfo>


list() ​

list(options?): Promise<ListResult<GroupInfo>>

Lists groups, optionally filtered by group type.

Parameters ​

options? ​

ListGroupsOptions

Filtering and pagination options

Returns ​

Promise<ListResult<GroupInfo>>


listDatabases() ​

listDatabases(groupType, groupId): Promise<GroupDatabaseInfo[]>

Lists all databases accessible to a group via DatabaseGroupPermission.

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

Returns ​

Promise<GroupDatabaseInfo[]>


listDocuments() ​

listDocuments(groupType, groupId): Promise<GroupDocumentInfo[]>

Lists all documents accessible to a group.

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

Returns ​

Promise<GroupDocumentInfo[]>


listMembers() ​

listMembers(groupType, groupId, options?): Promise<ListResult<GroupMemberInfo>>

Lists members of a group with optional pagination.

Pass include: "profiles" to join each member with their basic profile in the same round trip: userName/userEmail are reliably populated and avatarUrl is included (null when the user has no avatar). This replaces the per-member users.getBasic fan-out for roster views.

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

options? ​

Pagination options (limit, cursor) and include

cursor? ​

string

include? ​

"profiles"

limit? ​

number

Returns ​

Promise<ListResult<GroupMemberInfo>>


listPendingInvitations() ​

listPendingInvitations(groupType, groupId): Promise<PendingGroupInvitationEntry[]>

Lists pending (unresolved, non-expired) invitations scoped to a group. Returns denormalized rows so callers can render "members + pending" without touching the internal deferred-grants surface.

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

Returns ​

Promise<PendingGroupInvitationEntry[]>


listUserMemberships() ​

listUserMemberships(userId, options?): Promise<GroupMembershipInfo[]>

Lists all group memberships for a given user.

Parameters ​

userId ​

string

The ID of the user whose memberships to retrieve

options? ​

ListUserMembershipsOptions

Optional filters (e.g. groupType to limit to one group type)

Returns ​

Promise<GroupMembershipInfo[]>


removeMember() ​

removeMember(groupType, groupId, userIdOrParams): Promise<{ success: boolean; }>

Removes a member from a group by user ID or email address.

Parameters ​

groupType ​

string

The type category of the group

groupId ​

string

The unique identifier of the group within its type

userIdOrParams ​

string | { email: string; }

A user ID string, or an object with an email field to remove by email

Returns ​

Promise<{ success: boolean; }>


update() ​

update(groupType, groupId, params): Promise<GroupInfo>

Updates a group's name or description.

Parameters ​

groupType ​

string

The type category of the group to update

groupId ​

string

The unique identifier of the group within its type

params ​

UpdateGroupParams

Fields to update on the group

Returns ​

Promise<GroupInfo>

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