/**
 * Fact-loader descriptor contracts (D0091).
 *
 * The volatile parts of the BigQuery analytics warehouse — which columns
 * exist, which tables exist, and which artifact feeds which table — become
 * declarative `FactTableDescriptor` records. The stable part (read manifest,
 * extract, stage, MERGE) is the generic engine in `./engine.ts`, which knows
 * nothing about specific tables or columns.
 *
 * This module owns only the declarative side: the descriptor shape, the row
 * and column value types, and the pure-extractor context. The two I/O seams
 * (`RunArtifactReader`, `BigQueryFactStore`) are ports under `../ports/`; the
 * orchestration lives in `./engine.ts`. Concrete descriptors and adapters are
 * separate slices (W-fact-table-registry-v1, W-bigquery-fact-store-adapter).
 *
 * Modeled on the artifact registry (`../artifact-registry.ts`): one entry per
 * table, iterated generically, so adding a table or a column is a one-file
 * change.
 *
 * @see docs/decisions/D0091-bigquery-analytics-fact-loader.md
 * @see docs/design-docs/bigquery-analytics-fact-loader.md
 */
/**
 * Author a fact-table descriptor with full row-type checking, then widen it
 * for storage in a heterogeneous {@link FactTableRegistry}.
 *
 * The argument is checked against `FactTableDescriptor<TRow>` (so `mergeKey`,
 * `clusterFields`, and `partitionField` must name real columns and `extract`
 * must return `TRow[]`), while the return type is the widened
 * `FactTableDescriptor` the registry stores. The widening is needed because
 * `rowSchema: z.ZodType<TRow>` is invariant in `TRow`, so a precisely-typed
 * descriptor is not directly assignable to the widened element type. This is
 * the same authoring pattern as `buildDescriptor` / `defineTask`.
 */
export function defineFactTable(descriptor) {
    return descriptor;
}
/** Derive the store-facing table spec from a descriptor. */
export function toFactTableSpec(descriptor) {
    return {
        table: descriptor.table,
        dataset: descriptor.dataset,
        schema: descriptor.schema,
        partitionField: descriptor.partitionField,
        clusterFields: [...descriptor.clusterFields],
    };
}
