@nocobase/plugin-action-import 1.0.0-alpha.9 → 1.0.1-alpha.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.
Files changed (45) hide show
  1. package/dist/client/ImportActionInitializer.d.ts +1 -6
  2. package/dist/client/index.js +6 -6
  3. package/dist/client/useImportAction.d.ts +1 -0
  4. package/dist/externalVersion.js +9 -6
  5. package/dist/locale/en-US.json +3 -3
  6. package/dist/locale/es-ES.json +2 -2
  7. package/dist/locale/ko_KR.json +3 -3
  8. package/dist/locale/pt-BR.json +2 -2
  9. package/dist/locale/zh-CN.json +3 -3
  10. package/dist/node_modules/xlsx/bin/xlsx.njs +8 -0
  11. package/dist/node_modules/xlsx/bower.json +1 -1
  12. package/dist/node_modules/xlsx/dist/cpexcel.d.ts +39 -0
  13. package/dist/node_modules/xlsx/dist/xlsx.core.min.js +16 -17
  14. package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +11207 -15096
  15. package/dist/node_modules/xlsx/dist/xlsx.full.min.js +23 -23
  16. package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +9 -8
  17. package/dist/node_modules/xlsx/dist/xlsx.zahl.js +4 -0
  18. package/dist/node_modules/xlsx/dist/zahl.d.ts +4 -0
  19. package/dist/node_modules/xlsx/package.json +1 -1
  20. package/dist/node_modules/xlsx/types/index.d.ts +220 -40
  21. package/dist/node_modules/xlsx/xlsx.js +5 -4
  22. package/dist/node_modules/xlsx/xlsxworker.js +1 -2
  23. package/dist/server/actions/{downloadXlsxTemplate.js → download-xlsx-template.js} +13 -17
  24. package/dist/server/actions/import-xlsx.js +89 -0
  25. package/dist/server/actions/index.d.ts +2 -2
  26. package/dist/server/actions/index.js +4 -4
  27. package/dist/server/index.d.ts +1 -2
  28. package/dist/server/index.js +0 -6
  29. package/dist/server/services/template-creator.d.ts +24 -0
  30. package/dist/server/services/template-creator.js +70 -0
  31. package/dist/server/services/xlsx-importer.d.ts +37 -0
  32. package/dist/server/services/xlsx-importer.js +185 -0
  33. package/package.json +3 -3
  34. package/dist/node_modules/node-xlsx/lib/helpers.js +0 -142
  35. package/dist/node_modules/node-xlsx/lib/index.js +0 -6
  36. package/dist/node_modules/node-xlsx/lib/workbook.js +0 -16
  37. package/dist/node_modules/node-xlsx/package.json +0 -1
  38. package/dist/node_modules/xlsx/dist/jszip.js +0 -9000
  39. package/dist/node_modules/xlsx/dist/xlsx.js +0 -22693
  40. package/dist/node_modules/xlsx/dist/xlsx.min.js +0 -15
  41. package/dist/node_modules/xlsx/jszip.js +0 -9000
  42. package/dist/node_modules/xlsx/xlsx.mini.js +0 -10709
  43. package/dist/server/actions/importXlsx.js +0 -194
  44. /package/dist/server/actions/{downloadXlsxTemplate.d.ts → download-xlsx-template.d.ts} +0 -0
  45. /package/dist/server/actions/{importXlsx.d.ts → import-xlsx.d.ts} +0 -0
@@ -1,16 +1,23 @@
1
1
  /* index.d.ts (C) 2015-present SheetJS and contributors */
2
2
  // TypeScript Version: 2.2
3
- import * as CFB from "cfb";
4
- import * as SSF from "ssf";
3
+ // import * as CFB from "cfb";
4
+ // import * as SSF from "ssf";
5
5
 
6
6
  /** Version string */
7
7
  export const version: string;
8
8
 
9
9
  /** SSF Formatter Library */
10
- export { SSF };
10
+ // export { SSF };
11
+ export const SSF: any;
11
12
 
12
13
  /** CFB Library */
13
- export { CFB };
14
+ // export { CFB };
15
+ export const CFB: any;
16
+
17
+ /** Set internal `fs` instance */
18
+ export function set_fs(fs: any): void;
19
+ /** Set internal codepage tables */
20
+ export function set_cptable(cptable: any): void;
14
21
 
15
22
  /** NODE ONLY! Attempts to read filename and parse */
16
23
  export function readFile(filename: string, opts?: ParsingOptions): WorkBook;
@@ -18,11 +25,15 @@ export function readFile(filename: string, opts?: ParsingOptions): WorkBook;
18
25
  export function read(data: any, opts?: ParsingOptions): WorkBook;
19
26
  /** Attempts to write or download workbook data to file */
20
27
  export function writeFile(data: WorkBook, filename: string, opts?: WritingOptions): any;
28
+ /** Attempts to write or download workbook data to XLSX file */
29
+ export function writeFileXLSX(data: WorkBook, filename: string, opts?: WritingOptions): any;
21
30
  /** Attempts to write or download workbook data to file asynchronously */
22
31
  type CBFunc = () => void;
23
32
  export function writeFileAsync(filename: string, data: WorkBook, opts: WritingOptions | CBFunc, cb?: CBFunc): any;
24
33
  /** Attempts to write the workbook data */
25
- export function write(data: WorkBook, opts?: WritingOptions): any;
34
+ export function write(data: WorkBook, opts: WritingOptions): any;
35
+ /** Attempts to write the workbook data as XLSX */
36
+ export function writeXLSX(data: WorkBook, opts: WritingOptions): any;
26
37
 
27
38
  /** Utility Functions */
28
39
  export const utils: XLSX$Utils;
@@ -128,12 +139,37 @@ export interface DateNFOption {
128
139
  dateNF?: NumberFormat;
129
140
  }
130
141
 
142
+ export interface UTCOption {
143
+ /**
144
+ * For plaintext formats, interpret ambiguous datetimes in UTC
145
+ * If explicitly set to `false`, dates will be parsed in local time.
146
+ *
147
+ * The `true` option is consistent with spreadsheet application export.
148
+ *
149
+ * @default true
150
+ */
151
+ UTC?: boolean;
152
+ }
153
+
154
+ export interface DenseOption {
155
+ /** If true, generate dense-mode worksheets */
156
+ dense?: boolean;
157
+ }
158
+
131
159
  /** Options for read and readFile */
132
- export interface ParsingOptions extends CommonOptions {
160
+ export interface ParsingOptions extends UTCOption, CommonOptions, DenseOption {
133
161
  /** Input data encoding */
134
162
  type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
135
163
 
136
- /** Default codepage */
164
+ /**
165
+ * Default codepage for legacy files
166
+ *
167
+ * This requires encoding support to be loaded. It is automatically loaded
168
+ * in `xlsx.full.min.js` and in CommonJS / Extendscript, but an extra step
169
+ * is required in React / Angular / Webpack ESM deployments.
170
+ *
171
+ * Check the relevant guide https://docs.sheetjs.com/docs/getting-started/
172
+ */
137
173
  codepage?: number;
138
174
 
139
175
  /**
@@ -202,9 +238,22 @@ export interface ParsingOptions extends CommonOptions {
202
238
  /** If true, plaintext parsing will not parse values */
203
239
  raw?: boolean;
204
240
 
205
- dense?: boolean;
241
+ /** If true, ignore "dimensions" records and guess range using every cell */
242
+ nodim?: boolean;
243
+
244
+ /** If true, preserve _xlfn. prefixes in formula function names */
245
+ xlfn?: boolean;
246
+
247
+ /**
248
+ * For single-sheet formats (including CSV), override the worksheet name
249
+ * @default "Sheet1"
250
+ */
251
+ sheet?: string;
252
+
253
+ PRN?: boolean;
206
254
  }
207
255
 
256
+
208
257
  /** Options for write and writeFile */
209
258
  export interface WritingOptions extends CommonOptions {
210
259
  /** Output data encoding */
@@ -222,18 +271,15 @@ export interface WritingOptions extends CommonOptions {
222
271
  */
223
272
  bookType?: BookType;
224
273
 
225
- /**
226
- * Name of Worksheet (for single-sheet formats)
227
- * @default ''
228
- */
229
- sheet?: string;
230
-
231
274
  /**
232
275
  * Use ZIP compression for ZIP-based formats
233
276
  * @default false
234
277
  */
235
278
  compression?: boolean;
236
279
 
280
+ /** Overwride theme XML when exporting to XLSX/XLSM/XLSB */
281
+ themeXLSX?: string;
282
+
237
283
  /**
238
284
  * Suppress "number stored as text" errors in generated files
239
285
  * @default true
@@ -242,6 +288,35 @@ export interface WritingOptions extends CommonOptions {
242
288
 
243
289
  /** Override workbook properties on save */
244
290
  Props?: Properties;
291
+
292
+ /**
293
+ * Desired codepage for legacy file formats
294
+ *
295
+ * This requires encoding support to be loaded. It is automatically loaded
296
+ * in `xlsx.full.min.js` and in CommonJS / Extendscript, but an extra step
297
+ * is required in React / Angular / Webpack / ESM deployments.
298
+ *
299
+ * Check the relevant guide https://docs.sheetjs.com/docs/getting-started/
300
+ */
301
+ codepage?: number;
302
+
303
+ /** Base64 encoding of NUMBERS base for exports */
304
+ numbers?: string;
305
+
306
+ /**
307
+ * For single-sheet formats, export the specified worksheet.
308
+ *
309
+ * The property must be a string (sheet name) or number (`SheetNames` index).
310
+ *
311
+ * If this option is omitted, the first worksheet will be exported.
312
+ */
313
+ sheet?: string | number;
314
+
315
+ /** Field Separator ("delimiter") for CSV / Text output */
316
+ FS?: string;
317
+
318
+ /** Record Separator ("row separator") for CSV / Text output */
319
+ RS?: string;
245
320
  }
246
321
 
247
322
  /** Workbook Object */
@@ -259,11 +334,14 @@ export interface WorkBook {
259
334
  Props?: FullProperties;
260
335
 
261
336
  /** Custom workbook Properties */
262
- Custprops?: any;
337
+ Custprops?: object;
263
338
 
264
339
  Workbook?: WBProps;
265
340
 
266
341
  vbaraw?: any;
342
+
343
+ /** Original file type (when parsed with `read` or `readFile`) */
344
+ bookType?: BookType;
267
345
  }
268
346
 
269
347
  export interface SheetProps {
@@ -325,6 +403,21 @@ export interface WorkbookProperties {
325
403
  CodeName?: string;
326
404
  }
327
405
 
406
+ /** DBF Field Header */
407
+ export interface DBFField {
408
+ /** Original Field Name */
409
+ name?: string;
410
+
411
+ /** Field Type */
412
+ type?: string;
413
+
414
+ /** Field Length */
415
+ len?: number;
416
+
417
+ /** Field Decimal Count */
418
+ dec?: number;
419
+ }
420
+
328
421
  /** Column Properties Object */
329
422
  export interface ColInfo {
330
423
  /* --- visibility --- */
@@ -348,6 +441,9 @@ export interface ColInfo {
348
441
 
349
442
  /** Excel's "Max Digit Width" unit, always integral */
350
443
  MDW?: number;
444
+
445
+ /** DBF Field Header */
446
+ DBF?: DBFField;
351
447
  }
352
448
 
353
449
  /** Row Properties Object */
@@ -475,20 +571,52 @@ export type SheetKeys = string | MarginInfo | SheetType;
475
571
  /** General object representing a Sheet (worksheet or chartsheet) */
476
572
  export interface Sheet {
477
573
  /**
478
- * Indexing with a cell address string maps to a cell object
574
+ * Sparse-mode store cells with keys corresponding to A1-style address
575
+ * Dense-mode store cells in the '!data' key
479
576
  * Special keys start with '!'
480
577
  */
481
- [cell: string]: CellObject | SheetKeys | any;
578
+ [cell: string]: CellObject | CellObject[][] | SheetKeys | any;
579
+
580
+ /**
581
+ * Dense-mode worksheets store data in an array of arrays
582
+ *
583
+ * Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
584
+ */
585
+ '!data'?: CellObject[][];
482
586
 
483
587
  /** Sheet type */
484
588
  '!type'?: SheetType;
485
589
 
486
- /** Sheet Range */
590
+ /** Sheet Range (A1-style) */
487
591
  '!ref'?: string;
488
592
 
489
593
  /** Page Margins */
490
594
  '!margins'?: MarginInfo;
491
595
  }
596
+ /** General object representing a dense Sheet (worksheet or chartsheet) */
597
+ export interface DenseSheet extends Sheet {
598
+ /**
599
+ * Special keys start with '!'
600
+ * Dense-mode worksheets store data in the '!data' key
601
+ */
602
+ [cell: string]: CellObject[][] | SheetKeys | any;
603
+
604
+ /**
605
+ * Dense-mode worksheets store data in an array of arrays
606
+ *
607
+ * Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
608
+ */
609
+ '!data': CellObject[][];
610
+ }
611
+ /** General object representing a sparse Sheet (worksheet or chartsheet) */
612
+ export interface SparseSheet extends Sheet {
613
+ /**
614
+ * Sparse-mode store cells with keys corresponding to A1-style address
615
+ * Cells are accessed with sheet[addr]
616
+ */
617
+ '!data': never;
618
+ }
619
+
492
620
 
493
621
  /** AutoFilter properties */
494
622
  export interface AutoFilterInfo {
@@ -521,6 +649,15 @@ export interface WorkSheet extends Sheet {
521
649
  /** AutoFilter info */
522
650
  '!autofilter'?: AutoFilterInfo;
523
651
  }
652
+ /** Dense Worksheet Object */
653
+ export interface DenseWorkSheet extends DenseSheet {
654
+ /**
655
+ * Dense-mode worksheets store data in an array of arrays
656
+ *
657
+ * Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
658
+ */
659
+ '!data': CellObject[][];
660
+ }
524
661
 
525
662
  /**
526
663
  * Worksheet Object with CellObject type
@@ -539,7 +676,7 @@ export type ExcelDataType = 'b' | 'n' | 'e' | 's' | 'd' | 'z';
539
676
  * Type of generated workbook
540
677
  * @default 'xlsx'
541
678
  */
542
- export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth';
679
+ export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'slk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth' | 'dbf' | 'numbers';
543
680
 
544
681
  /** Comment element */
545
682
  export interface Comment {
@@ -548,6 +685,9 @@ export interface Comment {
548
685
 
549
686
  /** Plaintext of the comment */
550
687
  t: string;
688
+
689
+ /** If true, mark the comment as a part of a thread */
690
+ T?: boolean;
551
691
  }
552
692
 
553
693
  /** Cell comments */
@@ -585,6 +725,9 @@ export interface CellObject {
585
725
  /** Range of enclosing array if formula is array formula (if applicable) */
586
726
  F?: string;
587
727
 
728
+ /** If true, cell is a dynamic array formula (for supported file formats) */
729
+ D?: boolean;
730
+
588
731
  /** Rich text encoding (if applicable) */
589
732
  r?: any;
590
733
 
@@ -678,11 +821,32 @@ export interface Sheet2JSONOpts extends DateNFOption {
678
821
  /** if true, return raw data; if false, return formatted text */
679
822
  raw?: boolean;
680
823
 
824
+ /** if true, skip hidden rows and columns */
825
+ skipHidden?: boolean;
826
+
681
827
  /** if true, return raw numbers; if false, return formatted numbers */
682
828
  rawNumbers?: boolean;
829
+
830
+ /**
831
+ * If true, return dates whose UTC interpretation is correct
832
+ * By default, return dates whose local interpretation is correct
833
+ *
834
+ * @default false
835
+ */
836
+ UTC?: boolean;
837
+ }
838
+
839
+ export interface UTCDateOption {
840
+ /**
841
+ * If true, dates are interpreted using the UTC methods
842
+ * By default, dates are interpreted in the local timezone
843
+ *
844
+ * @default false
845
+ */
846
+ UTC?: boolean;
683
847
  }
684
848
 
685
- export interface AOA2SheetOpts extends CommonOptions, DateNFOption {
849
+ export interface AOA2SheetOpts extends CommonOptions, UTCDateOption, DateNFOption, DenseOption {
686
850
  /**
687
851
  * Create cell objects for stub cells
688
852
  * @default false
@@ -692,7 +856,7 @@ export interface AOA2SheetOpts extends CommonOptions, DateNFOption {
692
856
 
693
857
  export interface SheetAOAOpts extends AOA2SheetOpts, OriginOption {}
694
858
 
695
- export interface JSON2SheetOpts extends CommonOptions, DateNFOption {
859
+ export interface JSON2SheetOpts extends CommonOptions, UTCDateOption, DateNFOption, OriginOption, DenseOption {
696
860
  /** Use specified column order */
697
861
  header?: string[];
698
862
 
@@ -700,8 +864,6 @@ export interface JSON2SheetOpts extends CommonOptions, DateNFOption {
700
864
  skipHeader?: boolean;
701
865
  }
702
866
 
703
- export interface SheetJSONOpts extends JSON2SheetOpts, OriginOption {}
704
-
705
867
  export interface Table2SheetOpts extends CommonOptions, DateNFOption, OriginOption {
706
868
  /** If true, plaintext parsing will not parse values */
707
869
  raw?: boolean;
@@ -714,6 +876,28 @@ export interface Table2SheetOpts extends CommonOptions, DateNFOption, OriginOpti
714
876
 
715
877
  /** If true, hidden rows and cells will not be parsed */
716
878
  display?: boolean;
879
+
880
+ /**
881
+ * Override the worksheet name
882
+ * @default "Sheet1"
883
+ */
884
+ sheet?: string;
885
+
886
+ /**
887
+ * If true, interpret date strings as if they are UTC.
888
+ * By default, date strings are interpreted in the local timezone.
889
+ *
890
+ * @default false
891
+ */
892
+ UTC?: boolean;
893
+ }
894
+
895
+ export interface Table2BookOpts extends Table2SheetOpts {
896
+ /**
897
+ * Override the worksheet name
898
+ * @default "Sheet1"
899
+ */
900
+ sheet?: string;
717
901
  }
718
902
 
719
903
  /** General utilities */
@@ -730,7 +914,7 @@ export interface XLSX$Utils {
730
914
 
731
915
  /** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */
732
916
  table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet;
733
- table_to_book(data: any, opts?: Table2SheetOpts): WorkBook;
917
+ table_to_book(data: any, opts?: Table2BookOpts): WorkBook;
734
918
  sheet_add_dom(ws: WorkSheet, data: any, opts?: Table2SheetOpts): WorkSheet;
735
919
 
736
920
  /* --- Export Functions --- */
@@ -752,15 +936,6 @@ export interface XLSX$Utils {
752
936
  /** Generates a list of the formulae (with value fallbacks) */
753
937
  sheet_to_formulae(worksheet: WorkSheet): string[];
754
938
 
755
- /** Generates DIF */
756
- sheet_to_dif(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
757
-
758
- /** Generates SYLK (Symbolic Link) */
759
- sheet_to_slk(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
760
-
761
- /** Generates ETH */
762
- sheet_to_eth(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
763
-
764
939
  /* --- Cell Address Utilities --- */
765
940
 
766
941
  /** Converts 0-indexed cell address to A1 form */
@@ -793,11 +968,14 @@ export interface XLSX$Utils {
793
968
 
794
969
  /* --- General Utilities --- */
795
970
 
796
- /** Creates a new workbook */
797
- book_new(): WorkBook;
971
+ /** Create a new workbook */
972
+ book_new(ws?: WorkSheet, wsname?: string): WorkBook;
973
+
974
+ /** Create a new worksheet */
975
+ sheet_new(opts?: DenseOption): WorkSheet;
798
976
 
799
- /** Append a worksheet to a workbook */
800
- book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string): void;
977
+ /** Append a worksheet to a workbook, returns new worksheet name */
978
+ book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string, roll?: boolean): string;
801
979
 
802
980
  /** Set sheet visibility (visible/hidden/very hidden) */
803
981
  book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void;
@@ -815,15 +993,15 @@ export interface XLSX$Utils {
815
993
  cell_add_comment(cell: CellObject, text: string, author?: string): void;
816
994
 
817
995
  /** Assign an Array Formula to a range */
818
- sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string): WorkSheet;
996
+ sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string, dynamic?: boolean): WorkSheet;
819
997
 
820
998
  /** Add an array of arrays of JS data to a worksheet */
821
999
  sheet_add_aoa<T>(ws: WorkSheet, data: T[][], opts?: SheetAOAOpts): WorkSheet;
822
1000
  sheet_add_aoa(ws: WorkSheet, data: any[][], opts?: SheetAOAOpts): WorkSheet;
823
1001
 
824
1002
  /** Add an array of JS objects to a worksheet */
825
- sheet_add_json(ws: WorkSheet, data: any[], opts?: SheetJSONOpts): WorkSheet;
826
- sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: SheetJSONOpts): WorkSheet;
1003
+ sheet_add_json(ws: WorkSheet, data: any[], opts?: JSON2SheetOpts): WorkSheet;
1004
+ sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: JSON2SheetOpts): WorkSheet;
827
1005
 
828
1006
 
829
1007
  consts: XLSX$Consts;
@@ -850,4 +1028,6 @@ export interface StreamUtils {
850
1028
  to_html(sheet: WorkSheet, opts?: Sheet2HTMLOpts): any;
851
1029
  /** JSON object stream, generate one row at a time */
852
1030
  to_json(sheet: WorkSheet, opts?: Sheet2JSONOpts): any;
1031
+ /** Set `Readable` (internal) */
1032
+ set_readable(Readable: any): void;
853
1033
  }