import type { EntityTriggerMutationInfo } from './EntityMutationInfo.ts'; import type { EntityTransactionalQueryContext } from './EntityQueryContext.ts'; import type { ReadonlyEntity } from './ReadonlyEntity.ts'; import type { ViewerContext } from './ViewerContext.ts'; /** * Interface to define trigger behavior for entities. */ export interface EntityMutationTriggerConfiguration, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TSelectedFields extends keyof TFields = keyof TFields> { /** * Trigger set that runs within the transaction but before the entity is created in the database. */ beforeCreate?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but after the entity is created in the database and cache is invalidated. */ afterCreate?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but before the entity is updated in the database. */ beforeUpdate?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but after the entity is updated in the database and cache is invalidated. */ afterUpdate?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but before the entity is deleted from the database. */ beforeDelete?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but after the entity is deleted from the database and cache is invalidated. */ afterDelete?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but before the entity is created, updated, or deleted. */ beforeAll?: EntityMutationTrigger[]; /** * Trigger set that runs within the transaction but after the entity is created in, updated in, or deleted from * the database and the cache is invalidated. */ afterAll?: EntityMutationTrigger[]; /** * Trigger set that runs after committing the mutation transaction. If the call to the mutation is wrapped in a transaction, these * will be run after the wrapping transaction is completed. */ afterCommit?: EntityNonTransactionalMutationTrigger[]; } /** * A transactional trigger is a way to specify entity mutation operation side-effects that run within the * same transaction as the mutation itself. */ export declare abstract class EntityMutationTrigger, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TSelectedFields extends keyof TFields = keyof TFields> { abstract executeAsync(viewerContext: TViewerContext, queryContext: EntityTransactionalQueryContext, entity: TEntity, mutationInfo: EntityTriggerMutationInfo): Promise; } /** * A non-transactional trigger is like a EntityMutationTrigger but used for afterCommit triggers * since they run after the transaction is committed. */ export declare abstract class EntityNonTransactionalMutationTrigger, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity, TSelectedFields extends keyof TFields = keyof TFields> { abstract executeAsync(viewerContext: TViewerContext, entity: TEntity, mutationInfo: EntityTriggerMutationInfo): Promise; }