import type { AuthorizationResultBasedEntityLoader } from './AuthorizationResultBasedEntityLoader.ts'; import type { EntityCompositeField, EntityCompositeFieldValue } from './EntityConfiguration.ts'; import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts'; import type { ReadonlyEntity } from './ReadonlyEntity.ts'; import type { ViewerContext } from './ViewerContext.ts'; /** * Enforcing entity loader. All normal loads are batched, * cached, and authorized against the entity's EntityPrivacyPolicy. All loads * through this loader will throw if the load is not successful. */ export declare class EnforcingEntityLoader, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields> { private readonly entityLoader; constructor(entityLoader: AuthorizationResultBasedEntityLoader); /** * Load many entities where fieldName is one of fieldValues. * @param fieldName - entity field being queried * @param fieldValues - fieldName field values being queried * @returns map from fieldValue to entities that match the query for that fieldValue * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities */ loadManyByFieldEqualingManyAsync>(fieldName: N, fieldValues: readonly NonNullable[]): Promise, readonly TEntity[]>>; /** * Load many entities where compositeField is one of compositeFieldValues. * @param compositeField - composite field being queried * @param compositeFieldValues - compositeField values being queried * @returns map from compositeFieldValue to entities that match the query for that compositeFieldValue * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities */ loadManyByCompositeFieldEqualingManyAsync>>(compositeField: N, compositeFieldValues: readonly EntityCompositeFieldValue, N>[]): Promise, readonly TEntity[]>>; /** * Load many entities where fieldName equals fieldValue. * @param fieldName - entity field being queried * @param fieldValue - fieldName field value being queried * @returns array of entities that match the query for fieldValue * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities */ loadManyByFieldEqualingAsync>(fieldName: N, fieldValue: NonNullable): Promise; /** * Load many entities where compositeField equals compositeFieldValue. * @param compositeField - composite field being queried * @param compositeFieldValue - compositeField value being queried * @returns array of entities that match the query for compositeFieldValue * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities */ loadManyByCompositeFieldEqualingAsync>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue, N>): Promise; /** * Load an entity where fieldName equals fieldValue, or null if no entity exists. * @param uniqueFieldName - entity field being queried * @param fieldValue - uniqueFieldName field value being queried * @returns entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition. * @throws when multiple entities match the condition * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity */ loadByFieldEqualingAsync>(uniqueFieldName: N, fieldValue: NonNullable): Promise; /** * Load an entity where compositeField equals compositeFieldValue, or null if no entity exists. * @param compositeField - composite field being queried * @param compositeFieldValue - compositeField value being queried * @returns entity where compositeField equals compositeFieldValue, or null if no entity matches the condition. * @throws when multiple entities match the condition * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity */ loadByCompositeFieldEqualingAsync>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue, N>): Promise; /** * Loads an entity by a specified ID. * @param id - ID of the entity * @returns entity matching ID * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity * @throws EntityNotFoundError when no entity exists for ID */ loadByIDAsync(id: TFields[TIDField]): Promise; /** * Load an entity by a specified ID, or return null if non-existent. * @param id - ID of the entity * @returns entity for matching ID, or null if no entity exists for ID. * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity * @throws when multiple entities are found matching the condition */ loadByIDNullableAsync(id: TFields[TIDField]): Promise; /** * Loads many entities for a list of IDs. * @param ids - IDs of the entities to load * @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError. * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities * @throws EntityNotFoundError when no entity exists for one or more of the IDs */ loadManyByIDsAsync(ids: readonly TFields[TIDField][]): Promise>; /** * Loads many entities for a list of IDs, returning null for any IDs that are non-existent. * @param ids - IDs of the entities to load * @returns map from ID to nullable corresponding entity * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities */ loadManyByIDsNullableAsync(ids: readonly TFields[TIDField][]): Promise>; }