import { Account, Group, type GroupRole } from "../../internal.js"; /** * Defines how a nested CoValue’s owner is obtained when creating CoValues from JSON. * * This configuration is not used when using an explicit .create() for nested CoValues. * In that case, {@link SchemaPermissions.default} is used. */ export type OnInlineCreateOptions = /** * Always create a new group for CoValues created inline */ "newGroup" /** * Use the same owner as the container CoValue */ | "sameAsContainer" /** * Create a new group that includes the container CoValue's owner as a member (effectively inheriting * all permissions from the container) */ | "extendsContainer" /** * Similar to "extendsContainer", but allows overriding the role of the container CoValue's owner */ | { extendsContainer: GroupRole; } /** * Create a new group and configure it as needed */ | InlineGroupConfigurationCallback; export type InlineGroupConfigurationCallback = (newGroup: Group, context: { containerOwner: Group; }) => void; export type OnCreateCallback = (newGroup: Group) => void; /** * Internal callback type used by RefPermissions that includes init for discriminated union support. * @internal */ export type RefOnCreateCallback = (newGroup: Group, init?: unknown) => void; /** * Permissions to be used when creating or composing CoValues * @param default - default owner to be used when creating a CoValue without providing an explicit owner. * @param onInlineCreate - defines how a nested CoValue's owner is obtained when creating CoValues from JSON. * @param onCreate - callback that runs every time a CoValue is created. Can be used to configure the CoValue's owner. * Runs both when creating CoValues with `.create()` and when creating CoValues from JSON. * @default { default: () => Group.create(), onInlineCreate: "extendsContainer" } */ export type SchemaPermissions = { /** * default owner to be used when creating a CoValue without providing an explicit owner. */ default?: () => Group; /** * Defines how a nested CoValue's owner is obtained when creating CoValues from JSON. */ onInlineCreate?: OnInlineCreateOptions; /** * callback that runs every time a CoValue is created. Can be used to configure the CoValue's owner. * Runs both when creating CoValues with `.create()` and when creating CoValues from JSON. */ onCreate?: OnCreateCallback; /** * Restrict deletion operations on CoList values to manager/admin roles. */ writer?: "appendOnly"; }; export declare let DEFAULT_SCHEMA_PERMISSIONS: SchemaPermissions; /** * Update the default schema permissions for all new CoValue schemas. * Schemas created before calling this function will not be affected. */ export declare function setDefaultSchemaPermissions(permissions: SchemaPermissions): void; /** * Parsed {@link SchemaPermissions}, used by CoValue classes to set up permissions for referenced CoValues. */ export type RefPermissions = { newInlineOwnerStrategy: NewInlineOwnerStrategy; onCreate?: RefOnCreateCallback; }; /** * A function that creates a new owner for a new CoValue created inline. * @param createNewGroup - A function that creates a new group. * @param containerOwner - The owner of the container CoValue. * @param init - The value used to create the new CoValue. Necessary to determine the concrete * strategy to use in discriminated unions. * @returns The new owner. */ export type NewInlineOwnerStrategy = (createNewGroup: () => Group, containerOwner: Group, init?: unknown) => Group; export declare const extendContainerOwnerFactory: (roleOverride?: GroupRole) => NewInlineOwnerStrategy; /** * A function that creates a new owner for a new CoValue by extending the container CoValue's owner * (without overriding its role) */ export declare const extendContainerOwner: NewInlineOwnerStrategy; export declare function schemaToRefPermissions(permissions: SchemaPermissions): RefPermissions; export declare function getDefaultRefPermissions(): RefPermissions; export declare function withSchemaPermissions(options?: T | Account | Group, schemaPermissions?: SchemaPermissions): T & { onCreate?: OnCreateCallback; restrictDeletion?: boolean; }; //# sourceMappingURL=schemaPermissions.d.ts.map