import type { Result } from '@expo/results'; import type { IEntityClass } from './Entity.ts'; import type { EntityConfiguration } from './EntityConfiguration.ts'; import type { EntityPrivacyPolicy, EntityPrivacyPolicyEvaluationContext } from './EntityPrivacyPolicy.ts'; import type { EntityQueryContext } from './EntityQueryContext.ts'; import type { ReadonlyEntity } from './ReadonlyEntity.ts'; import type { ViewerContext } from './ViewerContext.ts'; import type { IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter.ts'; /** * Common entity loader utilities for entity construction and authorization. * Methods are exposed publicly since in rare cases they may need to be called manually. */ export declare class EntityConstructionUtils, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields> { private readonly viewerContext; private readonly queryContext; private readonly privacyPolicyEvaluationContext; private readonly entityConfiguration; private readonly entityClass; private readonly entitySelectedFields; private readonly privacyPolicy; protected readonly metricsAdapter: IEntityMetricsAdapter; constructor(viewerContext: TViewerContext, queryContext: EntityQueryContext, privacyPolicyEvaluationContext: EntityPrivacyPolicyEvaluationContext, entityConfiguration: EntityConfiguration, entityClass: IEntityClass, entitySelectedFields: TSelectedFields[] | undefined, privacyPolicy: TPrivacyPolicy, metricsAdapter: IEntityMetricsAdapter); /** * Construct an entity from a fields object (applying field selection if applicable), * checking that the ID field is specified. * * @param fieldsObject - fields object */ constructEntity(fieldsObject: TFields): TEntity; /** * Construct and authorize entities from fields map, returning error results for entities that fail * to construct or fail to authorize. * * @param map - map from an arbitrary key type to an array of entity field objects */ constructAndAuthorizeEntitiesAsync(map: ReadonlyMap[]>): Promise[]>>; /** * Construct and authorize entities from field objects array, returning error results for entities that fail * to construct or fail to authorize. * * @param fieldObjects - array of field objects */ constructAndAuthorizeEntitiesArrayAsync(fieldObjects: readonly Readonly[]): Promise[]>; private authorizeEntityResultAsync; constructAndAuthorizeEntityAsync(fieldsObject: Readonly): Promise>; /** * Validate that field values are valid according to the field's validation function. * * @param fieldName - field name to validate * @param fieldValues - field values to validate * @throws EntityInvalidFieldValueError when a field value is invalid */ validateFieldAndValues>(fieldName: N, fieldValues: readonly TFields[N][]): void; private tryConstructEntities; private tryConstructEntity; }