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

web


web / lib/types/schema-detection

lib/types/schema-detection

Defines the TypeScript types and interfaces related to schema detection and validation.

This file serves as a central repository for the data structures used throughout the schema building and import validation process. It ensures type safety and consistency when dealing with complex objects that represent schema fields, field statistics, schema changes, and duplicate information.

Interfaces

SchemaField

Properties

path

path: string

type

type: "string" | "number" | "boolean" | "object" | "array" | "date" | "null" | "mixed"

format?

optional format: string

nullable

nullable: boolean

enum?

optional enum: (null | string | number | boolean)[]

items?

optional items: SchemaField

properties?

optional properties: Record<string, SchemaField>


FieldStatistics

Properties

path

path: string

occurrences

occurrences: number

occurrencePercent

occurrencePercent: number

nullCount

nullCount: number

uniqueValues

uniqueValues: number

uniqueSamples

uniqueSamples: (null | string | number | boolean | Record<string, unknown>)[]

typeDistribution

typeDistribution: Record<string, number>

formats

formats: object

email?

optional email: number

url?

optional url: number

dateTime?

optional dateTime: number

date?

optional date: number

numeric?

optional numeric: number

numericStats?

optional numericStats: object

min

min: number

max

max: number

avg

avg: number

isInteger

isInteger: boolean

isEnumCandidate

isEnumCandidate: boolean

enumValues?

optional enumValues: object[]

value

value: unknown

count

count: number

percent

percent: number

geoHints?

optional geoHints: object

isLatitude

isLatitude: boolean

isLongitude

isLongitude: boolean

fieldNamePattern

fieldNamePattern: string

valueRange

valueRange: boolean

firstSeen

firstSeen: Date

lastSeen

lastSeen: Date

depth

depth: number


SchemaBuilderState

Properties

version

version: number

fieldStats

fieldStats: Record<string, FieldStatistics>

recordCount

recordCount: number

batchCount

batchCount: number

lastUpdated

lastUpdated: Date

dataSamples

dataSamples: unknown[]

maxSamples

maxSamples: number

detectedIdFields

detectedIdFields: string[]

detectedGeoFields

detectedGeoFields: object

latitude?

optional latitude: string

longitude?

optional longitude: string

combinedField?

optional combinedField: string

combinedFormat?

optional combinedFormat: string

locationField?

optional locationField: string

confidence

confidence: number

typeConflicts

typeConflicts: object[]

path

path: string

types

types: Record<string, number>

samples

samples: object[]


SchemaChange

Properties

type

type: "new_field" | "removed_field" | "type_change" | "enum_change" | "format_change"

path

path: string

details

details: unknown

severity

severity: "error" | "info" | "warning"

autoApprovable

autoApprovable: boolean


SchemaComparison

Properties

changes

changes: SchemaChange[]

isBreaking

isBreaking: boolean

requiresApproval

requiresApproval: boolean

canAutoApprove

canAutoApprove: boolean


DuplicateInfo

Properties

existingId

existingId: string

existingUniqueId

existingUniqueId: string

strategy

strategy: "uniqueId" | "contentHash"


DuplicateAction

Properties

action

action: "skipped" | "updated" | "versioned"

existingId

existingId: string

newId?

optional newId: string

Functions

isValidSchemaBuilderState()

isValidSchemaBuilderState(state): state is SchemaBuilderState

Type guard to check if schema builder state is valid.

Parameters

state

unknown

Returns

state is SchemaBuilderState


getSchemaBuilderState()

getSchemaBuilderState(job): null | SchemaBuilderState

Safe getter for schema builder state from import job.

Parameters

job
schemaBuilderState?

unknown

Returns

null | SchemaBuilderState


getFieldStats()

getFieldStats(job): Record<string, FieldStatistics>

Safe getter for field statistics from schema builder state.

Parameters

job
schemaBuilderState?

unknown

Returns

Record<string, FieldStatistics>

Last updated on