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?
optionalformat:string
nullable
nullable:
boolean
enum?
optionalenum: (null|string|number|boolean)[]
items?
optionalitems:SchemaField
properties?
optionalproperties: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?
optionalemail:number
url?
optionalurl:number
dateTime?
optionaldateTime:number
date?
optionaldate:number
numeric?
optionalnumeric:number
numericStats?
optionalnumericStats:object
min
min:
number
max
max:
number
avg
avg:
number
isInteger
isInteger:
boolean
isEnumCandidate
isEnumCandidate:
boolean
enumValues?
optionalenumValues:object[]
value
value:
unknown
count
count:
number
percent
percent:
number
geoHints?
optionalgeoHints: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?
optionallatitude:string
longitude?
optionallongitude:string
combinedField?
optionalcombinedField:string
combinedFormat?
optionalcombinedFormat:string
locationField?
optionallocationField: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?
optionalnewId: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>