clear-excel 0.1.0 → 1.0.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.
- package/CHANGELOG.md +25 -0
- package/README.md +120 -72
- package/dist/api/sanitize-excel-file.d.ts +5 -0
- package/dist/api/sanitize-excel-file.d.ts.map +1 -0
- package/dist/api/sanitize-excel.d.ts +3 -0
- package/dist/api/sanitize-excel.d.ts.map +1 -0
- package/dist/biff/workbook.d.ts +4 -0
- package/dist/biff/workbook.d.ts.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/formats.d.ts +5 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2777 -0
- package/dist/index.js.map +1 -0
- package/dist/ooxml/cleanup.d.ts +3 -0
- package/dist/ooxml/cleanup.d.ts.map +1 -0
- package/dist/ooxml/constants.d.ts +4 -0
- package/dist/ooxml/constants.d.ts.map +1 -0
- package/dist/ooxml/parts.d.ts +5 -0
- package/dist/ooxml/parts.d.ts.map +1 -0
- package/dist/ooxml/relationships.d.ts +21 -0
- package/dist/ooxml/relationships.d.ts.map +1 -0
- package/dist/ooxml/styles.d.ts +7 -0
- package/dist/ooxml/styles.d.ts.map +1 -0
- package/dist/ooxml/workbook.d.ts +3 -0
- package/dist/ooxml/workbook.d.ts.map +1 -0
- package/dist/ooxml/xml.d.ts +12 -0
- package/dist/ooxml/xml.d.ts.map +1 -0
- package/dist/options.d.ts +5 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/zip/central-directory.d.ts +7 -0
- package/dist/zip/central-directory.d.ts.map +1 -0
- package/package.json +64 -44
- package/index.cjs +0 -3
- package/index.d.ts +0 -62
- package/index.js +0 -7
- package/src/index.cjs +0 -894
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file. The project
|
|
4
|
+
follows [Semantic Versioning](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [1.0.0] - 2026-08-19
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- Rebuilt the package as a strict TypeScript, ESM-only library with bundled
|
|
11
|
+
declarations.
|
|
12
|
+
- Documented the CommonJS-to-ESM migration while keeping the public sanitizer
|
|
13
|
+
APIs, options, error codes, and behavior compatible with 0.1.
|
|
14
|
+
- Added package-content verification and CI coverage for supported Node.js
|
|
15
|
+
versions.
|
|
16
|
+
|
|
17
|
+
## [0.1.0] - 2026-08-17
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Initial release with buffer and file APIs for sanitizing `.xls`, `.xlsx`,
|
|
22
|
+
and `.xlsm` workbooks.
|
|
23
|
+
|
|
24
|
+
[1.0.0]: https://www.npmjs.com/package/clear-excel/v/1.0.0
|
|
25
|
+
[0.1.0]: https://www.npmjs.com/package/clear-excel/v/0.1.0
|
package/README.md
CHANGED
|
@@ -1,37 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
<h1>clear-excel</h1>
|
|
4
|
+
|
|
5
|
+
<p><strong>Remove drawings, comments, and embedded objects from Excel workbooks
|
|
6
|
+
without rebuilding their data model.</strong></p>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
<a href="https://www.npmjs.com/package/clear-excel"><img alt="npm version" src="https://img.shields.io/npm/v/clear-excel?style=flat-square&logo=npm"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/clear-excel"><img alt="npm downloads" src="https://img.shields.io/npm/dm/clear-excel?style=flat-square&logo=npm"></a>
|
|
11
|
+
<a href="https://github.com/Vlad1slav1vanov/clear-excel/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/Vlad1slav1vanov/clear-excel/ci.yml?branch=main&style=flat-square&logo=github&label=CI"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/clear-excel"><img alt="Node.js" src="https://img.shields.io/node/v/clear-excel?style=flat-square&logo=nodedotjs"></a>
|
|
13
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/clear-excel?style=flat-square"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
<a href="https://www.npmjs.com/package/clear-excel">npm</a> ·
|
|
18
|
+
<a href="https://github.com/Vlad1slav1vanov/clear-excel/releases">Releases</a> ·
|
|
19
|
+
<a href="./CHANGELOG.md">Changelog</a> ·
|
|
20
|
+
<a href="./CONTRIBUTING.md">Contributing</a> ·
|
|
21
|
+
<a href="./SECURITY.md">Security</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
`clear-excel` is an ESM-only Node.js library for sanitizing legacy `.xls` and
|
|
27
|
+
OOXML `.xlsx`/`.xlsm` workbooks while preserving worksheet data and structure.
|
|
28
|
+
It has no framework or consumer-side build requirement.
|
|
6
29
|
|
|
7
30
|
## What it removes
|
|
8
31
|
|
|
9
|
-
- drawings and
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
32
|
+
- drawings, images, comments, controls, and embedded OLE objects;
|
|
33
|
+
- VML drawings, threaded comments, and person metadata in OOXML workbooks;
|
|
34
|
+
- unused `cellXfs` style records in OOXML workbooks;
|
|
35
|
+
- BIFF drawing, note, object, and picture records plus embedded object storages
|
|
36
|
+
in legacy `.xls` workbooks.
|
|
14
37
|
|
|
15
38
|
Values, formulas and cached results, merged cells, worksheets, and styles that
|
|
16
|
-
are still referenced by cells, rows, or columns are retained.
|
|
39
|
+
are still referenced by cells, rows, or columns are retained. `.xlsm` VBA
|
|
40
|
+
projects and legacy `.xls` VBA storages are preserved; the library does not
|
|
41
|
+
execute or remove macros.
|
|
17
42
|
|
|
18
43
|
## Requirements
|
|
19
44
|
|
|
20
45
|
- Node.js 22 or newer;
|
|
21
|
-
- OOXML `.xlsx` input.
|
|
46
|
+
- Excel 97-2003 BIFF8 `.xls`, OOXML `.xlsx`, or macro-enabled `.xlsm` input.
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
supported.
|
|
48
|
+
Encrypted `.xls` workbooks are not supported.
|
|
25
49
|
|
|
26
50
|
## Installation
|
|
27
51
|
|
|
28
52
|
```sh
|
|
29
|
-
|
|
53
|
+
pnpm add clear-excel
|
|
30
54
|
```
|
|
31
55
|
|
|
32
|
-
|
|
56
|
+
The package is published on
|
|
57
|
+
[npm](https://www.npmjs.com/package/clear-excel) and includes TypeScript
|
|
58
|
+
declarations.
|
|
33
59
|
|
|
34
|
-
|
|
60
|
+
## Buffer API
|
|
35
61
|
|
|
36
62
|
```js
|
|
37
63
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -42,19 +68,15 @@ const output = await sanitizeExcel(input);
|
|
|
42
68
|
await writeFile("report.cleaned.xlsx", output);
|
|
43
69
|
```
|
|
44
70
|
|
|
45
|
-
|
|
71
|
+
`sanitizeExcel` accepts a Node.js `Buffer`, returns a new `Buffer`, and never
|
|
72
|
+
modifies the input buffer. It detects legacy CFB/BIFF workbooks by their file
|
|
73
|
+
signature and keeps the input format in the returned buffer.
|
|
46
74
|
|
|
47
|
-
|
|
48
|
-
const { readFile, writeFile } = require("node:fs/promises");
|
|
49
|
-
const { sanitizeExcel } = require("clear-excel");
|
|
75
|
+
## Version 1 migration
|
|
50
76
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
`sanitizeExcel` accepts a Node.js `Buffer`, returns a new `Buffer`, and never
|
|
57
|
-
modifies the input buffer.
|
|
77
|
+
Version 1 is ESM-only. Replace CommonJS `require("clear-excel")` calls with
|
|
78
|
+
ECMAScript imports. Runtime exports, option types, error codes, and sanitizing
|
|
79
|
+
behavior otherwise remain compatible with version 0.1.
|
|
58
80
|
|
|
59
81
|
## File API
|
|
60
82
|
|
|
@@ -64,9 +86,10 @@ import { sanitizeExcelFile } from "clear-excel";
|
|
|
64
86
|
await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx");
|
|
65
87
|
```
|
|
66
88
|
|
|
67
|
-
The input and output paths must be different and
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
The input and output paths must be different and use the same supported
|
|
90
|
+
extension: `.xls`, `.xlsx`, or `.xlsm` (case-insensitive). The file API does not
|
|
91
|
+
convert between formats. The output directory must already exist. An existing
|
|
92
|
+
output file is not replaced unless `overwrite: true` is explicitly supplied:
|
|
70
93
|
|
|
71
94
|
```js
|
|
72
95
|
await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx", {
|
|
@@ -79,24 +102,24 @@ await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx", {
|
|
|
79
102
|
|
|
80
103
|
Both sanitizing functions accept these options:
|
|
81
104
|
|
|
82
|
-
| Option
|
|
83
|
-
|
|
|
84
|
-
| `requireSingleWorksheet` | `boolean` | `false`
|
|
85
|
-
| `limits`
|
|
105
|
+
| Option | Type | Default | Description |
|
|
106
|
+
| ------------------------ | --------- | --------- | ------------------------------------------------------- |
|
|
107
|
+
| `requireSingleWorksheet` | `boolean` | `false` | Reject workbooks that do not contain exactly one sheet. |
|
|
108
|
+
| `limits` | `object` | See below | Override individual ZIP/XML safety limits. |
|
|
86
109
|
|
|
87
110
|
`sanitizeExcelFile` additionally accepts `overwrite`, which defaults to
|
|
88
111
|
`false`.
|
|
89
112
|
|
|
90
113
|
The exported `DEFAULT_LIMITS` object contains the defaults:
|
|
91
114
|
|
|
92
|
-
| Limit
|
|
93
|
-
|
|
|
94
|
-
| `maxEntryCount`
|
|
95
|
-
| `maxUncompressedBytes`
|
|
96
|
-
| `maxXmlBytes`
|
|
97
|
-
| `maxWorksheetXmlBytes`
|
|
98
|
-
| `maxStylesXmlBytes`
|
|
99
|
-
| `maxMetadataXmlBytes`
|
|
115
|
+
| Limit | Default |
|
|
116
|
+
| -------------------------- | ---------------------------: |
|
|
117
|
+
| `maxEntryCount` | 10,000 entries |
|
|
118
|
+
| `maxUncompressedBytes` | 512 MiB |
|
|
119
|
+
| `maxXmlBytes` | 512 MiB aggregate XML output |
|
|
120
|
+
| `maxWorksheetXmlBytes` | 256 MiB per worksheet |
|
|
121
|
+
| `maxStylesXmlBytes` | 64 MiB |
|
|
122
|
+
| `maxMetadataXmlBytes` | 16 MiB per metadata part |
|
|
100
123
|
| `maxRelationshipsXmlBytes` | 8 MiB per relationships part |
|
|
101
124
|
|
|
102
125
|
Only specified values are overridden:
|
|
@@ -111,7 +134,9 @@ const output = await sanitizeExcel(input, {
|
|
|
111
134
|
```
|
|
112
135
|
|
|
113
136
|
Every limit must be a positive safe integer. Raising limits can significantly
|
|
114
|
-
increase memory usage.
|
|
137
|
+
increase memory usage. For `.xls`, `maxEntryCount` and
|
|
138
|
+
`maxUncompressedBytes` apply to the CFB container; the XML-specific limits apply
|
|
139
|
+
only to `.xlsx` and `.xlsm`.
|
|
115
140
|
|
|
116
141
|
## Errors
|
|
117
142
|
|
|
@@ -131,50 +156,73 @@ try {
|
|
|
131
156
|
}
|
|
132
157
|
```
|
|
133
158
|
|
|
134
|
-
| Code
|
|
135
|
-
|
|
|
136
|
-
| `ERR_INVALID_ARGUMENT`
|
|
137
|
-
| `ERR_UNSUPPORTED_EXTENSION` |
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
159
|
+
| Code | Meaning |
|
|
160
|
+
| --------------------------- | --------------------------------------------------- |
|
|
161
|
+
| `ERR_INVALID_ARGUMENT` | An argument or option has an invalid type or value. |
|
|
162
|
+
| `ERR_UNSUPPORTED_EXTENSION` | Paths use an unsupported or mismatched extension. |
|
|
163
|
+
| `ERR_INVALID_XLS` | The CFB/BIFF workbook is malformed or unsupported. |
|
|
164
|
+
| `ERR_INVALID_XLSX` | The ZIP/OOXML package is malformed or unsupported. |
|
|
165
|
+
| `ERR_LIMIT_EXCEEDED` | A configured ZIP or XML limit was exceeded. |
|
|
166
|
+
| `ERR_WORKSHEET_COUNT` | Exactly one worksheet was required. |
|
|
167
|
+
| `ERR_SAME_PATH` | Input and output resolve to the same path. |
|
|
168
|
+
| `ERR_OUTPUT_EXISTS` | Output exists and `overwrite` is false. |
|
|
169
|
+
| `ERR_FILE_READ` | The input could not be read. |
|
|
170
|
+
| `ERR_FILE_WRITE` | The sanitized output could not be written. |
|
|
145
171
|
|
|
146
172
|
The original technical error is available through `error.cause` when one
|
|
147
173
|
exists. Limit and worksheet-count failures also include structured `details`.
|
|
148
174
|
|
|
149
175
|
## Security and memory model
|
|
150
176
|
|
|
151
|
-
Before loading an archive, `clear-excel` validates the ZIP central
|
|
152
|
-
rejects ZIP64 and multi-disk archives, rejects unsafe entry paths,
|
|
153
|
-
declared entry counts and expansion sizes. Required XML parts are
|
|
154
|
-
lazily with both per-part and aggregate runtime budgets, including
|
|
155
|
-
when ZIP size metadata has been forged.
|
|
177
|
+
Before loading an OOXML archive, `clear-excel` validates the ZIP central
|
|
178
|
+
directory, rejects ZIP64 and multi-disk archives, rejects unsafe entry paths,
|
|
179
|
+
and checks declared entry counts and expansion sizes. Required XML parts are
|
|
180
|
+
inflated lazily with both per-part and aggregate runtime budgets, including
|
|
181
|
+
protection when ZIP size metadata has been forged.
|
|
182
|
+
|
|
183
|
+
For `.xls`, the library validates CFB entry and byte limits, parses the BIFF
|
|
184
|
+
record stream without evaluating formulas, removes drawing-layer records, and
|
|
185
|
+
rewrites worksheet offsets after records move. Workbook records are not
|
|
186
|
+
converted through an OOXML or generic tabular representation.
|
|
156
187
|
|
|
157
188
|
JSZip still loads the ZIP directory and regenerates the complete workbook in
|
|
158
189
|
memory. Plan for memory usage above the input size, especially when increasing
|
|
159
|
-
the defaults. The sanitizer does not evaluate formulas
|
|
160
|
-
content.
|
|
190
|
+
the defaults. The sanitizer does not evaluate formulas, execute embedded
|
|
191
|
+
content, or execute VBA projects.
|
|
161
192
|
|
|
162
|
-
##
|
|
193
|
+
## Development
|
|
163
194
|
|
|
164
|
-
|
|
195
|
+
Install dependencies and run the complete verification suite:
|
|
165
196
|
|
|
166
197
|
```sh
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
npm login
|
|
170
|
-
npm publish
|
|
198
|
+
pnpm install --frozen-lockfile
|
|
199
|
+
pnpm run check
|
|
171
200
|
```
|
|
172
201
|
|
|
173
|
-
`
|
|
174
|
-
|
|
175
|
-
`
|
|
176
|
-
|
|
202
|
+
`pnpm run check` verifies Oxfmt formatting, runs type-aware Oxlint and strict
|
|
203
|
+
TypeScript checks, executes the tests, builds the ESM bundle and declarations,
|
|
204
|
+
inspects `pnpm pack --dry-run`, and installs a temporary tarball to smoke-test
|
|
205
|
+
both runtime imports and a TypeScript consumer.
|
|
206
|
+
|
|
207
|
+
Useful development commands:
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
pnpm run format
|
|
211
|
+
pnpm run lint
|
|
212
|
+
pnpm run check:types
|
|
213
|
+
pnpm test
|
|
214
|
+
pnpm run build
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for the contribution and release
|
|
218
|
+
process.
|
|
219
|
+
|
|
220
|
+
## Security
|
|
221
|
+
|
|
222
|
+
Please report vulnerabilities privately by following
|
|
223
|
+
[SECURITY.md](./SECURITY.md). Do not open a public issue for a suspected
|
|
224
|
+
security vulnerability.
|
|
177
225
|
|
|
178
226
|
## License
|
|
179
227
|
|
|
180
|
-
MIT
|
|
228
|
+
[MIT](./LICENSE) © Vladislav Ivanov
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { isExcelFilename, isXlsxFilename } from "../formats.js";
|
|
2
|
+
import type { SanitizeExcelFileOptions } from "../types.js";
|
|
3
|
+
export { isExcelFilename, isXlsxFilename };
|
|
4
|
+
export declare function sanitizeExcelFile(inputPath: string, outputPath: string, options?: SanitizeExcelFileOptions): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=sanitize-excel-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize-excel-file.d.ts","sourceRoot":"","sources":["../../src/api/sanitize-excel-file.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAE3C,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAuBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize-excel.d.ts","sourceRoot":"","sources":["../../src/api/sanitize-excel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NormalizedSanitizeOptions } from "../types.js";
|
|
2
|
+
export declare function hasCompoundFileSignature(buffer: Buffer): boolean;
|
|
3
|
+
export declare function sanitizeBiffWorkbook(buffer: Buffer, options: NormalizedSanitizeOptions): Promise<Buffer>;
|
|
4
|
+
//# sourceMappingURL=workbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbook.d.ts","sourceRoot":"","sources":["../../src/biff/workbook.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAmC7D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAKhE;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAqBjB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExcelSanitizationLimits } from "./types.js";
|
|
2
|
+
export declare const DEFAULT_LIMITS: Readonly<ExcelSanitizationLimits>;
|
|
3
|
+
export declare const SANITIZE_OPTION_NAMES: ReadonlySet<string>;
|
|
4
|
+
export declare const FILE_OPTION_NAMES: ReadonlySet<string>;
|
|
5
|
+
export declare const LIMIT_NAMES: ReadonlySet<string>;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,uBAAuB,CAQ3D,CAAC;AAEH,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAGpD,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAIhD,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAQ1C,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExcelSanitizationLimits } from "./types.js";
|
|
2
|
+
export type ExcelSanitizationErrorCode = "ERR_INVALID_ARGUMENT" | "ERR_UNSUPPORTED_EXTENSION" | "ERR_INVALID_XLS" | "ERR_INVALID_XLSX" | "ERR_LIMIT_EXCEEDED" | "ERR_WORKSHEET_COUNT" | "ERR_SAME_PATH" | "ERR_OUTPUT_EXISTS" | "ERR_FILE_READ" | "ERR_FILE_WRITE";
|
|
3
|
+
export interface ExcelSanitizationErrorOptions {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
details?: Readonly<Record<string, unknown>>;
|
|
6
|
+
}
|
|
7
|
+
interface CreateErrorOptions extends ExcelSanitizationErrorOptions {
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
export type SafetyLimitName = keyof ExcelSanitizationLimits | "partBytes";
|
|
11
|
+
export declare class ExcelSanitizationError extends Error {
|
|
12
|
+
readonly name = "ExcelSanitizationError";
|
|
13
|
+
readonly code: ExcelSanitizationErrorCode;
|
|
14
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
15
|
+
constructor(code: ExcelSanitizationErrorCode, message: string, options?: ExcelSanitizationErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
export declare function createError(code: ExcelSanitizationErrorCode, options?: CreateErrorOptions): ExcelSanitizationError;
|
|
18
|
+
export declare function limitExceeded(limit: SafetyLimitName, configured: number, actual: number, partName?: string): ExcelSanitizationError;
|
|
19
|
+
export {};
|
|
20
|
+
//# 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,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,0BAA0B,GAClC,sBAAsB,GACtB,2BAA2B,GAC3B,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,qBAAqB,GACrB,eAAe,GACf,mBAAmB,GACnB,eAAe,GACf,gBAAgB,CAAC;AAErB,MAAM,WAAW,6BAA6B;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC7C;AAED,UAAU,kBAAmB,SAAQ,6BAA6B;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAgB1E,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,IAAI,4BAA4B;IAClD,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAErD,YACE,IAAI,EAAE,0BAA0B,EAChC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,6BAAkC,EAO5C;CACF;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,0BAA0B,EAChC,OAAO,GAAE,kBAAuB,GAC/B,sBAAsB,CAExB;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,sBAAsB,CASxB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type ExcelFileFormat = "xls" | "xlsx" | "xlsm";
|
|
2
|
+
export declare function excelFileFormat(name: unknown): ExcelFileFormat | undefined;
|
|
3
|
+
export declare function isExcelFilename(name: unknown): name is string;
|
|
4
|
+
export declare function isXlsxFilename(name: unknown): name is string;
|
|
5
|
+
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAQ1E;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAE7D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAE5D"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { sanitizeExcel } from "./api/sanitize-excel.js";
|
|
2
|
+
export { isExcelFilename, isXlsxFilename, sanitizeExcelFile } from "./api/sanitize-excel-file.js";
|
|
3
|
+
export { DEFAULT_LIMITS } from "./constants.js";
|
|
4
|
+
export { ExcelSanitizationError } from "./errors.js";
|
|
5
|
+
export type { ExcelSanitizationErrorCode, ExcelSanitizationErrorOptions } from "./errors.js";
|
|
6
|
+
export type { ExcelFileFormat } from "./formats.js";
|
|
7
|
+
export type { ExcelSanitizationLimits, SanitizeExcelFileOptions, SanitizeExcelOptions, } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAC7F,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|