web / lib/services/schema-freshness
lib/services/schema-freshness
Provides utilities for determining if a dataset’s schema is up-to-date.
This service compares the current event count with the count when the schema was generated. Event counts are queried directly from the database on-demand, not cached, for accuracy.
Interfaces
SchemaFreshnessResult
Properties
stale
stale:
boolean
Whether the schema is stale and should be regenerated
reason?
optionalreason:StalenessReason
The reason for staleness, if stale
currentEventCount
currentEventCount:
number
Current number of events in the dataset
schemaEventCount
schemaEventCount:
number|null
Number of events when the schema was generated
schemaCreatedAt
schemaCreatedAt:
string|null
When the schema was created
Type Aliases
StalenessReason
StalenessReason =
"added"|"deleted"|"no_schema"
Functions
getSchemaFreshness()
getSchemaFreshness(
payload,datasetId,schema,req?):Promise<SchemaFreshnessResult>
Check if a dataset’s schema is stale by querying the actual event count.
Parameters
payload
BasePayload
Payload instance
datasetId
number
ID of the dataset to check
schema
The current schema version (or null if no schema exists)
DatasetSchema | null
req?
PayloadRequest
Optional request for context
Returns
Promise<SchemaFreshnessResult>
Freshness result with staleness status and reason