import { AgentSecret, CryptoProvider, Everyone, InviteSecret, LocalNode, Peer, RawAccount, SessionID } from "cojson"; import { AnonymousJazzAgent, BranchDefinition, CoFieldInit, type CoMap, type CoValue, CoValueBase, CoValueClass, CoValueClassOrSchema, CoValueJazzApi, Group, ID, MaybeLoaded, Settled, Profile, RefIfCoValue, RefsToResolve, RefsToResolveStrict, Resolved, Schema, SubscribeListenerOptions, TypeSym, inspect, InstanceOfSchemaCoValuesMaybeLoaded, LoadedAndRequired, CoValueCursor, LoadCoValueCursorOption } from "../internal.js"; import type { CoreAccountSchema } from "../implementation/zodSchema/schemaTypes/AccountSchema.js"; import type { AccountSchema as HydratedAccountSchema } from "../implementation/zodSchema/schemaTypes/AccountSchema.js"; export type AccountCreationProps = { name: string; onboarding?: boolean; }; /** @category Identity & Permissions */ export declare class Account extends CoValueBase implements CoValue { [TypeSym]: "Account"; static coValueSchema?: HydratedAccountSchema; /** * Jazz methods for Accounts are inside this property. * * This allows Accounts to be used as plain objects while still having * access to Jazz methods. */ $jazz: AccountJazzApi; readonly profile: MaybeLoaded; readonly root: MaybeLoaded; constructor(options: { fromRaw: RawAccount; }); /** * Whether this account is the currently active account. */ get isMe(): boolean; /** * Accept an invite to a `CoValue` or `Group`. * * @param valueID The ID of the `CoValue` or `Group` to accept the invite to. * @param inviteSecret The secret of the invite to accept. * @param coValueClass [Group] The class of the `CoValue` or `Group` to accept the invite to. * @returns The loaded `CoValue` or `Group`. */ acceptInvite(valueID: string, inviteSecret: InviteSecret, coValueClass?: S): Promise, true>>>; getRoleOf(member: Everyone | ID | "me"): "admin" | undefined; canRead(value: CoValue): boolean; canWrite(value: CoValue): boolean; canManage(value: CoValue): boolean; canAdmin(value: CoValue): boolean; /** @private */ static create(this: CoValueClass & typeof Account, options: { creationProps: { name: string; }; initialAgentSecret?: AgentSecret; peers?: Peer[]; crypto: CryptoProvider; }): Promise; static getMe(this: CoValueClass & typeof Account): A; /** * @deprecated Use `co.account(...).createAs` instead. */ static createAs(this: CoValueClass & typeof Account, worker: Account, options: { creationProps: { name: string; }; onCreate?: (account: A, worker: Account, credentials: { accountID: string; accountSecret: AgentSecret; }) => Promise; waitForSyncTimeout?: number; }): Promise<{ credentials: { accountID: string; accountSecret: AgentSecret; }; account: A; }>; static fromNode(this: CoValueClass, node: LocalNode): A; toJSON(): object | any[]; [inspect](): object | any[]; applyMigration(creationProps?: AccountCreationProps): Promise; migrate(creationProps?: AccountCreationProps): void; /** * Load an `Account` * @category Subscription & Loading * @deprecated Use `co.account(...).load` instead. */ static load = true>(this: CoValueClass, id: ID, options?: { resolve?: RefsToResolveStrict; loadAs?: Account | AnonymousJazzAgent; }): Promise>>; /** * Subscribe to an `Account`, when you have an ID but don't have an `Account` instance yet * @category Subscription & Loading * @deprecated Use `co.account(...).subscribe` instead. */ static subscribe = true>(this: CoValueClass, id: ID, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; static subscribe = true>(this: CoValueClass, id: ID, options: SubscribeListenerOptions, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; } declare class AccountJazzApi extends CoValueJazzApi { private account; raw: RawAccount; private coValueSchema; private descriptorCache; /** * Whether this account is the owner of the local node. * * @internal */ isLocalNodeOwner: boolean; /** @internal */ sessionID: SessionID | undefined; constructor(account: A, raw: RawAccount, coValueSchema: CoreAccountSchema); /** * Accounts have no owner. They can be accessed by everyone. */ get owner(): undefined; /** * Set the value of a key in the account. * * @param key The key to set. * @param value The value to set. * * @category Content */ set(key: K, value: CoFieldInit>): void; has(key: "root" | "profile"): boolean; /** * Get the descriptor for a given key * @internal */ getDescriptor(key: string): Schema | undefined; /** * If property `prop` is a `coField.ref(...)`, you can use `account.$jazz.refs.prop` to access * the `Ref` instead of the potentially loaded/null value. * * This allows you to always get the ID or load the value manually. * * @category Content */ get refs(): { profile: RefIfCoValue | undefined; root: RefIfCoValue | undefined; }; /** @category Subscription & Loading */ ensureLoaded>(this: AccountJazzApi, options: { resolve: RefsToResolveStrict; unstable_branch?: BranchDefinition; cursor?: LoadCoValueCursorOption; }): Promise>; /** @category Subscription & Loading */ subscribe>(this: AccountJazzApi, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; subscribe>(this: AccountJazzApi, options: { resolve?: RefsToResolveStrict; unstable_branch?: BranchDefinition; cursor?: CoValueCursor; }, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; /** * Wait for the `Account` to be uploaded to the other peers. * * @category Subscription & Loading */ waitForSync(options?: { timeout?: number; }): Promise; /** * Wait for all the available `CoValues` to be uploaded to the other peers. * * @category Subscription & Loading */ waitForAllCoValuesSync(options?: { timeout?: number; }): Promise; get loadedAs(): Account | AnonymousJazzAgent; } export declare const AccountAndGroupProxyHandler: ProxyHandler; export type ControlledAccount = Account & { $jazz: { raw: RawAccount; isLocalNodeOwner: true; sessionID: SessionID; }; }; /** @category Identity & Permissions */ export declare function isControlledAccount(account: Account): account is ControlledAccount; export type AccountClass = CoValueClass & { fromNode: (typeof Account)["fromNode"]; }; export {}; //# sourceMappingURL=account.d.ts.map