@mostlyrightmd/core 1.1.2 → 1.2.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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/discovery/index.cjs +44 -7
  3. package/dist/discovery/index.cjs.map +1 -1
  4. package/dist/discovery/index.d.cts +34 -6
  5. package/dist/discovery/index.d.ts +34 -6
  6. package/dist/discovery/index.mjs +44 -7
  7. package/dist/discovery/index.mjs.map +1 -1
  8. package/dist/index.cjs +39 -1
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +16 -2
  11. package/dist/index.d.ts +16 -2
  12. package/dist/index.global.js +37 -1
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.mjs +37 -1
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal/cache/index.browser.cjs +77 -4
  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 +79 -2
  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-IPC4XUYW.mjs} +70 -1
  29. package/dist/internal/chunk-IPC4XUYW.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.map +1 -1
  39. package/dist/temporal/index.mjs.map +1 -1
  40. package/dist/validator.cjs.map +1 -1
  41. package/dist/validator.mjs.map +1 -1
  42. package/package.json +34 -2
  43. package/dist/internal/chunk-PKJXHY27.mjs.map +0 -1
@@ -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 TradewindsErrorOptions {
270
+ reason: DataAvailabilityReason;
271
+ hint: string;
272
+ }
273
+ declare class DataAvailabilityError extends TradewindsError {
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;
@@ -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 };
@@ -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 TradewindsErrorOptions {
270
+ reason: DataAvailabilityReason;
271
+ hint: string;
272
+ }
273
+ declare class DataAvailabilityError extends TradewindsError {
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;
@@ -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 };
@@ -1064,6 +1064,40 @@ var TradewindsError = class extends Error {
1064
1064
  return safe;
1065
1065
  }
1066
1066
  };
1067
+ var DATA_AVAILABILITY_REASONS = [
1068
+ "model_unavailable",
1069
+ "out_of_window",
1070
+ "cache_miss",
1071
+ "source_404",
1072
+ "source_5xx",
1073
+ "rate_limited"
1074
+ ];
1075
+ var DataAvailabilityError = class extends TradewindsError {
1076
+ static defaultErrorCode = "DATA_AVAILABILITY";
1077
+ reason;
1078
+ hint;
1079
+ constructor(options) {
1080
+ if (!DATA_AVAILABILITY_REASONS.includes(options.reason)) {
1081
+ throw new RangeError(
1082
+ `DataAvailabilityError: unknown reason "${String(options.reason)}". Valid reasons: ${DATA_AVAILABILITY_REASONS.join(", ")}`
1083
+ );
1084
+ }
1085
+ if (typeof options.hint !== "string" || options.hint.length === 0) {
1086
+ throw new TypeError("DataAvailabilityError: hint is required and must be a non-empty string");
1087
+ }
1088
+ const message = `[${options.reason}] ${options.hint}`;
1089
+ super(message, options);
1090
+ this.reason = options.reason;
1091
+ this.hint = options.hint;
1092
+ }
1093
+ payload() {
1094
+ return {
1095
+ ...super.payload(),
1096
+ reason: this.reason,
1097
+ hint: this.hint
1098
+ };
1099
+ }
1100
+ };
1067
1101
 
1068
1102
  // src/formats/toon.ts
1069
1103
  var SAFE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_.]*$/;
@@ -1581,17 +1615,20 @@ var FEATURE_NAMES = Object.freeze([
1581
1615
  function featureCatalog() {
1582
1616
  return FEATURE_NAMES;
1583
1617
  }
1618
+ var CLIMATE_GAPS_HINT = "climateGaps() is server-only in v1.x. Architectural reason: GHCNh CSVs are 10+ MB per station-year; browser fetch doesn't slice (no HTTP Range) and IndexedDB quotas don't fit the working set. Use the Python SDK (mostlyright.discover.climate_gaps) for v1.x, or wait for the hosted climate-gap-precompute API (target: post-v1.x). See https://mostlyright.md/docs/sdk/typescript/climate-gaps for details.";
1584
1619
  function climateGaps(_station, _fromDate, _toDate) {
1585
- throw new ClimateGapsNotImplementedError(
1586
- "climateGaps is Python-only in v0.1.0; the TS climate cache lands in v0.2"
1587
- );
1620
+ throw new ClimateGapsNotImplementedError();
1588
1621
  }
1589
- var ClimateGapsNotImplementedError = class extends TradewindsError {
1590
- constructor(message) {
1591
- super(message);
1622
+ var ClimateGapsNotImplementedError = class extends DataAvailabilityError {
1623
+ static defaultErrorCode = "DATA_AVAILABILITY";
1624
+ constructor() {
1625
+ super({
1626
+ reason: "model_unavailable",
1627
+ source: "climate-cache-browser",
1628
+ hint: CLIMATE_GAPS_HINT
1629
+ });
1592
1630
  this.name = "ClimateGapsNotImplementedError";
1593
1631
  }
1594
- static defaultErrorCode = "NOT_IMPLEMENTED";
1595
1632
  };
1596
1633
  export {
1597
1634
  ClimateGapsNotImplementedError,