xlport 0.1.0 → 0.2.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 (61) hide show
  1. package/dist/lib/client.d.ts +23 -0
  2. package/dist/lib/client.d.ts.map +1 -0
  3. package/dist/{client.js → lib/client.js} +32 -6
  4. package/dist/lib/client.js.map +1 -0
  5. package/dist/lib/export.types.d.ts +51 -0
  6. package/dist/lib/export.types.d.ts.map +1 -0
  7. package/dist/lib/export.types.js +3 -0
  8. package/dist/lib/export.types.js.map +1 -0
  9. package/dist/lib/import.types.d.ts +24 -0
  10. package/dist/lib/import.types.d.ts.map +1 -0
  11. package/dist/lib/import.types.js +8 -0
  12. package/dist/lib/import.types.js.map +1 -0
  13. package/dist/lib/index.d.ts +5 -0
  14. package/dist/lib/index.d.ts.map +1 -0
  15. package/dist/{index.js → lib/index.js} +3 -1
  16. package/dist/lib/index.js.map +1 -0
  17. package/dist/lib/shared.types.d.ts +2 -0
  18. package/dist/lib/shared.types.d.ts.map +1 -0
  19. package/dist/lib/shared.types.js +3 -0
  20. package/dist/lib/shared.types.js.map +1 -0
  21. package/package.json +3 -3
  22. package/tests/export/column-formatting.json +151 -0
  23. package/tests/export/date.json +6 -0
  24. package/tests/export/days.json +7 -0
  25. package/tests/export/export.test.ts +60 -0
  26. package/tests/export/formats.json +169 -0
  27. package/tests/export/formulas-and-lookups.json +9 -0
  28. package/tests/export/multi-column-with-fixed-column.json +24 -0
  29. package/tests/export/multi-sheet-column-fixed-topleft.json +59 -0
  30. package/tests/export/multi-sheet-column-fixed.json +59 -0
  31. package/tests/export/multi-sheet-column-simple-dash.json +97 -0
  32. package/tests/export/multi-sheet-column-simple.json +68 -0
  33. package/tests/export/multi-sheet-column.json +68 -0
  34. package/tests/export/multi-sheet-simple.json +41 -0
  35. package/tests/export/multiple-objects-and-tables.json +83 -0
  36. package/tests/export/multiple-objects.json +20 -0
  37. package/tests/export/multiple-tables.json +88 -0
  38. package/tests/export/object.json +11 -0
  39. package/tests/export/query-table-simple.json +12 -0
  40. package/tests/export/query-table.json +27 -0
  41. package/tests/export/sheets.json +5 -0
  42. package/tests/export/table-with-calculations.json +27 -0
  43. package/tests/export/table.json +40 -0
  44. package/tests/export/utc.json +7 -0
  45. package/tests/import/import.test.ts +11 -0
  46. package/tests/import/large-table.json +1 -0
  47. package/tests/import/multisheet.json +1 -0
  48. package/tests/import/object.json +1 -0
  49. package/tests/import/table.json +1 -0
  50. package/tests/tsconfig.json +6 -0
  51. package/tsconfig.json +17 -15
  52. package/dist/client.d.ts +0 -12
  53. package/dist/client.d.ts.map +0 -1
  54. package/dist/client.js.map +0 -1
  55. package/dist/index.d.ts +0 -3
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/types.d.ts +0 -53
  59. package/dist/types.d.ts.map +0 -1
  60. package/dist/types.js +0 -15
  61. package/dist/types.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ import { Stream } from 'stream';
3
+ import * as Import from './import.types';
4
+ import * as Export from './export.types';
5
+ export declare type ClientOptions = {
6
+ url?: string;
7
+ apiKey: string;
8
+ };
9
+ export declare type ExcelFileExtension = 'xls' | 'xlsx' | 'xlsm' | 'xlsb';
10
+ export declare type ExcelDefaultMimeType = 'application/vnd.ms-excel';
11
+ export declare type ExcelMimeType = ExcelDefaultMimeType | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.ms-excel.sheet.macroEnabled.12' | 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';
12
+ export declare const excelDefaultMimeType = "application/vnd.ms-excel";
13
+ export declare const mimeTypes: MimeTypes;
14
+ export declare type MimeTypes = Record<ExcelFileExtension, ExcelMimeType>;
15
+ export declare class XlPort {
16
+ private config;
17
+ constructor(config: ClientOptions);
18
+ importFromFile(file: string | Buffer, request?: Import.Request): Promise<Import.Response>;
19
+ exportToFile(body: Export.Body): Stream;
20
+ private getExcelMimeType;
21
+ private loadFile;
22
+ }
23
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAExC,oBAAY,aAAa,GAAG;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,oBAAY,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AACjE,oBAAY,oBAAoB,GAAG,0BAA0B,CAAA;AAC7D,oBAAY,aAAa,GACrB,oBAAoB,GACpB,mEAAmE,GACnE,gDAAgD,GAChD,uDAAuD,CAAA;AAE3D,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAC9D,eAAO,MAAM,SAAS,EAAE,SAKvB,CAAA;AACD,oBAAY,SAAS,GAAG,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAA;AAEjE,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAyB;gBAC3B,MAAM,EAAE,aAAa;IAMpB,cAAc,CACzB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,GAAE,MAAM,CAAC,OAA+B,GAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;IA8BpB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM;IAgC9C,OAAO,CAAC,gBAAgB;YAIV,QAAQ;CASvB"}
@@ -1,4 +1,23 @@
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
+ };
2
21
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
22
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
23
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,22 +55,29 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
55
  }
37
56
  };
38
57
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.XlPort = void 0;
58
+ exports.XlPort = exports.mimeTypes = exports.excelDefaultMimeType = void 0;
40
59
  var request_promise_1 = require("request-promise");
41
60
  var request_1 = require("request");
42
61
  var fs_1 = require("fs");
43
62
  var path_1 = require("path");
44
63
  var util_1 = require("util");
45
- var types_1 = require("./types");
64
+ var Import = __importStar(require("./import.types"));
65
+ exports.excelDefaultMimeType = 'application/vnd.ms-excel';
66
+ exports.mimeTypes = {
67
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
68
+ xlsm: 'application/vnd.ms-excel.sheet.macroEnabled.12',
69
+ xlsb: 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
70
+ xls: 'application/vnd.ms-excel',
71
+ };
46
72
  var XlPort = /** @class */ (function () {
47
73
  function XlPort(config) {
48
74
  this.config = {
49
- url: config.url ? config.url.replace(/\/$/, '') : 'https://xlport.compute.molnify.com',
75
+ url: config.url ? config.url.replace(/\/$/, '') : 'https://api.xlport.io',
50
76
  apiKey: config.apiKey,
51
77
  };
52
78
  }
53
79
  XlPort.prototype.importFromFile = function (file, request) {
54
- if (request === void 0) { request = types_1.defaultImportRequest; }
80
+ if (request === void 0) { request = Import.defaultRequest; }
55
81
  return __awaiter(this, void 0, void 0, function () {
56
82
  var _a, _b;
57
83
  var _c, _d;
@@ -75,7 +101,7 @@ var XlPort = /** @class */ (function () {
75
101
  case 2:
76
102
  _b = {
77
103
  value: file,
78
- options: { filename: 'file.xlsx', contentType: types_1.excelDefaultMimeType },
104
+ options: { filename: 'file.xlsx', contentType: exports.excelDefaultMimeType },
79
105
  };
80
106
  _e.label = 3;
81
107
  case 3: return [2 /*return*/, _a.apply(void 0, [(_c.formData = (_d.file = _b,
@@ -129,7 +155,7 @@ var XlPort = /** @class */ (function () {
129
155
  });
130
156
  };
131
157
  XlPort.prototype.getExcelMimeType = function (path) {
132
- return types_1.mimeTypes[path_1.extname(path)] || types_1.excelDefaultMimeType;
158
+ return exports.mimeTypes[path_1.extname(path)] || exports.excelDefaultMimeType;
133
159
  };
134
160
  XlPort.prototype.loadFile = function (path) {
135
161
  return __awaiter(this, void 0, void 0, function () {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmD;AACnD,mCAA2C;AAC3C,yBAA6B;AAC7B,6BAA8B;AAC9B,6BAAgC;AAEhC,qDAAwC;AAgB3B,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,gBAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,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AAI,CAAC;6BACzC;iCACF;;;;KACF;IACH,aAAC;AAAD,CAAC,AAtFD,IAsFC;AAtFY,wBAAM"}
@@ -0,0 +1,51 @@
1
+ /// <reference types="node" />
2
+ import { ReadStream } from 'fs';
3
+ import * as Shared from './shared.types';
4
+ export declare type Body = FileBody | UrlBody | TemplateIdBody;
5
+ export declare type FileBody = {
6
+ template: Buffer | ReadStream;
7
+ data: DataWithSheets;
8
+ };
9
+ export declare type UrlBody = {
10
+ templateUrl: string;
11
+ data: DataWithSheets;
12
+ };
13
+ export declare type TemplateIdBody = {
14
+ templateId: string;
15
+ data: DataWithSheets;
16
+ };
17
+ export declare type NamedRange = Value;
18
+ export declare type Value = Shared.Scalar | ScalarWithOptions;
19
+ export declare type ScalarWithOptions = {
20
+ data: Shared.Scalar;
21
+ format?: string;
22
+ indent?: IndentLevel;
23
+ };
24
+ export declare type IndentLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
25
+ export declare type ExportTable = TableData | TableWithColumnModifications;
26
+ export declare type TableData = Record<string, Value>[];
27
+ export declare type TableWithColumnModifications = {
28
+ columns: ColumnDefinition[];
29
+ data: TableData;
30
+ };
31
+ export declare type SheetName = string;
32
+ export declare type ColumnName = string;
33
+ export declare type ColumnDefinition = {
34
+ name: ColumnName;
35
+ fromTemplateColumn: ColumnName;
36
+ format?: string;
37
+ indent?: IndentLevel;
38
+ };
39
+ export declare type DataElement = NamedRange | ExportTable;
40
+ export declare type DataWithoutSheets = Record<string, any>;
41
+ export declare type DataWithSheets = DataWithoutSheets & {
42
+ sheets?: Sheet[];
43
+ };
44
+ export declare type Sheet = {
45
+ name: SheetName;
46
+ fromTemplateSheet: SheetName;
47
+ tabColor?: HexColor;
48
+ data: DataWithoutSheets;
49
+ };
50
+ export declare type HexColor = `#${string}`;
51
+ //# sourceMappingURL=export.types.d.ts.map
@@ -0,0 +1 @@
1
+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EAAE,gBAAgB,EAAE,CAAA;IAC3B,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AACD,oBAAY,SAAS,GAAG,MAAM,CAAA;AAC9B,oBAAY,UAAU,GAAG,MAAM,CAAA;AAC/B,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,kBAAkB,EAAE,UAAU,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,oBAAY,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;AAClD,oBAAY,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AACnD,oBAAY,cAAc,GAAG,iBAAiB,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;CAAE,CAAA;AAErE,oBAAY,KAAK,GAAG;IAClB,IAAI,EAAE,SAAS,CAAA;IACf,iBAAiB,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,iBAAiB,CAAA;CACxB,CAAA;AAED,oBAAY,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=export.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.types.js","sourceRoot":"","sources":["../../lib/export.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import * as Shared from './shared.types';
2
+ export declare type Request = {
3
+ properties: string[];
4
+ tables?: Record<string, string[]>[] | ['*'];
5
+ };
6
+ export declare const defaultRequest: Request;
7
+ export declare type Response = Success | Error;
8
+ export interface Error {
9
+ status: 'error';
10
+ message: string;
11
+ }
12
+ export interface Success {
13
+ status: 'success';
14
+ data: ImportData;
15
+ }
16
+ export declare type ImportData = {
17
+ properties?: Record<string, Property>;
18
+ tables?: Record<string, ImportTable | SheetTables>;
19
+ };
20
+ export declare type Property = Shared.Scalar | SheetProperties;
21
+ export declare type SheetProperties = Record<string, Shared.Scalar>;
22
+ export declare type ImportTable = Record<string, Shared.Scalar>[];
23
+ export declare type SheetTables = Record<string, ImportTable>;
24
+ //# sourceMappingURL=import.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.types.d.ts","sourceRoot":"","sources":["../../lib/import.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,oBAAY,OAAO,GAAG;IACpB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,OAG5B,CAAA;AAED,oBAAY,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAA;AAEtC,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,oBAAY,UAAU,GAAG;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC,CAAA;CACnD,CAAA;AACD,oBAAY,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,eAAe,CAAA;AACtD,oBAAY,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;AAC3D,oBAAY,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;AACzD,oBAAY,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultRequest = void 0;
4
+ exports.defaultRequest = {
5
+ properties: ['*'],
6
+ tables: ['*'],
7
+ };
8
+ //# sourceMappingURL=import.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.types.js","sourceRoot":"","sources":["../../lib/import.types.ts"],"names":[],"mappings":";;;AAMa,QAAA,cAAc,GAAY;IACrC,UAAU,EAAE,CAAC,GAAG,CAAC;IACjB,MAAM,EAAE,CAAC,GAAG,CAAC;CACd,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './client';
2
+ export * from './export.types';
3
+ export * from './import.types';
4
+ export * from './shared.types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -11,5 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./client"), exports);
14
- __exportStar(require("./types"), exports);
14
+ __exportStar(require("./export.types"), exports);
15
+ __exportStar(require("./import.types"), exports);
16
+ __exportStar(require("./shared.types"), exports);
15
17
  //# 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"}
@@ -0,0 +1,2 @@
1
+ export declare type Scalar = boolean | string | number | null;
2
+ //# sourceMappingURL=shared.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.types.d.ts","sourceRoot":"","sources":["../../lib/shared.types.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=shared.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.types.js","sourceRoot":"","sources":["../../lib/shared.types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "xlport",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/lib/index.js",
6
+ "types": "dist/lib/index.d.ts",
7
7
  "scripts": {
8
8
  "run": "tsc",
9
9
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -0,0 +1,151 @@
1
+ {
2
+ "templateId": "template.xlsx",
3
+ "data": {
4
+ "CompanyBoolean": false,
5
+ "CompanyFloat": 2141.4,
6
+ "CompanyId": "cid1",
7
+ "CompanyInteger": 252454,
8
+ "CompanyLabel": "Company Name",
9
+ "CompanyLastUpdated": "2019-02-02T00:00:00.000Z",
10
+ "sheets": [
11
+ {
12
+ "name": "Q1",
13
+ "fromTemplateSheet": "Project",
14
+ "tabColor": "#FF0000",
15
+ "data": {
16
+ "ProjectId": "12345",
17
+ "ProjectLabel": "MyLabel",
18
+ "Integer": 42,
19
+ "Float": 37.005,
20
+ "Boolean": true,
21
+ "LastUpdated": "1982-01-25T00:00:00.000Z",
22
+ "MyProjectList": {
23
+ "columns": [
24
+ { "name": "Alpha", "fromTemplateColumn": "Action" },
25
+ { "name": "Beta", "fromTemplateColumn": "Deadline" },
26
+ { "name": "Gamma", "fromTemplateColumn": "Action" },
27
+ { "name": "Delta", "fromTemplateColumn": "Owner" },
28
+ { "name": "TakeTwoShort", "format": "0.0", "fromTemplateColumn": "Owner" },
29
+ { "name": "TakeTwoLong", "format": "0.000", "fromTemplateColumn": "Owner" }
30
+ ],
31
+ "data": [
32
+ {
33
+ "Alpha": "Complete adding tables",
34
+ "Beta": "Add back tables from the template",
35
+ "Gamma": "Markus",
36
+ "Delta": "1",
37
+ "TakeTwoShort": 12.3456,
38
+ "TakeTwoLong": 12.3456
39
+ },
40
+ {
41
+ "Alpha": "Build column magic",
42
+ "Beta": "Create function for moving columns",
43
+ "Gamma": "Milou",
44
+ "Delta": "2",
45
+ "TakeTwoShort": 2.13456,
46
+ "TakeTwoLong": 2.13456
47
+ },
48
+ {
49
+ "Alpha": "Also get import to JSON",
50
+ "Beta": "Take data from Excel to JSON",
51
+ "Gamma": "Amelie",
52
+ "Delta": "3",
53
+ "TakeTwoShort": 6.54321,
54
+ "TakeTwoLong": 6.54321
55
+ },
56
+ {
57
+ "Alpha": "",
58
+ "Beta": "",
59
+ "Gamma": "",
60
+ "Delta": "",
61
+ "TakeTwoShort": 6145.123,
62
+ "TakeTwoLong": 6145.123
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ },
68
+ {
69
+ "name": "Q2",
70
+ "fromTemplateSheet": "Project",
71
+ "tabColor": "#00FF00",
72
+ "data": {
73
+ "ProjectLabel": "Label 2",
74
+ "dummy": "dummy value"
75
+ }
76
+ },
77
+ {
78
+ "name": "Q3",
79
+ "fromTemplateSheet": "Project",
80
+ "tabColor": "#0000FF",
81
+ "data": {
82
+ "ProjectLabel": "Label X",
83
+ "dummy": "dummy value"
84
+ }
85
+ }
86
+ ],
87
+ "Initiatives": [
88
+ {
89
+ "Id": "uuidInitiative1",
90
+ "Name": "Initiative 1",
91
+ "StatusId": "uuidStatus1",
92
+ "SavingsPotential": 123.3,
93
+ "Achievement": 0.12,
94
+ "IsComplete": false,
95
+ "Date": "2018-04-11T00:00:00.000Z",
96
+ "Integer": 1,
97
+ "Calculated column": 146.727
98
+ },
99
+ {
100
+ "Id": "uuidInitiative2",
101
+ "Name": "Initiative 2",
102
+ "StatusId": "uuidStatus2",
103
+ "SavingsPotential": null,
104
+ "Achievement": 0,
105
+ "IsComplete": true,
106
+ "Date": "1966-05-01T00:00:00.000Z",
107
+ "Integer": -246537347,
108
+ "Calculated column": 0
109
+ },
110
+ {
111
+ "Id": "uuidInitiative3",
112
+ "Name": "Initiative 3",
113
+ "StatusId": "uuidStatus3",
114
+ "SavingsPotential": 456,
115
+ "Achievement": 0.2,
116
+ "IsComplete": false,
117
+ "Date": "2020-01-01T00:00:00.000Z",
118
+ "Integer": 1324275242,
119
+ "Calculated column": 542.64
120
+ }
121
+ ],
122
+ "Status": [
123
+ {
124
+ "Id": "uuidStatus1",
125
+ "Label": "On track"
126
+ },
127
+ {
128
+ "Id": "uuidStatus2",
129
+ "Label": "Some progress"
130
+ },
131
+ {
132
+ "Id": "uuidStatus3",
133
+ "Label": "Delayed"
134
+ }
135
+ ],
136
+ "Persons": [
137
+ {
138
+ "Id": "pid1",
139
+ "LastName": "Bolle"
140
+ },
141
+ {
142
+ "Id": "pid2",
143
+ "LastName": "Zwille"
144
+ },
145
+ {
146
+ "Id": "pid3",
147
+ "LastName": "Ralle"
148
+ }
149
+ ]
150
+ }
151
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "templateId": "ignored.xlsx",
3
+ "data": {
4
+ "thedate": "2021-05-09T00:00:00.000Z"
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "apikey": "pass123",
3
+ "templateId": "DAYS calculation bug/template.xlsx",
4
+ "data": {
5
+ "Staffing": [{ "Utilization": 7 }]
6
+ }
7
+ }
@@ -0,0 +1,60 @@
1
+ import * as columnFormattingSource from './column-formatting.json'
2
+ import * as dateSource from './date.json'
3
+ import * as daysSource from './days.json'
4
+ import * as formatsSource from './formats.json'
5
+ import * as formulasAndLookupsSource from './formulas-and-lookups.json'
6
+ import * as multiColumnWithFixedColumnSource from './multi-column-with-fixed-column.json'
7
+ import * as multipleObjectsSource from './multiple-objects.json'
8
+ import * as multipleObjectsAndTablesSource from './multiple-objects-and-tables.json'
9
+ import * as multipleTablesSource from './multiple-tables.json'
10
+ import * as multiSheetColumnFixedTopleftSource from './multi-sheet-column-fixed-topleft.json'
11
+ import * as multiSheetColumnSource from './multi-sheet-column.json'
12
+ import * as multiSheetColumnFixedSource from './multi-sheet-column-fixed.json'
13
+ import * as multiSheetColumnSimpleSource from './multi-sheet-column-simple.json'
14
+ import * as multiSheetColumnSimpleDashSource from './multi-sheet-column-simple-dash.json'
15
+ import * as multiSheetSimpleSource from './multi-sheet-simple.json'
16
+ import * as objectSource from './object.json'
17
+ import * as queryTableSource from './query-table.json'
18
+ import * as queryTableSimpleSource from './query-table-simple.json'
19
+ import * as sheetsSource from './sheets.json'
20
+ import * as tableSource from './table.json'
21
+ import * as tableWithCalculationsSource from './table-with-calculations.json'
22
+ import * as utcSource from './utc.json'
23
+ import type * as Export from '../../lib/export.types'
24
+
25
+ //convert string literal types (e.g. Export.HexColor) to string and literal numbers (e.g. Export.IndentLevel) to number
26
+ type Widen<T> = T extends string
27
+ ? string
28
+ : T extends number
29
+ ? number
30
+ : T extends boolean
31
+ ? boolean
32
+ : T extends Array<infer A>
33
+ ? Array<Widen<A>>
34
+ : T extends Record<infer X, infer Y>
35
+ ? Record<X, Widen<Y>>
36
+ : T
37
+
38
+ type WidenExport = Widen<Export.TemplateIdBody>
39
+ export const columnFormatting: WidenExport = columnFormattingSource
40
+ export const date: Export.TemplateIdBody = dateSource
41
+ export const days: Export.TemplateIdBody = daysSource
42
+ export const formats: WidenExport = formatsSource
43
+ export const formulasAndLookups: Export.TemplateIdBody = formulasAndLookupsSource
44
+ export const multiColumnWithFixedColumn: Export.TemplateIdBody = multiColumnWithFixedColumnSource
45
+ export const multipleObjects: Export.TemplateIdBody = multipleObjectsSource
46
+ export const multipleObjectsAndTables: Export.TemplateIdBody = multipleObjectsAndTablesSource
47
+ export const multipleTables: Export.TemplateIdBody = multipleTablesSource
48
+ export const multiSheetColumnFixedTopleft: WidenExport = multiSheetColumnFixedTopleftSource
49
+ export const multiSheetColumn: WidenExport = multiSheetColumnSource
50
+ export const multiSheetColumnFixed: WidenExport = multiSheetColumnFixedSource
51
+ export const multiSheetColumnSimple: WidenExport = multiSheetColumnSimpleSource
52
+ export const multiSheetColumnSimpleDash: WidenExport = multiSheetColumnSimpleDashSource
53
+ export const multiSheetSimple: WidenExport = multiSheetSimpleSource
54
+ export const object: Export.TemplateIdBody = objectSource
55
+ export const queryTable: Export.TemplateIdBody = queryTableSource
56
+ export const queryTableSimple: Export.TemplateIdBody = queryTableSimpleSource
57
+ export const sheets: Export.TemplateIdBody = sheetsSource
58
+ export const table: Export.TemplateIdBody = tableSource
59
+ export const tableWithCalculations: Export.TemplateIdBody = tableWithCalculationsSource
60
+ export const utc: Export.TemplateIdBody = utcSource