@jeremiahmanalang/excel-mapping 0.0.0-stage → 0.1.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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +7 -0
  3. package/README.md +28 -2
  4. package/dist/adapters/index.d.ts +4 -0
  5. package/dist/adapters/index.d.ts.map +1 -0
  6. package/dist/adapters/parseWorkbook.d.ts +8 -0
  7. package/dist/adapters/parseWorkbook.d.ts.map +1 -0
  8. package/dist/adapters/sheetjs.d.ts +7 -0
  9. package/dist/adapters/sheetjs.d.ts.map +1 -0
  10. package/dist/adapters/types.d.ts +28 -0
  11. package/dist/adapters/types.d.ts.map +1 -0
  12. package/dist/cli/bin.d.ts +2 -0
  13. package/dist/cli/bin.d.ts.map +1 -0
  14. package/dist/cli/index.d.ts +9 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli.js +170 -0
  17. package/dist/cli.js.map +7 -0
  18. package/dist/errors.d.ts +25 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/extract/extract.d.ts +14 -0
  21. package/dist/extract/extract.d.ts.map +1 -0
  22. package/dist/extract/index.d.ts +3 -0
  23. package/dist/extract/index.d.ts.map +1 -0
  24. package/dist/extract/types.d.ts +38 -0
  25. package/dist/extract/types.d.ts.map +1 -0
  26. package/dist/grid/a1.d.ts +31 -0
  27. package/dist/grid/a1.d.ts.map +1 -0
  28. package/dist/grid/grid.d.ts +19 -0
  29. package/dist/grid/grid.d.ts.map +1 -0
  30. package/dist/grid/index.d.ts +4 -0
  31. package/dist/grid/index.d.ts.map +1 -0
  32. package/dist/grid/types.d.ts +36 -0
  33. package/dist/grid/types.d.ts.map +1 -0
  34. package/dist/index.cjs +28327 -0
  35. package/dist/index.d.cts +12 -0
  36. package/dist/index.d.ts +12 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +28304 -0
  39. package/dist/node/index.cjs +55 -0
  40. package/dist/node/index.cjs.map +7 -0
  41. package/dist/node/index.d.cts +13 -0
  42. package/dist/node/index.d.ts +13 -0
  43. package/dist/node/index.d.ts.map +1 -0
  44. package/dist/node/index.js +32 -0
  45. package/dist/node/index.js.map +7 -0
  46. package/dist/resolve/index.d.ts +5 -0
  47. package/dist/resolve/index.d.ts.map +1 -0
  48. package/dist/resolve/resolveDataRange.d.ts +8 -0
  49. package/dist/resolve/resolveDataRange.d.ts.map +1 -0
  50. package/dist/resolve/resolveHeaderRange.d.ts +8 -0
  51. package/dist/resolve/resolveHeaderRange.d.ts.map +1 -0
  52. package/dist/resolve/resolveRanges.d.ts +9 -0
  53. package/dist/resolve/resolveRanges.d.ts.map +1 -0
  54. package/dist/resolve/types.d.ts +28 -0
  55. package/dist/resolve/types.d.ts.map +1 -0
  56. package/dist/spec/a1.d.ts +21 -0
  57. package/dist/spec/a1.d.ts.map +1 -0
  58. package/dist/spec/index.d.ts +7 -0
  59. package/dist/spec/index.d.ts.map +1 -0
  60. package/dist/spec/jsonSchema.d.ts +9 -0
  61. package/dist/spec/jsonSchema.d.ts.map +1 -0
  62. package/dist/spec/schema.d.ts +74 -0
  63. package/dist/spec/schema.d.ts.map +1 -0
  64. package/dist/spec/suggestKey.d.ts +14 -0
  65. package/dist/spec/suggestKey.d.ts.map +1 -0
  66. package/dist/spec/types.d.ts +36 -0
  67. package/dist/spec/types.d.ts.map +1 -0
  68. package/dist/spec/validate.d.ts +6 -0
  69. package/dist/spec/validate.d.ts.map +1 -0
  70. package/dist/spec/version.d.ts +5 -0
  71. package/dist/spec/version.d.ts.map +1 -0
  72. package/package.json +66 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 excel-mapping contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ excel-mapping
2
+ Copyright (c) 2026 excel-mapping contributors
3
+
4
+ This package bundles SheetJS Community Edition (xlsx 0.20.3),
5
+ licensed under the Apache License, Version 2.0:
6
+ https://cdn.sheetjs.com/xlsx-0.20.3/
7
+ https://www.apache.org/licenses/LICENSE-2.0
package/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # Temporary Holding Version
1
+ # `excel-mapping`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Declarative Excel & CSV data-extraction library for **Node.js** and the **browser**.
4
+
5
+ See the [repository README](../../README.md) and [Configuration Specification (v1)](../../docs/SPEC.md) for full documentation, examples, and schema details.
6
+
7
+ ## Quick Example
8
+
9
+ ```ts
10
+ import { extract } from "excel-mapping";
11
+ // Or in Node.js:
12
+ // import { extractFromPath } from "excel-mapping/node";
13
+
14
+ const result = await extract(fileUint8Array, {
15
+ specVersion: 1,
16
+ sheet: null,
17
+ mappings: [
18
+ {
19
+ key: "items",
20
+ direction: "below",
21
+ occurrence: "continuous",
22
+ header: { start: "A1", end: "D1" },
23
+ rangeType: "untilBlank",
24
+ rangeValue: null,
25
+ expectedHeaderText: ["SKU", "Description", "Qty", "Price"],
26
+ },
27
+ ],
28
+ });
29
+ ```
@@ -0,0 +1,4 @@
1
+ export { sheetJsAdapter } from "./sheetjs.js";
2
+ export { parseWorkbook, resolveParseLimits } from "./parseWorkbook.js";
3
+ export { DEFAULT_PARSE_LIMITS, type ParseLimits, type ResolvedParseLimits, type ParsedWorkbook, type WorkbookAdapter, type ParseWorkbookOptions, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACL,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type ParseLimits, type ParseWorkbookOptions, type ParsedWorkbook, type ResolvedParseLimits } from "./types.js";
2
+ export declare function resolveParseLimits(limits?: ParseLimits): ResolvedParseLimits;
3
+ /**
4
+ * Parses a spreadsheet binary (ArrayBuffer or Uint8Array) into a parser-agnostic
5
+ * ParsedWorkbook handle with lazy sheet-to-Grid conversion and upfront safety limits.
6
+ */
7
+ export declare function parseWorkbook(input: ArrayBuffer | Uint8Array, options?: ParseWorkbookOptions): ParsedWorkbook;
8
+ //# sourceMappingURL=parseWorkbook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseWorkbook.d.ts","sourceRoot":"","sources":["../../src/adapters/parseWorkbook.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AASpB,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,mBAAmB,CAM5E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,GAAG,UAAU,EAC/B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,cAAc,CAUhB"}
@@ -0,0 +1,7 @@
1
+ import type { WorkbookAdapter } from "./types.js";
2
+ /**
3
+ * SheetJS-backed WorkbookAdapter. Isolated behind WorkbookAdapter so the
4
+ * spreadsheet parser can be swapped without touching Grid, Resolver, or Extractor.
5
+ */
6
+ export declare const sheetJsAdapter: WorkbookAdapter;
7
+ //# sourceMappingURL=sheetjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheetjs.d.ts","sourceRoot":"","sources":["../../src/adapters/sheetjs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAuC,eAAe,EAAE,MAAM,YAAY,CAAC;AA8IvF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,eAsD5B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Grid } from "../grid/types.js";
2
+ export interface ParseLimits {
3
+ /** Maximum input file size in bytes. Default: 25 MiB. */
4
+ readonly maxFileBytes?: number | undefined;
5
+ /** Maximum number of rows per sheet. Default: 100,000. */
6
+ readonly maxRows?: number | undefined;
7
+ /** Maximum number of cells (rows * cols) per sheet. Default: 1,000,000. */
8
+ readonly maxCells?: number | undefined;
9
+ }
10
+ export interface ResolvedParseLimits {
11
+ readonly maxFileBytes: number;
12
+ readonly maxRows: number;
13
+ readonly maxCells: number;
14
+ }
15
+ export declare const DEFAULT_PARSE_LIMITS: ResolvedParseLimits;
16
+ export interface ParsedWorkbook {
17
+ readonly sheets: readonly string[];
18
+ grid(sheetName: string): Grid;
19
+ }
20
+ export interface WorkbookAdapter {
21
+ readonly name: string;
22
+ parse(bytes: Uint8Array, limits: ResolvedParseLimits): ParsedWorkbook;
23
+ }
24
+ export interface ParseWorkbookOptions {
25
+ readonly limits?: ParseLimits | undefined;
26
+ readonly adapter?: WorkbookAdapter | undefined;
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,oBAAoB,EAAE,mBAIjC,CAAC;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAAC;CACvE;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CAChD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export interface CliIo {
2
+ readonly stdout: (text: string) => void;
3
+ readonly stderr: (text: string) => void;
4
+ }
5
+ /**
6
+ * Programmatic entry point for the excel-mapping CLI. Returns an exit code (0 or 1).
7
+ */
8
+ export declare function runCli(argv: readonly string[], io?: CliIo): Promise<number>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AASD;;GAEG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,KAGH,GACA,OAAO,CAAC,MAAM,CAAC,CA8HjB"}
package/dist/cli.js ADDED
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli/index.ts
4
+ import { readFile } from "node:fs/promises";
5
+ import {
6
+ ExcelMappingError,
7
+ InvalidConfigError,
8
+ StrictModeError,
9
+ validateConfig
10
+ } from "./index.js";
11
+ import { extractFromPath } from "./node/index.js";
12
+ var CLI_VERSION = true ? "0.1.0" : "0.1.0-alpha.0";
13
+ var USAGE = `excel-mapping v${CLI_VERSION}
14
+
15
+ Usage:
16
+ excel-mapping extract <file> <config.json> [options]
17
+ excel-mapping validate <config.json>
18
+ excel-mapping --help | --version
19
+
20
+ Extract options:
21
+ --sheet <name|index> Override target sheet by name or 0-based index
22
+ --raw Use raw typed values instead of formatted display strings
23
+ --no-trim Disable string trimming
24
+ --skip-hidden Skip hidden rows
25
+ --strict Fail with exit code 1 if any warning is emitted
26
+ --pretty Pretty-print JSON output (default: compact)
27
+ `;
28
+ function parseSheetArg(value) {
29
+ if (/^\d+$/.test(value)) {
30
+ return Number(value);
31
+ }
32
+ return value;
33
+ }
34
+ async function runCli(argv, io = {
35
+ stdout: (text) => process.stdout.write(text),
36
+ stderr: (text) => process.stderr.write(text)
37
+ }) {
38
+ if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
39
+ io.stdout(USAGE);
40
+ return 0;
41
+ }
42
+ if (argv.includes("--version") || argv.includes("-v")) {
43
+ io.stdout(`${CLI_VERSION}
44
+ `);
45
+ return 0;
46
+ }
47
+ const command = argv[0];
48
+ if (command === "validate") {
49
+ const configPath = argv[1];
50
+ if (!configPath) {
51
+ io.stderr("Error: missing <config.json> path.\n\n" + USAGE);
52
+ return 1;
53
+ }
54
+ let rawJson;
55
+ try {
56
+ rawJson = JSON.parse(await readFile(configPath, "utf8"));
57
+ } catch (err) {
58
+ io.stderr(
59
+ `Error reading config "${configPath}": ${err instanceof Error ? err.message : String(err)}
60
+ `
61
+ );
62
+ return 1;
63
+ }
64
+ const res = validateConfig(rawJson);
65
+ if (res.ok) {
66
+ io.stdout(`${JSON.stringify({ ok: true, mappings: res.value.mappings.length })}
67
+ `);
68
+ return 0;
69
+ }
70
+ io.stderr(`${JSON.stringify({ ok: false, errors: res.errors }, null, 2)}
71
+ `);
72
+ return 1;
73
+ }
74
+ if (command === "extract") {
75
+ const filePath = argv[1];
76
+ const configPath = argv[2];
77
+ if (!filePath || !configPath) {
78
+ io.stderr("Error: extract requires <file> and <config.json>.\n\n" + USAGE);
79
+ return 1;
80
+ }
81
+ let sheet;
82
+ let valueMode = "formatted";
83
+ let trim = true;
84
+ let skipHiddenRows = false;
85
+ let strict = false;
86
+ let pretty = false;
87
+ for (let i = 3; i < argv.length; i += 1) {
88
+ const flag = argv[i];
89
+ if (flag === "--sheet") {
90
+ const next = argv[i + 1];
91
+ if (next === void 0) {
92
+ io.stderr("Error: --sheet requires a sheet name or 0-based index.\n");
93
+ return 1;
94
+ }
95
+ sheet = parseSheetArg(next);
96
+ i += 1;
97
+ } else if (flag === "--raw") {
98
+ valueMode = "raw";
99
+ } else if (flag === "--no-trim") {
100
+ trim = false;
101
+ } else if (flag === "--skip-hidden") {
102
+ skipHiddenRows = true;
103
+ } else if (flag === "--strict") {
104
+ strict = true;
105
+ } else if (flag === "--pretty") {
106
+ pretty = true;
107
+ } else {
108
+ io.stderr(`Error: unknown option "${String(flag)}".
109
+
110
+ ` + USAGE);
111
+ return 1;
112
+ }
113
+ }
114
+ let rawConfig;
115
+ try {
116
+ rawConfig = JSON.parse(await readFile(configPath, "utf8"));
117
+ } catch (err) {
118
+ io.stderr(
119
+ `Error reading config "${configPath}": ${err instanceof Error ? err.message : String(err)}
120
+ `
121
+ );
122
+ return 1;
123
+ }
124
+ const validation = validateConfig(rawConfig);
125
+ if (!validation.ok) {
126
+ io.stderr(
127
+ `${JSON.stringify({ error: "INVALID_CONFIG", issues: validation.errors }, null, 2)}
128
+ `
129
+ );
130
+ return 1;
131
+ }
132
+ try {
133
+ const result = await extractFromPath(filePath, validation.value, {
134
+ sheet,
135
+ valueMode,
136
+ trim,
137
+ skipHiddenRows,
138
+ strict
139
+ });
140
+ const json = pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result);
141
+ io.stdout(`${json}
142
+ `);
143
+ return 0;
144
+ } catch (err) {
145
+ if (err instanceof InvalidConfigError) {
146
+ io.stderr(`${JSON.stringify({ error: err.code, issues: err.issues }, null, 2)}
147
+ `);
148
+ } else if (err instanceof StrictModeError) {
149
+ io.stderr(`${JSON.stringify({ error: err.code, warnings: err.warnings }, null, 2)}
150
+ `);
151
+ } else if (err instanceof ExcelMappingError) {
152
+ io.stderr(`${JSON.stringify({ error: err.code, message: err.message }, null, 2)}
153
+ `);
154
+ } else {
155
+ io.stderr(`Error: ${err instanceof Error ? err.message : String(err)}
156
+ `);
157
+ }
158
+ return 1;
159
+ }
160
+ }
161
+ io.stderr(`Error: unknown command "${String(command)}".
162
+
163
+ ` + USAGE);
164
+ return 1;
165
+ }
166
+
167
+ // src/cli/bin.ts
168
+ var exitCode = await runCli(process.argv.slice(2));
169
+ process.exit(exitCode);
170
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/cli/index.ts", "../src/cli/bin.ts"],
4
+ "sourcesContent": ["import { readFile } from \"node:fs/promises\";\nimport {\n ExcelMappingError,\n InvalidConfigError,\n StrictModeError,\n validateConfig,\n} from \"../index.js\";\nimport { extractFromPath } from \"../node/index.js\";\n\ndeclare const __EXCEL_MAPPING_VERSION__: string | undefined;\n\nconst CLI_VERSION =\n typeof __EXCEL_MAPPING_VERSION__ === \"string\" ? __EXCEL_MAPPING_VERSION__ : \"0.1.0-alpha.0\";\n\nconst USAGE = `excel-mapping v${CLI_VERSION}\n\nUsage:\n excel-mapping extract <file> <config.json> [options]\n excel-mapping validate <config.json>\n excel-mapping --help | --version\n\nExtract options:\n --sheet <name|index> Override target sheet by name or 0-based index\n --raw Use raw typed values instead of formatted display strings\n --no-trim Disable string trimming\n --skip-hidden Skip hidden rows\n --strict Fail with exit code 1 if any warning is emitted\n --pretty Pretty-print JSON output (default: compact)\n`;\n\nexport interface CliIo {\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\nfunction parseSheetArg(value: string): string | number {\n if (/^\\d+$/.test(value)) {\n return Number(value);\n }\n return value;\n}\n\n/**\n * Programmatic entry point for the excel-mapping CLI. Returns an exit code (0 or 1).\n */\nexport async function runCli(\n argv: readonly string[],\n io: CliIo = {\n stdout: (text) => process.stdout.write(text),\n stderr: (text) => process.stderr.write(text),\n },\n): Promise<number> {\n if (argv.length === 0 || argv.includes(\"--help\") || argv.includes(\"-h\")) {\n io.stdout(USAGE);\n return 0;\n }\n\n if (argv.includes(\"--version\") || argv.includes(\"-v\")) {\n io.stdout(`${CLI_VERSION}\\n`);\n return 0;\n }\n\n const command = argv[0];\n\n if (command === \"validate\") {\n const configPath = argv[1];\n if (!configPath) {\n io.stderr(\"Error: missing <config.json> path.\\n\\n\" + USAGE);\n return 1;\n }\n\n let rawJson: unknown;\n try {\n rawJson = JSON.parse(await readFile(configPath, \"utf8\")) as unknown;\n } catch (err) {\n io.stderr(\n `Error reading config \"${configPath}\": ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n return 1;\n }\n\n const res = validateConfig(rawJson);\n if (res.ok) {\n io.stdout(`${JSON.stringify({ ok: true, mappings: res.value.mappings.length })}\\n`);\n return 0;\n }\n\n io.stderr(`${JSON.stringify({ ok: false, errors: res.errors }, null, 2)}\\n`);\n return 1;\n }\n\n if (command === \"extract\") {\n const filePath = argv[1];\n const configPath = argv[2];\n if (!filePath || !configPath) {\n io.stderr(\"Error: extract requires <file> and <config.json>.\\n\\n\" + USAGE);\n return 1;\n }\n\n let sheet: string | number | undefined;\n let valueMode: \"formatted\" | \"raw\" = \"formatted\";\n let trim = true;\n let skipHiddenRows = false;\n let strict = false;\n let pretty = false;\n\n for (let i = 3; i < argv.length; i += 1) {\n const flag = argv[i];\n if (flag === \"--sheet\") {\n const next = argv[i + 1];\n if (next === undefined) {\n io.stderr(\"Error: --sheet requires a sheet name or 0-based index.\\n\");\n return 1;\n }\n sheet = parseSheetArg(next);\n i += 1;\n } else if (flag === \"--raw\") {\n valueMode = \"raw\";\n } else if (flag === \"--no-trim\") {\n trim = false;\n } else if (flag === \"--skip-hidden\") {\n skipHiddenRows = true;\n } else if (flag === \"--strict\") {\n strict = true;\n } else if (flag === \"--pretty\") {\n pretty = true;\n } else {\n io.stderr(`Error: unknown option \"${String(flag)}\".\\n\\n` + USAGE);\n return 1;\n }\n }\n\n let rawConfig: unknown;\n try {\n rawConfig = JSON.parse(await readFile(configPath, \"utf8\")) as unknown;\n } catch (err) {\n io.stderr(\n `Error reading config \"${configPath}\": ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n return 1;\n }\n\n const validation = validateConfig(rawConfig);\n if (!validation.ok) {\n io.stderr(\n `${JSON.stringify({ error: \"INVALID_CONFIG\", issues: validation.errors }, null, 2)}\\n`,\n );\n return 1;\n }\n\n try {\n const result = await extractFromPath(filePath, validation.value, {\n sheet,\n valueMode,\n trim,\n skipHiddenRows,\n strict,\n });\n const json = pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result);\n io.stdout(`${json}\\n`);\n return 0;\n } catch (err) {\n if (err instanceof InvalidConfigError) {\n io.stderr(`${JSON.stringify({ error: err.code, issues: err.issues }, null, 2)}\\n`);\n } else if (err instanceof StrictModeError) {\n io.stderr(`${JSON.stringify({ error: err.code, warnings: err.warnings }, null, 2)}\\n`);\n } else if (err instanceof ExcelMappingError) {\n io.stderr(`${JSON.stringify({ error: err.code, message: err.message }, null, 2)}\\n`);\n } else {\n io.stderr(`Error: ${err instanceof Error ? err.message : String(err)}\\n`);\n }\n return 1;\n }\n }\n\n io.stderr(`Error: unknown command \"${String(command)}\".\\n\\n` + USAGE);\n return 1;\n}\n", "import { runCli } from \"./index.js\";\n\nconst exitCode = await runCli(process.argv.slice(2));\nprocess.exit(exitCode);\n"],
5
+ "mappings": ";;;AAAA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAIhC,IAAM,cACJ,OAAgD,UAA4B;AAE9E,IAAM,QAAQ,kBAAkB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqB3C,SAAS,cAAc,OAAgC;AACrD,MAAI,QAAQ,KAAK,KAAK,GAAG;AACvB,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO;AACT;AAKA,eAAsB,OACpB,MACA,KAAY;AAAA,EACV,QAAQ,CAAC,SAAS,QAAQ,OAAO,MAAM,IAAI;AAA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AAA,MACF,CAAC;AACD,YAAM,OAAO,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,KAAK,UAAU,MAAM;AAC7E,SAAG,OAAO,GAAG,IAAI;AAAA,CAAI;AACrB,aAAO;AAAA,IACT,SAAS,KAAK;AACZ,UAAI,eAAe,oBAAoB;AACrC,WAAG,OAAO,GAAG,KAAK,UAAU,EAAE,OAAO,IAAI,MAAM,QAAQ,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,MACnF,WAAW,eAAe,iBAAiB;AACzC,WAAG,OAAO,GAAG,KAAK,UAAU,EAAE,OAAO,IAAI,MAAM,UAAU,IAAI,SAAS,GAAG,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,MACvF,WAAW,eAAe,mBAAmB;AAC3C,WAAG,OAAO,GAAG,KAAK,UAAU,EAAE,OAAO,IAAI,MAAM,SAAS,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC;AAAA,CAAI;AAAA,MACrF,OAAO;AACL,WAAG,OAAO,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAAA,MAC1E;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,KAAG,OAAO,2BAA2B,OAAO,OAAO,CAAC;AAAA;AAAA,IAAW,KAAK;AACpE,SAAO;AACT;;;AC/KA,IAAM,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC;AACnD,QAAQ,KAAK,QAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { ValidationIssue } from "./spec/types.js";
2
+ import type { Warning } from "./extract/types.js";
3
+ export type LimitKind = "maxFileBytes" | "maxRows" | "maxCells";
4
+ export declare class ExcelMappingError extends Error {
5
+ readonly code: string;
6
+ constructor(code: string, message: string, options?: ErrorOptions);
7
+ }
8
+ export declare class InvalidConfigError extends ExcelMappingError {
9
+ readonly issues: readonly ValidationIssue[];
10
+ constructor(issues: readonly ValidationIssue[], message?: string);
11
+ }
12
+ export declare class UnsupportedFileError extends ExcelMappingError {
13
+ constructor(message: string, options?: ErrorOptions);
14
+ }
15
+ export declare class LimitExceededError extends ExcelMappingError {
16
+ readonly limit: LimitKind;
17
+ readonly actual: number;
18
+ readonly max: number;
19
+ constructor(limit: LimitKind, actual: number, max: number);
20
+ }
21
+ export declare class StrictModeError extends ExcelMappingError {
22
+ readonly warnings: readonly Warning[];
23
+ constructor(warnings: readonly Warning[]);
24
+ }
25
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhE,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKlE;AAED,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;gBAEhC,MAAM,EAAE,SAAS,eAAe,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;CAUjE;AAED,qBAAa,oBAAqB,SAAQ,iBAAiB;gBAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAU1D;AAED,qBAAa,eAAgB,SAAQ,iBAAiB;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;gBAE1B,QAAQ,EAAE,SAAS,OAAO,EAAE;CAMzC"}
@@ -0,0 +1,14 @@
1
+ import type { Grid } from "../grid/types.js";
2
+ import type { MappingConfig } from "../spec/types.js";
3
+ import type { ExtractFromGridOptions, ExtractOptions, ExtractResult } from "./types.js";
4
+ /**
5
+ * Extracts structured JSON data directly from an already-parsed Grid.
6
+ * Useful for browser designers previewing ranges without re-parsing files.
7
+ */
8
+ export declare function extractFromGrid(grid: Grid, config: MappingConfig, options?: ExtractFromGridOptions): ExtractResult;
9
+ /**
10
+ * Extracts structured JSON data from an Excel/CSV file buffer according to a
11
+ * declarative MappingConfig.
12
+ */
13
+ export declare function extract(input: ArrayBuffer | Uint8Array, config: MappingConfig, options?: ExtractOptions): Promise<ExtractResult>;
14
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/extract/extract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,kBAAkB,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,aAAa,EAAW,MAAM,YAAY,CAAC;AAqQjG;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,aAAa,CAMf;AAED;;;GAGG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,WAAW,GAAG,UAAU,EAC/B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
@@ -0,0 +1,3 @@
1
+ export { extract, extractFromGrid } from "./extract.js";
2
+ export type { WarningCode, Warning, ExtractFromGridOptions, ExtractOptions, ExtractMeta, ExtractResult, } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EACV,WAAW,EACX,OAAO,EACP,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { ParseLimits, WorkbookAdapter } from "../adapters/types.js";
2
+ import type { ValueMode } from "../grid/types.js";
3
+ import type { SupportedSpecVersion } from "../spec/version.js";
4
+ export type WarningCode = "RANGE_TRUNCATED" | "HEADER_MISMATCH" | "EMPTY_RESULT" | "MERGED_CELL_ADJUSTED";
5
+ export interface Warning {
6
+ readonly code: WarningCode;
7
+ readonly mappingKey: string;
8
+ readonly message: string;
9
+ readonly details?: Readonly<Record<string, unknown>> | undefined;
10
+ }
11
+ export interface ExtractFromGridOptions {
12
+ readonly sheetName?: string | undefined;
13
+ readonly valueMode?: ValueMode | undefined;
14
+ readonly trim?: boolean | undefined;
15
+ readonly skipHiddenRows?: boolean | undefined;
16
+ readonly strict?: boolean | undefined;
17
+ }
18
+ export interface ExtractOptions {
19
+ /** Override the sheet specified in config (name or 0-based index). */
20
+ readonly sheet?: string | number | null | undefined;
21
+ readonly valueMode?: ValueMode | undefined;
22
+ readonly trim?: boolean | undefined;
23
+ readonly skipHiddenRows?: boolean | undefined;
24
+ readonly strict?: boolean | undefined;
25
+ readonly limits?: ParseLimits | undefined;
26
+ readonly adapter?: WorkbookAdapter | undefined;
27
+ }
28
+ export interface ExtractMeta {
29
+ readonly sheet: string;
30
+ readonly rowsRead: number;
31
+ readonly specVersion: SupportedSpecVersion;
32
+ }
33
+ export interface ExtractResult {
34
+ readonly fields: Record<string, unknown>;
35
+ readonly warnings: readonly Warning[];
36
+ readonly meta: ExtractMeta;
37
+ }
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/extract/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,MAAM,WAAW,GACrB,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,GAAG,sBAAsB,CAAC;AAElF,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAClE;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;CAC5C;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B"}
@@ -0,0 +1,31 @@
1
+ import { A1_REF_REGEX, COL_LETTERS_REGEX, MAX_EXCEL_COLUMN, MAX_EXCEL_ROW, colLettersToIndex } from "../spec/a1.js";
2
+ import type { CellAddress, CellRange } from "./types.js";
3
+ export { A1_REF_REGEX, COL_LETTERS_REGEX, MAX_EXCEL_COLUMN, MAX_EXCEL_ROW, colLettersToIndex };
4
+ /**
5
+ * Converts a 0-based column index (0 = "A", 25 = "Z", 26 = "AA", 16383 = "XFD")
6
+ * to uppercase Excel column letters. Throws RangeError if out of Excel bounds.
7
+ */
8
+ export declare function indexToColLetters(col: number): string;
9
+ /**
10
+ * Parses an uppercase A1 cell reference (e.g. "A1", "AA10") into a 0-based CellAddress,
11
+ * or returns null if invalid.
12
+ */
13
+ export declare function parseCellAddress(ref: string): CellAddress | null;
14
+ /**
15
+ * Formats a 0-based CellAddress into an uppercase A1 reference (e.g. { row: 0, col: 0 } -> "A1").
16
+ */
17
+ export declare function formatA1Ref(addr: CellAddress): string;
18
+ /**
19
+ * Normalizes a CellRange so that start.row <= end.row and start.col <= end.col.
20
+ */
21
+ export declare function normalizeRange(range: CellRange): CellRange;
22
+ /**
23
+ * Parses an A1 range reference (e.g. "A1:C5" or single cell "B2") into a normalized 0-based CellRange,
24
+ * or returns null if invalid.
25
+ */
26
+ export declare function parseRangeRef(rangeRef: string): CellRange | null;
27
+ /**
28
+ * Formats a 0-based CellRange as an A1 range string ("A1:C5" or "A1" if single cell).
29
+ */
30
+ export declare function formatRangeRef(range: CellRange): string;
31
+ //# sourceMappingURL=a1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a1.d.ts","sourceRoot":"","sources":["../../src/grid/a1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAElB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AAE/F;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAerD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAShE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAOrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAW1D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAkBhE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAKvD"}
@@ -0,0 +1,19 @@
1
+ import type { CellData, CellRange, CellValue, Grid } from "./types.js";
2
+ export interface CreateGridOptions {
3
+ readonly rows: readonly (readonly CellData[])[];
4
+ readonly merges?: readonly (CellRange | string)[] | undefined;
5
+ readonly hiddenRows?: Iterable<number> | undefined;
6
+ }
7
+ export interface CreateGridFromArrayOptions {
8
+ readonly merges?: readonly (CellRange | string)[] | undefined;
9
+ readonly hiddenRows?: Iterable<number> | undefined;
10
+ }
11
+ /**
12
+ * Creates an immutable Grid from a 2D array of CellData objects.
13
+ */
14
+ export declare function createGrid(options: CreateGridOptions): Grid;
15
+ /**
16
+ * Convenience helper that builds a Grid from a plain 2D array of scalar values.
17
+ */
18
+ export declare function createGridFromArray(rows: readonly (readonly (CellValue | undefined)[])[], options?: CreateGridFromArrayOptions): Grid;
19
+ //# sourceMappingURL=grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/grid/grid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAmB,MAAM,YAAY,CAAC;AAIxF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,QAAQ,EAAE,CAAC,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACpD;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACpD;AAkCD;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CA4H3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE,EACrD,OAAO,CAAC,EAAE,0BAA0B,GACnC,IAAI,CAgBN"}
@@ -0,0 +1,4 @@
1
+ export { A1_REF_REGEX, COL_LETTERS_REGEX, MAX_EXCEL_COLUMN, MAX_EXCEL_ROW, colLettersToIndex, indexToColLetters, parseCellAddress, formatA1Ref, normalizeRange, parseRangeRef, formatRangeRef, } from "./a1.js";
2
+ export { createGrid, createGridFromArray, type CreateGridOptions, type CreateGridFromArrayOptions, } from "./grid.js";
3
+ export type { CellAddress, CellRange, CellValue, CellData, ValueMode, GridReadOptions, Grid, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,GAChC,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,eAAe,EACf,IAAI,GACL,MAAM,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ export interface CellAddress {
2
+ /** 0-based row index (0 = Excel row 1). */
3
+ readonly row: number;
4
+ /** 0-based column index (0 = Excel column A). */
5
+ readonly col: number;
6
+ }
7
+ export interface CellRange {
8
+ /** Top-left corner (inclusive, 0-based). */
9
+ readonly start: CellAddress;
10
+ /** Bottom-right corner (inclusive, 0-based). */
11
+ readonly end: CellAddress;
12
+ }
13
+ export type CellValue = string | number | boolean | Date | null;
14
+ export interface CellData {
15
+ readonly raw: CellValue;
16
+ readonly formatted: string | null;
17
+ }
18
+ export type ValueMode = "formatted" | "raw";
19
+ export interface GridReadOptions {
20
+ readonly valueMode?: ValueMode | undefined;
21
+ readonly trim?: boolean | undefined;
22
+ }
23
+ export interface Grid {
24
+ readonly rowCount: number;
25
+ readonly colCount: number;
26
+ readonly merges: readonly CellRange[];
27
+ readonly hiddenRows: ReadonlySet<number>;
28
+ getCell(row: number, col: number): CellData;
29
+ getValue(row: number, col: number, options?: GridReadOptions): CellValue;
30
+ getText(row: number, col: number, options?: {
31
+ readonly trim?: boolean | undefined;
32
+ }): string;
33
+ isBlank(row: number, col: number, options?: GridReadOptions): boolean;
34
+ getMergeAt(row: number, col: number): CellRange | null;
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/grid/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,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