/** * Access Control List defining CRUD permissions for a limetype or property * * The Acl interface represents the user's permissions for a {@link LimeType} or * {@link LimeProperty}. It follows the standard CRUD (Create, Read, Update, Delete) * permission model. * * ACL permissions are typically checked before allowing users to perform operations * on a type or property, and can be used to conditionally show or hide UI elements * based on what the user is allowed to do. * * Each permission below carries its own example. * * @public * @group Lime types */ export interface Acl { /** * Permission to delete objects of this type, or to delete this property's * value * * When `true`, the user is allowed to delete objects of the {@link LimeType} * this ACL belongs to, or clear this {@link LimeProperty}'s value. * * @example Deleting the current object * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const limetypes = platform.get(PlatformServiceName.LimeTypeRepository); * const objects = platform.get(PlatformServiceName.LimeObjectRepository); * * const currentType = context.limetype * ? limetypes.getLimeType(context.limetype) * : undefined; * * if (currentType?.acl.delete && context.limetype && context.id) { * await objects.deleteObject(context.limetype, context.id); * } * ``` */ delete: boolean; /** * Permission to read objects of this type, or read this property * * When `true`, the user is allowed to view objects of the {@link LimeType} * this ACL belongs to, or view this {@link LimeProperty}'s value. * * @example Listing only the types the user may read * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const repository = platform.get(PlatformServiceName.LimeTypeRepository); * * // Types the user may not read are hidden entirely * const visibleTypes = repository * .getLimeTypes() * .filter((limetype) => limetype.acl.read); * ``` */ read: boolean; /** * Permission to update objects of this type, or update this property * * When `true`, the user is allowed to modify objects of the {@link LimeType} * this ACL belongs to, or modify this {@link LimeProperty}'s value. * * @example Choosing between an editable and a read-only field * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const repository = platform.get(PlatformServiceName.LimeTypeRepository); * const property = repository.getLimeType('person')?.getProperty('name'); * * // An editable input when the user may update, read-only text otherwise * const fieldMode = property?.acl.update ? 'editable' : 'readonly'; * ``` */ update: boolean; /** * Permission to create new objects of this type * * When `true`, the user is allowed to create new objects of this * {@link LimeType}. This permission is only relevant on {@link LimeType}, * not on {@link LimeProperty}. * * @example Showing a create action * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const repository = platform.get(PlatformServiceName.LimeTypeRepository); * const companyType = repository.getLimeType('company'); * * if (companyType?.acl.create) { * // show a "create new company" action * } * ``` */ create: boolean; }