xlport 0.3.3 → 0.4.0

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 (118) hide show
  1. package/.vscode/launch.json +15 -0
  2. package/dist/lib/client.d.ts +4 -2
  3. package/dist/lib/client.d.ts.map +1 -1
  4. package/dist/lib/client.js +101 -200
  5. package/dist/lib/client.js.map +1 -1
  6. package/dist/lib/export.types.d.ts +2 -2
  7. package/dist/lib/export.types.d.ts.map +1 -1
  8. package/dist/lib/export.types.js +1 -1
  9. package/dist/lib/export.types.js.map +1 -1
  10. package/dist/lib/import.types.d.ts +3 -3
  11. package/dist/lib/import.types.d.ts.map +1 -1
  12. package/dist/lib/shared.types.d.ts +1 -1
  13. package/dist/lib/shared.types.d.ts.map +1 -1
  14. package/package.json +14 -11
  15. package/tests/client/additional/data-validation/expected.xlsx +0 -0
  16. package/tests/client/additional/data-validation/request.json +23 -0
  17. package/tests/client/additional/data-validation/result.xlsx +0 -0
  18. package/tests/client/additional/data-validation/template.xlsx +0 -0
  19. package/tests/client/additional/lookup/expected.xlsx +0 -0
  20. package/tests/client/additional/lookup/request.json +23 -0
  21. package/tests/client/additional/lookup/result.xlsx +0 -0
  22. package/tests/client/client.e2e.spec.ts +5 -5
  23. package/tests/client/export/1object/expected.xlsx +0 -0
  24. package/tests/client/export/1table/expected.xlsx +0 -0
  25. package/tests/client/export/1table/request.json +1 -1
  26. package/tests/client/export/1table/template.xlsx +0 -0
  27. package/tests/client/export/thirdXlPort2Test/expected.xlsx +0 -0
  28. package/tests/client/export/thirdXlPort2Test/request.json +2 -0
  29. package/tests/client/export/v2-formats/expected.xlsx +0 -0
  30. package/tests/client/export/v2-formats/template.xlsx +0 -0
  31. package/tests/client/import/1object/expected.json +1 -10
  32. package/tests/client/import/1object/workbook.xlsx +0 -0
  33. package/tests/client/import/1table/expected.json +1 -39
  34. package/tests/client/import/1table/workbook.xlsx +0 -0
  35. package/tests/client/import/1table-10col-100rows/expected.json +1 -1306
  36. package/tests/client/import/1table-10col-100rows/workbook.xlsx +0 -0
  37. package/tests/client/import/v2importMultipleSheets/expected.json +1 -0
  38. package/tests/client/import/v2importMultipleSheets/workbook.xlsx +0 -0
  39. package/tests/tsconfig.json +2 -1
  40. package/tsconfig.json +4 -4
  41. package/dist/client.d.ts +0 -23
  42. package/dist/client.js +0 -98
  43. package/dist/client.js.map +0 -1
  44. package/dist/export.types.d.ts +0 -53
  45. package/dist/export.types.js +0 -3
  46. package/dist/export.types.js.map +0 -1
  47. package/dist/import.types.d.ts +0 -25
  48. package/dist/import.types.js +0 -11
  49. package/dist/import.types.js.map +0 -1
  50. package/dist/index.d.ts +0 -4
  51. package/dist/index.js +0 -21
  52. package/dist/index.js.map +0 -1
  53. package/dist/shared.types.d.ts +0 -1
  54. package/dist/shared.types.js +0 -3
  55. package/dist/shared.types.js.map +0 -1
  56. package/dist/tests/client/client.e2e.spec.d.ts +0 -1
  57. package/dist/tests/client/client.e2e.spec.js +0 -109
  58. package/dist/tests/client/client.e2e.spec.js.map +0 -1
  59. package/dist/tests/client/export/simple-export/request.json +0 -6
  60. package/dist/tests/client/import/1object/expected.json +0 -10
  61. package/dist/tests/client/import/1table/expected.json +0 -39
  62. package/dist/tests/client/import/1table-10col-100rows/expected.json +0 -1306
  63. package/dist/tests/client/import/multipleObjects/expected.json +0 -20
  64. package/dist/tests/client/import/multipleObjectsAndTables/expected.json +0 -84
  65. package/dist/tests/types/export/column-formatting.json +0 -151
  66. package/dist/tests/types/export/date.json +0 -6
  67. package/dist/tests/types/export/days.json +0 -7
  68. package/dist/tests/types/export/formats.json +0 -169
  69. package/dist/tests/types/export/formulas-and-lookups.json +0 -9
  70. package/dist/tests/types/export/multi-column-with-fixed-column.json +0 -24
  71. package/dist/tests/types/export/multi-sheet-column-fixed-topleft.json +0 -59
  72. package/dist/tests/types/export/multi-sheet-column-fixed.json +0 -59
  73. package/dist/tests/types/export/multi-sheet-column-simple-dash.json +0 -97
  74. package/dist/tests/types/export/multi-sheet-column-simple.json +0 -68
  75. package/dist/tests/types/export/multi-sheet-column.json +0 -68
  76. package/dist/tests/types/export/multi-sheet-simple.json +0 -41
  77. package/dist/tests/types/export/multiple-objects-and-tables.json +0 -83
  78. package/dist/tests/types/export/multiple-objects.json +0 -20
  79. package/dist/tests/types/export/multiple-tables.json +0 -88
  80. package/dist/tests/types/export/object.json +0 -11
  81. package/dist/tests/types/export/query-table-simple.json +0 -12
  82. package/dist/tests/types/export/query-table.json +0 -27
  83. package/dist/tests/types/export/sheets.json +0 -6
  84. package/dist/tests/types/export/table-with-calculations.json +0 -27
  85. package/dist/tests/types/export/table.json +0 -40
  86. package/dist/tests/types/export/utc.json +0 -7
  87. package/dist/tests/types/export.test.d.ts +0 -26
  88. package/dist/tests/types/export.test.js +0 -48
  89. package/dist/tests/types/export.test.js.map +0 -1
  90. package/dist/tests/types/import/large-table.json +0 -1
  91. package/dist/tests/types/import/multisheet.json +0 -1
  92. package/dist/tests/types/import/object.json +0 -1
  93. package/dist/tests/types/import/table.json +0 -1
  94. package/dist/tests/types/import.test.d.ts +0 -5
  95. package/dist/tests/types/import.test.js +0 -12
  96. package/dist/tests/types/import.test.js.map +0 -1
  97. package/dist/tsconfig.tsbuildinfo +0 -1
  98. package/tests/client/export/1table/test.xlsx +0 -0
  99. package/tests/client/export/formats/expected.xlsx +0 -0
  100. package/tests/client/export/formats/template.xlsx +0 -0
  101. package/tests/client/export/secondXlPort2Test/~$expected.xlsx +0 -0
  102. package/tests/client/export/thirdXlPort2Test/~$expected.xlsx +0 -0
  103. package/tests/client/export/thirdXlPort2Test/~$template.xlsx +0 -0
  104. package/tests/client/export/v2-column-formatting/~$expected.xlsx +0 -0
  105. package/tests/client/export/v2-column-formatting/~$template.xlsx +0 -0
  106. package/tests/client/import/1object/Source.xlsx +0 -0
  107. package/tests/client/import/1object/data.xlsx +0 -0
  108. package/tests/client/import/1object/request.json +0 -10
  109. package/tests/client/import/1table/Source.xlsx +0 -0
  110. package/tests/client/import/1table/data.xlsx +0 -0
  111. package/tests/client/import/1table/request.json +0 -15
  112. package/tests/client/import/1table-10col-100rows/Source.xlsx +0 -0
  113. package/tests/client/import/1table-10col-100rows/data.xlsx +0 -0
  114. package/tests/client/import/1table-10col-100rows/request.json +0 -17
  115. /package/tests/client/{export/lookup/lookup.xlsx → additional/lookup/template.xlsx} +0 -0
  116. /package/tests/client/export/{formats → v2-formats}/request.json +0 -0
  117. /package/tests/client/import/multipleObjects/{Source.xlsx → workbook.xlsx} +0 -0
  118. /package/tests/client/import/multipleObjectsAndTables/{Source.xlsx → workbook.xlsx} +0 -0
@@ -0,0 +1 @@
1
+ {"tables":{"Q1":{"MyProjectList":[{"Gamma":"Markus","TakeTwo":12.3456,"Delta":1,"Alpha":"Complete adding tables","Beta":"Add back tables from the template"},{"Gamma":"Milou","TakeTwo":2.13456,"Delta":2,"Alpha":"Build column magic","Beta":"Create function for moving columns"},{"Gamma":"Amelie","TakeTwo":6.54321,"Delta":3,"Alpha":"Also get import to JSON","Beta":"Take data from Excel to JSON"},{"Gamma":null,"TakeTwo":6145.123,"Delta":null,"Alpha":null,"Beta":null}]},"Initiatives":[{"Integer":1,"SavingsPotential":123.3,"Calculated column":146.727,"StatusId":"uuidStatus1","Id":"uuidInitiative1","Achievement":0.12,"IsComplete":false,"Date":"2018-04-11T00:00:00.000Z","Name":"Initiative 1"},{"Integer":-2.46537347E8,"SavingsPotential":null,"Calculated column":0,"StatusId":"uuidStatus2","Id":"uuidInitiative2","Achievement":0,"IsComplete":true,"Date":"1966-05-01T00:00:00.000Z","Name":"Initiative 2"},{"Integer":1.324275242E9,"SavingsPotential":456,"Calculated column":542.64,"StatusId":"uuidStatus3","Id":"uuidInitiative3","Achievement":0.2,"IsComplete":false,"Date":"2020-01-01T00:00:00.000Z","Name":"Initiative 3"}],"Status":[{"Label":"On track","Id":"uuidStatus1"},{"Label":"Some progress","Id":"uuidStatus2"},{"Label":"Delayed","Id":"uuidStatus3"}],"Q2":{"MyProjectList":[{"Action":null,"Owner":null,"Description":null,"Deadline":null}]},"Q3":{"MyProjectList":[{"Action":null,"Owner":null,"Description":null,"Deadline":null}]},"Persons":[{"Id":"pid1","LastName":"Bolle"},{"Id":"pid2","LastName":"Zwille"},{"Id":"pid3","LastName":"Ralle"}]},"properties":{"Q1":{"RootId":null,"HierarchyId":null,"Integer":42,"Float":37.005,"HierarchyLabel":null,"ProjectId":12345,"LastUpdated":"1982-01-25T00:00:00.000Z","ProjectLabel":"MyLabel","Boolean":true},"RootId":null,"Q2":{"RootId":null,"HierarchyId":null,"Integer":null,"Float":null,"HierarchyLabel":null,"ProjectId":null,"LastUpdated":null,"ProjectLabel":"Label 2","Boolean":null},"CompanyBoolean":false,"CompanyId":"cid1","CompanyInteger":252454,"CompanyLabel":"Company Name","ProjectId":null,"ProjectLabel":"Label X","HierarchyId":null,"Integer":null,"Float":null,"CompanyLastUpdated":"2019-02-02T00:00:00.000Z","HierarchyLabel":null,"CompanyFloat":2141.4,"LastUpdated":null,"Boolean":null}}
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
- "noEmit": true
4
+ "noEmit": true,
5
+ "allowJs": true
5
6
  }
6
7
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
3
+ "target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4
4
  "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
5
5
  "lib": ["es2015"] /* Specify library files to be included in the compilation. */,
6
6
  "declaration": true /* Generates corresponding '.d.ts' file. */,
@@ -14,13 +14,13 @@
14
14
  "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
15
15
  "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
16
16
  "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
17
-
18
17
  "resolveJsonModule": true,
19
- "baseUrl": "." /* Base directory to resolve non-absolute module names. */,
18
+ "baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
20
19
  "paths": {
21
20
  "@xlport": ["lib/"],
22
21
  "@xlport/*": ["lib/*"]
23
22
  }
24
23
  },
25
- "include": ["lib/**/*.ts"]
24
+ "include": ["lib/**/*.ts"],
25
+ "exclude": ["node_modules", "dist", "tests"]
26
26
  }
package/dist/client.d.ts DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,98 +0,0 @@
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
@@ -1 +0,0 @@
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,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,oCAAoC;YACtF,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAA;IAMH,CAAC;IACM,KAAK,CAAC,cAAc,CACzB,IAAqB,EACrB,UAA0B,qBAAM,CAAC,cAAc;QA6B/C,OAAO,IAAA,qBAAU,EAAC;YAChB,GAAG,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;YACvG,QAAQ,EACN,UAAU,IAAI,IAAI;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,gBAAgB,CAAC,IAAY;QACnC,OAAO,iBAAS,CAAqB,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,IAAI,4BAAoB,CAAA;IAC7E,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,IAAY;QACjC,OAAO;YACL,KAAK,EAAE,MAAM,IAAA,gBAAS,EAAC,aAAQ,CAAC,CAAC,IAAI,CAAC;YACtC,OAAO,EAAE;gBACP,QAAQ,EAAE,WAAW;gBACrB,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;aACzC;SACF,CAAA;IACH,CAAC;CACF;AAjJD,wBAiJC"}
@@ -1,53 +0,0 @@
1
- /// <reference types="node" />
2
- /// <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
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=export.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export.types.js","sourceRoot":"","sources":["../lib/export.types.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- export * from './client';
2
- export * from './export.types';
3
- export * from './import.types';
4
- export * from './shared.types';
package/dist/index.js DELETED
@@ -1,21 +0,0 @@
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
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,iDAA8B;AAC9B,iDAA8B;AAC9B,iDAA8B"}
@@ -1 +0,0 @@
1
- export type Scalar = boolean | string | number | null;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=shared.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.types.js","sourceRoot":"","sources":["../lib/shared.types.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export {};
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const lib_1 = require("../../lib");
4
- const dotenv = require("dotenv");
5
- const simpleExport = require("./export/simple-export/request.json");
6
- const import1Object = require("./import/1object/expected.json");
7
- const import1Table = require("./import/1table/expected.json");
8
- const importLargeTable = require("./import/1table-10col-100rows/expected.json");
9
- const importMultipleObjects = require("./import/multipleObjects/expected.json");
10
- const importMultipleObjectsAndTables = require("./import/multipleObjectsAndTables/expected.json");
11
- const fs_1 = require("fs");
12
- const round = (value, precision) => Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
13
- const roundNumbers = (obj, precision = 8) => {
14
- if (Array.isArray(obj)) {
15
- obj.forEach((element) => {
16
- if (typeof element === 'number') {
17
- element = round(element, precision);
18
- }
19
- else {
20
- roundNumbers(element, precision);
21
- }
22
- });
23
- }
24
- else if (typeof obj === 'object') {
25
- for (const key in obj) {
26
- if (obj.hasOwnProperty(key)) {
27
- const element = obj[key];
28
- if (typeof element === 'number') {
29
- obj[key] = round(element, precision);
30
- }
31
- else {
32
- roundNumbers(element, precision);
33
- }
34
- }
35
- }
36
- }
37
- else if (typeof obj === 'number') {
38
- obj = round(obj, precision);
39
- }
40
- return obj;
41
- };
42
- describe('Client', () => {
43
- const getClient = () => {
44
- dotenv.config({ path: './tests/client/.env' });
45
- return new lib_1.Client({ apiKey: process.env.XLPORT_APIKEY });
46
- };
47
- it('should throw if API Key is undefined', () => {
48
- expect(() => new lib_1.Client({ apiKey: undefined })).toThrow();
49
- });
50
- it('should be able to create a client', () => {
51
- const client = getClient();
52
- expect(client).toBeDefined();
53
- });
54
- it('should be able to download a file', async () => {
55
- const client = getClient();
56
- const file = await client.exportToFile(simpleExport);
57
- expect(file).toBeDefined();
58
- });
59
- it('should be able to upload a template', async () => {
60
- const client = getClient();
61
- const result = await client.exportToFile({
62
- template: fs_1.createReadStream('./tests/client/export/simple-export/template.xlsx'),
63
- data: { test: 'Test' },
64
- });
65
- expect(result).toBeDefined();
66
- });
67
- it('should import data - 1object', async () => {
68
- const client = getClient();
69
- const result = await client.importFromFile('./tests/client/import/1object/Source.xlsx');
70
- expect(result.status).toBe('success');
71
- if (result.status === 'success') {
72
- expect(result.data.properties).toEqual(import1Object.properties);
73
- }
74
- });
75
- it('should import data - 1table', async () => {
76
- const client = getClient();
77
- const result = await client.importFromFile('./tests/client/import/1table/Source.xlsx');
78
- expect(result.status).toBe('success');
79
- if (result.status === 'success') {
80
- expect(result.data.tables).toEqual(import1Table.tables);
81
- }
82
- });
83
- it('should import data - large table', async () => {
84
- const client = getClient();
85
- const result = await client.importFromFile('./tests/client/import/1table-10col-100rows/Source.xlsx');
86
- expect(result.status).toBe('success');
87
- if (result.status === 'success') {
88
- expect(roundNumbers(result.data.tables)).toEqual(roundNumbers(importLargeTable.tables));
89
- }
90
- });
91
- it('should import data - multipleObjects', async () => {
92
- const client = getClient();
93
- const result = await client.importFromFile('./tests/client/import/multipleObjects/Source.xlsx');
94
- expect(result.status).toBe('success');
95
- if (result.status === 'success') {
96
- expect(result.data.properties).toEqual(importMultipleObjects.properties);
97
- }
98
- });
99
- it('should import data - multipleObjectsAndTables', async () => {
100
- const client = getClient();
101
- const result = await client.importFromFile('./tests/client/import/multipleObjectsAndTables/Source.xlsx');
102
- expect(result.status).toBe('success');
103
- if (result.status === 'success') {
104
- expect(result.data.properties).toEqual(importMultipleObjectsAndTables.properties);
105
- expect(result.data.tables).toEqual(importMultipleObjectsAndTables.tables);
106
- }
107
- });
108
- });
109
- //# sourceMappingURL=client.e2e.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.e2e.spec.js","sourceRoot":"","sources":["../../../tests/client/client.e2e.spec.ts"],"names":[],"mappings":";;AAAA,mCAAkC;AAClC,iCAAgC;AAKhC,oEAAmE;AACnE,gEAA+D;AAC/D,8DAA6D;AAC7D,gFAA+E;AAC/E,gFAA+E;AAC/E,kGAAiG;AACjG,2BAAqC;AASrC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,SAAiB,EAAE,EAAE,CACjD,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;AACvE,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAE,SAAS,GAAG,CAAC,EAAE,EAAE;IAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACtB,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAE/B,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;aACpC;iBAAM;gBACL,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;aACjC;QACH,CAAC,CAAC,CAAA;KACH;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAClC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;YACrB,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBAC3B,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;gBACxB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;o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AAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAA;SAC1E;IACH,CAAC,CAAC,CAAA;AA4BJ,CAAC,CAAC,CAAA"}
@@ -1,6 +0,0 @@
1
- {
2
- "templateId": "simple-export/template.xlsx",
3
- "data": {
4
- "test": "Test"
5
- }
6
- }
@@ -1,10 +0,0 @@
1
- {
2
- "properties": {
3
- "Boolean": true,
4
- "Float": -143242.25,
5
- "Integer": 114325352,
6
- "LastUpdated": "2019-01-01T00:00:00.000Z",
7
- "ProjectId": "pid1",
8
- "ProjectLabel": "Project Name"
9
- }
10
- }
@@ -1,39 +0,0 @@
1
- {
2
- "tables": {
3
- "Initiatives": [
4
- {
5
- "Id": "uuidInitiative1",
6
- "Name": "Initiative 1",
7
- "StatusId": "uuidStatus1",
8
- "SavingsPotential": 123.3,
9
- "Achievement": 0.12,
10
- "IsComplete": false,
11
- "Date": "2018-04-11T00:00:00.000Z",
12
- "Integer": 1,
13
- "Calculated column": 146.727
14
- },
15
- {
16
- "Id": "uuidInitiative2",
17
- "Name": "Initiative 2",
18
- "StatusId": "uuidStatus2",
19
- "SavingsPotential": null,
20
- "Achievement": 0,
21
- "IsComplete": true,
22
- "Date": "1966-05-01T00:00:00.000Z",
23
- "Integer": -246537347,
24
- "Calculated column": 0
25
- },
26
- {
27
- "Id": "uuidInitiative3",
28
- "Name": "Initiative 3",
29
- "StatusId": "uuidStatus3",
30
- "SavingsPotential": 456,
31
- "Achievement": 0.2,
32
- "IsComplete": false,
33
- "Date": "2020-01-01T00:00:00.000Z",
34
- "Integer": 1324275242,
35
- "Calculated column": 542.64
36
- }
37
- ]
38
- }
39
- }