import type { EntityAuthorizationAction, EntityPrivacyPolicyEvaluationMode } from '../EntityPrivacyPolicy.ts'; import type { EntityLoadMethodType } from '../internal/EntityLoadInterfaces.ts'; /** * The type of the load method being called. */ export declare enum EntityMetricsLoadType { /** * Standard EntityLoader load (the methods from EnforcingEntityLoader or AuthorizationResultBasedEntityLoader). */ LOAD_MANY = 0, /** * Knex loader load using loadManyByFieldEqualityConjunctionAsync. */ LOAD_MANY_EQUALITY_CONJUNCTION = 1, /** * Knex loader load using loadManyBySQL. */ LOAD_MANY_SQL = 2, /** * Internal data manager load via database adapter method loadOneEqualingAsync. */ LOAD_ONE = 3, /** * Knex loader load using loadPageAsync. */ LOAD_PAGE = 4 } /** * The type of the count method being called. */ export declare enum EntityMetricsCountType { /** * Knex loader count using countBySQLFragmentAsync. */ COUNT_SQL = 0, /** * Knex loader count using countByFieldEqualityConjunctionAsync. */ COUNT_EQUALITY_CONJUNCTION = 1 } /** * Event about a single call to an EntityLoader method. */ export interface EntityMetricsLoadEvent { /** * EntityMetricsLoadType for this load. */ type: EntityMetricsLoadType; /** * Whether this load is within a transaction. */ isInTransaction: boolean; /** * Class name of the Entity being loaded. */ entityClassName: string; /** * Total duration of this load, including fetch and construction of entities. */ duration: number; /** * Number of entities returned for this load. */ count: number; } /** * Event about a single call to an EntityLoader count method. Counts return a * number rather than entities, so they are reported separately from loads. */ export interface EntityMetricsCountEvent { /** * EntityMetricsCountType for this count. */ type: EntityMetricsCountType; /** * Whether this count is within a transaction. */ isInTransaction: boolean; /** * Class name of the Entity being counted. */ entityClassName: string; /** * Total duration of this count query. */ duration: number; /** * The number returned by the count query. No entities are loaded for a count. */ count: number; } /** * The type of mutation being performed. */ export declare enum EntityMetricsMutationType { CREATE = 0, UPDATE = 1, DELETE = 2 } export interface EntityMetricsMutationEvent { /** * EntityMetricsMutationType for this mutation. */ type: EntityMetricsMutationType; /** * Whether this mutation is within a transaction. */ isInTransaction: boolean; /** * Class name of the Entity being mutated. */ entityClassName: string; /** * Total duration of this mutation. */ duration: number; } /** * Type used to delineate dataloader, cache, and database load counts in EntityDataManager. */ export declare enum IncrementLoadCountEventType { /** * Type for when a dataloader load is initiated via the standard load methods * since all loads go through a dataloader. */ DATALOADER = 0, /** * Type for when a cache load is initiated due to a dataloader miss. */ CACHE = 1, /** * Type for when a database load is initiated due to a dataloader and cache miss, when an entity query doesn't support caching, or during a transaction. */ DATABASE = 2 } /** * Event used to record dataloader, cache, and database load counts in EntityDataManager. */ export interface IncrementLoadCountEvent { /** * Type of this event. */ type: IncrementLoadCountEventType; /** * Whether this load is within a transaction. */ isInTransaction: boolean; /** * Load method type for this event. */ loadType: EntityLoadMethodType; /** * Number of field values being loaded for this call. */ fieldValueCount: number; /** * Class name of the Entity being loaded. */ entityClassName: string; } export declare enum EntityMetricsAuthorizationResult { DENY = 0, ALLOW = 1 } /** * Event used to record a singe EntityPrivacyPolicy authorization. */ export interface EntityMetricsAuthorizationEvent { /** * Class name of the Entity being authorized. */ entityClassName: string; /** * The action being authorized. */ action: EntityAuthorizationAction; /** * The result of the authorization. */ evaluationResult: EntityMetricsAuthorizationResult; /** * The evaluation mode of the privacy policy. */ privacyPolicyEvaluationMode: EntityPrivacyPolicyEvaluationMode; } /** * An interface for gathering metrics about the Entity framework. Information about * entity load and mutation operations is piped to an instance of this adapter. * * Method implementations of this interface must not throw exceptions since they are called * in critical paths of entity loading and mutation, and thrown exceptions would cause entity * operations to fail at points not tested by unit tests of the adapter implementation. */ export interface IEntityMetricsAdapter { /** * Called when a EntityPrivacyPolicy authorization succeeds or fails. * @param authorizationEvent - info about the authorization event */ logAuthorizationEvent(authorizationEvent: EntityMetricsAuthorizationEvent): void; /** * Called when any load occurs. * @param loadEvent - info about the load event */ logDataManagerLoadEvent(loadEvent: EntityMetricsLoadEvent): void; /** * Called when any count occurs. Counts return a number rather than entities, * so they are reported separately from loads. * @param countEvent - info about the count event */ logDataManagerCountEvent(countEvent: EntityMetricsCountEvent): void; /** * Called when any mutation occurs. * @param mutationEvent - info about the mutation event */ logMutatorMutationEvent(mutationEvent: EntityMetricsMutationEvent): void; /** * Called when a dataloader, cache, or database load is initiated via the standard * load methods (not equality conjunction or raw). Most commonly used for logging * a waterfall to determine dataloader and cache hit rates and ratios. * @param incrementLoadCountEvent - count of field values being loaded for a field */ incrementDataManagerLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void; }