@mostlyrightmd/core 1.1.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/discovery/index.cjs +471 -169
  3. package/dist/discovery/index.cjs.map +1 -1
  4. package/dist/discovery/index.d.cts +39 -11
  5. package/dist/discovery/index.d.ts +39 -11
  6. package/dist/discovery/index.mjs +471 -169
  7. package/dist/discovery/index.mjs.map +1 -1
  8. package/dist/index.cjs +618 -174
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +326 -29
  11. package/dist/index.d.ts +326 -29
  12. package/dist/index.global.js +610 -173
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.mjs +610 -173
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal/cache/index.browser.cjs +501 -163
  17. package/dist/internal/cache/index.browser.cjs.map +1 -1
  18. package/dist/internal/cache/index.browser.d.cts +8 -2
  19. package/dist/internal/cache/index.browser.d.ts +8 -2
  20. package/dist/internal/cache/index.browser.mjs +10 -5
  21. package/dist/internal/cache/index.browser.mjs.map +1 -1
  22. package/dist/internal/cache/index.cjs +503 -161
  23. package/dist/internal/cache/index.cjs.map +1 -1
  24. package/dist/internal/cache/index.d.cts +12 -6
  25. package/dist/internal/cache/index.d.ts +12 -6
  26. package/dist/internal/cache/index.mjs +12 -3
  27. package/dist/internal/cache/index.mjs.map +1 -1
  28. package/dist/internal/{chunk-PKJXHY27.mjs → chunk-QDQSYUFW.mjs} +494 -160
  29. package/dist/internal/chunk-QDQSYUFW.mjs.map +1 -0
  30. package/dist/internal/{keys-B7C8C88N.d.cts → versionedCacheStore-DyHDqFIC.d.cts} +23 -1
  31. package/dist/internal/{keys-B7C8C88N.d.ts → versionedCacheStore-DyHDqFIC.d.ts} +23 -1
  32. package/dist/preprocessing/index.cjs +150 -0
  33. package/dist/preprocessing/index.cjs.map +1 -0
  34. package/dist/preprocessing/index.d.cts +111 -0
  35. package/dist/preprocessing/index.d.ts +111 -0
  36. package/dist/preprocessing/index.mjs +121 -0
  37. package/dist/preprocessing/index.mjs.map +1 -0
  38. package/dist/temporal/index.cjs +56 -4
  39. package/dist/temporal/index.cjs.map +1 -1
  40. package/dist/temporal/index.d.cts +24 -1
  41. package/dist/temporal/index.d.ts +24 -1
  42. package/dist/temporal/index.mjs +55 -4
  43. package/dist/temporal/index.mjs.map +1 -1
  44. package/dist/validator.cjs +694 -109
  45. package/dist/validator.cjs.map +1 -1
  46. package/dist/validator.mjs +694 -109
  47. package/dist/validator.mjs.map +1 -1
  48. package/package.json +25 -2
  49. package/dist/internal/chunk-PKJXHY27.mjs.map +0 -1
@@ -234,7 +234,7 @@ interface BuildSnapshotOptions {
234
234
  */
235
235
  declare function buildSnapshot(opts: BuildSnapshotOptions): DataSnapshot;
236
236
 
237
- interface TradewindsErrorOptions {
237
+ interface MostlyRightErrorOptions {
238
238
  errorCode?: string;
239
239
  source?: string | null;
240
240
  requestId?: string | null;
@@ -247,13 +247,13 @@ interface TradewindsErrorOptions {
247
247
  * involved (e.g. "iem.archive") when applicable, and `requestId` correlates a
248
248
  * JSON-RPC / MCP request id when applicable.
249
249
  */
250
- declare class TradewindsError extends Error {
250
+ declare class MostlyRightError extends Error {
251
251
  /** Subclass override — the stable string enum surfaced via `errorCode`. */
252
252
  static defaultErrorCode: string;
253
253
  readonly errorCode: string;
254
254
  readonly source: string | null;
255
255
  readonly requestId: string | null;
256
- constructor(message?: string, options?: TradewindsErrorOptions);
256
+ constructor(message?: string, options?: MostlyRightErrorOptions);
257
257
  /**
258
258
  * Subclass hook returning the structured attributes for `toDict`.
259
259
  * Values are passed through `toJsonSafe` by `toDict()`, so subclasses
@@ -263,6 +263,20 @@ declare class TradewindsError extends Error {
263
263
  /** Return a JSON-safe dict suitable for MCP `error.data`. */
264
264
  toDict(): Record<string, unknown>;
265
265
  }
266
+ /** Shared reason enum — MUST match Python EXACTLY (Phase 21 D-04). */
267
+ declare const DATA_AVAILABILITY_REASONS: readonly ["model_unavailable", "out_of_window", "cache_miss", "source_404", "source_5xx", "rate_limited"];
268
+ type DataAvailabilityReason = (typeof DATA_AVAILABILITY_REASONS)[number];
269
+ interface DataAvailabilityErrorOptions extends MostlyRightErrorOptions {
270
+ reason: DataAvailabilityReason;
271
+ hint: string;
272
+ }
273
+ declare class DataAvailabilityError extends MostlyRightError {
274
+ static defaultErrorCode: string;
275
+ readonly reason: DataAvailabilityReason;
276
+ readonly hint: string;
277
+ constructor(options: DataAvailabilityErrorOptions);
278
+ protected payload(): Record<string, unknown>;
279
+ }
266
280
 
267
281
  interface SchemaInfo {
268
282
  readonly id: string;
@@ -283,12 +297,12 @@ declare function registerSchema(info: SchemaInfo): void;
283
297
  /**
284
298
  * Return a multi-line description of a registered schema.
285
299
  *
286
- * @throws TradewindsError if `schemaId` is not registered. The error code is
300
+ * @throws MostlyRightError if `schemaId` is not registered. The error code is
287
301
  * `UNKNOWN_SCHEMA` so callers can distinguish from validation/IO errors.
288
302
  */
289
303
  declare function describe(schemaId: string): string;
290
304
  /** Thrown by `describe` when `schemaId` is not registered. */
291
- declare class UnknownSchemaError extends TradewindsError {
305
+ declare class UnknownSchemaError extends MostlyRightError {
292
306
  constructor(message: string);
293
307
  static readonly defaultErrorCode = "UNKNOWN_SCHEMA";
294
308
  }
@@ -299,15 +313,29 @@ declare class UnknownSchemaError extends TradewindsError {
299
313
  * snake_case names, here the camelCase TS names sorted identically.
300
314
  */
301
315
  declare function featureCatalog(): ReadonlyArray<string>;
316
+
302
317
  /**
303
- * Climate-gap scanning is Python-only in v0.1.0 (TS has no climate-year
304
- * parquet cache yet). Throws to match the documented contract.
318
+ * Climate-gap scanning TS v1.x deferral.
319
+ *
320
+ * Phase 21 21-11 messaging upgrade: raises DataAvailabilityError with a
321
+ * multi-paragraph hint explaining the architectural constraint (GHCNh
322
+ * CSVs are 10+ MB per station-year; browser cache layer doesn't scale).
323
+ *
324
+ * @throws DataAvailabilityError with reason="model_unavailable" and a
325
+ * hint pointing at the Python SDK as the supported v1.x workaround.
305
326
  */
306
327
  declare function climateGaps(_station: string, _fromDate: string, _toDate: string): never;
307
- /** Thrown by `climateGaps` until the TS climate cache lands. */
308
- declare class ClimateGapsNotImplementedError extends TradewindsError {
309
- constructor(message: string);
310
- static readonly defaultErrorCode = "NOT_IMPLEMENTED";
328
+ /**
329
+ * Back-compat subclass of DataAvailabilityError raised by `climateGaps`
330
+ * in v1.x. Existing `catch (e instanceof ClimateGapsNotImplementedError)`
331
+ * sites keep working; new code should catch the parent class
332
+ * `DataAvailabilityError` and dispatch on `reason === "model_unavailable"`.
333
+ *
334
+ * @deprecated Prefer catching `DataAvailabilityError` directly.
335
+ */
336
+ declare class ClimateGapsNotImplementedError extends DataAvailabilityError {
337
+ static readonly defaultErrorCode = "DATA_AVAILABILITY";
338
+ constructor();
311
339
  }
312
340
 
313
341
  export { type AvailabilityOptions, type AvailabilityResult, type BuildSnapshotOptions, ClimateGapsNotImplementedError, type DailyExtreme, type DataSnapshot, type DataVersion, type DataVersionComponents, type InternationalDailyExtremesOptions, type InternationalRow, type KeyEnumerableStore, UnknownSchemaError, availability, buildSnapshot, climateGaps, dataVersionForResearch, dataVersionFromComponents, describe, featureCatalog, internationalDailyExtremes, registerSchema };
@@ -234,7 +234,7 @@ interface BuildSnapshotOptions {
234
234
  */
235
235
  declare function buildSnapshot(opts: BuildSnapshotOptions): DataSnapshot;
236
236
 
237
- interface TradewindsErrorOptions {
237
+ interface MostlyRightErrorOptions {
238
238
  errorCode?: string;
239
239
  source?: string | null;
240
240
  requestId?: string | null;
@@ -247,13 +247,13 @@ interface TradewindsErrorOptions {
247
247
  * involved (e.g. "iem.archive") when applicable, and `requestId` correlates a
248
248
  * JSON-RPC / MCP request id when applicable.
249
249
  */
250
- declare class TradewindsError extends Error {
250
+ declare class MostlyRightError extends Error {
251
251
  /** Subclass override — the stable string enum surfaced via `errorCode`. */
252
252
  static defaultErrorCode: string;
253
253
  readonly errorCode: string;
254
254
  readonly source: string | null;
255
255
  readonly requestId: string | null;
256
- constructor(message?: string, options?: TradewindsErrorOptions);
256
+ constructor(message?: string, options?: MostlyRightErrorOptions);
257
257
  /**
258
258
  * Subclass hook returning the structured attributes for `toDict`.
259
259
  * Values are passed through `toJsonSafe` by `toDict()`, so subclasses
@@ -263,6 +263,20 @@ declare class TradewindsError extends Error {
263
263
  /** Return a JSON-safe dict suitable for MCP `error.data`. */
264
264
  toDict(): Record<string, unknown>;
265
265
  }
266
+ /** Shared reason enum — MUST match Python EXACTLY (Phase 21 D-04). */
267
+ declare const DATA_AVAILABILITY_REASONS: readonly ["model_unavailable", "out_of_window", "cache_miss", "source_404", "source_5xx", "rate_limited"];
268
+ type DataAvailabilityReason = (typeof DATA_AVAILABILITY_REASONS)[number];
269
+ interface DataAvailabilityErrorOptions extends MostlyRightErrorOptions {
270
+ reason: DataAvailabilityReason;
271
+ hint: string;
272
+ }
273
+ declare class DataAvailabilityError extends MostlyRightError {
274
+ static defaultErrorCode: string;
275
+ readonly reason: DataAvailabilityReason;
276
+ readonly hint: string;
277
+ constructor(options: DataAvailabilityErrorOptions);
278
+ protected payload(): Record<string, unknown>;
279
+ }
266
280
 
267
281
  interface SchemaInfo {
268
282
  readonly id: string;
@@ -283,12 +297,12 @@ declare function registerSchema(info: SchemaInfo): void;
283
297
  /**
284
298
  * Return a multi-line description of a registered schema.
285
299
  *
286
- * @throws TradewindsError if `schemaId` is not registered. The error code is
300
+ * @throws MostlyRightError if `schemaId` is not registered. The error code is
287
301
  * `UNKNOWN_SCHEMA` so callers can distinguish from validation/IO errors.
288
302
  */
289
303
  declare function describe(schemaId: string): string;
290
304
  /** Thrown by `describe` when `schemaId` is not registered. */
291
- declare class UnknownSchemaError extends TradewindsError {
305
+ declare class UnknownSchemaError extends MostlyRightError {
292
306
  constructor(message: string);
293
307
  static readonly defaultErrorCode = "UNKNOWN_SCHEMA";
294
308
  }
@@ -299,15 +313,29 @@ declare class UnknownSchemaError extends TradewindsError {
299
313
  * snake_case names, here the camelCase TS names sorted identically.
300
314
  */
301
315
  declare function featureCatalog(): ReadonlyArray<string>;
316
+
302
317
  /**
303
- * Climate-gap scanning is Python-only in v0.1.0 (TS has no climate-year
304
- * parquet cache yet). Throws to match the documented contract.
318
+ * Climate-gap scanning TS v1.x deferral.
319
+ *
320
+ * Phase 21 21-11 messaging upgrade: raises DataAvailabilityError with a
321
+ * multi-paragraph hint explaining the architectural constraint (GHCNh
322
+ * CSVs are 10+ MB per station-year; browser cache layer doesn't scale).
323
+ *
324
+ * @throws DataAvailabilityError with reason="model_unavailable" and a
325
+ * hint pointing at the Python SDK as the supported v1.x workaround.
305
326
  */
306
327
  declare function climateGaps(_station: string, _fromDate: string, _toDate: string): never;
307
- /** Thrown by `climateGaps` until the TS climate cache lands. */
308
- declare class ClimateGapsNotImplementedError extends TradewindsError {
309
- constructor(message: string);
310
- static readonly defaultErrorCode = "NOT_IMPLEMENTED";
328
+ /**
329
+ * Back-compat subclass of DataAvailabilityError raised by `climateGaps`
330
+ * in v1.x. Existing `catch (e instanceof ClimateGapsNotImplementedError)`
331
+ * sites keep working; new code should catch the parent class
332
+ * `DataAvailabilityError` and dispatch on `reason === "model_unavailable"`.
333
+ *
334
+ * @deprecated Prefer catching `DataAvailabilityError` directly.
335
+ */
336
+ declare class ClimateGapsNotImplementedError extends DataAvailabilityError {
337
+ static readonly defaultErrorCode = "DATA_AVAILABILITY";
338
+ constructor();
311
339
  }
312
340
 
313
341
  export { type AvailabilityOptions, type AvailabilityResult, type BuildSnapshotOptions, ClimateGapsNotImplementedError, type DailyExtreme, type DataSnapshot, type DataVersion, type DataVersionComponents, type InternationalDailyExtremesOptions, type InternationalRow, type KeyEnumerableStore, UnknownSchemaError, availability, buildSnapshot, climateGaps, dataVersionForResearch, dataVersionFromComponents, describe, featureCatalog, internationalDailyExtremes, registerSchema };