Skip to content

js-bao-wss-client


js-bao-wss-client / GroupsAPI

Interface: GroupsAPI

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<PaginatedResult<GroupInfo>>

Lists groups, optionally filtered by group type.

Parameters

options?

ListGroupsOptions

Filtering and pagination options

Returns

Promise<PaginatedResult<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<{ cursor?: string; items: GroupMemberInfo[]; }>

Lists members of a group with optional pagination.

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)

cursor?

string

limit?

number

Returns

Promise<{ cursor?: string; items: 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

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

string | { email: string; }

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>