read-excel-file 5.8.0 → 5.8.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/index.d.ts +2 -2
- package/map/index.d.ts +1 -1
- package/node/index.d.ts +2 -2
- package/package.json +1 -1
- package/schema/index.d.ts +2 -2
- package/types.d.ts +31 -27
- package/web-worker/index.d.ts +2 -2
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ParseWithoutSchemaOptions,
|
|
5
5
|
ParsedObjectsResult,
|
|
6
6
|
Row
|
|
7
|
-
} from './types.d';
|
|
7
|
+
} from './types.d.js';
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
Schema,
|
|
@@ -13,7 +13,7 @@ export {
|
|
|
13
13
|
Integer,
|
|
14
14
|
Email,
|
|
15
15
|
URL
|
|
16
|
-
} from './types.d';
|
|
16
|
+
} from './types.d.js';
|
|
17
17
|
|
|
18
18
|
export function parseExcelDate(excelSerialDate: number) : typeof Date;
|
|
19
19
|
|
package/map/index.d.ts
CHANGED
package/node/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ParseWithoutSchemaOptions,
|
|
11
11
|
ParsedObjectsResult,
|
|
12
12
|
Row
|
|
13
|
-
} from '../types.d';
|
|
13
|
+
} from '../types.d.js';
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
ParsedObjectsResult,
|
|
@@ -18,7 +18,7 @@ export {
|
|
|
18
18
|
Integer,
|
|
19
19
|
Email,
|
|
20
20
|
URL
|
|
21
|
-
} from '../types.d';
|
|
21
|
+
} from '../types.d.js';
|
|
22
22
|
|
|
23
23
|
export function parseExcelDate(excelSerialDate: number) : typeof Date;
|
|
24
24
|
|
package/package.json
CHANGED
package/schema/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
Schema
|
|
4
4
|
} from '../types.d.js';
|
|
5
5
|
|
|
6
|
-
export default function mapWithLegacyBehavior(data: Row[], schema: Schema
|
|
6
|
+
export default function mapWithLegacyBehavior<T>(data: Row[], schema: Schema<T>, options?: {
|
|
7
7
|
ignoreEmptyRows?: boolean,
|
|
8
8
|
includeNullValues?: boolean,
|
|
9
9
|
isColumnOriented?: boolean,
|
|
10
10
|
rowMap?: Record<string, number>
|
|
11
|
-
}):
|
|
11
|
+
}): T[];
|
package/types.d.ts
CHANGED
|
@@ -14,51 +14,55 @@ type BasicType =
|
|
|
14
14
|
| typeof URL
|
|
15
15
|
| typeof Email;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// A cell "type" is a function that receives a "raw" value and returns a "parsed" value or `undefined`.
|
|
18
|
+
export type Type<Value> = (value: Cell) => Value | undefined;
|
|
18
19
|
|
|
19
|
-
type
|
|
20
|
+
type SchemaEntryRequiredProperty<Object> = boolean | ((row: Object) => boolean);
|
|
20
21
|
|
|
21
|
-
interface
|
|
22
|
-
prop:
|
|
23
|
-
type?: BasicType | Type<
|
|
24
|
-
oneOf?:
|
|
25
|
-
required?:
|
|
26
|
-
validate?(value:
|
|
22
|
+
interface SchemaEntryForValue<Key extends keyof Object, Object, TopLevelObject> {
|
|
23
|
+
prop: Key;
|
|
24
|
+
type?: BasicType | Type<Object[Key]>;
|
|
25
|
+
oneOf?: Object[Key][];
|
|
26
|
+
required?: SchemaEntryRequiredProperty<TopLevelObject>;
|
|
27
|
+
validate?(value: Object[Key]): void;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Legacy versions of this library supported supplying a custom `parse()` function.
|
|
30
31
|
// Since then, the `parse()` function has been renamed to `type()` function.
|
|
31
|
-
interface
|
|
32
|
-
prop:
|
|
33
|
-
parse: (value: Cell) =>
|
|
34
|
-
oneOf?:
|
|
35
|
-
required?:
|
|
36
|
-
validate?(value:
|
|
32
|
+
interface SchemaEntryForValueLegacy<Key extends keyof Object, Object, TopLevelObject> {
|
|
33
|
+
prop: Key;
|
|
34
|
+
parse: (value: Cell) => Object[Key] | undefined;
|
|
35
|
+
oneOf?: Object[Key][];
|
|
36
|
+
required?: SchemaEntryRequiredProperty<TopLevelObject>;
|
|
37
|
+
validate?(value: Object[Key]): void;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// Implementing recursive types in TypeScript:
|
|
40
41
|
// https://dev.to/busypeoples/notes-on-typescript-recursive-types-and-immutability-5ck1
|
|
41
|
-
interface SchemaEntryRecursive {
|
|
42
|
-
prop:
|
|
43
|
-
type: Record<
|
|
44
|
-
required?:
|
|
42
|
+
interface SchemaEntryRecursive<Key extends keyof Object, Object, TopLevelObject> {
|
|
43
|
+
prop: Key;
|
|
44
|
+
type: Record<keyof Object[Key], SchemaEntry<keyof Object[Key], Object[Key], TopLevelObject>>;
|
|
45
|
+
required?: SchemaEntryRequiredProperty<TopLevelObject>;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
type SchemaEntry
|
|
48
|
+
type SchemaEntry<Key extends keyof Object, Object, TopLevelObject> =
|
|
49
|
+
SchemaEntryForValue<Key, Object, TopLevelObject> |
|
|
50
|
+
SchemaEntryForValueLegacy<Key, Object, TopLevelObject> |
|
|
51
|
+
SchemaEntryRecursive<Key, Object, TopLevelObject>
|
|
48
52
|
|
|
49
|
-
export type Schema = Record<string, SchemaEntry
|
|
53
|
+
export type Schema<Object = Record<string, any>> = Record<keyof Object, SchemaEntry<keyof Object, Object, Object>>
|
|
50
54
|
|
|
51
|
-
export interface Error {
|
|
55
|
+
export interface Error<Value = any> {
|
|
52
56
|
error: string;
|
|
53
57
|
reason?: string;
|
|
54
58
|
row: number;
|
|
55
59
|
column: string;
|
|
56
|
-
value?:
|
|
57
|
-
type?:
|
|
60
|
+
value?: Value;
|
|
61
|
+
type?: Type<Value>;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
export interface ParsedObjectsResult<
|
|
61
|
-
rows:
|
|
64
|
+
export interface ParsedObjectsResult<Object> {
|
|
65
|
+
rows: Object[];
|
|
62
66
|
errors: Error[];
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -68,8 +72,8 @@ interface ParseCommonOptions {
|
|
|
68
72
|
parseNumber?: (string: string) => any;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
export interface ParseWithSchemaOptions<
|
|
72
|
-
schema: Schema
|
|
75
|
+
export interface ParseWithSchemaOptions<Object> extends ParseCommonOptions, MappingParametersReadExcelFile {
|
|
76
|
+
schema: Schema<Object>;
|
|
73
77
|
transformData?: (rows: Row[]) => Row[];
|
|
74
78
|
ignoreEmptyRows?: boolean;
|
|
75
79
|
// `includeNullValues: true` parameter is deprecated.
|
package/web-worker/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ParseWithoutSchemaOptions,
|
|
5
5
|
ParsedObjectsResult,
|
|
6
6
|
Row
|
|
7
|
-
} from '../types.d';
|
|
7
|
+
} from '../types.d.js';
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
ParsedObjectsResult,
|
|
@@ -12,7 +12,7 @@ export {
|
|
|
12
12
|
Integer,
|
|
13
13
|
Email,
|
|
14
14
|
URL
|
|
15
|
-
} from '../types.d';
|
|
15
|
+
} from '../types.d.js';
|
|
16
16
|
|
|
17
17
|
export function parseExcelDate(excelSerialDate: number) : typeof Date;
|
|
18
18
|
|