@flattype/shared 1.11.0 → 1.12.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.
package/dist/index.d.cts CHANGED
@@ -28,6 +28,13 @@ interface EncodeOptions {
28
28
  */
29
29
  refs?: boolean;
30
30
  }
31
+ /** A problem lenient decoding repaired, and where it was. */
32
+ interface FlatWarning {
33
+ /** What was wrong and what was done, e.g. `Expected 5 values, got 4: the missing values are null`. */
34
+ message: string;
35
+ line: number;
36
+ column: number;
37
+ }
31
38
  interface DecodeOptions {
32
39
  /** Throw on malformed input (default). Set `false` to recover what it can, e.g. from LLM output. */
33
40
  strict?: boolean;
@@ -36,6 +43,11 @@ interface DecodeOptions {
36
43
  * it weren't there, instead of throwing. That's what `fromModelOutput` uses. Default `false`.
37
44
  */
38
45
  skipInvalidLines?: boolean;
46
+ /**
47
+ * With `strict: false`: called for every problem that was repaired (a missing value, a short row, a skipped
48
+ * line…), with its line and column, so you can tell the user where the data is wrong.
49
+ */
50
+ onWarning?: (warning: FlatWarning) => void;
39
51
  /** Called for every value after decoding, bottom-up, exactly like the second argument of `JSON.parse`. */
40
52
  reviver?: Reviver;
41
53
  /**
@@ -70,4 +82,4 @@ interface Decoder {
70
82
  end(): JsonValue;
71
83
  }
72
84
 
73
- export type { DecodeOptions, Decoder, DecoderOptions, Delimiter, EncodeOptions, FlatLeaf, FlatRecord, JsonPrimitive, JsonValue, Replacer, Reviver, TableRow };
85
+ export type { DecodeOptions, Decoder, DecoderOptions, Delimiter, EncodeOptions, FlatLeaf, FlatRecord, FlatWarning, JsonPrimitive, JsonValue, Replacer, Reviver, TableRow };
package/dist/index.d.ts CHANGED
@@ -28,6 +28,13 @@ interface EncodeOptions {
28
28
  */
29
29
  refs?: boolean;
30
30
  }
31
+ /** A problem lenient decoding repaired, and where it was. */
32
+ interface FlatWarning {
33
+ /** What was wrong and what was done, e.g. `Expected 5 values, got 4: the missing values are null`. */
34
+ message: string;
35
+ line: number;
36
+ column: number;
37
+ }
31
38
  interface DecodeOptions {
32
39
  /** Throw on malformed input (default). Set `false` to recover what it can, e.g. from LLM output. */
33
40
  strict?: boolean;
@@ -36,6 +43,11 @@ interface DecodeOptions {
36
43
  * it weren't there, instead of throwing. That's what `fromModelOutput` uses. Default `false`.
37
44
  */
38
45
  skipInvalidLines?: boolean;
46
+ /**
47
+ * With `strict: false`: called for every problem that was repaired (a missing value, a short row, a skipped
48
+ * line…), with its line and column, so you can tell the user where the data is wrong.
49
+ */
50
+ onWarning?: (warning: FlatWarning) => void;
39
51
  /** Called for every value after decoding, bottom-up, exactly like the second argument of `JSON.parse`. */
40
52
  reviver?: Reviver;
41
53
  /**
@@ -70,4 +82,4 @@ interface Decoder {
70
82
  end(): JsonValue;
71
83
  }
72
84
 
73
- export type { DecodeOptions, Decoder, DecoderOptions, Delimiter, EncodeOptions, FlatLeaf, FlatRecord, JsonPrimitive, JsonValue, Replacer, Reviver, TableRow };
85
+ export type { DecodeOptions, Decoder, DecoderOptions, Delimiter, EncodeOptions, FlatLeaf, FlatRecord, FlatWarning, JsonPrimitive, JsonValue, Replacer, Reviver, TableRow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flattype/shared",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Shared TypeScript contracts for FlatType.js",
5
5
  "license": "MIT",
6
6
  "type": "module",