export interface Mapping { id: string; attribute_id: number; created_at: string; dataset_id: number; mapping: MappingDefinition; status: MappingStatus; updated_at: string; created_by: number; updated_by: number; company_id?: number; scope: MappingScope; source: MappingSource; derived_from?: string; tags?: string[]; } type MappingStatus = "active" | "archived" | "pending" | "rejected"; type MappingScope = "global" | "private"; type MappingSource = "system" | "admin" | "company" | "lineage" | "rosetta_stone"; type CreateMappingSource = "company" | "rosetta_stone"; /** Only `active` and `pending` are accepted when creating a new mapping. */ type CreateMappingStatus = "active" | "pending"; export interface MappingExpressionDependencies { properties: string[]; } export interface RawPropertyMapping { path: string; expression: string; } export interface RawObjectMapping { type: "object_mapping"; property_mappings: RawPropertyMapping[]; } export interface RawValueMapping { type: "value_mapping"; expression: string; } /** * Create/update shape for cached mappings. * `cache_dataset_id` is assigned server-side and returned on the read shape (`CachedMapping`). * Only valid on company-scoped create endpoints (e.g. `POST /mappings/companies/{company_id}`). */ export interface RawCachedMapping { type: "cached_mapping"; /** One or more SQL expressions evaluated against the source dataset to build the join key. */ input_expressions: string[]; } export interface PropertyMapping { path: string; expression: string; dependencies: MappingExpressionDependencies; } export interface ObjectMapping { type: "object_mapping"; property_mappings: PropertyMapping[]; } export interface ValueMapping { type: "value_mapping"; expression: string; dependencies: MappingExpressionDependencies; } /** Read shape for cached mappings. See `RawCachedMapping` for create/update requests. */ export interface CachedMapping { type: "cached_mapping"; /** Dataset that stores the input → mapped_value lookup rows for this mapping. */ cache_dataset_id: number; /** One or more SQL expressions evaluated against the source dataset to build the join key. */ input_expressions: string[]; dependencies?: MappingExpressionDependencies; } export type MappingDefinition = ObjectMapping | ValueMapping | CachedMapping; export type RawMappingDefinition = RawObjectMapping | RawValueMapping | RawCachedMapping; export interface CreateMapping { attribute_id: number; dataset_id: number; mapping: RawMappingDefinition; tags?: string[]; status?: CreateMappingStatus; source?: CreateMappingSource; } export interface MappingTestResult { input: Record; output: Record; } export interface MappingTestResults { records: MappingTestResult[]; } export {};