import { StateRepository } from '../core'; import { LimeType } from './limetype'; /** * Repository for accessing limetype metadata and schema information. * * {@link LimeTypeRepository} provides access to limetype definitions that describe * the structure, properties, and access controls for business object types in Lime CRM. * Each {@link LimeType} contains: * - Property definitions (name, type, validation rules, etc.) * - Access control lists (ACLs) defining permissions * - Localized display names * - Relationship information to other limetypes * * The repository extends {@link StateRepository}, enabling: * - Reactive subscriptions to limetype changes * - Automatic updates when metadata changes * - Integration with state decorators * * **RECOMMENDED**: Use {@link SelectCurrentLimeType} decorator to automatically get the * limetype for the current context. This is more convenient than manual repository access * and ensures your component reacts to context changes. * * Each method below carries its own example. * * @public * @group Lime types * @see {@link LimeType} for the type definition structure * @see {@link SelectCurrentLimeType} decorator for automatic reactive access * @see {@link StateRepository} for subscription patterns */ export interface LimeTypeRepository extends StateRepository { /** * Get all loaded limetypes. * * Returns an array of all {@link LimeType} definitions currently loaded in the * repository state. This typically includes all limetypes that the current user * has access to in the Lime CRM system. * * The returned array may be empty if limetypes have not been loaded yet. * Limetypes are usually loaded automatically during platform initialization. * * @returns Array of {@link LimeType} definitions (may be empty) * * @example Finding the types the user may create * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const repository = platform.get(PlatformServiceName.LimeTypeRepository); * const types = repository.getLimeTypes(); * const creatableTypes = types.filter((limetype) => limetype.acl.create); * ``` * * @see {@link LimeType} for the structure of limetype definitions * @see {@link getLimeType} to retrieve a specific limetype by name */ getLimeTypes(): LimeType[]; /** * Get a specific limetype by name. * * Retrieves the {@link LimeType} definition for the specified limetype name. * Returns `undefined` if the limetype does not exist or has not been loaded. * * Common limetype names include: 'company', 'person', 'deal', 'todo', 'helpdesk', * but the available types depend on your Lime CRM configuration. * * @param name - Internal name of the limetype (e.g., 'deal', 'company', 'person') * @returns The {@link LimeType} definition, or `undefined` if not found * * @example Getting the deal limetype * ```ts * import { PlatformServiceName } from '@limetech/lime-web-components'; * * const repository = platform.get(PlatformServiceName.LimeTypeRepository); * const dealType = repository.getLimeType('deal'); * * if (dealType) { * console.log('Deal type:', dealType.localname.singular); * console.log('Can create deals:', dealType.acl.create); * } * ``` * * @see {@link LimeType} for the structure of limetype definitions * @see {@link getLimeTypes} to retrieve all available limetypes * @see {@link SelectCurrentLimeType} decorator for automatic context-based access */ getLimeType(name: string): LimeType | undefined; }