@elaraai/east-node-io 0.0.1-beta.0 → 0.0.1-beta.2

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 (114) hide show
  1. package/dist/compression/gzip.d.ts +108 -0
  2. package/dist/compression/gzip.d.ts.map +1 -0
  3. package/dist/compression/gzip.js +153 -0
  4. package/dist/compression/gzip.js.map +1 -0
  5. package/dist/compression/index.d.ts +308 -0
  6. package/dist/compression/index.d.ts.map +1 -0
  7. package/dist/compression/index.js +289 -0
  8. package/dist/compression/index.js.map +1 -0
  9. package/dist/compression/tar.d.ts +115 -0
  10. package/dist/compression/tar.d.ts.map +1 -0
  11. package/dist/compression/tar.js +254 -0
  12. package/dist/compression/tar.js.map +1 -0
  13. package/dist/compression/types.d.ts +124 -0
  14. package/dist/compression/types.d.ts.map +1 -0
  15. package/dist/compression/types.js +106 -0
  16. package/dist/compression/types.js.map +1 -0
  17. package/dist/compression/zip.d.ts +121 -0
  18. package/dist/compression/zip.d.ts.map +1 -0
  19. package/dist/compression/zip.js +200 -0
  20. package/dist/compression/zip.js.map +1 -0
  21. package/dist/connection/index.d.ts +78 -0
  22. package/dist/connection/index.d.ts.map +1 -0
  23. package/dist/connection/index.js +134 -0
  24. package/dist/connection/index.js.map +1 -0
  25. package/dist/format/csv.d.ts +210 -0
  26. package/dist/format/csv.d.ts.map +1 -0
  27. package/dist/format/csv.js +729 -0
  28. package/dist/format/csv.js.map +1 -0
  29. package/dist/format/index.d.ts +641 -0
  30. package/dist/format/index.d.ts.map +1 -0
  31. package/dist/format/index.js +463 -0
  32. package/dist/format/index.js.map +1 -0
  33. package/dist/format/types.d.ts +176 -0
  34. package/dist/format/types.d.ts.map +1 -0
  35. package/dist/format/types.js +122 -0
  36. package/dist/format/types.js.map +1 -0
  37. package/dist/format/xlsx.d.ts +178 -0
  38. package/dist/format/xlsx.d.ts.map +1 -0
  39. package/dist/format/xlsx.js +313 -0
  40. package/dist/format/xlsx.js.map +1 -0
  41. package/dist/format/xml.d.ts +302 -0
  42. package/dist/format/xml.d.ts.map +1 -0
  43. package/dist/format/xml.js +602 -0
  44. package/dist/format/xml.js.map +1 -0
  45. package/dist/index.d.ts +25 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/nosql/index.d.ts +503 -0
  50. package/dist/nosql/index.d.ts.map +1 -0
  51. package/dist/nosql/index.js +483 -0
  52. package/dist/nosql/index.js.map +1 -0
  53. package/dist/nosql/mongodb.d.ts +306 -0
  54. package/dist/nosql/mongodb.d.ts.map +1 -0
  55. package/dist/nosql/mongodb.js +552 -0
  56. package/dist/nosql/mongodb.js.map +1 -0
  57. package/dist/nosql/redis.d.ts +268 -0
  58. package/dist/nosql/redis.d.ts.map +1 -0
  59. package/dist/nosql/redis.js +371 -0
  60. package/dist/nosql/redis.js.map +1 -0
  61. package/dist/nosql/types.d.ts +70 -0
  62. package/dist/nosql/types.d.ts.map +1 -0
  63. package/dist/nosql/types.js +79 -0
  64. package/dist/nosql/types.js.map +1 -0
  65. package/dist/sql/index.d.ts +777 -0
  66. package/dist/sql/index.d.ts.map +1 -0
  67. package/dist/sql/index.js +515 -0
  68. package/dist/sql/index.js.map +1 -0
  69. package/dist/sql/mysql.d.ts +238 -0
  70. package/dist/sql/mysql.d.ts.map +1 -0
  71. package/dist/sql/mysql.js +396 -0
  72. package/dist/sql/mysql.js.map +1 -0
  73. package/dist/sql/postgres.d.ts +237 -0
  74. package/dist/sql/postgres.d.ts.map +1 -0
  75. package/dist/sql/postgres.js +381 -0
  76. package/dist/sql/postgres.js.map +1 -0
  77. package/dist/sql/sqlite.d.ts +217 -0
  78. package/dist/sql/sqlite.d.ts.map +1 -0
  79. package/dist/sql/sqlite.js +366 -0
  80. package/dist/sql/sqlite.js.map +1 -0
  81. package/dist/sql/types.d.ts +205 -0
  82. package/dist/sql/types.d.ts.map +1 -0
  83. package/dist/sql/types.js +175 -0
  84. package/dist/sql/types.js.map +1 -0
  85. package/dist/storage/index.d.ts +304 -0
  86. package/dist/storage/index.d.ts.map +1 -0
  87. package/dist/storage/index.js +234 -0
  88. package/dist/storage/index.js.map +1 -0
  89. package/dist/storage/s3.d.ts +373 -0
  90. package/dist/storage/s3.d.ts.map +1 -0
  91. package/dist/storage/s3.js +502 -0
  92. package/dist/storage/s3.js.map +1 -0
  93. package/dist/storage/types.d.ts +117 -0
  94. package/dist/storage/types.d.ts.map +1 -0
  95. package/dist/storage/types.js +94 -0
  96. package/dist/storage/types.js.map +1 -0
  97. package/dist/transfer/ftp.d.ts +333 -0
  98. package/dist/transfer/ftp.d.ts.map +1 -0
  99. package/dist/transfer/ftp.js +437 -0
  100. package/dist/transfer/ftp.js.map +1 -0
  101. package/dist/transfer/index.d.ts +456 -0
  102. package/dist/transfer/index.d.ts.map +1 -0
  103. package/dist/transfer/index.js +414 -0
  104. package/dist/transfer/index.js.map +1 -0
  105. package/dist/transfer/sftp.d.ts +333 -0
  106. package/dist/transfer/sftp.d.ts.map +1 -0
  107. package/dist/transfer/sftp.js +436 -0
  108. package/dist/transfer/sftp.js.map +1 -0
  109. package/dist/transfer/types.d.ts +108 -0
  110. package/dist/transfer/types.d.ts.map +1 -0
  111. package/dist/transfer/types.js +110 -0
  112. package/dist/transfer/types.js.map +1 -0
  113. package/dist/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +8 -8
@@ -0,0 +1,122 @@
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
+ /**
6
+ * XLSX type definitions for East Node IO.
7
+ *
8
+ * Provides East type definitions for reading and writing Excel (XLSX) files,
9
+ * representing spreadsheets as 2D arrays of literal values.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { StructType, OptionType, ArrayType, DictType, StringType, IntegerType, } from "@elaraai/east";
14
+ import { LiteralValueType } from "@elaraai/east/internal";
15
+ /**
16
+ * A single cell value in a spreadsheet.
17
+ *
18
+ * Can be a string, number, boolean, or null. Matches the LiteralValueType
19
+ * which supports all primitive JavaScript values that can appear in Excel cells.
20
+ */
21
+ export const XlsxCellType = LiteralValueType;
22
+ /**
23
+ * A row of cells in a spreadsheet.
24
+ *
25
+ * Represents a single row as an array of cell values.
26
+ */
27
+ export const XlsxRowType = ArrayType(XlsxCellType);
28
+ /**
29
+ * A 2D array representing a complete worksheet.
30
+ *
31
+ * Array of rows, where each row is an array of cell values.
32
+ * This is the main data structure for reading/writing XLSX files.
33
+ */
34
+ export const XlsxSheetType = ArrayType(XlsxRowType);
35
+ /**
36
+ * XLSX read options configuration.
37
+ *
38
+ * Controls how Excel files are parsed when reading.
39
+ */
40
+ export const XlsxReadOptionsType = StructType({
41
+ /**
42
+ * Name of the sheet to read.
43
+ * If not specified, reads the first sheet.
44
+ */
45
+ sheetName: OptionType(StringType),
46
+ });
47
+ /**
48
+ * XLSX write options configuration.
49
+ *
50
+ * Controls how data is written to Excel files.
51
+ */
52
+ export const XlsxWriteOptionsType = StructType({
53
+ /**
54
+ * Name of the sheet to create.
55
+ * Defaults to "Sheet1" if not specified.
56
+ */
57
+ sheetName: OptionType(StringType),
58
+ });
59
+ /**
60
+ * Information about sheets in an XLSX file.
61
+ */
62
+ export const XlsxSheetInfoType = StructType({
63
+ /** Sheet name */
64
+ name: StringType,
65
+ /** Number of rows (approximate) */
66
+ rowCount: IntegerType,
67
+ /** Number of columns (approximate) */
68
+ columnCount: IntegerType,
69
+ });
70
+ /**
71
+ * XLSX file metadata and sheet listing.
72
+ */
73
+ export const XlsxInfoType = StructType({
74
+ /** List of sheets in the workbook */
75
+ sheets: ArrayType(XlsxSheetInfoType),
76
+ });
77
+ /**
78
+ * A single cell value in a CSV file.
79
+ *
80
+ * Can be a string, number, boolean, or null. Matches the LiteralValueType
81
+ * which supports all primitive JavaScript values that can appear in CSV cells.
82
+ */
83
+ export const CsvCellType = LiteralValueType;
84
+ /**
85
+ * A row of cells in a CSV file represented as a dictionary.
86
+ *
87
+ * Maps column names (from the header row) to cell values.
88
+ * This allows accessing cells by name rather than index.
89
+ */
90
+ export const CsvRowType = DictType(StringType, CsvCellType);
91
+ /**
92
+ * CSV data as an array of rows.
93
+ *
94
+ * Each row is a dictionary mapping column names to values.
95
+ * The first row of the CSV file is used as column headers.
96
+ */
97
+ export const CsvDataType = ArrayType(CsvRowType);
98
+ /**
99
+ * CSV read options configuration.
100
+ *
101
+ * Controls how CSV files are parsed when reading.
102
+ */
103
+ export const CsvReadOptionsType = StructType({
104
+ /**
105
+ * Delimiter character.
106
+ * Defaults to "," if not specified.
107
+ */
108
+ delimiter: OptionType(StringType),
109
+ });
110
+ /**
111
+ * CSV write options configuration.
112
+ *
113
+ * Controls how data is written to CSV files.
114
+ */
115
+ export const CsvWriteOptionsType = StructType({
116
+ /**
117
+ * Delimiter character.
118
+ * Defaults to "," if not specified.
119
+ */
120
+ delimiter: OptionType(StringType),
121
+ });
122
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/format/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,UAAU,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC1C;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC;CACpC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC3C;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC;CACpC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACxC,iBAAiB;IACjB,IAAI,EAAE,UAAU;IAEhB,mCAAmC;IACnC,QAAQ,EAAE,WAAW;IAErB,sCAAsC;IACtC,WAAW,EAAE,WAAW;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACnC,qCAAqC;IACrC,MAAM,EAAE,SAAS,CAAC,iBAAiB,CAAC;CACvC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IACzC;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC;CACpC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC1C;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC;CACpC,CAAC,CAAC"}
@@ -0,0 +1,178 @@
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
+ /**
6
+ * XLSX (Excel) file format platform functions for East Node IO.
7
+ *
8
+ * Provides functions for reading and writing Excel files (.xlsx) as 2D arrays
9
+ * of literal values.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { BlobType } from "@elaraai/east";
14
+ import type { PlatformFunction } from "@elaraai/east/internal";
15
+ /**
16
+ * Reads an XLSX file and returns a 2D array of cell values.
17
+ *
18
+ * Parses an Excel file from a blob and extracts data as a 2D array where
19
+ * each row is an array of cell values. Cell values are represented as
20
+ * LiteralValueType (string, number, boolean, or null).
21
+ *
22
+ * This is a platform function for the East language, enabling Excel file
23
+ * operations in East programs running on Node.js.
24
+ *
25
+ * @param data - XLSX file content as a blob
26
+ * @param options - Read options (sheet name)
27
+ * @returns 2D array of cell values (ArrayType<ArrayType<LiteralValueType>>)
28
+ *
29
+ * @throws {EastError} When reading fails due to:
30
+ * - Invalid XLSX file format (location: "xlsx_read")
31
+ * - Sheet not found (location: "xlsx_read")
32
+ * - Corrupted file data (location: "xlsx_read")
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { East, BlobType, IntegerType, variant } from "@elaraai/east";
37
+ * import { Format } from "@elaraai/east-node-io";
38
+ *
39
+ * const countRows = East.function([BlobType], IntegerType, ($, xlsxBlob) => {
40
+ * const options = $.let({
41
+ * sheetName: variant('some', "Sheet1"),
42
+ * });
43
+ *
44
+ * const sheet = $.let(Format.XLSX.read(xlsxBlob, options));
45
+ *
46
+ * // Skip header row in East code
47
+ * const dataRows = $.let(sheet.slice(East.value(1n), sheet.size()));
48
+ *
49
+ * return $.return(dataRows.size());
50
+ * });
51
+ *
52
+ * const compiled = East.compile(countRows.toIR(), Format.XLSX.Implementation);
53
+ * const xlsxBlob = new Uint8Array([]);
54
+ * compiled(xlsxBlob); // 99n (row count after skipping header)
55
+ * ```
56
+ *
57
+ * @remarks
58
+ * - All read operations are synchronous (use East.compile)
59
+ * - Empty cells are represented as null
60
+ * - Numbers are converted to JavaScript numbers (not bigint)
61
+ * - Dates are converted to ISO 8601 strings
62
+ * - Formulas are evaluated and their results are returned
63
+ */
64
+ export declare const xlsx_read: import("@elaraai/east").PlatformDefinition<[BlobType, import("@elaraai/east").StructType<{
65
+ sheetName: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
66
+ }>], import("@elaraai/east").ArrayType<import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
67
+ Null: import("@elaraai/east").NullType;
68
+ Boolean: import("@elaraai/east").BooleanType;
69
+ Integer: import("@elaraai/east").IntegerType;
70
+ Float: import("@elaraai/east").FloatType;
71
+ String: import("@elaraai/east").StringType;
72
+ DateTime: import("@elaraai/east").DateTimeType;
73
+ Blob: BlobType;
74
+ }>>>>;
75
+ /**
76
+ * Writes a 2D array of cell values to an XLSX file.
77
+ *
78
+ * Creates an Excel file from a 2D array of literal values. Each nested array
79
+ * represents a row, and each value in the row represents a cell.
80
+ *
81
+ * This is a platform function for the East language, enabling Excel file
82
+ * creation in East programs running on Node.js.
83
+ *
84
+ * @param data - 2D array of cell values to write
85
+ * @param options - Write options (sheet name)
86
+ * @returns XLSX file content as a blob
87
+ *
88
+ * @throws {EastError} When writing fails due to:
89
+ * - Invalid data structure (location: "xlsx_write")
90
+ * - Unsupported cell value type (location: "xlsx_write")
91
+ * - Memory allocation failure for large files (location: "xlsx_write")
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { East, BlobType, variant } from "@elaraai/east";
96
+ * import { Format } from "@elaraai/east-node-io";
97
+ *
98
+ * const createExcel = East.function([], BlobType, $ => {
99
+ * const data = $.let([
100
+ * [variant('String', "Name"), variant('String', "Age"), variant('String', "City")],
101
+ * [variant('String', "Alice"), variant('Float', 30), variant('String', "New York")],
102
+ * [variant('String', "Bob"), variant('Float', 25), variant('String', "London")],
103
+ * ]);
104
+ *
105
+ * const options = $.let({
106
+ * sheetName: variant('some', "Employees"),
107
+ * });
108
+ *
109
+ * return $.return(Format.XLSX.write(data, options));
110
+ * });
111
+ *
112
+ * const compiled = East.compile(createExcel.toIR(), Format.XLSX.Implementation);
113
+ * const xlsxBlob = compiled();
114
+ * ```
115
+ *
116
+ * @remarks
117
+ * - All write operations are synchronous (use East.compile)
118
+ * - null values create empty cells
119
+ * - Numbers are written as numeric cells
120
+ * - Strings are written as text cells
121
+ * - Booleans are written as boolean cells
122
+ * - All rows should ideally have the same number of columns
123
+ */
124
+ export declare const xlsx_write: import("@elaraai/east").PlatformDefinition<[import("@elaraai/east").ArrayType<import("@elaraai/east").ArrayType<import("@elaraai/east").VariantType<{
125
+ Null: import("@elaraai/east").NullType;
126
+ Boolean: import("@elaraai/east").BooleanType;
127
+ Integer: import("@elaraai/east").IntegerType;
128
+ Float: import("@elaraai/east").FloatType;
129
+ String: import("@elaraai/east").StringType;
130
+ DateTime: import("@elaraai/east").DateTimeType;
131
+ Blob: BlobType;
132
+ }>>>, import("@elaraai/east").StructType<{
133
+ sheetName: import("@elaraai/east").OptionType<import("@elaraai/east").StringType>;
134
+ }>], BlobType>;
135
+ /**
136
+ * Gets metadata about an XLSX file without reading all data.
137
+ *
138
+ * Returns information about sheets in the workbook including names and
139
+ * approximate row/column counts. Useful for inspecting files before reading.
140
+ *
141
+ * @param data - XLSX file content as a blob
142
+ * @returns Metadata with sheet names and sizes
143
+ *
144
+ * @throws {EastError} When reading fails due to:
145
+ * - Invalid XLSX file format (location: "xlsx_info")
146
+ * - Corrupted file data (location: "xlsx_info")
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { East, BlobType, StringType } from "@elaraai/east";
151
+ * import { Format } from "@elaraai/east-node-io";
152
+ *
153
+ * const getFirstSheetName = East.function([BlobType], StringType, ($, xlsxBlob) => {
154
+ * const info = $.let(Format.XLSX.info(xlsxBlob));
155
+ * const firstSheet = $.let(info.sheets.at(East.value(0n)));
156
+ * return $.return(firstSheet.name);
157
+ * });
158
+ *
159
+ * const compiled = East.compile(getFirstSheetName.toIR(), Format.XLSX.Implementation);
160
+ * const xlsxBlob = new Uint8Array([]);
161
+ * compiled(xlsxBlob); // "Sheet1"
162
+ * ```
163
+ */
164
+ export declare const xlsx_info: import("@elaraai/east").PlatformDefinition<[BlobType], import("@elaraai/east").StructType<{
165
+ sheets: import("@elaraai/east").ArrayType<import("@elaraai/east").StructType<{
166
+ name: import("@elaraai/east").StringType;
167
+ rowCount: import("@elaraai/east").IntegerType;
168
+ columnCount: import("@elaraai/east").IntegerType;
169
+ }>>;
170
+ }>>;
171
+ /**
172
+ * Node.js platform implementation for XLSX operations.
173
+ *
174
+ * Provides the runtime implementations for XLSX read/write operations.
175
+ * Pass this to East.compile() to enable XLSX functionality.
176
+ */
177
+ export declare const XlsxImpl: PlatformFunction[];
178
+ //# sourceMappingURL=xlsx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xlsx.d.ts","sourceRoot":"","sources":["../../src/format/xlsx.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,QAAQ,EAAkB,MAAM,eAAe,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAU/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;KAA6E,CAAC;AACpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;cAA+E,CAAC;AAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,SAAS;;;;;;GAAuD,CAAC;AAqB9E;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAAgB,EAqKtC,CAAC"}
@@ -0,0 +1,313 @@
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
+ /**
6
+ * XLSX (Excel) file format platform functions for East Node IO.
7
+ *
8
+ * Provides functions for reading and writing Excel files (.xlsx) as 2D arrays
9
+ * of literal values.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import { East, BlobType, variant, match } from "@elaraai/east";
14
+ import { EastError, LiteralValueType } from "@elaraai/east/internal";
15
+ import * as XLSX from 'xlsx';
16
+ import { XlsxSheetType, XlsxReadOptionsType, XlsxWriteOptionsType, XlsxInfoType, } from "./types.js";
17
+ /**
18
+ * Reads an XLSX file and returns a 2D array of cell values.
19
+ *
20
+ * Parses an Excel file from a blob and extracts data as a 2D array where
21
+ * each row is an array of cell values. Cell values are represented as
22
+ * LiteralValueType (string, number, boolean, or null).
23
+ *
24
+ * This is a platform function for the East language, enabling Excel file
25
+ * operations in East programs running on Node.js.
26
+ *
27
+ * @param data - XLSX file content as a blob
28
+ * @param options - Read options (sheet name)
29
+ * @returns 2D array of cell values (ArrayType<ArrayType<LiteralValueType>>)
30
+ *
31
+ * @throws {EastError} When reading fails due to:
32
+ * - Invalid XLSX file format (location: "xlsx_read")
33
+ * - Sheet not found (location: "xlsx_read")
34
+ * - Corrupted file data (location: "xlsx_read")
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { East, BlobType, IntegerType, variant } from "@elaraai/east";
39
+ * import { Format } from "@elaraai/east-node-io";
40
+ *
41
+ * const countRows = East.function([BlobType], IntegerType, ($, xlsxBlob) => {
42
+ * const options = $.let({
43
+ * sheetName: variant('some', "Sheet1"),
44
+ * });
45
+ *
46
+ * const sheet = $.let(Format.XLSX.read(xlsxBlob, options));
47
+ *
48
+ * // Skip header row in East code
49
+ * const dataRows = $.let(sheet.slice(East.value(1n), sheet.size()));
50
+ *
51
+ * return $.return(dataRows.size());
52
+ * });
53
+ *
54
+ * const compiled = East.compile(countRows.toIR(), Format.XLSX.Implementation);
55
+ * const xlsxBlob = new Uint8Array([]);
56
+ * compiled(xlsxBlob); // 99n (row count after skipping header)
57
+ * ```
58
+ *
59
+ * @remarks
60
+ * - All read operations are synchronous (use East.compile)
61
+ * - Empty cells are represented as null
62
+ * - Numbers are converted to JavaScript numbers (not bigint)
63
+ * - Dates are converted to ISO 8601 strings
64
+ * - Formulas are evaluated and their results are returned
65
+ */
66
+ export const xlsx_read = East.platform("xlsx_read", [BlobType, XlsxReadOptionsType], XlsxSheetType);
67
+ /**
68
+ * Writes a 2D array of cell values to an XLSX file.
69
+ *
70
+ * Creates an Excel file from a 2D array of literal values. Each nested array
71
+ * represents a row, and each value in the row represents a cell.
72
+ *
73
+ * This is a platform function for the East language, enabling Excel file
74
+ * creation in East programs running on Node.js.
75
+ *
76
+ * @param data - 2D array of cell values to write
77
+ * @param options - Write options (sheet name)
78
+ * @returns XLSX file content as a blob
79
+ *
80
+ * @throws {EastError} When writing fails due to:
81
+ * - Invalid data structure (location: "xlsx_write")
82
+ * - Unsupported cell value type (location: "xlsx_write")
83
+ * - Memory allocation failure for large files (location: "xlsx_write")
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { East, BlobType, variant } from "@elaraai/east";
88
+ * import { Format } from "@elaraai/east-node-io";
89
+ *
90
+ * const createExcel = East.function([], BlobType, $ => {
91
+ * const data = $.let([
92
+ * [variant('String', "Name"), variant('String', "Age"), variant('String', "City")],
93
+ * [variant('String', "Alice"), variant('Float', 30), variant('String', "New York")],
94
+ * [variant('String', "Bob"), variant('Float', 25), variant('String', "London")],
95
+ * ]);
96
+ *
97
+ * const options = $.let({
98
+ * sheetName: variant('some', "Employees"),
99
+ * });
100
+ *
101
+ * return $.return(Format.XLSX.write(data, options));
102
+ * });
103
+ *
104
+ * const compiled = East.compile(createExcel.toIR(), Format.XLSX.Implementation);
105
+ * const xlsxBlob = compiled();
106
+ * ```
107
+ *
108
+ * @remarks
109
+ * - All write operations are synchronous (use East.compile)
110
+ * - null values create empty cells
111
+ * - Numbers are written as numeric cells
112
+ * - Strings are written as text cells
113
+ * - Booleans are written as boolean cells
114
+ * - All rows should ideally have the same number of columns
115
+ */
116
+ export const xlsx_write = East.platform("xlsx_write", [XlsxSheetType, XlsxWriteOptionsType], BlobType);
117
+ /**
118
+ * Gets metadata about an XLSX file without reading all data.
119
+ *
120
+ * Returns information about sheets in the workbook including names and
121
+ * approximate row/column counts. Useful for inspecting files before reading.
122
+ *
123
+ * @param data - XLSX file content as a blob
124
+ * @returns Metadata with sheet names and sizes
125
+ *
126
+ * @throws {EastError} When reading fails due to:
127
+ * - Invalid XLSX file format (location: "xlsx_info")
128
+ * - Corrupted file data (location: "xlsx_info")
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * import { East, BlobType, StringType } from "@elaraai/east";
133
+ * import { Format } from "@elaraai/east-node-io";
134
+ *
135
+ * const getFirstSheetName = East.function([BlobType], StringType, ($, xlsxBlob) => {
136
+ * const info = $.let(Format.XLSX.info(xlsxBlob));
137
+ * const firstSheet = $.let(info.sheets.at(East.value(0n)));
138
+ * return $.return(firstSheet.name);
139
+ * });
140
+ *
141
+ * const compiled = East.compile(getFirstSheetName.toIR(), Format.XLSX.Implementation);
142
+ * const xlsxBlob = new Uint8Array([]);
143
+ * compiled(xlsxBlob); // "Sheet1"
144
+ * ```
145
+ */
146
+ export const xlsx_info = East.platform("xlsx_info", [BlobType], XlsxInfoType);
147
+ /**
148
+ * Converts East LiteralValueType to native JavaScript value for XLSX.
149
+ *
150
+ * @param value - East LiteralValueType value
151
+ * @returns Native JavaScript value
152
+ * @internal
153
+ */
154
+ function convertLiteralToCell(value) {
155
+ return match(value, {
156
+ Null: () => null,
157
+ String: (v) => v,
158
+ Integer: (v) => Number(v), // Convert BigInt to Number for Excel
159
+ Float: (v) => v,
160
+ Boolean: (v) => v,
161
+ DateTime: (v) => v, // Keep as Date object
162
+ Blob: (v) => v.toString(), // Convert Blob to string representation
163
+ });
164
+ }
165
+ /**
166
+ * Node.js platform implementation for XLSX operations.
167
+ *
168
+ * Provides the runtime implementations for XLSX read/write operations.
169
+ * Pass this to East.compile() to enable XLSX functionality.
170
+ */
171
+ export const XlsxImpl = [
172
+ xlsx_read.implement((data, options) => {
173
+ try {
174
+ // Convert Uint8Array blob to Buffer
175
+ const buffer = Buffer.from(data);
176
+ // Parse the workbook with cellDates option to parse dates as Date objects
177
+ const workbook = XLSX.read(buffer, { type: 'buffer', cellDates: true });
178
+ // Determine which sheet to read
179
+ let sheetName;
180
+ if (options.sheetName?.type === 'some') {
181
+ sheetName = options.sheetName.value;
182
+ if (!workbook.Sheets[sheetName]) {
183
+ throw new EastError(`Sheet "${sheetName}" not found in workbook`, {
184
+ location: { filename: "xlsx_read", line: 0n, column: 0n }
185
+ });
186
+ }
187
+ }
188
+ else {
189
+ // Use first sheet if no name specified
190
+ const firstSheetName = workbook.SheetNames[0];
191
+ if (!firstSheetName) {
192
+ throw new EastError('Workbook contains no sheets', {
193
+ location: { filename: "xlsx_read", line: 0n, column: 0n }
194
+ });
195
+ }
196
+ sheetName = firstSheetName;
197
+ }
198
+ const worksheet = workbook.Sheets[sheetName];
199
+ if (!worksheet) {
200
+ throw new EastError(`Sheet "${sheetName}" not found in workbook`, {
201
+ location: { filename: "xlsx_read", line: 0n, column: 0n }
202
+ });
203
+ }
204
+ // Get the range of the worksheet
205
+ const range = XLSX.utils.decode_range(worksheet['!ref'] || 'A1');
206
+ // Convert worksheet to 2D array using cell metadata
207
+ const eastData = [];
208
+ for (let R = range.s.r; R <= range.e.r; R++) {
209
+ const row = [];
210
+ for (let C = range.s.c; C <= range.e.c; C++) {
211
+ const cellAddress = XLSX.utils.encode_cell({ r: R, c: C });
212
+ const cell = worksheet[cellAddress];
213
+ if (!cell) {
214
+ // Empty cell
215
+ row.push(variant('Null', null));
216
+ }
217
+ else {
218
+ // Use cell type metadata to determine the correct variant
219
+ switch (cell.t) {
220
+ case 'b': // Boolean
221
+ row.push(variant('Boolean', cell.v));
222
+ break;
223
+ case 'n': // Number
224
+ row.push(variant('Float', cell.v));
225
+ break;
226
+ case 's': // String
227
+ row.push(variant('String', cell.v));
228
+ break;
229
+ case 'd': // Date
230
+ row.push(variant('DateTime', cell.v));
231
+ break;
232
+ case 'z': // Stub (blank)
233
+ case 'e': // Error
234
+ default:
235
+ row.push(variant('Null', null));
236
+ break;
237
+ }
238
+ }
239
+ }
240
+ eastData.push(row);
241
+ }
242
+ return eastData;
243
+ }
244
+ catch (err) {
245
+ if (err instanceof EastError) {
246
+ throw err;
247
+ }
248
+ throw new EastError(`Failed to read XLSX file: ${err.message}`, {
249
+ location: { filename: "xlsx_read", line: 0n, column: 0n },
250
+ cause: err
251
+ });
252
+ }
253
+ }),
254
+ xlsx_write.implement((data, options) => {
255
+ try {
256
+ // Convert East 2D array to native JavaScript array
257
+ const nativeData = data.map(row => row.map(convertLiteralToCell));
258
+ // Create a new workbook and worksheet
259
+ const workbook = XLSX.utils.book_new();
260
+ const worksheet = XLSX.utils.aoa_to_sheet(nativeData);
261
+ // Determine sheet name
262
+ const sheetName = options.sheetName?.type === 'some' ? options.sheetName.value : 'Sheet1';
263
+ // Add worksheet to workbook
264
+ XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
265
+ // Write workbook to buffer
266
+ const buffer = XLSX.write(workbook, {
267
+ type: 'buffer',
268
+ bookType: 'xlsx',
269
+ });
270
+ // Convert Buffer to Uint8Array
271
+ return new Uint8Array(buffer);
272
+ }
273
+ catch (err) {
274
+ throw new EastError(`Failed to write XLSX file: ${err.message}`, {
275
+ location: { filename: "xlsx_write", line: 0n, column: 0n },
276
+ cause: err
277
+ });
278
+ }
279
+ }),
280
+ xlsx_info.implement((data) => {
281
+ try {
282
+ // Convert Uint8Array blob to Buffer
283
+ const buffer = Buffer.from(data);
284
+ // Parse the workbook (but don't read all data)
285
+ const workbook = XLSX.read(buffer, { type: 'buffer', bookVBA: false });
286
+ // Extract sheet information
287
+ const sheets = workbook.SheetNames.map(name => {
288
+ const worksheet = workbook.Sheets[name];
289
+ if (!worksheet) {
290
+ return {
291
+ name,
292
+ rowCount: 0n,
293
+ columnCount: 0n,
294
+ };
295
+ }
296
+ const range = XLSX.utils.decode_range(worksheet['!ref'] || 'A1');
297
+ return {
298
+ name,
299
+ rowCount: BigInt(range.e.r - range.s.r + 1),
300
+ columnCount: BigInt(range.e.c - range.s.c + 1),
301
+ };
302
+ });
303
+ return { sheets };
304
+ }
305
+ catch (err) {
306
+ throw new EastError(`Failed to read XLSX file info: ${err.message}`, {
307
+ location: { filename: "xlsx_info", line: 0n, column: 0n },
308
+ cause: err
309
+ });
310
+ }
311
+ }),
312
+ ];
313
+ //# sourceMappingURL=xlsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xlsx.js","sourceRoot":"","sources":["../../src/format/xlsx.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACH,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAE,aAAa,CAAC,CAAC;AACpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,aAAa,EAAE,oBAAoB,CAAC,EAAE,QAAQ,CAAC,CAAC;AAEvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;AAE9E;;;;;;GAMG;AACH,SAAS,oBAAoB,CAAC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