import { Account, BranchDefinition, CoMapSchemaDefinition, Group, Settled, RefsToResolveStrict, RefsToResolve, Resolved, Simplify, SubscribeCallback, SubscribeListenerOptions } from "../../../internal.js"; import { AnonymousJazzAgent } from "../../anonymousJazzAgent.js"; import { InstanceOrPrimitiveOfSchema } from "../typeConverters/InstanceOrPrimitiveOfSchema.js"; import { z } from "../zodReExport.js"; import { AnyZodOrCoValueSchema, Loaded, ResolveQuery } from "../zodSchema.js"; import { CoMapSchema, CoMapDescriptorsSchema, CoreCoMapSchema } from "./CoMapSchema.js"; import { CoOptionalSchema } from "./CoOptionalSchema.js"; import { CoreResolveQuery } from "./CoValueSchema.js"; import { AgentSecret } from "cojson"; export type BaseProfileShape = { name: z.core.$ZodString; inbox?: z.core.$ZodOptional; inboxInvite?: z.core.$ZodOptional; }; export type BaseAccountShape = { profile: CoreCoMapSchema; root: CoreCoMapSchema; }; export type DefaultAccountShape = { profile: CoMapSchema; root: CoMapSchema<{}>; }; export declare class AccountSchema implements CoreAccountSchema { #private; private coValueClass; collaborative: true; builtin: "Account"; shape: Shape; getDescriptorsSchema: () => CoMapDescriptorsSchema; getDefinition: () => CoMapSchemaDefinition; getValidationSchema: () => z.ZodType>; /** * Default resolve query to be used when loading instances of this schema. * This resolve query will be used when no resolve query is provided to the load method. * @default true */ resolveQuery: DefaultResolveQuery; constructor(coreSchema: CoreAccountSchema, coValueClass: typeof Account); create(options: Simplify[0]>): Promise>; load> = DefaultResolveQuery>(id: string, options?: { loadAs?: Account | AnonymousJazzAgent; resolve?: RefsToResolveStrict, R>; }): Promise, R>>>; /** * Creates a new account as a worker account, useful for generating controlled accounts from a server environment. * This method initializes a new account, applies migrations, invokes the `onCreate` callback, and then shuts down the temporary node to avoid memory leaks. * Returns the created account (loaded on the worker) and its credentials. * * The method internally calls `waitForAllCoValuesSync` on the new account. If many CoValues are created during `onCreate`, * consider adjusting the timeout using the `waitForSyncTimeout` option. * * @param worker - The worker account to create the new account from * @param options.creationProps - The creation properties for the new account * @param options.onCreate - The callback to use to initialize the account after it is created * @param options.waitForSyncTimeout - The timeout for the sync to complete * @returns The credentials and the created account loaded by the worker account * * * @example * ```ts * const { credentials, account } = await AccountSchema.createAs(worker, { * creationProps: { name: "My Account" }, * onCreate: async (account, worker, credentials) => { * account.root.$jazz.owner.addMember(worker, "writer"); * }, * }); * ``` */ createAs(worker: Account, options: { creationProps: { name: string; }; onCreate?: (account: AccountInstance, worker: Account, credentials: { accountID: string; accountSecret: AgentSecret; }) => Promise; waitForSyncTimeout?: number; }): Promise<{ credentials: { accountID: string; accountSecret: AgentSecret; }; account: Loaded, DefaultResolveQuery>; }>; unstable_merge> = DefaultResolveQuery>(id: string, options: { loadAs?: Account | AnonymousJazzAgent; resolve?: RefsToResolveStrict, R>; branch: BranchDefinition; }): Promise; subscribe>> = DefaultResolveQuery>(id: string, listener: SubscribeCallback>, R>>): () => void; subscribe>> = DefaultResolveQuery>(id: string, options: SubscribeListenerOptions>, R>, listener: SubscribeCallback>, R>>): () => void; getMe(): Loaded; withMigration(migration: (account: Loaded>, creationProps?: { name: string; }) => void): AccountSchema; getCoValueClass(): typeof Account; optional(): CoOptionalSchema; /** * Adds a default resolve query to be used when loading instances of this schema. * This resolve query will be used when no resolve query is provided to the load method. */ resolved>>(resolveQuery: RefsToResolveStrict, R>): AccountSchema; } export declare function createCoreAccountSchema(shape: Shape): CoreAccountSchema; export type DefaultProfileShape = { name: z.core.$ZodString; inbox: z.core.$ZodOptional; inboxInvite: z.core.$ZodOptional; }; export type CoProfileSchema = CoMapSchema; export interface CoreAccountSchema extends Omit, "builtin"> { builtin: "Account"; } export type AccountInstance = { readonly [key in keyof Shape]: InstanceOrPrimitiveOfSchema; } & Account; //# sourceMappingURL=AccountSchema.d.ts.map