@mostlyrightmd/core/discovery
Classes
Section titled “Classes”DailySummaryGapsNotImplementedError
Section titled “DailySummaryGapsNotImplementedError”Compatibility subclass of DataAvailabilityError raised by dailySummaryGaps.
Existing catch (e instanceof DailySummaryGapsNotImplementedError) sites keep
working; new code should catch the parent class
DataAvailabilityError and dispatch on reason === "model_unavailable".
Deprecated
Section titled “Deprecated”Prefer catching DataAvailabilityError directly.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”new DailySummaryGapsNotImplementedError()
Section titled “new DailySummaryGapsNotImplementedError()”new DailySummaryGapsNotImplementedError():
DailySummaryGapsNotImplementedError
Returns
Section titled “Returns”DailySummaryGapsNotImplementedError
Overrides
Section titled “Overrides”DataAvailabilityError.constructor
Properties
Section titled “Properties”defaultErrorCode
Section titled “defaultErrorCode”
readonlystaticdefaultErrorCode:"DATA_AVAILABILITY"="DATA_AVAILABILITY"
Subclass override — the stable string enum surfaced via errorCode.
Overrides
Section titled “Overrides”DataAvailabilityError.defaultErrorCode
errorCode
Section titled “errorCode”
readonlyerrorCode:string
Inherited from
Section titled “Inherited from”DataAvailabilityError.errorCode
readonlyhint:string
Inherited from
Section titled “Inherited from”reason
Section titled “reason”
readonlyreason:"model_unavailable"|"out_of_window"|"cache_miss"|"source_404"|"source_5xx"|"rate_limited"
Inherited from
Section titled “Inherited from”requestId
Section titled “requestId”
readonlyrequestId:null|string
Inherited from
Section titled “Inherited from”DataAvailabilityError.requestId
source
Section titled “source”
readonlysource:null|string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”toDict()
Section titled “toDict()”toDict():
Record<string,unknown>
Return a JSON-safe dict suitable for MCP error.data.
Returns
Section titled “Returns”Record<string, unknown>
Inherited from
Section titled “Inherited from”UnknownSchemaError
Section titled “UnknownSchemaError”Thrown by describe when schemaId is not registered.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”new UnknownSchemaError()
Section titled “new UnknownSchemaError()”new UnknownSchemaError(
message):UnknownSchemaError
Parameters
Section titled “Parameters”message
Section titled “message”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”defaultErrorCode
Section titled “defaultErrorCode”
readonlystaticdefaultErrorCode:"UNKNOWN_SCHEMA"="UNKNOWN_SCHEMA"
Subclass override — the stable string enum surfaced via errorCode.
Overrides
Section titled “Overrides”MostlyrightError.defaultErrorCode
errorCode
Section titled “errorCode”
readonlyerrorCode:string
Inherited from
Section titled “Inherited from”requestId
Section titled “requestId”
readonlyrequestId:null|string
Inherited from
Section titled “Inherited from”source
Section titled “source”
readonlysource:null|string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”toDict()
Section titled “toDict()”toDict():
Record<string,unknown>
Return a JSON-safe dict suitable for MCP error.data.
Returns
Section titled “Returns”Record<string, unknown>
Inherited from
Section titled “Inherited from”Interfaces
Section titled “Interfaces”AvailabilityOptions
Section titled “AvailabilityOptions”Options for availability().
Properties
Section titled “Properties”validate?
Section titled “validate?”
readonlyoptionalvalidate:boolean
If true, confirm each candidate key with cache.get() before counting.
Eliminates the small overcount possible on stores whose listKeys() can
return keys with already-expired TTL entries (FsStore and IndexedDBStore
lazy-evict on get, not on listKeys). Off by default
because the v0.1.0 research() flow never writes with ttlMs, so the
overcount window is empty; turn on only if you populate the cache with
explicit TTLs.
Cost: one get() per matching key. On warm caches this is cheap
(MemoryStore + IndexedDBStore in-memory). On FsStore it reads each
candidate’s file.
AvailabilityResult
Section titled “AvailabilityResult”Cache-coverage summary for a station.
Mirrors Python availability() return shape.
Properties
Section titled “Properties”dailySummaryYears
Section titled “dailySummaryYears”dailySummaryYears:
number
Count of cached daily-summary years.
firstDailySummaryYear
Section titled “firstDailySummaryYear”firstDailySummaryYear:
null|string
Earliest cached daily-summary year as "YYYY", or null if none.
firstMonth
Section titled “firstMonth”firstMonth:
null|string
Earliest cached month as "YYYY-MM", or null if none.
lastDailySummaryYear
Section titled “lastDailySummaryYear”lastDailySummaryYear:
null|string
Latest cached daily-summary year as "YYYY", or null if none.
lastMonth
Section titled “lastMonth”lastMonth:
null|string
Latest cached month as "YYYY-MM", or null if none.
monthsCached
Section titled “monthsCached”monthsCached:
number
Count of distinct (year, month) observation cache entries.
station
Section titled “station”station:
string
BuildSnapshotOptions
Section titled “BuildSnapshotOptions”Properties
Section titled “Properties”dataVersion?
Section titled “dataVersion?”
optionaldataVersion:null|DataVersion
knowledgeTime?
Section titled “knowledgeTime?”
optionalknowledgeTime:string|Date
metadata?
Section titled “metadata?”
optionalmetadata:Record<string,unknown>
rows: readonly
Record<string,unknown>[]
schemaId
Section titled “schemaId”schemaId:
string
source
Section titled “source”source:
string
DailyExtreme
Section titled “DailyExtreme”Properties
Section titled “Properties”localDate
Section titled “localDate”localDate:
string
Station-local calendar date as YYYY-MM-DD.
nObs:
number
Count of rows with a parseable temp_c.
precipMm
Section titled “precipMm”precipMm:
number
Total 1-hour precipitation across the local day, in mm.
sourceTmax
Section titled “sourceTmax”sourceTmax:
null|string
Source identifier of the row that produced tmax (or null on low coverage).
sourceTmin
Section titled “sourceTmin”sourceTmin:
null|string
Source identifier of the row that produced tmin (or null on low coverage).
tempMaxC
Section titled “tempMaxC”tempMaxC:
null|number
Max temperature in °C, or null on low coverage.
tempMaxF
Section titled “tempMaxF”tempMaxF:
null|number
Max temperature in °F, or null on low coverage.
tempMeanC
Section titled “tempMeanC”tempMeanC:
null|number
Mean temperature in °C, or null on low coverage.
tempMinC
Section titled “tempMinC”tempMinC:
null|number
Min temperature in °C, or null on low coverage.
tempMinF
Section titled “tempMinF”tempMinF:
null|number
Min temperature in °F, or null on low coverage.
DataSnapshot
Section titled “DataSnapshot”Frozen snapshot wrapper around row data + provenance.
Properties
Section titled “Properties”dataVersion
Section titled “dataVersion”
readonlydataVersion:null|DataVersion
Optional reproducibility token.
knowledgeTime
Section titled “knowledgeTime”
readonlyknowledgeTime:string
ISO 8601 UTC instant when the snapshot was built (always ends with Z).
metadata
Section titled “metadata”
readonlymetadata:Readonly<Record<string,unknown>>
Optional arbitrary metadata. JSON-safe-coerced on toDict.
readonlyrows: readonlyReadonly<Record<string,unknown>>[]
Row payload — opaque to this layer. Frozen.
schemaId
Section titled “schemaId”
readonlyschemaId:string
Schema id the rows conform to.
source
Section titled “source”
readonlysource:string
Source identifier (e.g. iem.archive, awc.live). Snapshot-scoped.
Methods
Section titled “Methods”toDict()
Section titled “toDict()”toDict():
Record<string,unknown>
JSON-safe dict form.
Returns
Section titled “Returns”Record<string, unknown>
toToon()
Section titled “toToon()”toToon():
string
TOON-v3 tabular form (rows only — provenance lives in the dict form).
Returns
Section titled “Returns”string
DataVersion
Section titled “DataVersion”Immutable reproducibility token stamping a single research() call.
Properties
Section titled “Properties”codeSha
Section titled “codeSha”
readonlycodeSha:string
dataSha
Section titled “dataSha”
readonlydataSha:string
schemaIds
Section titled “schemaIds”
readonlyschemaIds: readonlystring[]
sdkVersion
Section titled “sdkVersion”
readonlysdkVersion:string
sources
Section titled “sources”
readonlysources: readonlystring[]
readonlytoken:string
DataVersionComponents
Section titled “DataVersionComponents”Properties
Section titled “Properties”codeSha
Section titled “codeSha”codeSha:
string
dataSha
Section titled “dataSha”dataSha:
string
schemaIds
Section titled “schemaIds”schemaIds: readonly
string[]
sdkVersion
Section titled “sdkVersion”sdkVersion:
string
sources
Section titled “sources”sources: readonly
string[]
InternationalDailyExtremesOptions
Section titled “InternationalDailyExtremesOptions”Properties
Section titled “Properties”minObs?
Section titled “minObs?”
optionalminObs:number
Minimum number of observations required for tmin/tmax/tmean to be populated. Defaults to 12 (the Python threshold). Tests can override.
precision?
Section titled “precision?”
optionalprecision:number
Decimal places for HALF_UP rounding. Defaults to 0 (whole °C) — the
international convention. Pass 1 for US-station tenths.
stationTz
Section titled “stationTz”stationTz:
string
IANA timezone identifier for the station, e.g. "Asia/Tokyo". Required.
InternationalRow
Section titled “InternationalRow”Minimal row shape consumed by internationalDailyExtremes.
Properties
Section titled “Properties”event_time_utc?
Section titled “event_time_utc?”
optionalevent_time_utc:null|string
ISO 8601 UTC instant. Must end with Z or include an offset.
precipitation_mm_1h?
Section titled “precipitation_mm_1h?”
optionalprecipitation_mm_1h:null|number
1-hour precipitation total in millimeters.
source?
Section titled “source?”
optionalsource:null|string
Source identifier (preserved on the tmin/tmax aggregate).
temp_c?
Section titled “temp_c?”
optionaltemp_c:null|number
Air temperature in degrees Celsius.
KeyEnumerableStore
Section titled “KeyEnumerableStore”Optional adapter that lets availability() enumerate keys from a store.
CacheStore’s mandatory contract is opaque key-value: get/set/delete/withLock.
Discovery needs to enumerate which keys exist for a station — this is
implementation-specific (Memory iterates its Map, IndexedDB uses
getAllKeys, Fs walks the directory tree). Stores that support enumeration
implement the optional listKeys(prefix) method and availability() uses
it; stores without it return zero-coverage but never throw.
Listed keys may exceed the requested prefix in the result (callers filter);
listKeys is best-effort.
Extends
Section titled “Extends”CacheStore
Methods
Section titled “Methods”delete()
Section titled “delete()”delete(
key):Promise<void>
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”CacheStore.delete
get<
T>(key):Promise<null|T>
Type Parameters
Section titled “Type Parameters”• T = unknown
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<null | T>
Inherited from
Section titled “Inherited from”CacheStore.get
listKeys()
Section titled “listKeys()”listKeys(
prefix):Promise<readonlystring[]>
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
Returns
Section titled “Returns”Promise<readonly string[]>
set<
T>(key,value,opts?):Promise<void>
Type Parameters
Section titled “Type Parameters”• T = unknown
Parameters
Section titled “Parameters”string
T
CacheSetOptions
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”CacheStore.set
withLock()
Section titled “withLock()”withLock<
T>(key,fn):Promise<T>
Type Parameters
Section titled “Type Parameters”• T
Parameters
Section titled “Parameters”string
() => Promise<T>
Returns
Section titled “Returns”Promise<T>
Inherited from
Section titled “Inherited from”CacheStore.withLock
Functions
Section titled “Functions”availability()
Section titled “availability()”availability(
station,cache,opts):Promise<AvailabilityResult>
Return a summary of cached coverage for station.
Stores without enumeration support return a zero-coverage result with the station name populated (counts all zero, dates null).
Pass { validate: true } to confirm each candidate key via cache.get()
— needed if your callers populate the cache with ttlMs and might query
after expiry. The v0.1.0 research() flow does not use ttlMs, so the
default (fast scan, no validation) is correct for the canonical path.
Parameters
Section titled “Parameters”station
Section titled “station”string
CacheStore
AvailabilityOptions = {}
Returns
Section titled “Returns”Promise<AvailabilityResult>
buildSnapshot()
Section titled “buildSnapshot()”buildSnapshot(
opts):DataSnapshot
Build a frozen DataSnapshot.
Throws RangeError on invalid knowledgeTime. Row payloads are shallow-
cloned and frozen so callers can’t mutate snapshot state post-build.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”dailySummaryGaps()
Section titled “dailySummaryGaps()”dailySummaryGaps(
_station,_fromDate,_toDate):never
Climate-gap scanning is unavailable in TypeScript because GHCNh archives are too large for the browser cache.
Parameters
Section titled “Parameters”_station
Section titled “_station”string
_fromDate
Section titled “_fromDate”string
_toDate
Section titled “_toDate”string
Returns
Section titled “Returns”never
Throws
Section titled “Throws”DataAvailabilityError with reason=“model_unavailable” and a hint pointing at the Python SDK as the supported alternative.
dataVersionForResearch()
Section titled “dataVersionForResearch()”dataVersionForResearch(
args):Promise<DataVersion>
Build a DataVersion for a research() call. Mirrors Python DataVersion.for_research:
the codeSha encodes the call signature (research:STATION:FROM:TO) and dataSha
is supplied by the caller (typically a cache fingerprint).
The schema ids + source contract match the v0.1.0 Python SDK exactly so tokens computed in TS match tokens computed in Python for the same inputs.
Parameters
Section titled “Parameters”dataSha
Section titled “dataSha”string
fromDate
Section titled “fromDate”string
sdkVersion
Section titled “sdkVersion”string
station
Section titled “station”string
toDate
Section titled “toDate”string
Returns
Section titled “Returns”Promise<DataVersion>
dataVersionFromComponents()
Section titled “dataVersionFromComponents()”dataVersionFromComponents(
components):Promise<DataVersion>
Build a frozen DataVersion from explicit components.
Mirrors Python DataVersion.from_components: sorts schemaIds + sources
internally before the canonical hash so input order does not affect the
token, while the returned object keeps the caller’s order on its schemaIds
and sources arrays. Sorting the stored arrays too would hide source-priority
order — iem.archive, iem.live, awc.live, ghcnh, nws.cli is the precedence
Python preserves on the tuple, not alphabetical order.
Parameters
Section titled “Parameters”components
Section titled “components”Returns
Section titled “Returns”Promise<DataVersion>
describe()
Section titled “describe()”describe(
schemaId):string
Return a multi-line description of a registered schema.
Parameters
Section titled “Parameters”schemaId
Section titled “schemaId”string
Returns
Section titled “Returns”string
Throws
Section titled “Throws”MostlyrightError if schemaId is not registered. The error code is
UNKNOWN_SCHEMA so callers can distinguish from validation/IO errors.
internationalDailyExtremes()
Section titled “internationalDailyExtremes()”internationalDailyExtremes(
rows,opts):DailyExtreme[]
Roll up observation rows to per-local-calendar-day temperature extremes.
Parameters
Section titled “Parameters”readonly InternationalRow[]
raw observation rows (any source). Rows without a parseable
event_time_utc are dropped.
InternationalDailyExtremesOptions
stationTz is required. Optional precision (default 0;
pass 1 for US-station tenths) and minObs (default 12).
Returns
Section titled “Returns”one entry per local calendar day with at least one row. Days
with fewer than minObs rows have temps set to null.
registerSchema()
Section titled “registerSchema()”registerSchema(
info):void
Register or override a schema for describe(). Built-in v0.1.0 schemas
are registered at module load (BUILT_IN_SCHEMAS); callers may add custom
schemas or override built-ins (e.g. with richer descriptions).
Parameters
Section titled “Parameters”SchemaInfo
Returns
Section titled “Returns”void