import type { IEntityClass } from './Entity.ts'; import type { CacheAdapterFlavor, DatabaseAdapterFlavor } from './EntityCompanionProvider.ts'; import type { EntityFieldDefinition } from './EntityFieldDefinition.ts'; import { CompositeFieldHolder } from './internal/CompositeFieldHolder.ts'; /** * A composite field is an unordered set of fields by which entities can be loaded in a batched * and (optionally) cached manner akin to how normal fieldName loads are batched and (optionally) cached. */ export type EntityCompositeField> = readonly (keyof TFields)[]; /** * Specification of composite field for an entity and whether it can be cached. */ export type EntityCompositeFieldDefinition> = { /** * The composite field. */ compositeField: EntityCompositeField; /** * Whether or not to cache loaded instances of the entity by this composite field. The column names in * the composite field are used to derive a cache key for the cache entry. If true, the set of columns * must be able uniquely identify the entity and the database must have a unique constraint on the * set of columns. */ cache: boolean; }; /** * A composite field value is a mapping of fields to values for a composite field. */ export type EntityCompositeFieldValue, TCompositeField extends EntityCompositeField> = Record>; /** * Helper class to validate and store composite field information. */ export declare class CompositeFieldInfo, TIDField extends keyof TFields> { private readonly compositeFieldInfoMap; constructor(compositeFieldsDefinitions: EntityCompositeFieldDefinition[]); getCompositeFieldHolderForCompositeField(compositeField: EntityCompositeField): CompositeFieldHolder | undefined; getAllCompositeFieldHolders(): readonly CompositeFieldHolder[]; canCacheCompositeField(compositeField: EntityCompositeField): boolean; } /** * The data storage configuration for a type of Entity. Contains information relating to IDs, * cachable fields, field mappings, and types of cache and database adapter. */ export declare class EntityConfiguration, TIDField extends keyof TFields> { readonly idField: TIDField; readonly tableName: string; readonly cacheableKeys: ReadonlySet; readonly compositeFieldInfo: CompositeFieldInfo; readonly cacheKeyVersion: number; readonly inboundEdges: IEntityClass[]; readonly schema: ReadonlyMap>; readonly entityToDBFieldsKeyMapping: ReadonlyMap; readonly dbToEntityFieldsKeyMapping: ReadonlyMap; readonly databaseAdapterFlavor: DatabaseAdapterFlavor; readonly cacheAdapterFlavor: CacheAdapterFlavor; constructor({ idField, tableName, schema, inboundEdges, cacheKeyVersion, compositeFieldDefinitions, databaseAdapterFlavor, cacheAdapterFlavor, }: { /** * The field used to identify this entity. Must be a unique field in the table. */ idField: TIDField; /** * The name of the table where entities of this type are stored. */ tableName: string; /** * Map from each entity field to an EntityFieldDefinition specifying information about the field. */ schema: Omit>, TIDField> & Record>; /** * List of other entity types that reference this type in EntityFieldDefinition associations. */ inboundEdges?: IEntityClass[]; /** * Cache key version for this entity type. Should be bumped when a field is added to, removed from, or changed * in this entity and the underlying database table. */ cacheKeyVersion?: number; /** * Composite field definitions for this entity. */ compositeFieldDefinitions?: EntityCompositeFieldDefinition[]; /** * Backing database and transaction type for this entity. */ databaseAdapterFlavor: DatabaseAdapterFlavor; /** * Cache system for this entity. */ cacheAdapterFlavor: CacheAdapterFlavor; }); private validateSchemaMap; private static computeCacheableKeys; private static computeEntityToDBFieldsKeyMapping; }