import type { DataPlane } from "../data-planes/types"; import type { Mapping } from "../mappings/types"; export interface Dataset { id: number; company_id: number; created_at: string; description?: string; name: string; display_name: string; retention_policy: RetentionPolicy; schema: Schema; status: DatasetStatus; tags: string[]; updated_at: string; write_mode: DatasetWriteMode; last_snapshot_created_at?: string; active_dataset_stored_bytes?: number; mappings: Mapping[]; subscription_id?: string; stats?: DatasetStats; is_narrative_managed: boolean; external_id?: string; data_plane: DataPlane; materialized_view_config?: { nql: string; refresh_schedule_config?: { schedule: string; schedule_zone_id: string; status: "active" | "pending" | "archived"; updated_at: string; created_at: string; stats_enabled?: boolean; }; }; compute_pool_config?: { default_compute_pool_id?: string; }; } export interface DatasetStats extends DatasetSummaryStatistics { last_snapshot_added_bytes: number; last_snapshot_added_delete_files: number; last_snapshot_added_files: number; last_snapshot_added_records: number; last_snapshot_deleted_files: number; last_snapshot_deleted_records: number; last_snapshot_removed_bytes: number; last_snapshot_removed_delete_files: number; } export interface DatasetSummaryStatistics { active_dataset_stored_bytes: number; active_dataset_stored_files: number; active_dataset_stored_records: number; est_total_dataset_stored_bytes: number; est_total_dataset_stored_files: number; est_total_dataset_stored_records: number; } export interface RecalculationInfo { recalculation_id?: string; snapshots: string[]; from_snapshot_timestamp?: string; until_snapshot_timestamp?: string; } export interface DatasetColumnSummary { id: number; name: string; type: string; nan_value_count?: number; null_value_count?: number; value_count?: number; lower_bound?: any; upper_bound?: any; column_stored_bytes?: number; } export interface DatasetTableSummary extends DatasetSummaryStatistics { snapshot_id: number; snapshot_created_at: string; snapshot_added_files: number; snapshot_added_records: number; snapshot_deleted_records: number; snapshot_added_bytes: number; snapshot_deleted_files: number; snapshot_added_delete_files: number; snapshot_removed_delete_files: number; snapshot_removed_bytes: number; } export interface DatasetTableSummaryAPIResponse { dataset_id: number; records: DatasetTableSummary[]; } export type SchemaPropertiesType = "string" | "boolean" | "double" | "long" | "timestamptz" | "object" | "array"; export type DatasetStatus = "active" | "archived" | "pending"; export type DatasetWriteMode = "append" | "overwrite"; type SchemaType = "object" | "value"; export declare enum Operator { GreaterThan = ">", LessThan = "<", GreaterThanOrEqualTo = ">=", LessThanOrEqualTo = "<=" } export interface SnapshotAgeExpression { type: "snapshot_age"; operator: Operator; period: string; } export type RetentionPolicy = { type: "retain_everything"; } | { type: "expire_everything"; } | { type: "retain_when"; expression?: SnapshotAgeExpression; } | { type: "expire_when"; expression?: SnapshotAgeExpression; }; export interface RowClock { kind: "event_time"; attribute?: string; } export type TTLPolicyKind = "row_ttl" | "table_ttl" | "snapshot_ttl"; export interface RowTTLPolicy { type: { kind: "row_ttl"; clock?: RowClock; }; enabled: boolean; interval: string; } export type TableClockKind = "created_at" | "max_event_time" | "static_time"; export interface TableClock { kind: TableClockKind; column?: string; } export interface TableTTLPolicy { type: { kind: "table_ttl"; clock: TableClock; }; enabled: boolean; interval: string; } export interface SnapshotTTLPolicy { type: { kind: "snapshot_ttl"; }; enabled: boolean; interval: string; snapshot_retention_policy: RetentionPolicy; } export type TTLPolicy = RowTTLPolicy | TableTTLPolicy | SnapshotTTLPolicy; export interface RetentionScheduleConfig { schedule: string; schedule_zone_id?: string; status?: "active" | "pending" | "archived"; } export interface UpsertRetentionPoliciesRequest { policies: TTLPolicy[]; schedule_config?: RetentionScheduleConfig; } export type SchemaFileConfigType = "flat" | "json" | "parquet"; export interface FlatFileConfig { type: "flat"; delimiter?: string; escape?: string; header?: boolean; quote?: string; } export interface JsonFileConfig { type: "json"; normalize_field_names?: boolean; } export interface ParquetFileConfig { type: "parquet"; } export type SchemaFileConfig = FlatFileConfig | JsonFileConfig | ParquetFileConfig; export type SchemaProperties = Record; export type SchemaProperty = SchemaPrimitiveProperty | SchemaArrayProperty | SchemaObjectProperty; export interface SchemaPrimitiveProperty { display_name: string; type: SchemaPropertiesType; order?: number; approximate_cardinality?: number; description?: string; enum?: (string | number)[]; } export interface SchemaObjectProperty { display_name: string; type: SchemaPropertiesType; order?: number; approximate_cardinality?: number; description?: string; properties: SchemaProperties; sensitive?: string[]; } export interface SchemaArrayProperty { display_name: string; type: SchemaPropertiesType; order?: number; approximate_cardinality?: number; description?: string; items: SchemaArrayItems; } export type SchemaArrayItemsPrimitive = Omit; export type SchemaArrayItemsObject = Omit; export type SchemaArrayItemsArray = Omit; export type SchemaArrayItems = SchemaArrayItemsPrimitive | SchemaArrayItemsObject | SchemaArrayItemsArray; export interface Schema { file_config: SchemaFileConfig; type: SchemaType; properties: SchemaProperties; primary?: string; required?: string[]; unsellable?: string[]; sensitive?: string[]; } interface File { path: string; size: number; } interface Snapshot { files: File[]; snapshot_id: string; timestamp: string; is_downloadable: boolean; } export interface FilePerSnapshotResponse { files_per_snapshot: Snapshot[]; has_next: boolean; next_snapshot: string | null; } export interface ColumnStatistics { advanced_statistics_metadata: AdvancedStatisticsMetadata | null; columns_summary: ColumnSummary[]; } export interface AdvancedStatisticsMetadata { snapshot_range: SnapshotRange; configuration: Configuration; } export interface SnapshotRange { from_snapshot: string; until_snapshot: string; from_snapshot_timestamp: string; until_snapshot_timestamp: string; } export interface Configuration { value_histogram: Columns; completeness: Columns; approx_count_distinct: Columns; count_distinct: Columns; observed_types_histogram: Columns; mean: Columns; deviation: Columns; } export interface Columns { columns: string[]; } export interface ColumnSummary { name: string; type: string; basic_statistics: BasicStatistics; advanced_statistics: AdvancedStatistics | null; } export interface BasicStatistics { nan_value_count: number | null; null_value_count: number; lower_bound: string | number | null | boolean; upper_bound: string | number | null | boolean; value_count: number; } export interface AdvancedStatistics { approx_count_distinct: number | null; count_distinct: number | null; histogram: Histogram | null; mean: number | null; standard_deviation: number | null; completeness: number | null; observed_types: Histogram | null; } export interface Histogram { values: Record; number_of_bins: number; } export interface Value { absolute: number; ratio: number; } export interface UpdateDatasetRequest { dataset_id: number; name?: string; display_name?: string; description?: string; tags?: string[]; write_mode?: DatasetWriteMode; schema?: Schema; } export interface CreateDatasetRequest { name: string; schema: Schema; /** Defaults to `"append"` server-side when omitted. */ write_mode?: DatasetWriteMode; display_name?: string; description?: string; tags?: string[]; derive_metrics_config?: boolean; /** * Pin the new dataset to a specific data plane. When omitted, the platform * falls back to the company's default data plane. Validated server-side. */ data_plane_id?: string; /** Optional external identifier; must be excluded when registering a dataset in an external data plane. */ external_id?: string; /** Whether the dataset is managed by Narrative. Optional for backwards compatibility. */ is_narrative_managed?: boolean; } export interface IngestDatasetFileRequest { source_file: string; } export interface DatasetInterfaceRef { app_id: number; interface_id: string; } /** * A JSON-Schema 2020-12 "Basic" output node, used recursively in validation errors. * `errors` is keyed by JSON-Schema keyword (`"required"`, `"type"`, etc.); values * are human-readable strings. */ export interface JsonSchemaValidationNode { valid: boolean; evaluationPath: string; schemaLocation: string; instanceLocation: string; errors?: Record; details?: JsonSchemaValidationNode[]; } export interface DatasetInterfaceError extends DatasetInterfaceRef { details: JsonSchemaValidationNode; } export interface DatasetInterfaceValidation { dataset_id: number; accepted: DatasetInterfaceRef[]; errors: DatasetInterfaceError[]; } export interface UpdateDatasetRefreshScheduleRequest { cron?: string; cron_zone_id?: string; execution_cluster?: { type: "dedicated" | "shared"; }; stats_enabled?: boolean; status?: DatasetStatus; compute_pool_id?: string; } export interface CreateDatasetRefreshScheduleRequest { cron: string; cron_zone_id: string; execution_cluster?: { type: "dedicated" | "shared"; }; stats_enabled?: boolean; status?: DatasetStatus; compute_pool_id?: string; } export {};