import type { IEntityClass } from './Entity.ts'; import type { IPrivacyPolicyClass } from './EntityCompanion.ts'; import { EntityCompanion } from './EntityCompanion.ts'; import type { EntityConfiguration } from './EntityConfiguration.ts'; import type { EntityMutationTriggerConfiguration } from './EntityMutationTriggerConfiguration.ts'; import type { EntityMutationValidatorConfiguration } from './EntityMutationValidatorConfiguration.ts'; import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts'; import type { EntityQueryContextProvider } from './EntityQueryContextProvider.ts'; import type { IEntityCacheAdapterProvider } from './IEntityCacheAdapterProvider.ts'; import type { IEntityDatabaseAdapterProvider } from './IEntityDatabaseAdapterProvider.ts'; import type { ReadonlyEntity } from './ReadonlyEntity.ts'; import type { ViewerContext } from './ViewerContext.ts'; import type { IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter.ts'; /** * Backing database and transaction type for an entity. The definitions and implementations * are provided by injection in the root EntityCompanionProvider to allow for mocking and sharing. */ export type DatabaseAdapterFlavor = string; /** * Cache system for an entity. The definitions and implementations are provided by injection * in the root EntityCompanionProvider to allow for mocking and sharing. */ export type CacheAdapterFlavor = string; /** * Defines a set interfaces for a entity database adapter flavor. An entity that uses a flavor * will use the specified adapter for database accesses and the specified query context provider * for providing query contexts. */ export interface DatabaseAdapterFlavorDefinition { adapterProvider: IEntityDatabaseAdapterProvider; queryContextProvider: EntityQueryContextProvider; } /** * Defines an interface for a cache adapter flavor. An entity that uses a flavor will use the * specified adapter for caching. */ export interface CacheAdapterFlavorDefinition { cacheAdapterProvider: IEntityCacheAdapterProvider; } /** * Definition for constructing a companion for an entity. Defines the core set of objects * used to power the entity framework for a particular type of entity. */ export interface EntityCompanionDefinition, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields> { /** * The concrete Entity class for which this is the definition. */ readonly entityClass: IEntityClass; /** * The EntityConfiguration for this entity. */ readonly entityConfiguration: EntityConfiguration; /** * The EntityPrivacyPolicy class for this entity. */ readonly privacyPolicyClass: IPrivacyPolicyClass; /** * An optional EntityMutationValidatorConfiguration for this entity. */ readonly mutationValidators?: EntityMutationValidatorConfiguration; /** * An optional EntityMutationTriggerConfiguration for this entity. */ readonly mutationTriggers?: EntityMutationTriggerConfiguration; /** * An optional subset of fields defined in the EntityConfiguration which belong to this entity. * For use when multiple types of entities are backed by a single table (EntityConfiguration) yet * only expose a subset of the fields. */ readonly entitySelectedFields?: TSelectedFields[]; } /** * An instance of the Entity framework. * * Required to create a ViewerContext, which is the application entry point * into the framework. * * Internally, this is a lazy entity companion factory that instantiates and caches one * EntityCompanion for each type of Entity. */ export declare class EntityCompanionProvider { readonly metricsAdapter: IEntityMetricsAdapter; private readonly databaseAdapterFlavors; private readonly cacheAdapterFlavors; readonly globalMutationTriggers: EntityMutationTriggerConfiguration; private readonly companionDefinitionMap; private readonly companionMap; private readonly tableDataCoordinatorMap; /** * Instantiate an Entity framework. * @param metricsAdapter - An IEntityMetricsAdapter for collecting metrics on this instance * @param databaseAdapterFlavors - Database adapter configurations for this instance * @param cacheAdapterFlavors - Cache adapter configurations for this instance * @param globalMutationTriggers - Optional set of EntityMutationTrigger to run for all entity mutations systemwide. */ constructor(metricsAdapter: IEntityMetricsAdapter, databaseAdapterFlavors: ReadonlyMap, cacheAdapterFlavors: ReadonlyMap, globalMutationTriggers?: EntityMutationTriggerConfiguration); /** * Get the entity companion for specified entity. If not already computed and cached, the entity * companion is constructed using the configuration provided by the factory. * * @param entityClass - entity class to load */ getCompanionForEntity, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields>(entityClass: IEntityClass): EntityCompanion; getQueryContextProviderForDatabaseAdapterFlavor(databaseAdapterFlavor: DatabaseAdapterFlavor): EntityQueryContextProvider; private getTableDataCoordinatorForEntity; }