@web-ts-toolkit/json-frame 0.34.3 → 0.35.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/index.d.mts +195 -1
- package/index.d.ts +195 -1
- package/index.js +1660 -0
- package/index.mjs +1645 -0
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,2 +1,196 @@
|
|
|
1
|
+
/** Scalar JSON values accepted by `fromOrient` payloads and exporters. */
|
|
2
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
/** JSON arrays accepted by `fromOrient` payloads and returned by exporters. */
|
|
4
|
+
type JsonArray = readonly JsonValue[];
|
|
5
|
+
/** JSON objects accepted by `fromOrient` payloads and returned by exporters. */
|
|
6
|
+
interface JsonObject {
|
|
7
|
+
readonly [key: string]: JsonValue;
|
|
8
|
+
}
|
|
9
|
+
/** Any JSON-compatible value accepted by `fromOrient` payloads and exporters. */
|
|
10
|
+
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
11
|
+
/** pandas orient names supported by `fromOrient`. */
|
|
12
|
+
type ResolvedOrient = 'records' | 'index' | 'columns' | 'values' | 'split' | 'table';
|
|
13
|
+
/** Orient selection for `fromOrient`. `auto` performs structural detection when possible. */
|
|
14
|
+
type Orient = 'auto' | ResolvedOrient;
|
|
15
|
+
/** Public column labels are unique strings in the initial release. */
|
|
16
|
+
type ColumnLabel = string;
|
|
17
|
+
/** Supported index labels preserved by parsed frames and label-bearing exporters. */
|
|
18
|
+
type IndexLabel = string | number;
|
|
19
|
+
/** Internal index provenance exposed by later frame APIs. */
|
|
20
|
+
type IndexKind = 'source' | 'synthetic';
|
|
21
|
+
/** Parsed payload for `orient='records'`. */
|
|
22
|
+
type RecordsPayload = readonly JsonObject[];
|
|
23
|
+
/** Parsed payload for `orient='index'`. */
|
|
24
|
+
type IndexPayload = Readonly<Record<string, JsonObject>>;
|
|
25
|
+
/** Parsed payload for `orient='columns'`. */
|
|
26
|
+
type ColumnsPayload = Readonly<Record<string, JsonObject>>;
|
|
27
|
+
/** Parsed payload for `orient='values'`. */
|
|
28
|
+
type ValuesPayload = readonly JsonArray[];
|
|
29
|
+
/** Parsed payload for `orient='split'`. */
|
|
30
|
+
interface SplitPayload {
|
|
31
|
+
readonly columns: readonly ColumnLabel[];
|
|
32
|
+
readonly index: readonly IndexLabel[];
|
|
33
|
+
readonly data: readonly JsonArray[];
|
|
34
|
+
}
|
|
35
|
+
/** Known Frictionless/Table Schema field types emitted by pandas. */
|
|
36
|
+
type TableSchemaFieldType = 'any' | 'array' | 'boolean' | 'date' | 'datetime' | 'duration' | 'geojson' | 'integer' | 'number' | 'object' | 'string' | 'year' | 'yearmonth' | (string & {});
|
|
37
|
+
/** Table Schema constraint metadata preserved when present. */
|
|
38
|
+
interface TableSchemaConstraints {
|
|
39
|
+
/** Enumerated allowed scalar values, commonly used for pandas categoricals. */
|
|
40
|
+
readonly enum?: readonly JsonPrimitive[];
|
|
41
|
+
readonly [key: string]: JsonValue | undefined;
|
|
42
|
+
}
|
|
43
|
+
type JsonMetadata = Readonly<Record<string, JsonValue | undefined>>;
|
|
44
|
+
/** Table Schema field metadata preserved during table ingestion and export. */
|
|
45
|
+
type TableSchemaField = JsonMetadata & {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly type: TableSchemaFieldType;
|
|
48
|
+
readonly format?: string;
|
|
49
|
+
readonly constraints?: TableSchemaConstraints;
|
|
50
|
+
readonly ordered?: boolean;
|
|
51
|
+
readonly extDtype?: string;
|
|
52
|
+
readonly tz?: string;
|
|
53
|
+
readonly freq?: string;
|
|
54
|
+
};
|
|
55
|
+
/** Table Schema metadata preserved for `orient='table'`. */
|
|
56
|
+
type TableSchema = JsonMetadata & {
|
|
57
|
+
readonly fields: readonly TableSchemaField[];
|
|
58
|
+
readonly primaryKey?: readonly string[];
|
|
59
|
+
readonly pandas_version?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Parsed payload for `orient='table'`. */
|
|
62
|
+
interface TablePayload {
|
|
63
|
+
readonly schema: TableSchema;
|
|
64
|
+
readonly data: readonly JsonObject[];
|
|
65
|
+
}
|
|
66
|
+
/** Logical column types inferred or preserved by the frame. */
|
|
67
|
+
type ColumnType = 'integer' | 'float' | 'string' | 'boolean' | 'datetime' | 'categorical' | 'mixed' | 'unknown';
|
|
68
|
+
/** Public logical type metadata for a stored column. */
|
|
69
|
+
interface ColumnInfo {
|
|
70
|
+
/** Narrowest logical type inferred or preserved for the column. */
|
|
71
|
+
readonly type: ColumnType;
|
|
72
|
+
/** Whether any row in the column contains `null`. */
|
|
73
|
+
readonly nullable: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for `fromOrient`.
|
|
77
|
+
*
|
|
78
|
+
* `columns` is required only for explicit `values` input because that orient
|
|
79
|
+
* carries no column labels. `columnTypes` supplies explicit logical metadata
|
|
80
|
+
* for label-preserving orients that do not carry Table Schema field types.
|
|
81
|
+
*/
|
|
82
|
+
interface FromOrientOptions {
|
|
83
|
+
/** Explicit orient, or `auto` to detect only structurally unambiguous shapes. */
|
|
84
|
+
readonly orient?: Orient;
|
|
85
|
+
/** Explicit column names used when parsing `orient='values'`. */
|
|
86
|
+
readonly columns?: readonly ColumnLabel[];
|
|
87
|
+
/** Explicit logical column types applied after parsing when no Table Schema is present. */
|
|
88
|
+
readonly columnTypes?: Readonly<Partial<Record<ColumnLabel, ColumnType>>>;
|
|
89
|
+
/** Packing threshold for typed-array storage. `0` disables packing. */
|
|
90
|
+
readonly packThreshold?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Options for `toTable()` and `toJSONString('table', ...)`. */
|
|
93
|
+
interface ToTableOptions {
|
|
94
|
+
/** Override the emitted table index field name when the default would collide. */
|
|
95
|
+
readonly indexField?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Additional options accepted by `toJSONString()`. */
|
|
98
|
+
type ToJSONStringOptions = ToTableOptions;
|
|
99
|
+
/**
|
|
100
|
+
* Immutable column-major view over pandas-compatible tabular JSON.
|
|
101
|
+
*
|
|
102
|
+
* Instances are created by `fromOrient()`. The generic row type improves row
|
|
103
|
+
* and callback ergonomics only; runtime validation still follows the JSON
|
|
104
|
+
* Frame contracts for the selected orient.
|
|
105
|
+
*/
|
|
106
|
+
interface DataFrame<TRow extends Record<string, JsonValue> = Record<string, JsonValue>> {
|
|
107
|
+
readonly columns: readonly string[];
|
|
108
|
+
readonly index: readonly IndexLabel[];
|
|
109
|
+
readonly columnInfo: ReadonlyMap<string, ColumnInfo>;
|
|
110
|
+
readonly length: number;
|
|
111
|
+
toRecords(): RecordsPayload;
|
|
112
|
+
toIndex(): IndexPayload;
|
|
113
|
+
toColumns(): ColumnsPayload;
|
|
114
|
+
toValues(): ValuesPayload;
|
|
115
|
+
toSplit(): SplitPayload;
|
|
116
|
+
toTable(options?: ToTableOptions): TablePayload;
|
|
117
|
+
toJSONString(orient: ResolvedOrient, options?: ToJSONStringOptions): string;
|
|
118
|
+
row(position: number): Readonly<TRow>;
|
|
119
|
+
rows(): readonly Readonly<TRow>[];
|
|
120
|
+
filter(predicate: (row: Readonly<TRow>, index: IndexLabel, position: number) => boolean): DataFrame<TRow>;
|
|
121
|
+
sort(compare: (left: Readonly<TRow>, right: Readonly<TRow>, leftIndex: IndexLabel, rightIndex: IndexLabel, leftPosition: number, rightPosition: number) => number): DataFrame<TRow>;
|
|
122
|
+
select(...columns: readonly string[]): DataFrame<Record<string, JsonValue>>;
|
|
123
|
+
rename(mapping: Readonly<Record<string, string>>): DataFrame<Record<string, JsonValue>>;
|
|
124
|
+
resetIndex(): DataFrame<TRow>;
|
|
125
|
+
}
|
|
1
126
|
|
|
2
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Parses pandas-compatible JSON into an immutable `DataFrame`.
|
|
129
|
+
*
|
|
130
|
+
* `auto` detection recognizes only structurally unambiguous payloads. Pass an
|
|
131
|
+
* explicit `options.orient` for `index`, `columns`, empty arrays, empty
|
|
132
|
+
* objects, and all `values` payloads. The generic row type is for TypeScript
|
|
133
|
+
* ergonomics and is not runtime-validated beyond the documented JSON-orient
|
|
134
|
+
* contracts.
|
|
135
|
+
*/
|
|
136
|
+
declare function fromOrient<TRow extends Record<string, JsonValue> = Record<string, JsonValue>>(input: string, options?: FromOrientOptions): DataFrame<TRow>;
|
|
137
|
+
declare function fromOrient<TRow extends Record<string, JsonValue>>(input: readonly TRow[], options?: FromOrientOptions & {
|
|
138
|
+
readonly orient?: 'auto' | 'records';
|
|
139
|
+
}): DataFrame<TRow>;
|
|
140
|
+
declare function fromOrient<TRow extends Record<string, JsonValue> = Record<string, JsonValue>>(input: JsonValue, options?: FromOrientOptions): DataFrame<TRow>;
|
|
141
|
+
|
|
142
|
+
type JsonFrameErrorContext = {
|
|
143
|
+
readonly orient?: Orient;
|
|
144
|
+
readonly path?: string;
|
|
145
|
+
readonly row?: number;
|
|
146
|
+
readonly column?: string;
|
|
147
|
+
readonly value?: unknown;
|
|
148
|
+
};
|
|
149
|
+
/** Base class for all structured `@web-ts-toolkit/json-frame` runtime failures. */
|
|
150
|
+
declare class JsonFrameError extends Error {
|
|
151
|
+
readonly orient?: Orient;
|
|
152
|
+
readonly path?: string;
|
|
153
|
+
readonly row?: number;
|
|
154
|
+
readonly column?: string;
|
|
155
|
+
readonly value?: unknown;
|
|
156
|
+
constructor(message: string, context?: JsonFrameErrorContext);
|
|
157
|
+
}
|
|
158
|
+
/** Raised when a JSON string cannot be parsed before orient validation begins. */
|
|
159
|
+
declare class JsonFrameParseError extends JsonFrameError {
|
|
160
|
+
readonly cause: SyntaxError;
|
|
161
|
+
constructor(message: string, cause: SyntaxError);
|
|
162
|
+
}
|
|
163
|
+
/** Raised when caller-supplied options are invalid before payload traversal begins. */
|
|
164
|
+
declare class JsonFrameOptionError extends JsonFrameError {
|
|
165
|
+
readonly option: string;
|
|
166
|
+
constructor(message: string, option: string, value: unknown);
|
|
167
|
+
}
|
|
168
|
+
/** Raised when an orient payload violates the documented JSON Frame contract. */
|
|
169
|
+
declare class JsonFrameValidationError extends JsonFrameError {
|
|
170
|
+
readonly orient?: ResolvedOrient;
|
|
171
|
+
constructor(message: string, context?: JsonFrameErrorContext & {
|
|
172
|
+
readonly orient?: ResolvedOrient;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/** Raised when `auto` detection cannot distinguish between multiple valid orients. */
|
|
176
|
+
declare class AmbiguousOrientError extends JsonFrameError {
|
|
177
|
+
readonly candidates: readonly ResolvedOrient[];
|
|
178
|
+
constructor(message: string, candidates: readonly ResolvedOrient[]);
|
|
179
|
+
}
|
|
180
|
+
/** Raised when a pandas shape or feature is explicitly outside the initial release scope. */
|
|
181
|
+
declare class UnsupportedFeatureError extends JsonFrameError {
|
|
182
|
+
readonly feature: string;
|
|
183
|
+
readonly orient?: ResolvedOrient;
|
|
184
|
+
constructor(message: string, feature: string, context?: JsonFrameErrorContext & {
|
|
185
|
+
readonly orient?: ResolvedOrient;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/** Raised when object-key exporters would collapse distinct index labels to the same JSON key. */
|
|
189
|
+
declare class ExportKeyCollisionError extends JsonFrameError {
|
|
190
|
+
readonly key: string;
|
|
191
|
+
readonly labels: readonly (string | number)[];
|
|
192
|
+
readonly orient: ResolvedOrient;
|
|
193
|
+
constructor(message: string, orient: ResolvedOrient, key: string, labels: readonly (string | number)[]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { AmbiguousOrientError, type ColumnInfo, type ColumnLabel, type ColumnType, type ColumnsPayload, type DataFrame, ExportKeyCollisionError, type FromOrientOptions, type IndexKind, type IndexLabel, type IndexPayload, type JsonArray, JsonFrameError, JsonFrameOptionError, JsonFrameParseError, JsonFrameValidationError, type JsonObject, type JsonPrimitive, type JsonValue, type Orient, type RecordsPayload, type ResolvedOrient, type SplitPayload, type TablePayload, type TableSchema, type TableSchemaConstraints, type TableSchemaField, type TableSchemaFieldType, type ToJSONStringOptions, type ToTableOptions, UnsupportedFeatureError, type ValuesPayload, fromOrient };
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,196 @@
|
|
|
1
|
+
/** Scalar JSON values accepted by `fromOrient` payloads and exporters. */
|
|
2
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
/** JSON arrays accepted by `fromOrient` payloads and returned by exporters. */
|
|
4
|
+
type JsonArray = readonly JsonValue[];
|
|
5
|
+
/** JSON objects accepted by `fromOrient` payloads and returned by exporters. */
|
|
6
|
+
interface JsonObject {
|
|
7
|
+
readonly [key: string]: JsonValue;
|
|
8
|
+
}
|
|
9
|
+
/** Any JSON-compatible value accepted by `fromOrient` payloads and exporters. */
|
|
10
|
+
type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
11
|
+
/** pandas orient names supported by `fromOrient`. */
|
|
12
|
+
type ResolvedOrient = 'records' | 'index' | 'columns' | 'values' | 'split' | 'table';
|
|
13
|
+
/** Orient selection for `fromOrient`. `auto` performs structural detection when possible. */
|
|
14
|
+
type Orient = 'auto' | ResolvedOrient;
|
|
15
|
+
/** Public column labels are unique strings in the initial release. */
|
|
16
|
+
type ColumnLabel = string;
|
|
17
|
+
/** Supported index labels preserved by parsed frames and label-bearing exporters. */
|
|
18
|
+
type IndexLabel = string | number;
|
|
19
|
+
/** Internal index provenance exposed by later frame APIs. */
|
|
20
|
+
type IndexKind = 'source' | 'synthetic';
|
|
21
|
+
/** Parsed payload for `orient='records'`. */
|
|
22
|
+
type RecordsPayload = readonly JsonObject[];
|
|
23
|
+
/** Parsed payload for `orient='index'`. */
|
|
24
|
+
type IndexPayload = Readonly<Record<string, JsonObject>>;
|
|
25
|
+
/** Parsed payload for `orient='columns'`. */
|
|
26
|
+
type ColumnsPayload = Readonly<Record<string, JsonObject>>;
|
|
27
|
+
/** Parsed payload for `orient='values'`. */
|
|
28
|
+
type ValuesPayload = readonly JsonArray[];
|
|
29
|
+
/** Parsed payload for `orient='split'`. */
|
|
30
|
+
interface SplitPayload {
|
|
31
|
+
readonly columns: readonly ColumnLabel[];
|
|
32
|
+
readonly index: readonly IndexLabel[];
|
|
33
|
+
readonly data: readonly JsonArray[];
|
|
34
|
+
}
|
|
35
|
+
/** Known Frictionless/Table Schema field types emitted by pandas. */
|
|
36
|
+
type TableSchemaFieldType = 'any' | 'array' | 'boolean' | 'date' | 'datetime' | 'duration' | 'geojson' | 'integer' | 'number' | 'object' | 'string' | 'year' | 'yearmonth' | (string & {});
|
|
37
|
+
/** Table Schema constraint metadata preserved when present. */
|
|
38
|
+
interface TableSchemaConstraints {
|
|
39
|
+
/** Enumerated allowed scalar values, commonly used for pandas categoricals. */
|
|
40
|
+
readonly enum?: readonly JsonPrimitive[];
|
|
41
|
+
readonly [key: string]: JsonValue | undefined;
|
|
42
|
+
}
|
|
43
|
+
type JsonMetadata = Readonly<Record<string, JsonValue | undefined>>;
|
|
44
|
+
/** Table Schema field metadata preserved during table ingestion and export. */
|
|
45
|
+
type TableSchemaField = JsonMetadata & {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly type: TableSchemaFieldType;
|
|
48
|
+
readonly format?: string;
|
|
49
|
+
readonly constraints?: TableSchemaConstraints;
|
|
50
|
+
readonly ordered?: boolean;
|
|
51
|
+
readonly extDtype?: string;
|
|
52
|
+
readonly tz?: string;
|
|
53
|
+
readonly freq?: string;
|
|
54
|
+
};
|
|
55
|
+
/** Table Schema metadata preserved for `orient='table'`. */
|
|
56
|
+
type TableSchema = JsonMetadata & {
|
|
57
|
+
readonly fields: readonly TableSchemaField[];
|
|
58
|
+
readonly primaryKey?: readonly string[];
|
|
59
|
+
readonly pandas_version?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Parsed payload for `orient='table'`. */
|
|
62
|
+
interface TablePayload {
|
|
63
|
+
readonly schema: TableSchema;
|
|
64
|
+
readonly data: readonly JsonObject[];
|
|
65
|
+
}
|
|
66
|
+
/** Logical column types inferred or preserved by the frame. */
|
|
67
|
+
type ColumnType = 'integer' | 'float' | 'string' | 'boolean' | 'datetime' | 'categorical' | 'mixed' | 'unknown';
|
|
68
|
+
/** Public logical type metadata for a stored column. */
|
|
69
|
+
interface ColumnInfo {
|
|
70
|
+
/** Narrowest logical type inferred or preserved for the column. */
|
|
71
|
+
readonly type: ColumnType;
|
|
72
|
+
/** Whether any row in the column contains `null`. */
|
|
73
|
+
readonly nullable: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for `fromOrient`.
|
|
77
|
+
*
|
|
78
|
+
* `columns` is required only for explicit `values` input because that orient
|
|
79
|
+
* carries no column labels. `columnTypes` supplies explicit logical metadata
|
|
80
|
+
* for label-preserving orients that do not carry Table Schema field types.
|
|
81
|
+
*/
|
|
82
|
+
interface FromOrientOptions {
|
|
83
|
+
/** Explicit orient, or `auto` to detect only structurally unambiguous shapes. */
|
|
84
|
+
readonly orient?: Orient;
|
|
85
|
+
/** Explicit column names used when parsing `orient='values'`. */
|
|
86
|
+
readonly columns?: readonly ColumnLabel[];
|
|
87
|
+
/** Explicit logical column types applied after parsing when no Table Schema is present. */
|
|
88
|
+
readonly columnTypes?: Readonly<Partial<Record<ColumnLabel, ColumnType>>>;
|
|
89
|
+
/** Packing threshold for typed-array storage. `0` disables packing. */
|
|
90
|
+
readonly packThreshold?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Options for `toTable()` and `toJSONString('table', ...)`. */
|
|
93
|
+
interface ToTableOptions {
|
|
94
|
+
/** Override the emitted table index field name when the default would collide. */
|
|
95
|
+
readonly indexField?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Additional options accepted by `toJSONString()`. */
|
|
98
|
+
type ToJSONStringOptions = ToTableOptions;
|
|
99
|
+
/**
|
|
100
|
+
* Immutable column-major view over pandas-compatible tabular JSON.
|
|
101
|
+
*
|
|
102
|
+
* Instances are created by `fromOrient()`. The generic row type improves row
|
|
103
|
+
* and callback ergonomics only; runtime validation still follows the JSON
|
|
104
|
+
* Frame contracts for the selected orient.
|
|
105
|
+
*/
|
|
106
|
+
interface DataFrame<TRow extends Record<string, JsonValue> = Record<string, JsonValue>> {
|
|
107
|
+
readonly columns: readonly string[];
|
|
108
|
+
readonly index: readonly IndexLabel[];
|
|
109
|
+
readonly columnInfo: ReadonlyMap<string, ColumnInfo>;
|
|
110
|
+
readonly length: number;
|
|
111
|
+
toRecords(): RecordsPayload;
|
|
112
|
+
toIndex(): IndexPayload;
|
|
113
|
+
toColumns(): ColumnsPayload;
|
|
114
|
+
toValues(): ValuesPayload;
|
|
115
|
+
toSplit(): SplitPayload;
|
|
116
|
+
toTable(options?: ToTableOptions): TablePayload;
|
|
117
|
+
toJSONString(orient: ResolvedOrient, options?: ToJSONStringOptions): string;
|
|
118
|
+
row(position: number): Readonly<TRow>;
|
|
119
|
+
rows(): readonly Readonly<TRow>[];
|
|
120
|
+
filter(predicate: (row: Readonly<TRow>, index: IndexLabel, position: number) => boolean): DataFrame<TRow>;
|
|
121
|
+
sort(compare: (left: Readonly<TRow>, right: Readonly<TRow>, leftIndex: IndexLabel, rightIndex: IndexLabel, leftPosition: number, rightPosition: number) => number): DataFrame<TRow>;
|
|
122
|
+
select(...columns: readonly string[]): DataFrame<Record<string, JsonValue>>;
|
|
123
|
+
rename(mapping: Readonly<Record<string, string>>): DataFrame<Record<string, JsonValue>>;
|
|
124
|
+
resetIndex(): DataFrame<TRow>;
|
|
125
|
+
}
|
|
1
126
|
|
|
2
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Parses pandas-compatible JSON into an immutable `DataFrame`.
|
|
129
|
+
*
|
|
130
|
+
* `auto` detection recognizes only structurally unambiguous payloads. Pass an
|
|
131
|
+
* explicit `options.orient` for `index`, `columns`, empty arrays, empty
|
|
132
|
+
* objects, and all `values` payloads. The generic row type is for TypeScript
|
|
133
|
+
* ergonomics and is not runtime-validated beyond the documented JSON-orient
|
|
134
|
+
* contracts.
|
|
135
|
+
*/
|
|
136
|
+
declare function fromOrient<TRow extends Record<string, JsonValue> = Record<string, JsonValue>>(input: string, options?: FromOrientOptions): DataFrame<TRow>;
|
|
137
|
+
declare function fromOrient<TRow extends Record<string, JsonValue>>(input: readonly TRow[], options?: FromOrientOptions & {
|
|
138
|
+
readonly orient?: 'auto' | 'records';
|
|
139
|
+
}): DataFrame<TRow>;
|
|
140
|
+
declare function fromOrient<TRow extends Record<string, JsonValue> = Record<string, JsonValue>>(input: JsonValue, options?: FromOrientOptions): DataFrame<TRow>;
|
|
141
|
+
|
|
142
|
+
type JsonFrameErrorContext = {
|
|
143
|
+
readonly orient?: Orient;
|
|
144
|
+
readonly path?: string;
|
|
145
|
+
readonly row?: number;
|
|
146
|
+
readonly column?: string;
|
|
147
|
+
readonly value?: unknown;
|
|
148
|
+
};
|
|
149
|
+
/** Base class for all structured `@web-ts-toolkit/json-frame` runtime failures. */
|
|
150
|
+
declare class JsonFrameError extends Error {
|
|
151
|
+
readonly orient?: Orient;
|
|
152
|
+
readonly path?: string;
|
|
153
|
+
readonly row?: number;
|
|
154
|
+
readonly column?: string;
|
|
155
|
+
readonly value?: unknown;
|
|
156
|
+
constructor(message: string, context?: JsonFrameErrorContext);
|
|
157
|
+
}
|
|
158
|
+
/** Raised when a JSON string cannot be parsed before orient validation begins. */
|
|
159
|
+
declare class JsonFrameParseError extends JsonFrameError {
|
|
160
|
+
readonly cause: SyntaxError;
|
|
161
|
+
constructor(message: string, cause: SyntaxError);
|
|
162
|
+
}
|
|
163
|
+
/** Raised when caller-supplied options are invalid before payload traversal begins. */
|
|
164
|
+
declare class JsonFrameOptionError extends JsonFrameError {
|
|
165
|
+
readonly option: string;
|
|
166
|
+
constructor(message: string, option: string, value: unknown);
|
|
167
|
+
}
|
|
168
|
+
/** Raised when an orient payload violates the documented JSON Frame contract. */
|
|
169
|
+
declare class JsonFrameValidationError extends JsonFrameError {
|
|
170
|
+
readonly orient?: ResolvedOrient;
|
|
171
|
+
constructor(message: string, context?: JsonFrameErrorContext & {
|
|
172
|
+
readonly orient?: ResolvedOrient;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/** Raised when `auto` detection cannot distinguish between multiple valid orients. */
|
|
176
|
+
declare class AmbiguousOrientError extends JsonFrameError {
|
|
177
|
+
readonly candidates: readonly ResolvedOrient[];
|
|
178
|
+
constructor(message: string, candidates: readonly ResolvedOrient[]);
|
|
179
|
+
}
|
|
180
|
+
/** Raised when a pandas shape or feature is explicitly outside the initial release scope. */
|
|
181
|
+
declare class UnsupportedFeatureError extends JsonFrameError {
|
|
182
|
+
readonly feature: string;
|
|
183
|
+
readonly orient?: ResolvedOrient;
|
|
184
|
+
constructor(message: string, feature: string, context?: JsonFrameErrorContext & {
|
|
185
|
+
readonly orient?: ResolvedOrient;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/** Raised when object-key exporters would collapse distinct index labels to the same JSON key. */
|
|
189
|
+
declare class ExportKeyCollisionError extends JsonFrameError {
|
|
190
|
+
readonly key: string;
|
|
191
|
+
readonly labels: readonly (string | number)[];
|
|
192
|
+
readonly orient: ResolvedOrient;
|
|
193
|
+
constructor(message: string, orient: ResolvedOrient, key: string, labels: readonly (string | number)[]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { AmbiguousOrientError, type ColumnInfo, type ColumnLabel, type ColumnType, type ColumnsPayload, type DataFrame, ExportKeyCollisionError, type FromOrientOptions, type IndexKind, type IndexLabel, type IndexPayload, type JsonArray, JsonFrameError, JsonFrameOptionError, JsonFrameParseError, JsonFrameValidationError, type JsonObject, type JsonPrimitive, type JsonValue, type Orient, type RecordsPayload, type ResolvedOrient, type SplitPayload, type TablePayload, type TableSchema, type TableSchemaConstraints, type TableSchemaField, type TableSchemaFieldType, type ToJSONStringOptions, type ToTableOptions, UnsupportedFeatureError, type ValuesPayload, fromOrient };
|