/** * Effect-based delete operations for entities. * * Uses Ref for atomic state mutation and typed errors * (NotFoundError, OperationError, ForeignKeyError). * * Preserves soft delete support, foreign key constraint checking, * and cascade handling from the legacy implementation. */ import { Effect, PubSub, Ref } from "effect"; import { type ForeignKeyError, type HookError, NotFoundError, OperationError } from "../../errors/crud-errors.js"; import type { DeleteManyResult } from "../../types/crud-types.js"; import type { HooksConfig } from "../../types/hook-types.js"; import type { CollectionIndexes } from "../../types/index-types.js"; import type { ChangeEvent } from "../../types/reactive-types.js"; import type { SearchIndexMap } from "../../types/search-types.js"; type HasId = { readonly id: string; }; type RelationshipConfig = { readonly type: "ref" | "inverse"; readonly target: string; readonly foreignKey?: string; }; type DeleteOptions = { readonly soft?: boolean; }; type DeleteManyOptions = { readonly soft?: boolean; readonly limit?: number; }; /** * Delete a single entity by ID with optional soft delete. * * Steps: * 1. Look up entity by ID in Ref state (O(1)) * 2. Run beforeDelete hooks (can reject) * 3. If soft delete requested, verify entity has deletedAt field * 4. Check foreign key constraints across all collections * 5. Soft delete: update entity with deletedAt timestamp * Hard delete: remove entity from Ref state */ export declare const del: (collectionName: string, allRelationships: Record>, ref: Ref.Ref>, stateRefs: Record>>, supportsSoftDelete?: boolean, indexes?: CollectionIndexes, hooks?: HooksConfig, searchIndexRef?: Ref.Ref, searchIndexFields?: ReadonlyArray, changePubSub?: PubSub.PubSub) => (id: string, options?: DeleteOptions) => Effect.Effect; /** * Delete multiple entities matching a predicate with optional soft delete. * * Uses a predicate function to select which entities to delete. * The caller (database factory) can use the Stream-based filter pipeline * to build the predicate from a WhereClause. * * Runs hooks per entity: beforeDelete can reject deletion, * afterDelete and onChange run after state mutation. * * All matching entities are deleted atomically in a single Ref.update call. */ export declare const deleteMany: (collectionName: string, allRelationships: Record>, ref: Ref.Ref>, stateRefs: Record>>, supportsSoftDelete?: boolean, indexes?: CollectionIndexes, hooks?: HooksConfig, searchIndexRef?: Ref.Ref, searchIndexFields?: ReadonlyArray, changePubSub?: PubSub.PubSub) => (predicate: (entity: T) => boolean, options?: DeleteManyOptions) => Effect.Effect, OperationError | ForeignKeyError | HookError>; export {}; //# sourceMappingURL=delete.d.ts.map