web / lib/services/schema-detection/utilities/patterns
lib/services/schema-detection/utilities/patterns
Field pattern matching utilities.
Provides language-aware pattern matching for detecting standard event fields (title, description, timestamp, location) based on column names and data characteristics.
Interfaces
FieldPatternMatch
Result of matching a name against field patterns.
Properties
name
name:
string
The name that matched
patternIndex
patternIndex:
number
Index of the matched pattern (lower = more specific)
patternCount
patternCount:
number
Total patterns checked
isFallback
isFallback:
boolean
Whether the match came from the primary language or the English fallback
Variables
FIELD_PATTERNS
constFIELD_PATTERNS:object
Language-specific field name patterns.
Patterns are ordered by specificity - more specific patterns first to ensure higher confidence scores for better matches.
Type Declaration
title
readonlytitle:object
title.eng
readonlyeng: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.deu
readonlydeu: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.fra
readonlyfra: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.spa
readonlyspa: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.ita
readonlyita: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.nld
readonlynld: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
title.por
readonlypor: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description
readonlydescription:object
description.eng
readonlyeng: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.deu
readonlydeu: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.fra
readonlyfra: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.spa
readonlyspa: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.ita
readonlyita: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.nld
readonlynld: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
description.por
readonlypor: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName
readonlylocationName:object
locationName.eng
readonlyeng: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.deu
readonlydeu: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.fra
readonlyfra: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.spa
readonlyspa: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.ita
readonlyita: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.nld
readonlynld: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
locationName.por
readonlypor: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp
readonlytimestamp:object
timestamp.eng
readonlyeng: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.deu
readonlydeu: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.fra
readonlyfra: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.spa
readonlyspa: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.ita
readonlyita: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.nld
readonlynld: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
timestamp.por
readonlypor: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location
readonlylocation:object
location.eng
readonlyeng: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.deu
readonlydeu: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.fra
readonlyfra: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.spa
readonlyspa: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.ita
readonlyita: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.nld
readonlynld: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
location.por
readonlypor: readonly [RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp,RegExp]
LATITUDE_PATTERNS
constLATITUDE_PATTERNS:RegExp[]
Latitude patterns for coordinate detection.
Supports separators: underscore, space, hyphen, dot
LONGITUDE_PATTERNS
constLONGITUDE_PATTERNS:RegExp[]
Longitude patterns for coordinate detection.
Supports separators: underscore, space, hyphen, dot
COMBINED_COORDINATE_PATTERNS
constCOMBINED_COORDINATE_PATTERNS:RegExp[]
Combined coordinate patterns.
Recognizes fields that contain both latitude and longitude in a single value.
COORDINATE_BOUNDS
constCOORDINATE_BOUNDS:object
Valid coordinate bounds.
Type Declaration
latitude
latitude:
object
latitude.min
min:
number=-90
latitude.max
max:
number=90
longitude
longitude:
object
longitude.min
min:
number=-180
longitude.max
max:
number=180
ADDRESS_PATTERNS
constADDRESS_PATTERNS:RegExp[]
Address patterns for geocoding field detection.
Matches fields that contain textual address information suitable for geocoding.
Functions
matchFieldNamePatterns()
matchFieldNamePatterns(
names,fieldType,language):FieldPatternMatch|null
Match a list of field/column names against FIELD_PATTERNS for a given field type and language.
Tries language-specific patterns first, then falls back to English. Returns the first (most specific) match found, or null if no match.
Used by both preview-time detection and background job detection to ensure the pattern-matching portion of field detection uses consistent logic.
Parameters
names
string[]
fieldType
FieldType
language
string
Returns
FieldPatternMatch | null
getFieldPatterns()
getFieldPatterns(
fieldType,language,options?): readonlyRegExp[]
Get patterns for a field type and language, falling back to English.
When options provide fieldPatterns for the given field type and language, they are prepended to defaults (or replace them if the field type is in replacePatterns).
Single source of truth for pattern selection.
Parameters
fieldType
string
language
string
options?
Returns
readonly RegExp[]
detectFieldMappings()
detectFieldMappings(
fieldStats,language,options?):FieldMappingsResult
Detect field mappings for all standard fields (structured result with confidence).
Parameters
fieldStats
Record<string, FieldStatistics>
Field statistics from schema builder
language
string
ISO 639-3 language code
options?
Optional detection options for customizing behavior
Returns
Field mappings result with confidence scores