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/schema-detection/service

lib/services/schema-detection/service

Schema Detection Service.

Manages detector selection and execution. Similar to how geocoding providers work - you select a detector for a dataset, and it handles all detection with automatic fallback to the default detector.

Classes

SchemaDetectionService

Service for managing and executing schema detectors.

Example

const service = new SchemaDetectionService([customDetector, defaultDetector]); const result = await service.detect('custom-detector', { fieldStats: stats, sampleData: samples, headers: ['name', 'date', 'location'], config: { enabled: true, priority: 1 } });

Constructors

Constructor

new SchemaDetectionService(detectors): SchemaDetectionService

Create a new detection service with the given detectors.

Parameters
detectors

SchemaDetector[]

Array of detectors to register. The detector named ‘default’ will be used as the fallback when other detectors can’t handle input.

Returns

SchemaDetectionService

Methods

register()

register(detector): void

Register a new detector.

Parameters
detector

SchemaDetector

Returns

void

getDetector()

getDetector(name): SchemaDetector | undefined

Get a detector by name.

Parameters
name

string

Returns

SchemaDetector | undefined

getAllDetectors()

getAllDetectors(): SchemaDetector[]

Get all registered detectors.

Returns

SchemaDetector[]

detect()

detect(detectorName, context): Promise<DetectionResult>

Run detection using the specified detector with fallback to default.

Parameters
detectorName

string | null

Name of the detector to use, or null to use default

context

DetectionContext

Detection context containing field stats, samples, headers

Returns

Promise<DetectionResult>

Detection result with language, field mappings, and patterns

findCompatibleDetector()

findCompatibleDetector(context): Promise<SchemaDetector | null>

Find the first detector that can handle the given context.

Parameters
context

DetectionContext

Detection context

Returns

Promise<SchemaDetector | null>

The first detector that can handle the input, or null

Last updated on