import type { Result } from "effect"; import type { CollectionConfig } from "../types/database-config-types.js"; export type SourceCollectionSelection = "all" | ReadonlyArray; export type SourceStrictness = "error"; export type UnknownCollectionPolicy = "error" | "preserve"; export type DocumentGraphFragmentErrorPolicy = "error" | "skip-fragment" | "skip-root"; export interface DocumentSourceConfig { readonly id: string; readonly kind: "documents"; readonly root: string; readonly include?: string | ReadonlyArray; readonly exclude?: string | ReadonlyArray; readonly format?: string; readonly collections?: SourceCollectionSelection; readonly unknownCollections?: UnknownCollectionPolicy; readonly duplicates?: SourceStrictness; readonly outbox: string; readonly optional?: boolean; } export interface FileSourceConfig { readonly id: string; readonly kind: "file"; readonly collection: string; readonly file: string; readonly format?: string; } export interface DirectorySourceConfig { readonly id: string; readonly kind: "directory"; readonly collection: string; readonly directory: string; readonly format: string; } export interface AppendOnlyLogSourceConfig { readonly id: string; readonly kind: "appendOnly"; readonly collection: string; readonly file: string; readonly format?: string; } /** * Context passed to a {@link DocumentGraphTransform} for one decoded fragment. */ export interface DocumentGraphTransformContext { readonly sourceId: string; readonly rootId: string; readonly path: string; readonly extension: string; } /** * Pure decode transform for a document-graph fragment. Receives the decoded * document and returns a {@link Result}: success carries the (possibly reshaped) * document, failure carries a user-defined typed error wrapped by the loader * with source/path context. */ export type DocumentGraphTransform = (document: unknown, context: DocumentGraphTransformContext) => Result.Result; export interface DocumentGraphRootConfig { readonly id?: string; readonly root: string; readonly optional?: boolean; readonly include?: string | ReadonlyArray; readonly exclude?: string | ReadonlyArray; readonly collections?: SourceCollectionSelection; } export interface DocumentGraphSourceConfig { readonly id: string; readonly kind: "documentGraph"; readonly roots: ReadonlyArray; readonly collections?: SourceCollectionSelection; readonly include?: string | ReadonlyArray; readonly exclude?: string | ReadonlyArray; readonly transform?: DocumentGraphTransform; readonly onFragmentError?: DocumentGraphFragmentErrorPolicy; } export type DatabaseSourceConfig = DocumentSourceConfig | FileSourceConfig | DirectorySourceConfig | AppendOnlyLogSourceConfig | DocumentGraphSourceConfig; export interface NormalizedDocumentSourceConfig { readonly id: string; readonly kind: "documents"; readonly root: string; readonly include: ReadonlyArray; readonly exclude: ReadonlyArray; readonly format: string; readonly collections: ReadonlyArray; readonly unknownCollections: UnknownCollectionPolicy; readonly duplicates: SourceStrictness; readonly outbox: string; readonly optional: boolean; } export interface NormalizedDocumentGraphRootConfig { readonly id: string; readonly root: string; readonly optional: boolean; readonly include: ReadonlyArray; readonly exclude: ReadonlyArray; readonly collections: ReadonlyArray; } export interface NormalizedDocumentGraphSourceConfig { readonly id: string; readonly kind: "documentGraph"; readonly roots: ReadonlyArray; readonly collections: ReadonlyArray; readonly transform?: DocumentGraphTransform; readonly onFragmentError: DocumentGraphFragmentErrorPolicy; } export type NormalizedDatabaseSourceConfig = NormalizedDocumentSourceConfig | NormalizedDocumentGraphSourceConfig; export interface SourceOrientedConfigInput { readonly collections: Record; readonly sources?: ReadonlyArray; } export interface NormalizedSourceConfig { readonly collections: ReadonlyArray; readonly collectionConfigs: Record; readonly sources: ReadonlyArray; } export declare const relativeToRoot: (root: string, path: string) => string; export declare const matchesDocumentSourcePattern: (source: Pick, path: string) => boolean; export declare const normalizeSourceConfig: (config: SourceOrientedConfigInput) => NormalizedSourceConfig; //# sourceMappingURL=source-config.d.ts.map