import type { AuthorizationResultBasedEntityAssociationLoader } from './AuthorizationResultBasedEntityAssociationLoader.ts'; import type { AuthorizationResultBasedEntityLoader } from './AuthorizationResultBasedEntityLoader.ts'; import type { EnforcingEntityAssociationLoader } from './EnforcingEntityAssociationLoader.ts'; import type { EnforcingEntityLoader } from './EnforcingEntityLoader.ts'; import type { IEntityClass } from './Entity.ts'; import type { EntityInvalidationUtils } from './EntityInvalidationUtils.ts'; import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts'; import type { EntityQueryContext } from './EntityQueryContext.ts'; import type { ViewerContext } from './ViewerContext.ts'; /** * A readonly entity exposes only the read functionality of an Entity. Used as the base * type for most entity operations excluding mutations. * * This is also useful as a base class for Entities that should not be mutated, such as: * - Entities representing SQL views. * - Entities representing immutable tables. */ export declare abstract class ReadonlyEntity, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TSelectedFields extends keyof TFields = keyof TFields> { private readonly viewerContext; private readonly id; private readonly databaseFields; private readonly selectedFields; /** * Constructs an instance of an Entity. * * @param constructorParam - data needed to construct an instance of an entity * viewerContext - the ViewerContext reading this entity * id - the ID of this entity * databaseFields - all underlying fields for this entity's data * selectedFields - selected fields for this entity from TSelectedFields type * * This should only be overridden in cases where additional data validation is needed. * The params should not be modified when calling super during constructions. * * @internal */ constructor({ viewerContext, id, databaseFields, selectedFields, }: { viewerContext: TViewerContext; id: TFields[TIDField]; databaseFields: Readonly; selectedFields: Readonly>; }); toString(): string; getUniqueIdentifier(): string; /** * @returns the ViewerContext authorized to read this entity */ getViewerContext(): TViewerContext; /** * @returns the ID of this entity */ getID(): TFields[TIDField]; /** * @returns EnforcingEntityAssociationLoader for this entity */ associationLoader(queryContext?: EntityQueryContext): EnforcingEntityAssociationLoader; /** * @returns AuthorizationResultBasedEntityAssociationLoader for this entity */ associationLoaderWithAuthorizationResults(queryContext?: EntityQueryContext): AuthorizationResultBasedEntityAssociationLoader; /** * Get a underlying field from this entity's data * @param fieldName - the field to get * @returns the value of the field or undefined if not loaded with that field */ getField>(fieldName: K): Pick[K]; /** * @returns all underlying fields from this entity's data */ getAllFields(): Readonly>; /** * @returns all underlying fields from this entity's database data */ getAllDatabaseFields(): Readonly; /** * Vend loader for loading an entity in a given query context. * @param viewerContext - viewer context of loading user * @param queryContext - query context in which to perform the load */ static loader>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends ReadonlyEntity, TMPrivacyPolicy extends EntityPrivacyPolicy, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): EnforcingEntityLoader; /** * Vend loader for loading an entity in a given query context. * @param viewerContext - viewer context of loading user * @param queryContext - query context in which to perform the load */ static loaderWithAuthorizationResults>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends ReadonlyEntity, TMPrivacyPolicy extends EntityPrivacyPolicy, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): AuthorizationResultBasedEntityLoader; /** * Utilities for entity invalidation. * Call these manually to keep entity cache consistent when performing operations outside of the entity framework. */ static invalidationUtils>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends ReadonlyEntity, TMPrivacyPolicy extends EntityPrivacyPolicy, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass, viewerContext: TMViewerContext2): EntityInvalidationUtils; }