@tachybase/plugin-action-import 0.23.8

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 (78) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/README.md +222 -0
  3. package/README.zh-CN.md +222 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/ImportActionInitializer.d.ts +8 -0
  7. package/dist/client/ImportDesigner.d.ts +2 -0
  8. package/dist/client/ImportModal.d.ts +6 -0
  9. package/dist/client/ImportPluginProvider.d.ts +3 -0
  10. package/dist/client/constants.d.ts +1 -0
  11. package/dist/client/context.d.ts +28 -0
  12. package/dist/client/index.d.ts +9 -0
  13. package/dist/client/index.js +24 -0
  14. package/dist/client/locale/index.d.ts +0 -0
  15. package/dist/client/schemaSettings.d.ts +2 -0
  16. package/dist/client/useFields.d.ts +1 -0
  17. package/dist/client/useImportAction.d.ts +6 -0
  18. package/dist/client/useShared.d.ts +75 -0
  19. package/dist/externalVersion.js +16 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +43 -0
  22. package/dist/locale/en-US.json +27 -0
  23. package/dist/locale/es-ES.json +27 -0
  24. package/dist/locale/ko_KR.json +28 -0
  25. package/dist/locale/pt-BR.json +27 -0
  26. package/dist/locale/zh-CN.json +28 -0
  27. package/dist/node_modules/node-xlsx/dist/bin/cli.cjs +95 -0
  28. package/dist/node_modules/node-xlsx/dist/bin/cli.d.cts +1 -0
  29. package/dist/node_modules/node-xlsx/dist/bin/cli.d.ts +1 -0
  30. package/dist/node_modules/node-xlsx/dist/bin/cli.js +37 -0
  31. package/dist/node_modules/node-xlsx/dist/chunk-ID6OMQGT.js +78 -0
  32. package/dist/node_modules/node-xlsx/dist/index.cjs +7 -0
  33. package/dist/node_modules/node-xlsx/dist/index.d.cts +46 -0
  34. package/dist/node_modules/node-xlsx/dist/index.d.ts +46 -0
  35. package/dist/node_modules/node-xlsx/dist/index.js +13 -0
  36. package/dist/node_modules/node-xlsx/node_modules/.bin/xlsx +17 -0
  37. package/dist/node_modules/node-xlsx/package.json +1 -0
  38. package/dist/node_modules/xlsx/LICENSE +201 -0
  39. package/dist/node_modules/xlsx/bin/xlsx.njs +310 -0
  40. package/dist/node_modules/xlsx/bower.json +22 -0
  41. package/dist/node_modules/xlsx/dist/cpexcel.js +1506 -0
  42. package/dist/node_modules/xlsx/dist/shim.min.js +2 -0
  43. package/dist/node_modules/xlsx/dist/xlsx.core.min.js +15 -0
  44. package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +24642 -0
  45. package/dist/node_modules/xlsx/dist/xlsx.full.min.js +22 -0
  46. package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +9 -0
  47. package/dist/node_modules/xlsx/dist/xlsx.zahl.js +4 -0
  48. package/dist/node_modules/xlsx/node_modules/.bin/crc32 +17 -0
  49. package/dist/node_modules/xlsx/package.json +1 -0
  50. package/dist/node_modules/xlsx/types/index.d.ts +900 -0
  51. package/dist/node_modules/xlsx/xlsx.js +7 -0
  52. package/dist/node_modules/xlsx/xlsxworker.js +14 -0
  53. package/dist/server/actions/downloadXlsxTemplate.d.ts +2 -0
  54. package/dist/server/actions/downloadXlsxTemplate.js +62 -0
  55. package/dist/server/actions/importXlsx.d.ts +2 -0
  56. package/dist/server/actions/importXlsx.js +187 -0
  57. package/dist/server/actions/index.d.ts +2 -0
  58. package/dist/server/actions/index.js +23 -0
  59. package/dist/server/index.d.ts +7 -0
  60. package/dist/server/index.js +53 -0
  61. package/dist/server/locale/en-US.d.ts +11 -0
  62. package/dist/server/locale/en-US.js +32 -0
  63. package/dist/server/locale/fr-FR.d.ts +11 -0
  64. package/dist/server/locale/fr-FR.js +32 -0
  65. package/dist/server/locale/index.d.ts +2 -0
  66. package/dist/server/locale/index.js +40 -0
  67. package/dist/server/locale/zh-CN.d.ts +12 -0
  68. package/dist/server/locale/zh-CN.js +33 -0
  69. package/dist/server/middleware/index.d.ts +2 -0
  70. package/dist/server/middleware/index.js +34 -0
  71. package/dist/server/utils/index.d.ts +6 -0
  72. package/dist/server/utils/index.js +54 -0
  73. package/dist/server/utils/transform.d.ts +84 -0
  74. package/dist/server/utils/transform.js +226 -0
  75. package/dist/swagger/index.json +33 -0
  76. package/package.json +39 -0
  77. package/server.d.ts +2 -0
  78. package/server.js +1 -0
@@ -0,0 +1,75 @@
1
+ import type { VoidField } from '@tachybase/schema';
2
+ export declare const useShared: () => {
3
+ importSettingsSchema: {
4
+ type: string;
5
+ 'x-component': string;
6
+ properties: {
7
+ explain: {
8
+ type: string;
9
+ title: string;
10
+ 'x-decorator': string;
11
+ 'x-component': string;
12
+ };
13
+ importColumns: {
14
+ type: string;
15
+ 'x-component': string;
16
+ 'x-decorator': string;
17
+ items: {
18
+ type: string;
19
+ properties: {
20
+ space: {
21
+ type: string;
22
+ 'x-component': string;
23
+ 'x-component-props': {
24
+ className: string;
25
+ };
26
+ properties: {
27
+ sort: {
28
+ type: string;
29
+ 'x-decorator': string;
30
+ 'x-component': string;
31
+ };
32
+ dataIndex: {
33
+ type: string;
34
+ 'x-decorator': string;
35
+ 'x-component': import("react").ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & import("react").RefAttributes<unknown>>;
36
+ required: boolean;
37
+ enum: any[];
38
+ 'x-component-props': {
39
+ fieldNames: {
40
+ label: string;
41
+ value: string;
42
+ children: string;
43
+ };
44
+ changeOnSelect: boolean;
45
+ };
46
+ };
47
+ remove: {
48
+ type: string;
49
+ 'x-decorator': string;
50
+ 'x-component': string;
51
+ };
52
+ };
53
+ };
54
+ };
55
+ };
56
+ properties: {
57
+ add: {
58
+ type: string;
59
+ title: string;
60
+ 'x-component': string;
61
+ 'x-component-props': {
62
+ className: string;
63
+ };
64
+ };
65
+ };
66
+ };
67
+ };
68
+ };
69
+ beforeUploadHandler(): boolean;
70
+ uploadValidator(value: any, rule: any): "" | {
71
+ type: string;
72
+ message: string;
73
+ };
74
+ validateUpload(form: any, submitField: VoidField, deps: any): void;
75
+ };
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ "react": "18.3.1",
3
+ "@tachybase/client": "0.23.8",
4
+ "@tachybase/schema": "0.23.8",
5
+ "@tachybase/components": "0.23.8",
6
+ "react-i18next": "15.2.0",
7
+ "@ant-design/icons": "5.3.7",
8
+ "antd": "5.22.5",
9
+ "react-dom": "18.3.1",
10
+ "lodash": "4.17.21",
11
+ "@tachybase/server": "0.23.8",
12
+ "@tachybase/actions": "0.23.8",
13
+ "@tachybase/database": "0.23.8",
14
+ "@tachybase/utils": "0.23.8",
15
+ "mathjs": "10.6.4"
16
+ };
@@ -0,0 +1,3 @@
1
+ export * from './server';
2
+ export { default } from './server';
3
+ export declare const namespace: string;
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default,
32
+ namespace: () => namespace
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+ var import_package = require("../package.json");
36
+ __reExport(src_exports, require("./server"), module.exports);
37
+ var import_server = __toESM(require("./server"));
38
+ const namespace = import_package.name;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ namespace,
42
+ ...require("./server")
43
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ "Add importable field": "Add importable field",
3
+ "Done": "Done",
4
+ "Download template": "Download template",
5
+ "Download tip": "- Download the template and fill in the data according to the format \r\n - Import only the first worksheet \r\n - Support single import of up to 10,000 rows of data \r\n - Do not change the header of the template to prevent import failure",
6
+ "Excel data importing": "Excel data importing",
7
+ "Field {{fieldName}} does not exist": "Field {{fieldName}} does not exist",
8
+ "File size cannot exceed 10M": "File size cannot exceed 10M",
9
+ "Illegal percentage format": "Illegal percentage format",
10
+ "Import Data": "Import Data",
11
+ "Import done, total success have {{successCount}} , total failure have {{failureCount}}": "Import is complete, with a total of {{successCount}} successful and {{failureCount}} failed",
12
+ "Import explain": "Guide",
13
+ "Incorrect date format": "Incorrect date format",
14
+ "Incorrect email format": "Incorrect email format",
15
+ "Incorrect time format": "Incorrect time format",
16
+ "No": "No",
17
+ "Only one file is allowed to be uploaded": "Only one file is allowed to be uploaded",
18
+ "Please upload the file of Excel": "Please upload the file of Excel",
19
+ "Start import": "Start import",
20
+ "Step 1: Download template": "Step 1: Download template",
21
+ "Step 2: Upload Excel": "Step 2: Upload Excel",
22
+ "To download the failure data": "To download the failure data",
23
+ "Upload placeholder": "Drag and drop the file here or click to upload, file size should not exceed 30M",
24
+ "Yes": "Yes",
25
+ "can not find value": "can not find value",
26
+ "password is empty": "password is empty"
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "Add importable field": "Añadir campo importable",
3
+ "Done": "Hecho",
4
+ "Download template": "Descargar plantilla",
5
+ "Download tip": "- Descargar la plantilla y rellenar los datos según el formato \r\n - Importar sólo la primera hoja de cálculo \r\n - Soportar una única importación de hasta 10.000 filas de datos \r\n - No cambiar la cabecera de la plantilla para evitar fallos en la importación",
6
+ "Excel data importing": "Importación de datos Excel",
7
+ "Field {{fieldName}} does not exist": "El campo {{fieldName}} no existe",
8
+ "File size cannot exceed 10M": "El tamaño del archivo no puede superar los 10M",
9
+ "Illegal percentage format": "Formato de porcentaje ilegal",
10
+ "Import Data": "Importar datos",
11
+ "Import done, total success have {{successCount}} , total failure have {{failureCount}}": "La importación se ha completado, con un total de {{successCount}} correctos y {{failureCount}} fallidos",
12
+ "Import explain": "Guía",
13
+ "Incorrect date format": "Formato de fecha incorrecto",
14
+ "Incorrect email format": "Formato de correo electrónico incorrecto",
15
+ "Incorrect time format": "Formato de hora incorrecto",
16
+ "No": "No",
17
+ "Only one file is allowed to be uploaded": "Sólo se permite cargar un archivo",
18
+ "Please upload the file of Excel": "Por favor, cargue el archivo de Excel",
19
+ "Start import": "Iniciar importación",
20
+ "Step 1: Download template": "Paso 1: Descargar plantilla",
21
+ "Step 2: Upload Excel": "Paso 2: Cargar Excel",
22
+ "To download the failure data": "Para descargar los datos de fallo",
23
+ "Upload placeholder": "Arrastra y suelta el archivo aquí o haga clic para cargarlo, el tamaño del archivo no debe superar los 10M",
24
+ "Yes": "Sí",
25
+ "can not find value": "no se puede encontrar el valor",
26
+ "password is empty": "la contraseña está vacía"
27
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "Add importable field": "가져올 수 있는 필드 추가",
3
+ "Done": "완료",
4
+ "Download template": "템플릿 다운로드",
5
+ "Download tip": "- 템플릿을 다운로드하고 형식에 맞게 데이터를 작성합니다.\r\n - 첫 번째 시트만 가져옵니다.\r\n - 단일 가져오기로 10000행 이하의 데이터를 지원합니다.\r\n - 템플릿 헤더를 수정하지 마세요. 가져오기 실패를 방지합니다.",
6
+ "Excel data importing": "Excel 데이터 가져오기 중입니다. 창을 닫지 마십시오.",
7
+ "Field {{fieldName}} does not exist": "필드 {{fieldName}}가 존재하지 않습니다",
8
+ "File size cannot exceed 10M": "파일 크기는 10M을 초과할 수 없습니다",
9
+ "Illegal percentage format": "잘못된 백분율 형식",
10
+ "Import Data": "데이터 가져오기",
11
+ "Import done, total success have {{successCount}} , total failure have {{failureCount}}": "가져오기 완료, 총 성공 {{successCount}} 건, 총 실패 {{failureCount}} 건",
12
+ "Import explain": "가져오기 설명",
13
+ "Imported template does not match, please download again.": "가져온 템플릿이 일치하지 않습니다. 다시 다운로드하세요.",
14
+ "Incorrect date format": "잘못된 날짜 형식",
15
+ "Incorrect email format": "잘못된 이메일 형식",
16
+ "Incorrect time format": "잘못된 시간 형식",
17
+ "No": "아니요",
18
+ "Only one file is allowed to be uploaded": "하나의 파일만 업로드 할 수 있습니다",
19
+ "Please upload the file of Excel": "Excel 파일을 업로드하십시오",
20
+ "Start import": "가져오기 시작",
21
+ "Step 1: Download template": "단계 1: 템플릿 다운로드",
22
+ "Step 2: Upload Excel": "단계 2: Excel 업로드",
23
+ "To download the failure data": "실패한 데이터를 다운로드하려면",
24
+ "Upload placeholder": "파일을 여기에 드래그하거나 클릭하여 업로드하십시오. 파일 크기는 10M을 초과할 수 없습니다.",
25
+ "Yes": "예",
26
+ "can not find value": "값을 찾을 수 없습니다",
27
+ "password is empty": "암호가 비어 있습니다"
28
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "Add importable field": "Adicionar campo importável",
3
+ "Done": "Concluído",
4
+ "Download template": "Baixar modelo",
5
+ "Download tip": "- Baixe o modelo e preencha os dados de acordo com o formato \r\n - Importe apenas a primeira planilha \r\n - Suporte de importação única de até 10.000 linhas de dados \r\n - Não altere o cabeçalho do modelo para evitar falhas de importação",
6
+ "Excel data importing": "Importando dados do Excel",
7
+ "Field {{fieldName}} does not exist": "O campo {{fieldName}} não existe",
8
+ "File size cannot exceed 10M": "O tamanho do arquivo não pode exceder 10 MB",
9
+ "Illegal percentage format": "Formato de porcentagem ilegal",
10
+ "Import Data": "Importar dados",
11
+ "Import done, total success have {{successCount}} , total failure have {{failureCount}}": "Importação concluída, com um total de {{successCount}} sucesso e {{failureCount}} falhas",
12
+ "Import explain": "Guia",
13
+ "Incorrect date format": "Formato de data incorreto",
14
+ "Incorrect email format": "Formato de e-mail incorreto",
15
+ "Incorrect time format": "Formato de hora incorreto",
16
+ "No": "Não",
17
+ "Only one file is allowed to be uploaded": "Somente um arquivo pode ser enviado de cada vez",
18
+ "Please upload the file of Excel": "Por favor, envie um arquivo do Excel",
19
+ "Start import": "Iniciar importação",
20
+ "Step 1: Download template": "Passo 1: Baixar modelo",
21
+ "Step 2: Upload Excel": "Passo 2: Enviar Excel",
22
+ "To download the failure data": "Para baixar os dados que falharam",
23
+ "Upload placeholder": "Arraste e solte o arquivo aqui ou clique para enviar, o tamanho do arquivo não deve exceder 10 MB",
24
+ "Yes": "Sim",
25
+ "can not find value": "Não foi possível encontrar o valor",
26
+ "password is empty": "A senha está vazia"
27
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "Add importable field": "添加可导入字段",
3
+ "Done": "完成",
4
+ "Download template": "下载模板",
5
+ "Download tip": "- 下载模板后,按格式填写数据\r\n - 只导入第一张工作表\r\n - 支持单次导入不超过10000行数据\r\n - 请勿改模板表头,防止导入失败",
6
+ "Excel data importing": "数据导入中,请勿关闭窗口",
7
+ "Field {{fieldName}} does not exist": "字段 {{fieldName}} 不存在",
8
+ "File size cannot exceed 10M": "文件大小不能超过10M",
9
+ "Illegal percentage format": "百分比格式有误",
10
+ "Import Data": "导入数据",
11
+ "Import done, total success have {{successCount}} , total failure have {{failureCount}}": "导入完成,共导入成功{{successCount}}条数据,共导入失败{{failureCount}}条数据",
12
+ "Import explain": "说明",
13
+ "Imported template does not match, please download again.": "导入模板不匹配,请检查导入文件标题行或重新下载导入模板",
14
+ "Incorrect date format": "日期格式不正确",
15
+ "Incorrect email format": "邮箱格式不正确",
16
+ "Incorrect time format": "时间格式不正确",
17
+ "No": "否",
18
+ "Only one file is allowed to be uploaded": "只允许上传一个文件",
19
+ "Please upload the file of Excel": "请上传Excel的文件",
20
+ "Start import": "开始导入",
21
+ "Step 1: Download template": "1.下载模板",
22
+ "Step 2: Upload Excel": "2.上传完善后的表格",
23
+ "To download the failure data": "下载导入失败的数据",
24
+ "Upload placeholder": "将文件拖曳到此处或点击上传,文件大小不超过10M",
25
+ "Yes": "是",
26
+ "can not find value": "找不到对应值",
27
+ "password is empty": "密码为空"
28
+ }
@@ -0,0 +1,95 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/bin/cli.ts
27
+ var import_promises = require("fs/promises");
28
+
29
+ // src/index.ts
30
+ var import_xlsx2 = require("xlsx");
31
+
32
+ // src/config.ts
33
+ var fs = __toESM(require("fs"), 1);
34
+ var import_xlsx = require("xlsx");
35
+ (0, import_xlsx.set_fs)(fs);
36
+
37
+ // src/workbook.ts
38
+ var WorkBook = class {
39
+ Sheets = {};
40
+ SheetNames = [];
41
+ };
42
+
43
+ // src/index.ts
44
+ var build = (worksheets, { parseOptions = {}, writeOptions = {}, sheetOptions = {}, ...otherOptions } = {}) => {
45
+ const { bookType = "xlsx", bookSST = false, type = "buffer", ...otherWriteOptions } = writeOptions;
46
+ const legacyOptions = Object.keys(otherOptions).filter((key) => {
47
+ if (["!cols", "!rows", "!merges", "!protect", "!autofilter"].includes(key)) {
48
+ console.debug(`Deprecated options['${key}'], please use options.sheetOptions['${key}'] instead.`);
49
+ return true;
50
+ }
51
+ console.debug(`Unknown options['${key}'], please use options.parseOptions / options.writeOptions`);
52
+ return false;
53
+ });
54
+ const workBook = worksheets.reduce((soFar, { name, data, options = {} }, index) => {
55
+ const sheetName = name || `Sheet_${index}`;
56
+ const sheetData = import_xlsx2.utils.aoa_to_sheet(data, parseOptions);
57
+ soFar.SheetNames.push(sheetName);
58
+ soFar.Sheets[sheetName] = sheetData;
59
+ Object.assign(soFar.Sheets[sheetName], legacyOptions, sheetOptions, options);
60
+ return soFar;
61
+ }, new WorkBook());
62
+ return (0, import_xlsx2.write)(workBook, { bookType, bookSST, type, ...otherWriteOptions });
63
+ };
64
+
65
+ // src/bin/cli.ts
66
+ var [action = "build", ...args] = process.argv.slice(2);
67
+ var readStdin = async (bufferSize) => {
68
+ return new Promise((resolve) => {
69
+ const buffers = [];
70
+ process.stdin.on("readable", () => {
71
+ const read2 = process.stdin.read();
72
+ if (read2) {
73
+ buffers.push(read2);
74
+ }
75
+ });
76
+ process.stdin.on("end", () => {
77
+ resolve(Buffer.concat(buffers, bufferSize));
78
+ });
79
+ });
80
+ };
81
+ var main = async () => {
82
+ switch (action) {
83
+ case "build": {
84
+ const stdin = JSON.parse((await readStdin()).toString("utf8"));
85
+ const result = build(stdin);
86
+ await (0, import_promises.writeFile)(args[0] || `${process.cwd()}/out.xlsx`, result);
87
+ break;
88
+ }
89
+ default:
90
+ console.log("Sorry, that is not something I know how to do.");
91
+ }
92
+ process.exit(0);
93
+ };
94
+ main();
95
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +1 @@
1
+ #! /usr/bin/env node
@@ -0,0 +1 @@
1
+ #! /usr/bin/env node
@@ -0,0 +1,37 @@
1
+ #! /usr/bin/env node
2
+ import {
3
+ build
4
+ } from "../chunk-ID6OMQGT.js";
5
+
6
+ // src/bin/cli.ts
7
+ import { writeFile } from "fs/promises";
8
+ var [action = "build", ...args] = process.argv.slice(2);
9
+ var readStdin = async (bufferSize) => {
10
+ return new Promise((resolve) => {
11
+ const buffers = [];
12
+ process.stdin.on("readable", () => {
13
+ const read = process.stdin.read();
14
+ if (read) {
15
+ buffers.push(read);
16
+ }
17
+ });
18
+ process.stdin.on("end", () => {
19
+ resolve(Buffer.concat(buffers, bufferSize));
20
+ });
21
+ });
22
+ };
23
+ var main = async () => {
24
+ switch (action) {
25
+ case "build": {
26
+ const stdin = JSON.parse((await readStdin()).toString("utf8"));
27
+ const result = build(stdin);
28
+ await writeFile(args[0] || `${process.cwd()}/out.xlsx`, result);
29
+ break;
30
+ }
31
+ default:
32
+ console.log("Sorry, that is not something I know how to do.");
33
+ }
34
+ process.exit(0);
35
+ };
36
+ main();
37
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,78 @@
1
+ // src/index.ts
2
+ import {
3
+ read,
4
+ readFile,
5
+ utils,
6
+ write
7
+ } from "xlsx";
8
+
9
+ // src/config.ts
10
+ import * as fs from "fs";
11
+ import { set_fs } from "xlsx";
12
+ set_fs(fs);
13
+
14
+ // src/helpers.ts
15
+ var isString = (maybeString) => typeof maybeString === "string";
16
+
17
+ // src/workbook.ts
18
+ var WorkBook = class {
19
+ Sheets = {};
20
+ SheetNames = [];
21
+ };
22
+
23
+ // src/index.ts
24
+ var parse = (mixed, options = {}) => {
25
+ const { dateNF, header = 1, range, blankrows, defval, raw = true, rawNumbers, ...otherOptions } = options;
26
+ const workBook = isString(mixed) ? readFile(mixed, { dateNF, raw, ...otherOptions }) : read(mixed, { dateNF, raw, ...otherOptions });
27
+ return Object.keys(workBook.Sheets).map((name) => {
28
+ const sheet = workBook.Sheets[name];
29
+ return {
30
+ name,
31
+ data: utils.sheet_to_json(sheet, {
32
+ dateNF,
33
+ header,
34
+ range: typeof range === "function" ? range(sheet) : range,
35
+ blankrows,
36
+ defval,
37
+ raw,
38
+ rawNumbers
39
+ })
40
+ };
41
+ });
42
+ };
43
+ var parseMetadata = (mixed, options = {}) => {
44
+ const workBook = isString(mixed) ? readFile(mixed, options) : read(mixed, options);
45
+ return Object.keys(workBook.Sheets).map((name) => {
46
+ const sheet = workBook.Sheets[name];
47
+ return { name, data: sheet["!ref"] ? utils.decode_range(sheet["!ref"]) : null };
48
+ });
49
+ };
50
+ var build = (worksheets, { parseOptions = {}, writeOptions = {}, sheetOptions = {}, ...otherOptions } = {}) => {
51
+ const { bookType = "xlsx", bookSST = false, type = "buffer", ...otherWriteOptions } = writeOptions;
52
+ const legacyOptions = Object.keys(otherOptions).filter((key) => {
53
+ if (["!cols", "!rows", "!merges", "!protect", "!autofilter"].includes(key)) {
54
+ console.debug(`Deprecated options['${key}'], please use options.sheetOptions['${key}'] instead.`);
55
+ return true;
56
+ }
57
+ console.debug(`Unknown options['${key}'], please use options.parseOptions / options.writeOptions`);
58
+ return false;
59
+ });
60
+ const workBook = worksheets.reduce((soFar, { name, data, options = {} }, index) => {
61
+ const sheetName = name || `Sheet_${index}`;
62
+ const sheetData = utils.aoa_to_sheet(data, parseOptions);
63
+ soFar.SheetNames.push(sheetName);
64
+ soFar.Sheets[sheetName] = sheetData;
65
+ Object.assign(soFar.Sheets[sheetName], legacyOptions, sheetOptions, options);
66
+ return soFar;
67
+ }, new WorkBook());
68
+ return write(workBook, { bookType, bookSST, type, ...otherWriteOptions });
69
+ };
70
+ var src_default = { parse, parseMetadata, build };
71
+
72
+ export {
73
+ parse,
74
+ parseMetadata,
75
+ build,
76
+ src_default
77
+ };
78
+ //# sourceMappingURL=chunk-ID6OMQGT.js.map