// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FieldMapper } from "../../../../../../FieldMapper";
import type { JsonTopology } from "../../../../../../JsonTopology";

/**
 * Information about a backfill operation
 */
export type BackfillInfo = { 
/**
 * Unique hash identifying this specific backfill operation
 */
backfill_hash: string, 
/**
 * Transform ID being backfilled
 */
transform_id: string, 
/**
 * Schema name
 */
schema_name: string, 
/**
 * Current status
 */
status: BackfillStatus, 
/**
 * When the backfill started (Unix timestamp in seconds)
 */
start_time: number, 
/**
 * When the backfill completed (if finished)
 */
end_time: number, 
/**
 * Error message if failed
 */
error: string | null, 
/**
 * Records produced by the backfill
 */
records_produced: number, 
/**
 * Expected number of mutations to be created (for completion tracking)
 */
mutations_expected: number, 
/**
 * Number of mutations completed so far
 */
mutations_completed: number, 
/**
 * Number of mutations that failed
 */
mutations_failed: number, };

/**
 * Aggregate statistics from all backfills
 */
export type BackfillStatistics = { 
/**
 * Total number of backfills
 */
total_backfills: number, 
/**
 * Number of backfills currently in progress
 */
active_backfills: number, 
/**
 * Number of completed backfills
 */
completed_backfills: number, 
/**
 * Number of failed backfills
 */
failed_backfills: number, 
/**
 * Total mutations expected across all backfills
 */
total_mutations_expected: number, 
/**
 * Total mutations completed across all backfills
 */
total_mutations_completed: number, 
/**
 * Total mutations failed across all backfills
 */
total_mutations_failed: number, 
/**
 * Total records produced across all backfills
 */
total_records_produced: number, };

/**
 * Status of a backfill operation
 */
export type BackfillStatus = "InProgress" | "Completed" | "Failed";

/**
 * Declarative schema definition - the primary schema representation.
 * This is the unified schema type that replaces the old Schema/DeclarativeSchemaDefinition split.
 */
export type DeclarativeSchemaDefinition = { 
/**
 * Schema name
 */
name: string, 
/**
 * Human-readable descriptive name for the schema (used in AI-generated proposals)
 */
descriptive_name: string | null, 
/**
 * Schema type ("Single" | "Range" | "HashRange")
 */
schema_type: DeclarativeSchemaType, 
/**
 * Key configuration (required when schema_type == "HashRange" or "Range")
 */
key: KeyConfig | null, 
/**
 * Field names - plain data fields without transformations
 */
fields: Array<string> | null, 
/**
 * Transform fields - computed fields with expressions (optional, only for transform schemas)
 */
transform_fields: { [key in string]?: string } | null, field_mappers: { [key in string]?: FieldMapper } | null, 
/**
 * SHA256 hash of the schema content for integrity verification
 */
hash: string | null, 
/**
 * Molecule UUIDs for each field (persisted for data continuity after mutations)
 * Maps field_name -> molecule_uuid. Synced from runtime_fields before persistence.
 */
field_molecule_uuids: { [key in string]?: string } | null, 
/**
 * Topology definitions for each field (defines JSON structure)
 * Maps field_name -> JsonTopology. Every field MUST have a topology.
 */
field_topologies: { [key in string]?: JsonTopology }, 
/**
 * Hash of each field's topology for change detection
 * Maps field_name -> topology_hash
 */
field_topology_hashes: { [key in string]?: string } | null, 
/**
 * Hash of all field topologies combined - unique fingerprint of schema structure
 */
topology_hash: string | null, };

/**
 * Represents the schema-level type information.
 */
export type DeclarativeSchemaType = "Single" | "Range" | "HashRange";

/**
 * HashRange filter operations for querying hash-range fields
 */
export type HashRangeFilter = { "HashRangeKey": { hash: string, range: string, } } | { "HashKey": string } | { "HashRangePrefix": { hash: string, prefix: string, } } | { "RangePrefix": string } | { "HashRangeRange": { hash: string, start: string, end: string, } } | { "RangeRange": { start: string, end: string, } } | { "SampleN": number } | { "HashRangeKeys": Array<[string, string]> } | { "HashRangePattern": { hash: string, pattern: string, } } | { "RangePattern": string } | { "HashPattern": string } | { "HashRange": { start: string, end: string, } };

/**
 * Result of a hash-range filter operation
 */
export type HashRangeFilterResult = { 
/**
 * Matches with composite keys in format "KeyValue" -> atom_uuid
 */
matches: { [key in KeyValue]?: string }, 
/**
 * Total count of matches found
 */
total_count: number, 
/**
 * Number of hash groups that had matches
 */
hash_groups_count: number, };

export type KeyConfig = { hash_field: string | null, range_field: string | null, };

/**
 * Represents resolved key values for hash and range components.
 */
export type KeyValue = { hash: string | null, range: string | null, };

/**
 * Transform stores only a schema_name reference to avoid duplication.
 * The full schema is stored in schemas_tree and looked up when needed.
 * This saves ~50% storage for transform schemas (previously stored in both trees).
 */
export type Transform = { 
/**
 * The name of the schema (stored in schemas_tree)
 */
schema_name: string, };
