md-spreadsheet-parser 1.2.2 → 1.3.1

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/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare class Table {
23
23
  metadata: any | undefined;
24
24
  startLine: number | undefined;
25
25
  endLine: number | undefined;
26
- constructor(data?: Partial<Table>);
26
+ constructor(data?: Partial<Table> & Record<string, any>);
27
27
  toDTO(): any;
28
28
  /**
29
29
  * Returns a JSON-compatible plain object representation.
@@ -45,8 +45,10 @@ export declare class Table {
45
45
  export declare class Sheet {
46
46
  name: string | undefined;
47
47
  tables: any[] | undefined;
48
+ sheetType: string | undefined;
49
+ content: any | undefined;
48
50
  metadata: any | undefined;
49
- constructor(data?: Partial<Sheet>);
51
+ constructor(data?: Partial<Sheet> & Record<string, any>);
50
52
  toDTO(): any;
51
53
  /**
52
54
  * Returns a JSON-compatible plain object representation.
@@ -63,8 +65,12 @@ export declare class Sheet {
63
65
  }
64
66
  export declare class Workbook {
65
67
  sheets: any[] | undefined;
68
+ name: string | undefined;
69
+ startLine: number | undefined;
70
+ endLine: number | undefined;
66
71
  metadata: any | undefined;
67
- constructor(data?: Partial<Workbook>);
72
+ rootContent: any | undefined;
73
+ constructor(data?: Partial<Workbook> & Record<string, any>);
68
74
  toDTO(): any;
69
75
  /**
70
76
  * Returns a JSON-compatible plain object representation.
@@ -85,7 +91,7 @@ export declare class ParsingSchema {
85
91
  requireOuterPipes: boolean | undefined;
86
92
  stripWhitespace: boolean | undefined;
87
93
  convertBrToNewline: boolean | undefined;
88
- constructor(data?: Partial<ParsingSchema>);
94
+ constructor(data?: Partial<ParsingSchema> & Record<string, any>);
89
95
  toDTO(): any;
90
96
  }
91
97
  export declare class MultiTableParsingSchema {
@@ -94,18 +100,18 @@ export declare class MultiTableParsingSchema {
94
100
  requireOuterPipes: boolean | undefined;
95
101
  stripWhitespace: boolean | undefined;
96
102
  convertBrToNewline: boolean | undefined;
97
- rootMarker: string | undefined;
103
+ rootMarker: any | undefined;
98
104
  sheetHeaderLevel: number | undefined;
99
105
  tableHeaderLevel: number | undefined;
100
106
  captureDescription: boolean | undefined;
101
- constructor(data?: Partial<MultiTableParsingSchema>);
107
+ constructor(data?: Partial<MultiTableParsingSchema> & Record<string, any>);
102
108
  toDTO(): any;
103
109
  }
104
110
  export declare class ConversionSchema {
105
111
  booleanPairs: string | undefined;
106
112
  customConverters: string | undefined;
107
113
  fieldConverters: string | undefined;
108
- constructor(data?: Partial<ConversionSchema>);
114
+ constructor(data?: Partial<ConversionSchema> & Record<string, any>);
109
115
  toDTO(): any;
110
116
  }
111
117
  export declare class ExcelParsingSchema {
@@ -113,6 +119,6 @@ export declare class ExcelParsingSchema {
113
119
  fillMergedHeaders: boolean | undefined;
114
120
  delimiter: string | undefined;
115
121
  headerSeparator: string | undefined;
116
- constructor(data?: Partial<ExcelParsingSchema>);
122
+ constructor(data?: Partial<ExcelParsingSchema> & Record<string, any>);
117
123
  toDTO(): any;
118
124
  }
package/dist/index.js CHANGED
@@ -112,14 +112,17 @@ export function scanTablesIter(source, schema) {
112
112
  export class Table {
113
113
  constructor(data) {
114
114
  if (data) {
115
- this.headers = data.headers;
116
- this.rows = data.rows;
117
- this.alignments = data.alignments;
118
- this.name = data.name;
119
- this.description = data.description;
120
- this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
121
- this.startLine = data.startLine;
122
- this.endLine = data.endLine;
115
+ this.headers = data.headers ?? data.headers;
116
+ this.rows = data.rows ?? data.rows;
117
+ this.alignments = data.alignments ?? data.alignments;
118
+ this.name = data.name ?? data.name;
119
+ this.description = data.description ?? data.description;
120
+ {
121
+ const val = data.metadata ?? data.metadata;
122
+ this.metadata = (typeof val === 'string') ? JSON.parse(val) : val;
123
+ }
124
+ this.startLine = data.startLine ?? data.start_line;
125
+ this.endLine = data.endLine ?? data.end_line;
123
126
  }
124
127
  }
125
128
  toDTO() {
@@ -227,9 +230,14 @@ export class Table {
227
230
  export class Sheet {
228
231
  constructor(data) {
229
232
  if (data) {
230
- this.name = data.name;
231
- this.tables = (data.tables || []).map((x) => x instanceof Table ? x : new Table(x));
232
- this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
233
+ this.name = data.name ?? data.name;
234
+ this.tables = ((data.tables ?? data.tables) || []).map((x) => x instanceof Table ? x : new Table(x));
235
+ this.sheetType = data.sheetType ?? data.sheet_type;
236
+ this.content = data.content ?? data.content;
237
+ {
238
+ const val = data.metadata ?? data.metadata;
239
+ this.metadata = (typeof val === 'string') ? JSON.parse(val) : val;
240
+ }
233
241
  }
234
242
  }
235
243
  toDTO() {
@@ -248,6 +256,8 @@ export class Sheet {
248
256
  return {
249
257
  name: this.name,
250
258
  tables: (this.tables || []).map((t) => t.json ? t.json : t),
259
+ sheetType: this.sheetType,
260
+ content: this.content,
251
261
  metadata: this.metadata ?? {},
252
262
  };
253
263
  }
@@ -302,8 +312,15 @@ export class Sheet {
302
312
  export class Workbook {
303
313
  constructor(data) {
304
314
  if (data) {
305
- this.sheets = (data.sheets || []).map((x) => x instanceof Sheet ? x : new Sheet(x));
306
- this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
315
+ this.sheets = ((data.sheets ?? data.sheets) || []).map((x) => x instanceof Sheet ? x : new Sheet(x));
316
+ this.name = data.name ?? data.name;
317
+ this.startLine = data.startLine ?? data.start_line;
318
+ this.endLine = data.endLine ?? data.end_line;
319
+ {
320
+ const val = data.metadata ?? data.metadata;
321
+ this.metadata = (typeof val === 'string') ? JSON.parse(val) : val;
322
+ }
323
+ this.rootContent = data.rootContent ?? data.root_content;
307
324
  }
308
325
  }
309
326
  toDTO() {
@@ -320,8 +337,10 @@ export class Workbook {
320
337
  */
321
338
  get json() {
322
339
  return {
340
+ name: this.name,
323
341
  sheets: (this.sheets || []).map((s) => s.json ? s.json : s),
324
342
  metadata: this.metadata ?? {},
343
+ rootContent: this.rootContent,
325
344
  };
326
345
  }
327
346
  getSheet(name) {
@@ -375,11 +394,11 @@ export class Workbook {
375
394
  export class ParsingSchema {
376
395
  constructor(data) {
377
396
  if (data) {
378
- this.columnSeparator = data.columnSeparator;
379
- this.headerSeparatorChar = data.headerSeparatorChar;
380
- this.requireOuterPipes = data.requireOuterPipes;
381
- this.stripWhitespace = data.stripWhitespace;
382
- this.convertBrToNewline = data.convertBrToNewline;
397
+ this.columnSeparator = data.columnSeparator ?? data.column_separator;
398
+ this.headerSeparatorChar = data.headerSeparatorChar ?? data.header_separator_char;
399
+ this.requireOuterPipes = data.requireOuterPipes ?? data.require_outer_pipes;
400
+ this.stripWhitespace = data.stripWhitespace ?? data.strip_whitespace;
401
+ this.convertBrToNewline = data.convertBrToNewline ?? data.convert_br_to_newline;
383
402
  }
384
403
  }
385
404
  toDTO() {
@@ -390,15 +409,15 @@ export class ParsingSchema {
390
409
  export class MultiTableParsingSchema {
391
410
  constructor(data) {
392
411
  if (data) {
393
- this.columnSeparator = data.columnSeparator;
394
- this.headerSeparatorChar = data.headerSeparatorChar;
395
- this.requireOuterPipes = data.requireOuterPipes;
396
- this.stripWhitespace = data.stripWhitespace;
397
- this.convertBrToNewline = data.convertBrToNewline;
398
- this.rootMarker = data.rootMarker;
399
- this.sheetHeaderLevel = data.sheetHeaderLevel;
400
- this.tableHeaderLevel = data.tableHeaderLevel;
401
- this.captureDescription = data.captureDescription;
412
+ this.columnSeparator = data.columnSeparator ?? data.column_separator;
413
+ this.headerSeparatorChar = data.headerSeparatorChar ?? data.header_separator_char;
414
+ this.requireOuterPipes = data.requireOuterPipes ?? data.require_outer_pipes;
415
+ this.stripWhitespace = data.stripWhitespace ?? data.strip_whitespace;
416
+ this.convertBrToNewline = data.convertBrToNewline ?? data.convert_br_to_newline;
417
+ this.rootMarker = data.rootMarker ?? data.root_marker;
418
+ this.sheetHeaderLevel = data.sheetHeaderLevel ?? data.sheet_header_level;
419
+ this.tableHeaderLevel = data.tableHeaderLevel ?? data.table_header_level;
420
+ this.captureDescription = data.captureDescription ?? data.capture_description;
402
421
  }
403
422
  }
404
423
  toDTO() {
@@ -409,9 +428,15 @@ export class MultiTableParsingSchema {
409
428
  export class ConversionSchema {
410
429
  constructor(data) {
411
430
  if (data) {
412
- this.booleanPairs = data.booleanPairs;
413
- this.customConverters = (typeof data.customConverters === 'string') ? JSON.parse(data.customConverters) : data.customConverters;
414
- this.fieldConverters = (typeof data.fieldConverters === 'string') ? JSON.parse(data.fieldConverters) : data.fieldConverters;
431
+ this.booleanPairs = data.booleanPairs ?? data.boolean_pairs;
432
+ {
433
+ const val = data.customConverters ?? data.custom_converters;
434
+ this.customConverters = (typeof val === 'string') ? JSON.parse(val) : val;
435
+ }
436
+ {
437
+ const val = data.fieldConverters ?? data.field_converters;
438
+ this.fieldConverters = (typeof val === 'string') ? JSON.parse(val) : val;
439
+ }
415
440
  }
416
441
  }
417
442
  toDTO() {
@@ -426,10 +451,10 @@ export class ConversionSchema {
426
451
  export class ExcelParsingSchema {
427
452
  constructor(data) {
428
453
  if (data) {
429
- this.headerRows = data.headerRows;
430
- this.fillMergedHeaders = data.fillMergedHeaders;
431
- this.delimiter = data.delimiter;
432
- this.headerSeparator = data.headerSeparator;
454
+ this.headerRows = data.headerRows ?? data.header_rows;
455
+ this.fillMergedHeaders = data.fillMergedHeaders ?? data.fill_merged_headers;
456
+ this.delimiter = data.delimiter ?? data.delimiter;
457
+ this.headerSeparator = data.headerSeparator ?? data.header_separator;
433
458
  }
434
459
  }
435
460
  toDTO() {
@@ -42,9 +42,15 @@ export interface Table {
42
42
  export interface Sheet {
43
43
  name: string,
44
44
  tables: Array<Table>,
45
+ sheetType?: string,
46
+ content?: string,
45
47
  metadata?: string,
46
48
  }
47
49
  export interface Workbook {
48
50
  sheets: Array<Sheet>,
51
+ name?: string,
52
+ startLine?: number,
53
+ endLine?: number,
49
54
  metadata?: string,
55
+ rootContent?: string,
50
56
  }
@@ -1,9 +1,9 @@
1
1
  /** @module Interface wasi:sockets/ip-name-lookup@0.2.0 **/
2
2
  export function resolveAddresses(network: Network, name: string): ResolveAddressStream;
3
- export type Network = import('./wasi-sockets-network.js').Network;
4
- export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
5
3
  export type IpAddress = import('./wasi-sockets-network.js').IpAddress;
4
+ export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
6
5
  export type Pollable = import('./wasi-io-poll.js').Pollable;
6
+ export type Network = import('./wasi-sockets-network.js').Network;
7
7
 
8
8
  export class ResolveAddressStream {
9
9
  /**
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file