/** * Effect-based update operations with relationship support. * * Uses Ref for atomic state mutation, Effect Schema for validation, * and typed errors. Supports $disconnect, $connect, $update, $delete, and $set * operations for both ref (single) and inverse (many) relationship types. */ import { Effect, PubSub, Ref, type Schema } from "effect"; import { ForeignKeyError, NotFoundError, type OperationError, ValidationError } from "../../errors/crud-errors.js"; import type { ComputedFieldsConfig } from "../../types/computed-types.js"; import type { UpdateWithRelationshipsInput } from "../../types/crud-relationship-types.js"; import type { DerivedIdConfig } from "../../types/database-config-types.js"; import type { ChangeEvent } from "../../types/reactive-types.js"; import type { RelationshipDef } from "../../types/types.js"; type HasId = { readonly id: string; }; type RelationshipConfig = { readonly type: "ref" | "inverse"; readonly target?: string; readonly __targetCollection?: string; readonly foreignKey?: string; }; type CollectionConfig = { readonly schema: Schema.Codec; readonly relationships: Record; readonly id?: DerivedIdConfig; }; type DatabaseConfig = Record; /** * Update a single entity with relationship support. * * Steps: * 1. Strip computed field keys from input (they are derived, not stored) * 2. Look up existing entity by ID * 3. Parse relationship operations from input * 4. Extract base entity updates (non-relationship fields) * 5. Process $disconnect: set FK to null (ref) or update inverse entities * 6. Process $connect: set FK (ref) or update inverse entity FKs * 7. Process $update: update related entities in target collections * 8. Process $delete: disconnect specific inverse entities * 9. Process $set: replace all inverse relationships * 10. Merge base updates, validate, and update the entity */ export declare const updateWithRelationships: (collectionName: string, schema: Schema.Codec, relationships: Record, ref: Ref.Ref>, stateRefs: Record>>, dbConfig: DatabaseConfig, computed?: ComputedFieldsConfig, changePubSub?: PubSub.PubSub, derivedId?: DerivedIdConfig) => (id: string, input: UpdateWithRelationshipsInput>) => Effect.Effect; export {}; //# sourceMappingURL=update-with-relationships.d.ts.map