@senlinz/import-export 0.1.1 → 0.1.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.
@@ -29,6 +29,8 @@ interface ExcelDefinition {
29
29
  titleHeight?: number;
30
30
  /** Format applied to the optional merged title row. */
31
31
  titleFormat?: ExcelCellFormatDefinition;
32
+ /** Maximum upload size (in bytes) enforced for browser-based imports. Defaults to 25 MiB when omitted. */
33
+ maxFileSizeBytes?: number;
32
34
  /** Default height used for data rows when exporting a worksheet. */
33
35
  defaultRowHeight?: number;
34
36
  /** Height applied to header rows during template/export generation. */
@@ -46,6 +48,8 @@ interface ExcelDefinition {
46
48
  * The callback must resolve to image bytes for the provided URL or identifier.
47
49
  */
48
50
  imageFetcher?: (url: string) => Promise<Uint8Array>;
51
+ /** Escapes text cells that look like formulas to prevent Excel formula injection. Enabled by default. */
52
+ escapeFormulas?: boolean;
49
53
  }
50
54
  interface ExcelColumnDefinition {
51
55
  /** Stable programmatic key used to map row objects. Must be unique within a definition. */
@@ -104,6 +108,8 @@ interface DynamicExcelImportOptions {
104
108
  sheetName?: string;
105
109
  /** 1-based worksheet row number to use as the header row. Defaults to the first non-empty row. */
106
110
  headerRow?: number;
111
+ /** Maximum upload size (in bytes) enforced for browser-based dynamic imports. Defaults to 25 MiB when omitted. */
112
+ maxFileSizeBytes?: number;
107
113
  }
108
114
  interface DynamicExcelImportResult {
109
115
  /** Actual worksheet name that was imported. */
@@ -2,7 +2,7 @@ export type * from './ExcelDefinition';
2
2
  export type { InitializeWasmOptions } from './runtime.js';
3
3
  import { ExcelDefinition } from './ExcelDefinition';
4
4
  import type { DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
5
- import { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, fromExcel, fromExcelDynamic, toExcel, generateExcelTemplate } from './utils.js';
5
+ import { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, fromExcel, fromExcelDynamic, toExcel, generateExcelTemplate, testUtils } from './utils.js';
6
6
  import { bundledWasmSource, initializeWasm } from './runtime.js';
7
7
  declare function getUtils(): {
8
8
  importExcel: typeof importExcel;
@@ -22,4 +22,4 @@ declare function _fromExcelDynamic(buffer: Uint8Array, options?: DynamicExcelImp
22
22
  declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array>;
23
23
  declare function _downloadExcelTemplate(definition: ExcelDefinition): Promise<void>;
24
24
  declare function _generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array>;
25
- export { bundledWasmSource, getUtils, initializeWasm, _importExcel as importExcel, _importExcelDynamic as importExcelDynamic, _exportExcel as exportExcel, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, _downloadExcelTemplate as downloadExcelTemplate, _generateExcelTemplate as generateExcelTemplate, };
25
+ export { bundledWasmSource, getUtils, initializeWasm, _importExcel as importExcel, _importExcelDynamic as importExcelDynamic, _exportExcel as exportExcel, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, _downloadExcelTemplate as downloadExcelTemplate, _generateExcelTemplate as generateExcelTemplate, testUtils, };
@@ -1,4 +1,24 @@
1
- import { ExcelDefinition, DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
1
+ import { ExcelColumnDefinition, ExcelDefinition, DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
2
+ declare const SUPPORTED_DATA_TYPES: readonly ["text", "number", "date", "image"];
3
+ type NormalizedDataType = typeof SUPPORTED_DATA_TYPES[number];
4
+ type NormalizedExcelColumnDefinition = Omit<ExcelColumnDefinition, 'dataType'> & {
5
+ dataType?: NormalizedDataType;
6
+ };
7
+ type NormalizedExcelDefinition = Omit<ExcelDefinition, 'columns'> & {
8
+ columns: NormalizedExcelColumnDefinition[];
9
+ maxFileSizeBytes: number;
10
+ escapeFormulas: boolean;
11
+ };
12
+ type NormalizedDynamicImportOptions = DynamicExcelImportOptions & {
13
+ maxFileSizeBytes: number;
14
+ };
15
+ type TestingUtils = {
16
+ normalizeDefinition(definition: ExcelDefinition): NormalizedExcelDefinition;
17
+ normalizeDynamicImportOptions(options?: DynamicExcelImportOptions): NormalizedDynamicImportOptions;
18
+ sanitizeTextCellValue(value: string, escapeFormulas?: boolean): string;
19
+ defaultMaxFileSizeBytes: number;
20
+ };
21
+ declare const testUtils: TestingUtils;
2
22
  declare function _fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
3
23
  declare function _fromExcelDynamic(buffer: Uint8Array, options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
4
24
  declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array<ArrayBufferLike>>;
@@ -8,4 +28,4 @@ declare function download(data: Uint8Array | string, name: string, type?: string
8
28
  declare function importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
9
29
  declare function importExcelDynamic(options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
10
30
  declare function exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
11
- export { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, generateExcelTemplate, download };
31
+ export { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, generateExcelTemplate, download, testUtils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senlinz/import-export",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "import/export excel core",
5
5
  "files": [
6
6
  "dist/**/*.js",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "fflate": "^0.8.2",
42
- "@senlinz/import-export-wasm": "0.1.1"
42
+ "@senlinz/import-export-wasm": "0.1.2"
43
43
  },
44
44
  "keywords": [
45
45
  "rust",
@@ -57,6 +57,7 @@
57
57
  "scripts": {
58
58
  "build": "rollup -c",
59
59
  "dev": "rollup -c -w",
60
+ "test:unit": "npm run build && node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config jest.config.mjs --runInBand",
60
61
  "test": "playwright test -c playwright.config.ts",
61
62
  "e2e-serve": "serve -l 8080 ."
62
63
  }