@elaraai/east 0.0.1-beta.1 → 0.0.1-beta.11
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/LICENSE.md +15 -666
- package/README.md +15 -6
- package/dist/src/analyze.d.ts +4 -4
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +142 -44
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/ast.d.ts +18 -7
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +1 -146
- package/dist/src/ast.js.map +1 -1
- package/dist/src/ast_to_ir.d.ts +7 -0
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +80 -11
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +89 -64
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +19 -2
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +137 -221
- package/dist/src/compile.js.map +1 -1
- package/dist/src/default.d.ts.map +1 -1
- package/dist/src/default.js +2 -0
- package/dist/src/default.js.map +1 -1
- package/dist/src/eastir.d.ts +12 -10
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +20 -19
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/expr/array.d.ts +66 -0
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +161 -51
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/ast.d.ts.map +1 -1
- package/dist/src/expr/ast.js +6 -0
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.d.ts +49 -0
- package/dist/src/expr/asyncfunction.d.ts.map +1 -0
- package/dist/src/expr/asyncfunction.js +60 -0
- package/dist/src/expr/asyncfunction.js.map +1 -0
- package/dist/src/expr/blob.d.ts +25 -1
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +36 -1
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +82 -8
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +278 -16
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/dict.js +47 -47
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +9 -0
- package/dist/src/expr/expr.d.ts.map +1 -1
- package/dist/src/expr/expr.js +5 -1
- package/dist/src/expr/expr.js.map +1 -1
- package/dist/src/expr/index.d.ts +112 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +110 -8
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/libs/array.js +1 -1
- package/dist/src/expr/libs/array.js.map +1 -1
- package/dist/src/expr/libs/dict.js +3 -3
- package/dist/src/expr/libs/dict.js.map +1 -1
- package/dist/src/expr/libs/integer.d.ts +19 -0
- package/dist/src/expr/libs/integer.d.ts.map +1 -1
- package/dist/src/expr/libs/integer.js +47 -0
- package/dist/src/expr/libs/integer.js.map +1 -1
- package/dist/src/expr/libs/set.js +2 -2
- package/dist/src/expr/libs/set.js.map +1 -1
- package/dist/src/expr/ref.js +1 -1
- package/dist/src/expr/ref.js.map +1 -1
- package/dist/src/expr/set.js +38 -38
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/struct.d.ts +2 -0
- package/dist/src/expr/struct.d.ts.map +1 -1
- package/dist/src/expr/types.d.ts +8 -5
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +53 -0
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +56 -0
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +5 -0
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/internal.d.ts +8 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +8 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +231 -33
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +3 -1
- package/dist/src/ir.js.map +1 -1
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +59 -18
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast2-stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2-stream.js +5 -0
- package/dist/src/serialization/beast2-stream.js.map +1 -1
- package/dist/src/serialization/beast2.d.ts.map +1 -1
- package/dist/src/serialization/beast2.js +10 -4
- package/dist/src/serialization/beast2.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +139 -0
- package/dist/src/serialization/csv.d.ts.map +1 -0
- package/dist/src/serialization/csv.js +615 -0
- package/dist/src/serialization/csv.js.map +1 -0
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +9 -1
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/index.d.ts +1 -0
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -0
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +8 -2
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/type_of_type.d.ts +20 -3
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.js +101 -13
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/types.d.ts +59 -16
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +141 -91
- package/dist/src/types.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*
|
|
5
|
+
* CSV serialization following RFC 4180 (Common Format and MIME Type for CSV Files).
|
|
6
|
+
* @see https://www.rfc-editor.org/rfc/rfc4180
|
|
7
|
+
*/
|
|
8
|
+
import type { ValueTypeOf, ArrayType } from "../types.js";
|
|
9
|
+
import { StructType, OptionType, StringType, BooleanType, DictType } from "../types.js";
|
|
10
|
+
import type { EastTypeValue } from "../type_of_type.js";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for CSV parsing.
|
|
13
|
+
* All properties are optional with sensible defaults.
|
|
14
|
+
*/
|
|
15
|
+
export type CsvParseOptions = {
|
|
16
|
+
/** Field delimiter (default: ",") */
|
|
17
|
+
delimiter?: string;
|
|
18
|
+
/** Quote character (default: '"') */
|
|
19
|
+
quoteChar?: string;
|
|
20
|
+
/** Escape character (default: '"' for doubled quotes) */
|
|
21
|
+
escapeChar?: string;
|
|
22
|
+
/** Line ending - auto-detects if not provided */
|
|
23
|
+
newline?: string;
|
|
24
|
+
/** Whether first row is headers (default: true) */
|
|
25
|
+
hasHeader?: boolean;
|
|
26
|
+
/** String values to treat as null (default: [""]) */
|
|
27
|
+
nullStrings?: string[];
|
|
28
|
+
/** Skip rows that are entirely empty (default: true) */
|
|
29
|
+
skipEmptyLines?: boolean;
|
|
30
|
+
/** Trim whitespace from field values (default: false) */
|
|
31
|
+
trimFields?: boolean;
|
|
32
|
+
/** Map CSV headers to struct field names */
|
|
33
|
+
columnMapping?: Map<string, string>;
|
|
34
|
+
/** Error on schema mismatch (default: false) */
|
|
35
|
+
strict?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Configuration options for CSV serialization.
|
|
39
|
+
* All properties are optional with sensible defaults.
|
|
40
|
+
*/
|
|
41
|
+
export type CsvSerializeOptions = {
|
|
42
|
+
/** Field delimiter (default: ",") */
|
|
43
|
+
delimiter?: string;
|
|
44
|
+
/** Quote character (default: '"') */
|
|
45
|
+
quoteChar?: string;
|
|
46
|
+
/** Escape character (default: '"') */
|
|
47
|
+
escapeChar?: string;
|
|
48
|
+
/** Line ending (default: "\r\n") */
|
|
49
|
+
newline?: string;
|
|
50
|
+
/** Include header row (default: true) */
|
|
51
|
+
includeHeader?: boolean;
|
|
52
|
+
/** String to output for null/none values (default: "") */
|
|
53
|
+
nullString?: string;
|
|
54
|
+
/** Always quote all fields (default: false) */
|
|
55
|
+
alwaysQuote?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* East type for CSV parse configuration.
|
|
59
|
+
*/
|
|
60
|
+
export declare const CsvParseConfigType: StructType<{
|
|
61
|
+
delimiter: OptionType<StringType>;
|
|
62
|
+
quoteChar: OptionType<StringType>;
|
|
63
|
+
escapeChar: OptionType<StringType>;
|
|
64
|
+
newline: OptionType<StringType>;
|
|
65
|
+
hasHeader: OptionType<BooleanType>;
|
|
66
|
+
nullStrings: OptionType<ArrayType<StringType>>;
|
|
67
|
+
skipEmptyLines: OptionType<BooleanType>;
|
|
68
|
+
trimFields: OptionType<BooleanType>;
|
|
69
|
+
columnMapping: OptionType<DictType<StringType, StringType>>;
|
|
70
|
+
strict: OptionType<BooleanType>;
|
|
71
|
+
}>;
|
|
72
|
+
export type CsvParseConfigType = typeof CsvParseConfigType;
|
|
73
|
+
/**
|
|
74
|
+
* East type for CSV serialize configuration.
|
|
75
|
+
*/
|
|
76
|
+
export declare const CsvSerializeConfigType: StructType<{
|
|
77
|
+
delimiter: OptionType<StringType>;
|
|
78
|
+
quoteChar: OptionType<StringType>;
|
|
79
|
+
escapeChar: OptionType<StringType>;
|
|
80
|
+
newline: OptionType<StringType>;
|
|
81
|
+
includeHeader: OptionType<BooleanType>;
|
|
82
|
+
nullString: OptionType<StringType>;
|
|
83
|
+
alwaysQuote: OptionType<BooleanType>;
|
|
84
|
+
}>;
|
|
85
|
+
export type CsvSerializeConfigType = typeof CsvSerializeConfigType;
|
|
86
|
+
/**
|
|
87
|
+
* Converts TypeScript CsvParseOptions to an East config value.
|
|
88
|
+
*/
|
|
89
|
+
export declare function csvParseOptionsToValue(options?: CsvParseOptions): ValueTypeOf<CsvParseConfigType>;
|
|
90
|
+
/**
|
|
91
|
+
* Converts TypeScript CsvSerializeOptions to an East config value.
|
|
92
|
+
*/
|
|
93
|
+
export declare function csvSerializeOptionsToValue(options?: CsvSerializeOptions): ValueTypeOf<CsvSerializeConfigType>;
|
|
94
|
+
/**
|
|
95
|
+
* Extracts resolved options from an East config value, applying defaults.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveParseConfig(config: ValueTypeOf<CsvParseConfigType>): Required<Omit<CsvParseOptions, 'columnMapping'>> & {
|
|
98
|
+
columnMapping: Map<string, string>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Extracts resolved options from an East config value, applying defaults.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveSerializeConfig(config: ValueTypeOf<CsvSerializeConfigType>): Required<CsvSerializeOptions>;
|
|
104
|
+
/**
|
|
105
|
+
* Location information for CSV parsing errors.
|
|
106
|
+
*/
|
|
107
|
+
export interface CsvLocation {
|
|
108
|
+
/** 1-indexed row number (excluding header) */
|
|
109
|
+
row: number;
|
|
110
|
+
/** 0-indexed column index */
|
|
111
|
+
column: number;
|
|
112
|
+
/** Column header name if available */
|
|
113
|
+
columnName?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown during CSV parsing with location information.
|
|
117
|
+
*/
|
|
118
|
+
export declare class CsvError extends Error {
|
|
119
|
+
location?: CsvLocation | undefined;
|
|
120
|
+
constructor(message: string, location?: CsvLocation | undefined);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Creates a type-specialized CSV decoder for Array<Struct>.
|
|
124
|
+
*
|
|
125
|
+
* @param structType - The struct type for each row
|
|
126
|
+
* @param config - Configuration as East value (from CsvParseConfigType)
|
|
127
|
+
* @param frozen - Whether to freeze the decoded values
|
|
128
|
+
*/
|
|
129
|
+
export declare function decodeCsvFor(structType: EastTypeValue, config?: ValueTypeOf<CsvParseConfigType>, frozen?: boolean): (blob: Uint8Array) => any;
|
|
130
|
+
export declare function decodeCsvFor<T extends StructType>(structType: T, config?: ValueTypeOf<CsvParseConfigType>, frozen?: boolean): (blob: Uint8Array) => ValueTypeOf<ArrayType<T>>;
|
|
131
|
+
/**
|
|
132
|
+
* Creates a type-specialized CSV encoder for Array<Struct>.
|
|
133
|
+
*
|
|
134
|
+
* @param structType - The struct type for each row
|
|
135
|
+
* @param config - Configuration as East value (from CsvSerializeConfigType)
|
|
136
|
+
*/
|
|
137
|
+
export declare function encodeCsvFor(structType: EastTypeValue, config?: ValueTypeOf<CsvSerializeConfigType>): (value: any[]) => Uint8Array;
|
|
138
|
+
export declare function encodeCsvFor<T extends StructType>(structType: T, config?: ValueTypeOf<CsvSerializeConfigType>): (value: ValueTypeOf<ArrayType<T>>) => Uint8Array;
|
|
139
|
+
//# sourceMappingURL=csv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/serialization/csv.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAqC,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG3H,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,oBAAoB,CAAC;AAO3F;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qDAAqD;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