Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/services/import-transforms

lib/services/import-transforms

Applies import transform rules to incoming data.

This service transforms raw import data (CSV rows, JSON objects, Excel rows) according to dataset-level transform rules, enabling flexible field mapping and schema evolution.

Transforms are applied before schema detection and validation, ensuring that incoming data is normalized to match the dataset’s canonical schema regardless of the source format.

Functions

applyTransforms()

applyTransforms(data, transforms): Record<string, unknown>

Apply transform rules to a data object.

Transforms are applied in the order they appear in the transforms array. Only active transforms are applied. The input data object is cloned to avoid mutations.

Parameters

data

Record<string, unknown>

The data object to transform (CSV row, JSON object, etc.)

transforms

ImportTransform[]

Array of transform rules to apply

Returns

Record<string, unknown>

Transformed data object with field mappings applied

Example

const data = { date: "2024-01-15", name: "Event" }; const transforms = [ { type: "rename", from: "date", to: "start_date", active: true } ]; const result = applyTransforms(data, transforms); // Returns: { start_date: "2024-01-15", name: "Event" }

applyTransformsBatch()

applyTransformsBatch(dataArray, transforms): Record<string, unknown>[]

Apply transforms to an array of data objects.

Convenience function for batch processing. Each object is transformed independently.

Parameters

dataArray

Record<string, unknown>[]

Array of data objects to transform

transforms

ImportTransform[]

Array of transform rules to apply

Returns

Record<string, unknown>[]

Array of transformed data objects

Example

const rows = [ { date: "2024-01-15", name: "Event 1" }, { date: "2024-01-16", name: "Event 2" } ]; const transforms = [ { type: "rename", from: "date", to: "start_date", active: true } ]; const result = applyTransformsBatch(rows, transforms); // Returns array with start_date instead of date
Last updated on