/** * Effect-based create operations with relationship support. * * Uses Ref for atomic state mutation, Effect Schema for validation, * and typed errors. Supports $connect, $create, and $connectOrCreate operations * for both ref (single) and inverse (many) relationship types. */ import { Effect, PubSub, Ref, type Schema } from "effect"; import { ForeignKeyError, type OperationError, ValidationError } from "../../errors/crud-errors.js"; import type { ComputedFieldsConfig } from "../../types/computed-types.js"; import type { CreateWithRelationshipsInput } 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; /** * Create a single entity with relationship support. * * Steps: * 1. Strip computed field keys from input (they are derived, not stored) * 2. Parse relationship operations from input * 3. Generate parent ID early for use in inverse relationships * 4. Process $create: create nested entities in target collections * 5. Process $connectOrCreate: find or create target entities * 6. Process $connect: resolve target entity IDs * 7. Set foreign keys from resolved relationships * 8. Validate and create the parent entity * 9. Update inverse relationship foreign keys on connected entities */ export declare const createWithRelationships: (collectionName: string, schema: Schema.Codec, relationships: Record, ref: Ref.Ref>, stateRefs: Record>>, dbConfig: DatabaseConfig, computed?: ComputedFieldsConfig, changePubSub?: PubSub.PubSub, derivedId?: DerivedIdConfig) => (input: CreateWithRelationshipsInput>) => Effect.Effect; export {}; //# sourceMappingURL=create-with-relationships.d.ts.map