xlport 0.3.0 → 0.3.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/.env +1 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.js +98 -0
- package/dist/client.js.map +1 -0
- package/dist/export.types.d.ts +53 -0
- package/dist/export.types.js +3 -0
- package/dist/export.types.js.map +1 -0
- package/dist/import.types.d.ts +25 -0
- package/dist/import.types.js +11 -0
- package/dist/import.types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +7 -9
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +109 -69
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/export.types.d.ts +1 -0
- package/dist/lib/export.types.d.ts.map +1 -1
- package/dist/lib/index.js +5 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/shared.types.d.ts +1 -1
- package/dist/lib/shared.types.d.ts.map +1 -1
- package/dist/shared.types.d.ts +1 -0
- package/dist/shared.types.js +3 -0
- package/dist/shared.types.js.map +1 -0
- package/dist/tests/client/client.e2e.spec.d.ts +1 -0
- package/dist/tests/client/client.e2e.spec.js +109 -0
- package/dist/tests/client/client.e2e.spec.js.map +1 -0
- package/dist/tests/client/export/simple-export/request.json +6 -0
- package/dist/tests/client/import/1object/expected.json +10 -0
- package/dist/tests/client/import/1table/expected.json +39 -0
- package/dist/tests/client/import/1table-10col-100rows/expected.json +1306 -0
- package/dist/tests/client/import/multipleObjects/expected.json +20 -0
- package/dist/tests/client/import/multipleObjectsAndTables/expected.json +84 -0
- package/dist/tests/types/export/column-formatting.json +151 -0
- package/dist/tests/types/export/date.json +6 -0
- package/dist/tests/types/export/days.json +7 -0
- package/dist/tests/types/export/formats.json +169 -0
- package/dist/tests/types/export/formulas-and-lookups.json +9 -0
- package/dist/tests/types/export/multi-column-with-fixed-column.json +24 -0
- package/dist/tests/types/export/multi-sheet-column-fixed-topleft.json +59 -0
- package/dist/tests/types/export/multi-sheet-column-fixed.json +59 -0
- package/dist/tests/types/export/multi-sheet-column-simple-dash.json +97 -0
- package/dist/tests/types/export/multi-sheet-column-simple.json +68 -0
- package/dist/tests/types/export/multi-sheet-column.json +68 -0
- package/dist/tests/types/export/multi-sheet-simple.json +41 -0
- package/dist/tests/types/export/multiple-objects-and-tables.json +83 -0
- package/dist/tests/types/export/multiple-objects.json +20 -0
- package/dist/tests/types/export/multiple-tables.json +88 -0
- package/dist/tests/types/export/object.json +11 -0
- package/dist/tests/types/export/query-table-simple.json +12 -0
- package/dist/tests/types/export/query-table.json +27 -0
- package/dist/tests/types/export/sheets.json +6 -0
- package/dist/tests/types/export/table-with-calculations.json +27 -0
- package/dist/tests/types/export/table.json +40 -0
- package/dist/tests/types/export/utc.json +7 -0
- package/dist/tests/types/export.test.d.ts +26 -0
- package/dist/tests/types/export.test.js +48 -0
- package/dist/tests/types/export.test.js.map +1 -0
- package/dist/tests/types/import/large-table.json +1 -0
- package/dist/tests/types/import/multisheet.json +1 -0
- package/dist/tests/types/import/object.json +1 -0
- package/dist/tests/types/import/table.json +1 -0
- package/dist/tests/types/import.test.d.ts +5 -0
- package/dist/tests/types/import.test.js +12 -0
- package/dist/tests/types/import.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -5
- package/tests/client/.env +1 -0
- package/tests/client/.env.example +1 -0
- package/tests/client/client.e2e.spec.ts +149 -0
- package/tests/client/export/1object/expected.xlsx +0 -0
- package/tests/{export/object.json → client/export/1object/request.json} +0 -0
- package/tests/client/export/1object/template.xlsx +0 -0
- package/tests/client/export/1table/expected.xlsx +0 -0
- package/tests/client/export/1table/request.json +40 -0
- package/tests/client/export/1table/template.xlsx +0 -0
- package/tests/client/export/1table/test.xlsx +0 -0
- package/tests/client/export/1table-10col-100rows/expected.xlsx +0 -0
- package/tests/client/export/1table-10col-100rows/request.json +1307 -0
- package/tests/client/export/1table-10col-100rows/template.xlsx +0 -0
- package/tests/client/export/1table-with-calculations/expected.xlsx +0 -0
- package/tests/{export/table-with-calculations.json → client/export/1table-with-calculations/request.json} +0 -0
- package/tests/client/export/1table-with-calculations/template.xlsx +0 -0
- package/tests/client/export/4col_10000rows/expected.xlsx +0 -0
- package/tests/client/export/4col_10000rows/request.json +70011 -0
- package/tests/client/export/4col_10000rows/template.xlsx +0 -0
- package/tests/client/export/4col_100rows/expected.xlsx +0 -0
- package/tests/client/export/4col_100rows/request.json +711 -0
- package/tests/client/export/4col_100rows/template.xlsx +0 -0
- package/tests/client/export/4col_20000rows/expected.xlsx +0 -0
- package/tests/client/export/4col_20000rows/request.json +140011 -0
- package/tests/client/export/4col_20000rows/template.xlsx +0 -0
- package/tests/client/export/daysbug/expected.xlsx +0 -0
- package/tests/{export/days.json → client/export/daysbug/request.json} +0 -0
- package/tests/client/export/daysbug/template.xlsx +0 -0
- package/tests/client/export/deals/expected.xlsx +0 -0
- package/tests/client/export/deals/request.json +444 -0
- package/tests/client/export/deals/template.xlsx +0 -0
- package/tests/client/export/firstXlPort2Test/expected.xlsx +0 -0
- package/tests/client/export/firstXlPort2Test/request.json +119 -0
- package/tests/client/export/firstXlPort2Test/template.xlsx +0 -0
- package/tests/client/export/formats/expected.xlsx +0 -0
- package/tests/{export/formats.json → client/export/formats/request.json} +0 -0
- package/tests/client/export/formats/template.xlsx +0 -0
- package/tests/client/export/formulasAndLookups/expected.xlsx +0 -0
- package/tests/client/export/formulasAndLookups/request.json +8 -0
- package/tests/client/export/formulasAndLookups/template.xlsx +0 -0
- package/tests/client/export/multipleObjects/expected.xlsx +0 -0
- package/tests/{export/multiple-objects.json → client/export/multipleObjects/request.json} +0 -0
- package/tests/client/export/multipleObjects/template.xlsx +0 -0
- package/tests/client/export/multipleObjectsAndTables/expected.xlsx +0 -0
- package/tests/{export/multiple-objects-and-tables.json → client/export/multipleObjectsAndTables/request.json} +0 -0
- package/tests/client/export/multipleObjectsAndTables/template.xlsx +0 -0
- package/tests/client/export/multipleTables/expected.xlsx +0 -0
- package/tests/{export/multiple-tables.json → client/export/multipleTables/request.json} +0 -0
- package/tests/client/export/multipleTables/template.xlsx +0 -0
- package/tests/client/export/query_table_bug/expected.xlsx +0 -0
- package/tests/{export/query-table.json → client/export/query_table_bug/request.json} +0 -0
- package/tests/client/export/query_table_bug/template copy.xlsx +0 -0
- package/tests/client/export/query_table_bug/template updated.xlsx +0 -0
- package/tests/client/export/query_table_bug/template.xlsx +0 -0
- package/tests/client/export/query_table_simple/expected.xlsx +0 -0
- package/tests/{export/query-table-simple.json → client/export/query_table_simple/request.json} +0 -0
- package/tests/client/export/query_table_simple/template copy.xlsx +0 -0
- package/tests/client/export/query_table_simple/template updated.xlsx +0 -0
- package/tests/client/export/query_table_simple/template.xlsx +0 -0
- package/tests/client/export/secondXlPort2Test/expected.xlsx +0 -0
- package/tests/client/export/secondXlPort2Test/request.json +131 -0
- package/tests/client/export/secondXlPort2Test/template.xlsx +0 -0
- package/tests/client/export/secondXlPort2Test/~$expected.xlsx +0 -0
- package/tests/client/export/sheets/expected.xlsx +0 -0
- package/tests/{export/sheets.json → client/export/sheets/request.json} +0 -0
- package/tests/client/export/simple-export/expected.xlsx +0 -0
- package/tests/client/export/simple-export/request.json +6 -0
- package/tests/client/export/simple-export/template.xlsx +0 -0
- package/tests/client/export/simple-export/test.xlsx +0 -0
- package/tests/client/export/thedate/expected.xlsx +0 -0
- package/tests/{export/date.json → client/export/thedate/request.json} +0 -0
- package/tests/client/export/thedate/template.xlsx +0 -0
- package/tests/client/export/thirdXlPort2Test/expected.xlsx +0 -0
- package/tests/client/export/thirdXlPort2Test/request.json +149 -0
- package/tests/client/export/thirdXlPort2Test/template.xlsx +0 -0
- package/tests/client/export/thirdXlPort2Test/~$expected.xlsx +0 -0
- package/tests/client/export/thirdXlPort2Test/~$template.xlsx +0 -0
- package/tests/client/export/v2-alma-minimized/expected.xlsx +0 -0
- package/tests/client/export/v2-alma-minimized/request.json +33 -0
- package/tests/client/export/v2-alma-minimized/template.xlsx +0 -0
- package/tests/client/export/v2-alma-scorecard-export/expected.xlsx +0 -0
- package/tests/client/export/v2-alma-scorecard-export/request.json +89 -0
- package/tests/client/export/v2-alma-scorecard-export/template.xlsx +0 -0
- package/tests/client/export/v2-alma-table/expected.xlsx +0 -0
- package/tests/client/export/v2-alma-table/request.json +66 -0
- package/tests/client/export/v2-alma-table/template.xlsx +0 -0
- package/tests/client/export/v2-column-formatting/expected.xlsx +0 -0
- package/tests/client/export/v2-column-formatting/request.json +160 -0
- package/tests/client/export/v2-column-formatting/template.xlsx +0 -0
- package/tests/client/export/v2-column-formatting/~$expected.xlsx +0 -0
- package/tests/client/export/v2-column-formatting/~$template.xlsx +0 -0
- package/tests/client/export/v2-multi-column-with-fixed-column/expected.xlsx +0 -0
- package/tests/{export/multi-column-with-fixed-column.json → client/export/v2-multi-column-with-fixed-column/request.json} +0 -0
- package/tests/client/export/v2-multi-column-with-fixed-column/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-column/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-column.json → client/export/v2-multi-sheet-column/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-column/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-column-fixed/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-column-fixed.json → client/export/v2-multi-sheet-column-fixed/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-column-fixed/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-column-fixed-topleft/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-column-fixed-topleft.json → client/export/v2-multi-sheet-column-fixed-topleft/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-column-fixed-topleft/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-column-simple/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-column-simple.json → client/export/v2-multi-sheet-column-simple/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-column-simple/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-column-simple-dash/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-column-simple-dash.json → client/export/v2-multi-sheet-column-simple-dash/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-column-simple-dash/template.xlsx +0 -0
- package/tests/client/export/v2-multi-sheet-simple/expected.xlsx +0 -0
- package/tests/{export/multi-sheet-simple.json → client/export/v2-multi-sheet-simple/request.json} +0 -0
- package/tests/client/export/v2-multi-sheet-simple/template.xlsx +0 -0
- package/tests/client/export/v2-utc/expected.xlsx +0 -0
- package/tests/{export/utc.json → client/export/v2-utc/request.json} +0 -0
- package/tests/client/export/v2-utc/template.xlsx +0 -0
- package/tests/client/import/1object/Source.xlsx +0 -0
- package/tests/client/import/1object/data.xlsx +0 -0
- package/tests/client/import/1object/expected.json +10 -0
- package/tests/client/import/1object/request.json +10 -0
- package/tests/client/import/1table/Source.xlsx +0 -0
- package/tests/client/import/1table/data.xlsx +0 -0
- package/tests/client/import/1table/expected.json +39 -0
- package/tests/client/import/1table/request.json +15 -0
- package/tests/client/import/1table-10col-100rows/Source.xlsx +0 -0
- package/tests/client/import/1table-10col-100rows/data.xlsx +0 -0
- package/tests/client/import/1table-10col-100rows/expected.json +1306 -0
- package/tests/client/import/1table-10col-100rows/request.json +17 -0
- package/tests/client/import/multipleObjects/Source.xlsx +0 -0
- package/tests/client/import/multipleObjects/data.xlsx +0 -0
- package/tests/client/import/multipleObjects/expected.json +20 -0
- package/tests/client/import/multipleObjects/request.json +20 -0
- package/tests/client/import/multipleObjectsAndTables/Source.xlsx +0 -0
- package/tests/client/import/multipleObjectsAndTables/data.xlsx +0 -0
- package/tests/client/import/multipleObjectsAndTables/expected.json +84 -0
- package/tests/client/import/multipleObjectsAndTables/request.json +40 -0
- package/tests/client/import/multipleTables/Source.xlsx +0 -0
- package/tests/client/import/multipleTables/data.xlsx +0 -0
- package/tests/client/import/multipleTables/expected.json +87 -0
- package/tests/client/import/multipleTables/request.json +29 -0
- package/tests/{export → types/export}/column-formatting.json +0 -0
- package/tests/types/export/date.json +6 -0
- package/tests/types/export/days.json +7 -0
- package/tests/types/export/formats.json +169 -0
- package/tests/{export → types/export}/formulas-and-lookups.json +0 -0
- package/tests/types/export/multi-column-with-fixed-column.json +24 -0
- package/tests/types/export/multi-sheet-column-fixed-topleft.json +59 -0
- package/tests/types/export/multi-sheet-column-fixed.json +59 -0
- package/tests/types/export/multi-sheet-column-simple-dash.json +97 -0
- package/tests/types/export/multi-sheet-column-simple.json +68 -0
- package/tests/types/export/multi-sheet-column.json +68 -0
- package/tests/types/export/multi-sheet-simple.json +41 -0
- package/tests/types/export/multiple-objects-and-tables.json +83 -0
- package/tests/types/export/multiple-objects.json +20 -0
- package/tests/types/export/multiple-tables.json +88 -0
- package/tests/types/export/object.json +11 -0
- package/tests/types/export/query-table-simple.json +12 -0
- package/tests/types/export/query-table.json +27 -0
- package/tests/types/export/sheets.json +5 -0
- package/tests/types/export/table-with-calculations.json +27 -0
- package/tests/{export → types/export}/table.json +0 -0
- package/tests/types/export/utc.json +7 -0
- package/tests/{export.test.ts → types/export.test.ts} +2 -1
- package/tests/{import → types/import}/large-table.json +0 -0
- package/tests/{import → types/import}/multisheet.json +0 -0
- package/tests/{import → types/import}/object.json +0 -0
- package/tests/{import → types/import}/table.json +0 -0
- package/tests/{import.test.ts → types/import.test.ts} +1 -2
- package/tsconfig.json +6 -44
package/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
XLPORT_APIKEY=test
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Stream } from 'stream';
|
|
4
|
+
import { Import } from './import.types';
|
|
5
|
+
import { Export } from './export.types';
|
|
6
|
+
export type ClientOptions = {
|
|
7
|
+
url?: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
};
|
|
10
|
+
export type ExcelFileExtension = 'xls' | 'xlsx' | 'xlsm' | 'xlsb';
|
|
11
|
+
export type ExcelDefaultMimeType = 'application/vnd.ms-excel';
|
|
12
|
+
export type ExcelMimeType = ExcelDefaultMimeType | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.ms-excel.sheet.macroEnabled.12' | 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';
|
|
13
|
+
export declare const excelDefaultMimeType = "application/vnd.ms-excel";
|
|
14
|
+
export declare const mimeTypes: MimeTypes;
|
|
15
|
+
export type MimeTypes = Record<ExcelFileExtension, ExcelMimeType>;
|
|
16
|
+
export declare class Client {
|
|
17
|
+
private config;
|
|
18
|
+
constructor(config: ClientOptions);
|
|
19
|
+
importFromFile(file: string | Buffer, request?: Import.Request): Promise<Import.Response>;
|
|
20
|
+
exportToFile(body: Export.Body): Stream;
|
|
21
|
+
private getExcelMimeType;
|
|
22
|
+
private loadFile;
|
|
23
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = exports.mimeTypes = exports.excelDefaultMimeType = void 0;
|
|
4
|
+
const request_promise_1 = require("request-promise");
|
|
5
|
+
const request_1 = require("request");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const import_types_1 = require("./import.types");
|
|
10
|
+
exports.excelDefaultMimeType = 'application/vnd.ms-excel';
|
|
11
|
+
exports.mimeTypes = {
|
|
12
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
13
|
+
xlsm: 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
|
14
|
+
xlsb: 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
|
15
|
+
xls: 'application/vnd.ms-excel',
|
|
16
|
+
};
|
|
17
|
+
class Client {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
if (config.apiKey === undefined)
|
|
20
|
+
throw Error('API Key is undefined');
|
|
21
|
+
this.config = {
|
|
22
|
+
url: config.url ? config.url.replace(/\/$/, '') : 'https://xlport.compute.molnify.com',
|
|
23
|
+
apiKey: config.apiKey,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async importFromFile(file, request = import_types_1.Import.defaultRequest) {
|
|
27
|
+
return (0, request_promise_1.put)({
|
|
28
|
+
url: `${this.config.url}/import`,
|
|
29
|
+
headers: {
|
|
30
|
+
Authorization: 'xlport apikey ' + this.config.apiKey,
|
|
31
|
+
},
|
|
32
|
+
method: 'put',
|
|
33
|
+
formData: {
|
|
34
|
+
file: typeof file === 'string'
|
|
35
|
+
? await this.loadFile(file)
|
|
36
|
+
: {
|
|
37
|
+
value: file,
|
|
38
|
+
options: { filename: 'file.xlsx', contentType: exports.excelDefaultMimeType },
|
|
39
|
+
},
|
|
40
|
+
request: {
|
|
41
|
+
value: Buffer.from(JSON.stringify(request)),
|
|
42
|
+
options: {
|
|
43
|
+
filename: 'request.json',
|
|
44
|
+
contentType: 'application/json',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
.then(JSON.parse)
|
|
50
|
+
.then((response) => {
|
|
51
|
+
if (!response)
|
|
52
|
+
throw Error('Response body is empty');
|
|
53
|
+
return response;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exportToFile(body) {
|
|
57
|
+
return (0, request_1.put)({
|
|
58
|
+
url: `${this.config.url}/export`,
|
|
59
|
+
headers: {
|
|
60
|
+
Authorization: 'xlport apikey ' + this.config.apiKey,
|
|
61
|
+
},
|
|
62
|
+
body: 'templateId' in body ? JSON.stringify(body) : 'templateUrl' in body ? JSON.stringify(body) : null,
|
|
63
|
+
formData: 'template' in body
|
|
64
|
+
? {
|
|
65
|
+
template: {
|
|
66
|
+
value: body.template,
|
|
67
|
+
options: {
|
|
68
|
+
filename: 'template.xlsx',
|
|
69
|
+
contentType: 'application/vnd.ms-excel',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
data: {
|
|
73
|
+
value: Buffer.from(JSON.stringify(body.data)),
|
|
74
|
+
options: {
|
|
75
|
+
filename: 'data.json',
|
|
76
|
+
contentType: 'application/json',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
: undefined,
|
|
81
|
+
encoding: null,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getExcelMimeType(path) {
|
|
85
|
+
return exports.mimeTypes[(0, path_1.extname)(path)] || exports.excelDefaultMimeType;
|
|
86
|
+
}
|
|
87
|
+
async loadFile(path) {
|
|
88
|
+
return {
|
|
89
|
+
value: await (0, util_1.promisify)(fs_1.readFile)(path),
|
|
90
|
+
options: {
|
|
91
|
+
filename: 'file.xlsx',
|
|
92
|
+
contentType: this.getExcelMimeType(path),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.Client = Client;
|
|
98
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../lib/client.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AACnD,qCAAoC;AACpC,+BAAgC;AAChC,2BAA6B;AAK7B,+BAA8B;AAE9B,iDAAuC;AAgB1B,QAAA,oBAAoB,GAAG,0BAA0B,CAAA;AACjD,QAAA,SAAS,GAAc;IAClC,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,gDAAgD;IACtD,IAAI,EAAE,uDAAuD;IAC7D,GAAG,EAAE,0BAA0B;CAChC,CAAA;AAGD,MAAa,MAAM;IAMjB,YAAY,MAAqB;QAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACpE,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAA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
|
+
/// <reference types="node" />
|
|
3
|
+
import { ReadStream } from 'fs';
|
|
4
|
+
import * as Shared from './shared.types';
|
|
5
|
+
export declare namespace Export {
|
|
6
|
+
type Body = FileBody | UrlBody | TemplateIdBody;
|
|
7
|
+
type FileBody = {
|
|
8
|
+
template: Buffer | ReadStream;
|
|
9
|
+
data: DataWithSheets;
|
|
10
|
+
};
|
|
11
|
+
type UrlBody = {
|
|
12
|
+
templateUrl: string;
|
|
13
|
+
data: DataWithSheets;
|
|
14
|
+
};
|
|
15
|
+
type TemplateIdBody = {
|
|
16
|
+
templateId: string;
|
|
17
|
+
data: DataWithSheets;
|
|
18
|
+
};
|
|
19
|
+
type NamedRange = Value;
|
|
20
|
+
type Value = Shared.Scalar | ScalarWithOptions;
|
|
21
|
+
type ScalarWithOptions = {
|
|
22
|
+
data: Shared.Scalar;
|
|
23
|
+
format?: string;
|
|
24
|
+
indent?: IndentLevel;
|
|
25
|
+
};
|
|
26
|
+
type IndentLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
|
|
27
|
+
type Table = TableData | TableWithColumnModifications;
|
|
28
|
+
type TableData = Record<string, Value>[];
|
|
29
|
+
type TableWithColumnModifications = {
|
|
30
|
+
columns: ColumnDefinition[];
|
|
31
|
+
data: TableData;
|
|
32
|
+
};
|
|
33
|
+
type SheetName = string;
|
|
34
|
+
type ColumnName = string;
|
|
35
|
+
type ColumnDefinition = {
|
|
36
|
+
name: ColumnName;
|
|
37
|
+
fromTemplateColumn: ColumnName;
|
|
38
|
+
format?: string;
|
|
39
|
+
indent?: IndentLevel;
|
|
40
|
+
};
|
|
41
|
+
type DataElement = NamedRange | Table;
|
|
42
|
+
type DataWithoutSheets = Record<string, any>;
|
|
43
|
+
type DataWithSheets = DataWithoutSheets & {
|
|
44
|
+
sheets?: Sheet[];
|
|
45
|
+
};
|
|
46
|
+
type Sheet = {
|
|
47
|
+
name: SheetName;
|
|
48
|
+
fromTemplateSheet: SheetName;
|
|
49
|
+
tabColor?: HexColor;
|
|
50
|
+
data: DataWithoutSheets;
|
|
51
|
+
};
|
|
52
|
+
type HexColor = `#${string}`;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.types.js","sourceRoot":"","sources":["../lib/export.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Shared from './shared.types';
|
|
2
|
+
export declare namespace Import {
|
|
3
|
+
type Request = {
|
|
4
|
+
properties: string[];
|
|
5
|
+
tables?: Record<string, string[]>[] | ['*'];
|
|
6
|
+
};
|
|
7
|
+
const defaultRequest: Request;
|
|
8
|
+
type Response = Success | Error;
|
|
9
|
+
interface Error {
|
|
10
|
+
status: 'error';
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
interface Success {
|
|
14
|
+
status: 'success';
|
|
15
|
+
data: Data;
|
|
16
|
+
}
|
|
17
|
+
type Data = {
|
|
18
|
+
properties?: Record<string, Property>;
|
|
19
|
+
tables?: Record<string, Table | SheetTables>;
|
|
20
|
+
};
|
|
21
|
+
type Property = Shared.Scalar | SheetProperties;
|
|
22
|
+
type SheetProperties = Record<string, Shared.Scalar>;
|
|
23
|
+
type Table = Record<string, Shared.Scalar>[];
|
|
24
|
+
type SheetTables = Record<string, Table>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Import = void 0;
|
|
4
|
+
var Import;
|
|
5
|
+
(function (Import) {
|
|
6
|
+
Import.defaultRequest = {
|
|
7
|
+
properties: ['*'],
|
|
8
|
+
tables: ['*'],
|
|
9
|
+
};
|
|
10
|
+
})(Import = exports.Import || (exports.Import = {}));
|
|
11
|
+
//# sourceMappingURL=import.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.types.js","sourceRoot":"","sources":["../lib/import.types.ts"],"names":[],"mappings":";;;AACA,IAAiB,MAAM,CA+BtB;AA/BD,WAAiB,MAAM;IAMR,qBAAc,GAAY;QACrC,UAAU,EAAE,CAAC,GAAG,CAAC;QACjB,MAAM,EAAE,CAAC,GAAG,CAAC;KACd,CAAA;AAsBH,CAAC,EA/BgB,MAAM,GAAN,cAAM,KAAN,cAAM,QA+BtB"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./export.types"), exports);
|
|
19
|
+
__exportStar(require("./import.types"), exports);
|
|
20
|
+
__exportStar(require("./shared.types"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,iDAA8B;AAC9B,iDAA8B;AAC9B,iDAA8B"}
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Stream } from 'stream';
|
|
3
|
-
import { AxiosInstance } from 'axios';
|
|
4
4
|
import { Import } from './import.types';
|
|
5
5
|
import { Export } from './export.types';
|
|
6
|
-
export
|
|
6
|
+
export type ClientOptions = {
|
|
7
7
|
url?: string;
|
|
8
8
|
apiKey: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
10
|
+
export type ExcelFileExtension = 'xls' | 'xlsx' | 'xlsm' | 'xlsb';
|
|
11
|
+
export type ExcelDefaultMimeType = 'application/vnd.ms-excel';
|
|
12
|
+
export type ExcelMimeType = ExcelDefaultMimeType | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.ms-excel.sheet.macroEnabled.12' | 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';
|
|
13
13
|
export declare const excelDefaultMimeType = "application/vnd.ms-excel";
|
|
14
14
|
export declare const mimeTypes: MimeTypes;
|
|
15
|
-
export
|
|
15
|
+
export type MimeTypes = Record<ExcelFileExtension, ExcelMimeType>;
|
|
16
16
|
export declare class Client {
|
|
17
17
|
private config;
|
|
18
|
-
private get authHeader();
|
|
19
|
-
axios: AxiosInstance;
|
|
20
18
|
constructor(config: ClientOptions);
|
|
21
19
|
importFromFile(file: string | Buffer, request?: Import.Request): Promise<Import.Response>;
|
|
22
|
-
exportToFile(body: Export.Body):
|
|
20
|
+
exportToFile(body: Export.Body): Stream;
|
|
23
21
|
private getExcelMimeType;
|
|
24
22
|
private loadFile;
|
|
25
23
|
}
|
package/dist/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":";;AASA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AACjE,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAA;AAC7D,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,mEAAmE,GACnE,gDAAgD,GAChD,uDAAuD,CAAA;AAE3D,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAC9D,eAAO,MAAM,SAAS,EAAE,SAKvB,CAAA;AACD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAA;AAEjE,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAyB;gBAK3B,MAAM,EAAE,aAAa;IAYpB,cAAc,CACzB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,GAAE,MAAM,CAAC,OAA+B,GAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;IAiFpB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM;IA8B9C,OAAO,CAAC,gBAAgB;YAIV,QAAQ;CASvB"}
|
package/dist/lib/client.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -33,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
33
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
15
|
function step(op) {
|
|
35
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
37
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
20
|
switch (op[0]) {
|
|
@@ -56,10 +37,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
56
37
|
};
|
|
57
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
39
|
exports.Client = exports.mimeTypes = exports.excelDefaultMimeType = void 0;
|
|
40
|
+
var request_promise_1 = require("request-promise");
|
|
41
|
+
var request_1 = require("request");
|
|
42
|
+
var util_1 = require("util");
|
|
59
43
|
var fs_1 = require("fs");
|
|
44
|
+
// import { createReadStream } from 'fs'
|
|
45
|
+
// import FormData from 'form-data'
|
|
46
|
+
// import Axios, { AxiosInstance, toFormData } from 'axios'
|
|
60
47
|
var path_1 = require("path");
|
|
61
|
-
var util_1 = require("util");
|
|
62
|
-
var axios_1 = __importStar(require("axios"));
|
|
63
48
|
var import_types_1 = require("./import.types");
|
|
64
49
|
exports.excelDefaultMimeType = 'application/vnd.ms-excel';
|
|
65
50
|
exports.mimeTypes = {
|
|
@@ -69,59 +54,89 @@ exports.mimeTypes = {
|
|
|
69
54
|
xls: 'application/vnd.ms-excel',
|
|
70
55
|
};
|
|
71
56
|
var Client = /** @class */ (function () {
|
|
57
|
+
// private get authHeader() {
|
|
58
|
+
// return 'xlport apikey ' + this.config.apiKey
|
|
59
|
+
// }
|
|
60
|
+
// public axios: AxiosInstance
|
|
72
61
|
function Client(config) {
|
|
62
|
+
if (config.apiKey === undefined)
|
|
63
|
+
throw Error('API Key is undefined');
|
|
73
64
|
this.config = {
|
|
74
65
|
url: config.url ? config.url.replace(/\/$/, '') : 'https://xlport.compute.molnify.com',
|
|
75
66
|
apiKey: config.apiKey,
|
|
76
67
|
};
|
|
77
|
-
this.axios =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
68
|
+
// this.axios = Axios.create({
|
|
69
|
+
// headers: {
|
|
70
|
+
// Authorization: this.authHeader,
|
|
71
|
+
// },
|
|
72
|
+
// })
|
|
82
73
|
}
|
|
83
|
-
Object.defineProperty(Client.prototype, "authHeader", {
|
|
84
|
-
get: function () {
|
|
85
|
-
return 'xlport apikey ' + this.config.apiKey;
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
74
|
Client.prototype.importFromFile = function (file, request) {
|
|
91
75
|
if (request === void 0) { request = import_types_1.Import.defaultRequest; }
|
|
92
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var _a, _b
|
|
94
|
-
var
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
77
|
+
var _a, _b;
|
|
78
|
+
var _c, _d;
|
|
79
|
+
return __generator(this, function (_e) {
|
|
80
|
+
switch (_e.label) {
|
|
97
81
|
case 0:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
_a = request_promise_1.put;
|
|
83
|
+
_c = {
|
|
84
|
+
url: "".concat(this.config.url, "/import"),
|
|
85
|
+
headers: {
|
|
86
|
+
Authorization: 'xlport apikey ' + this.config.apiKey,
|
|
87
|
+
},
|
|
88
|
+
method: 'put'
|
|
89
|
+
};
|
|
90
|
+
_d = {};
|
|
103
91
|
if (!(typeof file === 'string')) return [3 /*break*/, 2];
|
|
104
92
|
return [4 /*yield*/, this.loadFile(file)];
|
|
105
93
|
case 1:
|
|
106
|
-
|
|
94
|
+
_b = _e.sent();
|
|
107
95
|
return [3 /*break*/, 3];
|
|
108
96
|
case 2:
|
|
109
|
-
|
|
97
|
+
_b = {
|
|
110
98
|
value: file,
|
|
111
99
|
options: { filename: 'file.xlsx', contentType: exports.excelDefaultMimeType },
|
|
112
100
|
};
|
|
113
|
-
|
|
114
|
-
case 3:
|
|
115
|
-
|
|
101
|
+
_e.label = 3;
|
|
102
|
+
case 3:
|
|
103
|
+
// const formData = new FormData()
|
|
104
|
+
// if (typeof file === 'string') {
|
|
105
|
+
// try {
|
|
106
|
+
// const options = { contentType: this.getExcelMimeType(file) }
|
|
107
|
+
// formData.append('file.xlsx', createReadStream(file), options)
|
|
108
|
+
// } catch (error) {
|
|
109
|
+
// console.error(error)
|
|
110
|
+
// throw error
|
|
111
|
+
// }
|
|
112
|
+
// } else {
|
|
113
|
+
// formData.append('file.xlsx', file, { contentType: excelDefaultMimeType })
|
|
114
|
+
// }
|
|
115
|
+
// formData.append('request', JSON.stringify(request))
|
|
116
|
+
// return this.axios
|
|
117
|
+
// .put(`${this.config.url}/import`, formData, {
|
|
118
|
+
// headers: {
|
|
119
|
+
// Accept: 'application/json',
|
|
120
|
+
// 'Content-Type': 'multipart/form-data',
|
|
121
|
+
// ...formData.getHeaders(),
|
|
122
|
+
// },
|
|
123
|
+
// })
|
|
124
|
+
// .then((response) => JSON.parse(response.data))
|
|
125
|
+
// .then((response) => {
|
|
126
|
+
// if (!response) throw Error('Response body is empty')
|
|
127
|
+
// return response
|
|
128
|
+
// })
|
|
129
|
+
return [2 /*return*/, _a.apply(void 0, [(_c.formData = (_d.file = _b,
|
|
130
|
+
_d.request = {
|
|
116
131
|
value: Buffer.from(JSON.stringify(request)),
|
|
117
132
|
options: {
|
|
118
133
|
filename: 'request.json',
|
|
119
134
|
contentType: 'application/json',
|
|
120
135
|
},
|
|
121
136
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.then(
|
|
137
|
+
_d),
|
|
138
|
+
_c)])
|
|
139
|
+
.then(JSON.parse)
|
|
125
140
|
.then(function (response) {
|
|
126
141
|
if (!response)
|
|
127
142
|
throw Error('Response body is empty');
|
|
@@ -131,11 +146,39 @@ var Client = /** @class */ (function () {
|
|
|
131
146
|
});
|
|
132
147
|
});
|
|
133
148
|
};
|
|
149
|
+
// public exportToFile(body: Export.Body): Promise<Stream> {
|
|
150
|
+
// let data =
|
|
151
|
+
// 'templateId' in body || 'templateUrl' in body
|
|
152
|
+
// ? body
|
|
153
|
+
// : toFormData({
|
|
154
|
+
// template: {
|
|
155
|
+
// value: body.template,
|
|
156
|
+
// options: {
|
|
157
|
+
// filename: 'template.xlsx',
|
|
158
|
+
// contentType: 'application/vnd.ms-excel',
|
|
159
|
+
// },
|
|
160
|
+
// },
|
|
161
|
+
// data: {
|
|
162
|
+
// value: Buffer.from(JSON.stringify(body.data)),
|
|
163
|
+
// options: {
|
|
164
|
+
// filename: 'data.json',
|
|
165
|
+
// contentType: 'application/json',
|
|
166
|
+
// },
|
|
167
|
+
// },
|
|
168
|
+
// })
|
|
169
|
+
// return this.axios.put(`${this.config.url}/export`, data, { responseType: 'stream' }).then((response) => {
|
|
170
|
+
// if (response.status !== 200) throw Error(response.statusText)
|
|
171
|
+
// return response.data as Stream
|
|
172
|
+
// })
|
|
134
173
|
Client.prototype.exportToFile = function (body) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
:
|
|
138
|
-
|
|
174
|
+
return (0, request_1.put)({
|
|
175
|
+
url: "".concat(this.config.url, "/export"),
|
|
176
|
+
headers: {
|
|
177
|
+
Authorization: 'xlport apikey ' + this.config.apiKey,
|
|
178
|
+
},
|
|
179
|
+
body: 'templateId' in body ? JSON.stringify(body) : 'templateUrl' in body ? JSON.stringify(body) : null,
|
|
180
|
+
formData: 'template' in body
|
|
181
|
+
? {
|
|
139
182
|
template: {
|
|
140
183
|
value: body.template,
|
|
141
184
|
options: {
|
|
@@ -143,23 +186,20 @@ var Client = /** @class */ (function () {
|
|
|
143
186
|
contentType: 'application/vnd.ms-excel',
|
|
144
187
|
},
|
|
145
188
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
189
|
+
data: {
|
|
190
|
+
value: Buffer.from(JSON.stringify(body.data)),
|
|
191
|
+
options: {
|
|
192
|
+
filename: 'data.json',
|
|
193
|
+
contentType: 'application/json',
|
|
194
|
+
},
|
|
152
195
|
},
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (response.status !== 200)
|
|
157
|
-
throw Error(response.statusText);
|
|
158
|
-
return response.data;
|
|
196
|
+
}
|
|
197
|
+
: undefined,
|
|
198
|
+
encoding: null,
|
|
159
199
|
});
|
|
160
200
|
};
|
|
161
201
|
Client.prototype.getExcelMimeType = function (path) {
|
|
162
|
-
return exports.mimeTypes[path_1.extname(path)] || exports.excelDefaultMimeType;
|
|
202
|
+
return exports.mimeTypes[(0, path_1.extname)(path)] || exports.excelDefaultMimeType;
|
|
163
203
|
};
|
|
164
204
|
Client.prototype.loadFile = function (path) {
|
|
165
205
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -168,7 +208,7 @@ var Client = /** @class */ (function () {
|
|
|
168
208
|
switch (_b.label) {
|
|
169
209
|
case 0:
|
|
170
210
|
_a = {};
|
|
171
|
-
return [4 /*yield*/, util_1.promisify(fs_1.readFile)(path)];
|
|
211
|
+
return [4 /*yield*/, (0, util_1.promisify)(fs_1.readFile)(path)];
|
|
172
212
|
case 1: return [2 /*return*/, (_a.value = _b.sent(),
|
|
173
213
|
_a.options = {
|
|
174
214
|
filename: 'file.xlsx',
|
package/dist/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmD;AACnD,mCAAoC;AACpC,6BAAgC;AAChC,yBAA6B;AAE7B,wCAAwC;AACxC,mCAAmC;AACnC,2DAA2D;AAC3D,6BAA8B;AAE9B,+CAAuC;AAgB1B,QAAA,oBAAoB,GAAG,0BAA0B,CAAA;AACjD,QAAA,SAAS,GAAc;IAClC,IAAI,EAAE,mEAAmE;IACzE,IAAI,EAAE,gDAAgD;IACtD,IAAI,EAAE,uDAAuD;IAC7D,GAAG,EAAE,0BAA0B;CAChC,CAAA;AAGD;IAEE,6BAA6B;IAC7B,iDAAiD;IACjD,IAAI;IACJ,8BAA8B;IAC9B,gBAAY,MAAqB;QAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACpE,IAAI,CAAC,MAAM,GAA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;gBAChB,CAAC,CAAC;oBACE,QAAQ,EAAE;wBACR,KAAK,EAAE,IAAI,CAAC,QAAQ;wBACpB,OAAO,EAAE;4BACP,QAAQ,EAAE,eAAe;4BACzB,WAAW,EAAE,0BAA0B;yBACxC;qBACF;oBACD,IAAI,EAAE;wBACJ,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC7C,OAAO,EAAE;4BACP,QAAQ,EAAE,WAAW;4BACrB,WAAW,EAAE,kBAAkB;yBAChC;qBACF;iBACF;gBACH,CAAC,CAAC,SAAS;YACf,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;IACJ,CAAC;IAEO,iCAAgB,GAAxB,UAAyB,IAAY;QACnC,OAAO,iBAAS,CAAqB,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,IAAI,4BAAoB,CAAA;IAC7E,CAAC;IAEa,yBAAQ,GAAtB,UAAuB,IAAY;;;;;;;wBAExB,qBAAM,IAAA,gBAAS,EAAC,aAAQ,CAAC,CAAC,IAAI,CAAC,EAAA;4BADxC,uBACE,QAAK,GAAE,SAA+B;4BACtC,UAAO,GAAE;gCACP,QAAQ,EAAE,WAAW;gCACrB,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;6BACzC;iCACF;;;;KACF;IACH,aAAC;AAAD,CAAC,AAjJD,IAiJC;AAjJY,wBAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.types.d.ts","sourceRoot":"","sources":["../../lib/export.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.types.d.ts","sourceRoot":"","sources":["../../lib/export.types.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,yBAAiB,MAAM,CAAC;IACtB,KAAY,IAAI,GAAG,QA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;QAChB,kBAAkB,EAAE,UAAU,CAAA;QAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,WAAW,CAAA;KACrB,CAAA;IAED,KAAY,WAAW,GAAG,UAAU,GAAG,KAAK,CAAA;IAC5C,KAAY,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnD,KAAY,cAAc,GAAG,iBAAiB,GAAG;QAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;KAAE,CAAA;IAErE,KAAY,KAAK,GAAG;QAClB,IAAI,EAAE,SAAS,CAAA;QACf,iBAAiB,EAAE,SAAS,CAAA;QAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAA;QACnB,IAAI,EAAE,iBAAiB,CAAA;KACxB,CAAA;IAED,KAAY,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAA;CACpC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,iDAA8B;AAC9B,iDAA8B;AAC9B,iDAA8B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Scalar = boolean | string | number | null;
|
|
2
2
|
//# sourceMappingURL=shared.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.types.d.ts","sourceRoot":"","sources":["../../lib/shared.types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"shared.types.d.ts","sourceRoot":"","sources":["../../lib/shared.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Scalar = boolean | string | number | null;
|