import { type AccountRole, type AgentID, type Everyone, type InviteSecret, type RawAccountID, type RawGroup, type Role } from "cojson"; import { AnonymousJazzAgent, CoValue, CoValueClass, ID, Settled, RefsToResolve, RefsToResolveStrict, Resolved, SubscribeListenerOptions, TypeSym } from "../internal.js"; import { Account, CoValueBase, CoValueJazzApi, Ref } from "../internal.js"; type GroupMember = { id: string; role: AccountRole; ref: Ref; account: Account; }; /** * Roles that can be granted to a group member. */ export type GroupRole = "reader" | "writer" | "admin" | "manager"; /** @category Identity & Permissions */ export declare class Group extends CoValueBase implements CoValue { [TypeSym]: "Group"; $jazz: GroupJazzApi; /** @deprecated Don't use constructor directly, use .create */ constructor(options: { fromRaw: RawGroup; } | { owner: Account; name?: string; }); static create(this: CoValueClass, options?: { owner?: Account; name?: string; } | Account): G; myRole(): Role | undefined; addMember(member: Everyone, role: "writer" | "reader" | "writeOnly"): void; addMember(member: Account, role: AccountRole): void; /** @category Identity & Permissions * Gives members of a parent group membership in this group. * @param member The group that will gain access to this group. * @param role The role all members of the parent group should have in this group. */ addMember(member: Group, role?: GroupRole | "inherit"): void; addMember(member: Group | Account, role: "reader" | "writer" | "admin" | "manager"): void; removeMember(member: Everyone | Account): void; /** @category Identity & Permissions * Revokes membership from members a parent group. * @param member The group that will lose access to this group. */ removeMember(member: Group): void; private getMembersFromKeys; /** * Returns all members of the group, including inherited members from parent * groups. * * If you need only the direct members of the group, use * {@link getDirectMembers} instead. * * @returns The members of the group. */ get members(): GroupMember[]; /** * Returns the direct members of the group. * * If you need all members of the group, including inherited members from * parent groups, use {@link Group.members|members} instead. * @returns The direct members of the group. */ getDirectMembers(): GroupMember[]; getRoleOf(member: Everyone | ID | "me"): Role | undefined; /** * Make the group public, so that everyone can read it. * Alias for `addMember("everyone", role)`. * * @param role - Optional: the role to grant to everyone. Defaults to "reader". * @returns The group itself. */ makePublic(role?: "reader" | "writer"): this; getParentGroups(): Array; /** @category Identity & Permissions * Gives members of a parent group membership in this group. * @deprecated Use `addMember` instead. * @param parent The group that will gain access to this group. * @param roleMapping The role all members of the parent group should have in this group. * @returns This group. */ extend(parent: Group, roleMapping?: "reader" | "writer" | "admin" | "manager" | "inherit"): this; /** @category Identity & Permissions * Revokes membership from members a parent group. * @deprecated Use `removeMember` instead. * @param parent The group that will lose access to this group. * @returns This group. */ revokeExtend(parent: Group): Promise; /** @category Subscription & Loading * * @deprecated Use `co.group(...).load` instead. */ static load>(this: CoValueClass, id: ID, options?: { resolve?: RefsToResolveStrict; loadAs?: Account | AnonymousJazzAgent; }): Promise>>; /** @category Subscription & Loading * * @deprecated Use `co.group(...).subscribe` instead. */ static subscribe>(this: CoValueClass, id: ID, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; static subscribe>(this: CoValueClass, id: ID, options: SubscribeListenerOptions, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; /** @category Invites * Creates a group invite * @param id The ID of the group to create an invite for * @param options Optional configuration * @param options.role The role to grant to the accepter of the invite. Defaults to 'reader' * @param options.loadAs The account to use when loading the group. Defaults to the current account * @returns An invite secret, (a string starting with "inviteSecret_"). Can be * accepted using `Account.acceptInvite()` */ static createInvite(this: CoValueClass, id: ID, options?: { role?: AccountRole; loadAs?: Account; }): Promise; } export declare class GroupJazzApi extends CoValueJazzApi { private group; raw: RawGroup; constructor(group: G, raw: RawGroup); /** * The ID of this `Group` * @category Content */ get id(): ID; /** * Groups have no owner. They can be accessed by everyone. */ get owner(): undefined; /** * Optional display name set at group creation. Immutable; stored in plaintext. * * @category Content */ get name(): string | undefined; /** @category Subscription & Loading */ ensureLoaded>(this: GroupJazzApi, options?: { resolve?: RefsToResolveStrict; }): Promise>; /** @category Subscription & Loading */ subscribe>(this: GroupJazzApi, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; subscribe>(this: GroupJazzApi, options: { resolve?: RefsToResolveStrict; }, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; /** * Create an invite to this group * * @category Invites */ createInvite(role?: AccountRole): InviteSecret; /** * Wait for the `Group` to be uploaded to the other peers. * * @category Subscription & Loading */ waitForSync(options?: { timeout?: number; }): Promise; } export declare function isAccountID(id: RawAccountID | AgentID): id is RawAccountID; export declare function getCoValueOwner(coValue: CoValue): Group; export {}; //# sourceMappingURL=group.d.ts.map