table 6.0.9 → 6.3.1

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 (107) hide show
  1. package/README.md +53 -1
  2. package/dist/src/alignString.d.ts +6 -0
  3. package/dist/src/alignString.js +64 -0
  4. package/dist/src/alignTableData.d.ts +3 -0
  5. package/dist/src/alignTableData.js +21 -0
  6. package/dist/src/calculateCellHeight.d.ts +2 -0
  7. package/dist/src/calculateCellHeight.js +17 -0
  8. package/dist/src/calculateCellWidthIndex.d.ts +6 -0
  9. package/dist/src/calculateCellWidthIndex.js +17 -0
  10. package/dist/src/calculateMaximumColumnWidthIndex.d.ts +6 -0
  11. package/dist/src/calculateMaximumColumnWidthIndex.js +25 -0
  12. package/dist/src/calculateRowHeightIndex.d.ts +6 -0
  13. package/dist/src/calculateRowHeightIndex.js +30 -0
  14. package/dist/src/createStream.d.ts +3 -0
  15. package/dist/src/createStream.js +74 -0
  16. package/dist/src/drawBorder.d.ts +25 -0
  17. package/dist/src/drawBorder.js +55 -0
  18. package/dist/src/drawHorizontalContent.d.ts +11 -0
  19. package/dist/src/drawHorizontalContent.js +19 -0
  20. package/dist/src/drawRow.d.ts +7 -0
  21. package/dist/src/drawRow.js +17 -0
  22. package/dist/src/drawTable.d.ts +3 -0
  23. package/dist/src/drawTable.js +38 -0
  24. package/dist/src/getBorderCharacters.d.ts +3 -0
  25. package/dist/src/getBorderCharacters.js +83 -0
  26. package/dist/{index.js.flow → src/index.d.ts} +2 -6
  27. package/dist/src/index.js +24 -0
  28. package/dist/src/makeConfig.d.ts +8 -0
  29. package/dist/src/makeConfig.js +59 -0
  30. package/dist/src/makeStreamConfig.d.ts +8 -0
  31. package/dist/src/makeStreamConfig.js +60 -0
  32. package/dist/src/mapDataUsingRowHeightIndex.d.ts +3 -0
  33. package/dist/src/mapDataUsingRowHeightIndex.js +27 -0
  34. package/dist/src/padTableData.d.ts +3 -0
  35. package/dist/src/padTableData.js +11 -0
  36. package/dist/src/stringifyTableData.d.ts +3 -0
  37. package/dist/src/stringifyTableData.js +8 -0
  38. package/dist/src/table.d.ts +3 -0
  39. package/dist/src/table.js +28 -0
  40. package/dist/src/truncateTableData.d.ts +6 -0
  41. package/dist/src/truncateTableData.js +20 -0
  42. package/dist/src/types/api.d.ts +100 -0
  43. package/dist/src/types/api.js +3 -0
  44. package/dist/src/types/internal.d.ts +1 -0
  45. package/dist/src/types/internal.js +3 -0
  46. package/dist/src/validateConfig.d.ts +3 -0
  47. package/dist/src/validateConfig.js +27 -0
  48. package/dist/src/validateTableData.d.ts +2 -0
  49. package/dist/src/validateTableData.js +29 -0
  50. package/dist/{validators.js → src/validators.js} +54 -14
  51. package/dist/src/wrapCell.d.ts +9 -0
  52. package/dist/src/wrapCell.js +33 -0
  53. package/dist/src/wrapString.d.ts +10 -0
  54. package/dist/src/wrapString.js +25 -0
  55. package/dist/src/wrapWord.d.ts +2 -0
  56. package/dist/src/wrapWord.js +29 -0
  57. package/package.json +32 -25
  58. package/dist/alignString.js +0 -107
  59. package/dist/alignString.js.flow +0 -97
  60. package/dist/alignTableData.js +0 -34
  61. package/dist/alignTableData.js.flow +0 -21
  62. package/dist/calculateCellHeight.js +0 -37
  63. package/dist/calculateCellHeight.js.flow +0 -24
  64. package/dist/calculateCellWidthIndex.js +0 -27
  65. package/dist/calculateCellWidthIndex.js.flow +0 -17
  66. package/dist/calculateMaximumColumnWidthIndex.js +0 -36
  67. package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
  68. package/dist/calculateRowHeightIndex.js +0 -45
  69. package/dist/calculateRowHeightIndex.js.flow +0 -36
  70. package/dist/createStream.js +0 -124
  71. package/dist/createStream.js.flow +0 -125
  72. package/dist/drawBorder.js +0 -109
  73. package/dist/drawBorder.js.flow +0 -101
  74. package/dist/drawRow.js +0 -25
  75. package/dist/drawRow.js.flow +0 -15
  76. package/dist/drawTable.js +0 -58
  77. package/dist/drawTable.js.flow +0 -53
  78. package/dist/getBorderCharacters.js +0 -118
  79. package/dist/getBorderCharacters.js.flow +0 -120
  80. package/dist/index.js +0 -31
  81. package/dist/makeConfig.js +0 -91
  82. package/dist/makeConfig.js.flow +0 -76
  83. package/dist/makeStreamConfig.js +0 -97
  84. package/dist/makeStreamConfig.js.flow +0 -83
  85. package/dist/mapDataUsingRowHeightIndex.js +0 -41
  86. package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
  87. package/dist/padTableData.js +0 -23
  88. package/dist/padTableData.js.flow +0 -14
  89. package/dist/schemas/config.json +0 -23
  90. package/dist/schemas/shared.json +0 -98
  91. package/dist/schemas/streamConfig.json +0 -20
  92. package/dist/stringifyTableData.js +0 -21
  93. package/dist/stringifyTableData.js.flow +0 -11
  94. package/dist/table.js +0 -109
  95. package/dist/table.js.flow +0 -96
  96. package/dist/truncateTableData.js +0 -29
  97. package/dist/truncateTableData.js.flow +0 -17
  98. package/dist/validateConfig.js +0 -40
  99. package/dist/validateConfig.js.flow +0 -27
  100. package/dist/validateTableData.js +0 -54
  101. package/dist/validateTableData.js.flow +0 -44
  102. package/dist/wrapCell.js +0 -47
  103. package/dist/wrapCell.js.flow +0 -35
  104. package/dist/wrapString.js +0 -39
  105. package/dist/wrapString.js.flow +0 -29
  106. package/dist/wrapWord.js +0 -46
  107. package/dist/wrapWord.js.flow +0 -39
@@ -0,0 +1,24 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getBorderCharacters = exports.createStream = exports.table = void 0;
17
+ const createStream_1 = __importDefault(require("./createStream"));
18
+ exports.createStream = createStream_1.default;
19
+ const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
20
+ exports.getBorderCharacters = getBorderCharacters_1.default;
21
+ const table_1 = __importDefault(require("./table"));
22
+ exports.table = table_1.default;
23
+ __exportStar(require("./types/api"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { TableUserConfig } from './types/api';
2
+ import type { Row, TableConfig } from './types/internal';
3
+ declare const _default: (rows: Row[], userConfig?: TableUserConfig) => TableConfig;
4
+ /**
5
+ * Makes a new configuration object out of the userConfig object
6
+ * using default values for the missing configuration properties.
7
+ */
8
+ export default _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
7
+ const calculateMaximumColumnWidthIndex_1 = __importDefault(require("./calculateMaximumColumnWidthIndex"));
8
+ const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
9
+ const validateConfig_1 = __importDefault(require("./validateConfig"));
10
+ /**
11
+ * Merges user provided border characters with the default border ("honeywell") characters.
12
+ */
13
+ const makeBorder = (border) => {
14
+ return {
15
+ ...getBorderCharacters_1.default('honeywell'),
16
+ ...border,
17
+ };
18
+ };
19
+ /**
20
+ * Creates a configuration for every column using default
21
+ * values for the missing configuration properties.
22
+ */
23
+ const makeColumns = (rows, columns, columnDefault) => {
24
+ const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex_1.default(rows);
25
+ return rows[0].map((_cell, index) => {
26
+ return {
27
+ alignment: 'left',
28
+ paddingLeft: 1,
29
+ paddingRight: 1,
30
+ truncate: Number.POSITIVE_INFINITY,
31
+ width: maximumColumnWidthIndex[index],
32
+ wrapWord: false,
33
+ ...columnDefault,
34
+ ...columns === null || columns === void 0 ? void 0 : columns[index],
35
+ };
36
+ });
37
+ };
38
+ /**
39
+ * Makes a new configuration object out of the userConfig object
40
+ * using default values for the missing configuration properties.
41
+ */
42
+ exports.default = (rows, userConfig = {}) => {
43
+ var _a, _b, _c;
44
+ validateConfig_1.default('config.json', userConfig);
45
+ const config = lodash_clonedeep_1.default(userConfig);
46
+ return {
47
+ ...config,
48
+ border: makeBorder(config.border),
49
+ columns: makeColumns(rows, config.columns, config.columnDefault),
50
+ drawHorizontalLine: (_a = config.drawHorizontalLine) !== null && _a !== void 0 ? _a : (() => {
51
+ return true;
52
+ }),
53
+ drawVerticalLine: (_b = config.drawVerticalLine) !== null && _b !== void 0 ? _b : (() => {
54
+ return true;
55
+ }),
56
+ singleLine: (_c = config.singleLine) !== null && _c !== void 0 ? _c : false,
57
+ };
58
+ };
59
+ //# sourceMappingURL=makeConfig.js.map
@@ -0,0 +1,8 @@
1
+ import type { StreamUserConfig } from './types/api';
2
+ import type { StreamConfig } from './types/internal';
3
+ declare const _default: (userConfig: StreamUserConfig) => StreamConfig;
4
+ /**
5
+ * Makes a new configuration object out of the userConfig object
6
+ * using default values for the missing configuration properties.
7
+ */
8
+ export default _default;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
7
+ const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
8
+ const validateConfig_1 = __importDefault(require("./validateConfig"));
9
+ /**
10
+ * Merges user provided border characters with the default border ("honeywell") characters.
11
+ *
12
+ */
13
+ const makeBorder = (border) => {
14
+ return {
15
+ ...getBorderCharacters_1.default('honeywell'),
16
+ ...border,
17
+ };
18
+ };
19
+ /**
20
+ * Creates a configuration for every column using default
21
+ * values for the missing configuration properties.
22
+ */
23
+ const makeColumns = (columnCount, columns = {}, columnDefault) => {
24
+ return Array.from({ length: columnCount }).map((_, index) => {
25
+ return {
26
+ alignment: 'left',
27
+ paddingLeft: 1,
28
+ paddingRight: 1,
29
+ truncate: Number.POSITIVE_INFINITY,
30
+ wrapWord: false,
31
+ ...columnDefault,
32
+ ...columns[index],
33
+ };
34
+ });
35
+ };
36
+ /**
37
+ * Makes a new configuration object out of the userConfig object
38
+ * using default values for the missing configuration properties.
39
+ */
40
+ exports.default = (userConfig) => {
41
+ var _a;
42
+ validateConfig_1.default('streamConfig.json', userConfig);
43
+ const config = lodash_clonedeep_1.default(userConfig);
44
+ if (!config.columnDefault || !config.columnDefault.width) {
45
+ throw new Error('Must provide config.columnDefault.width when creating a stream.');
46
+ }
47
+ if (!config.columnCount) {
48
+ throw new Error('Must provide config.columnCount.');
49
+ }
50
+ return {
51
+ ...config,
52
+ border: makeBorder(config.border),
53
+ columnCount: config.columnCount,
54
+ columns: makeColumns(config.columnCount, config.columns, config.columnDefault),
55
+ drawVerticalLine: (_a = config.drawVerticalLine) !== null && _a !== void 0 ? _a : (() => {
56
+ return true;
57
+ }),
58
+ };
59
+ };
60
+ //# sourceMappingURL=makeStreamConfig.js.map
@@ -0,0 +1,3 @@
1
+ import type { BaseConfig, Row } from './types/internal';
2
+ declare const _default: (unmappedRows: Row[], rowHeightIndex: number[], config: BaseConfig) => Row[];
3
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
7
+ const wrapCell_1 = __importDefault(require("./wrapCell"));
8
+ exports.default = (unmappedRows, rowHeightIndex, config) => {
9
+ const tableWidth = unmappedRows[0].length;
10
+ const mappedRows = unmappedRows.map((row, index0) => {
11
+ const rowHeight = Array.from({ length: rowHeightIndex[index0] }, () => {
12
+ return new Array(tableWidth).fill('');
13
+ });
14
+ // rowHeight
15
+ // [{row index within rowSaw; index2}]
16
+ // [{cell index within a virtual row; index1}]
17
+ row.forEach((cell, index1) => {
18
+ const cellLines = wrapCell_1.default(cell, config.columns[index1].width, config.columns[index1].wrapWord);
19
+ cellLines.forEach((cellLine, index2) => {
20
+ rowHeight[index2][index1] = cellLine;
21
+ });
22
+ });
23
+ return rowHeight;
24
+ });
25
+ return lodash_flatten_1.default(mappedRows);
26
+ };
27
+ //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
@@ -0,0 +1,3 @@
1
+ import type { BaseConfig, Row } from './types/internal';
2
+ declare const _default: (rows: Row[], config: BaseConfig) => Row[];
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows, config) => {
4
+ return rows.map((cells) => {
5
+ return cells.map((value, index1) => {
6
+ const column = config.columns[index1];
7
+ return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
8
+ });
9
+ });
10
+ };
11
+ //# sourceMappingURL=padTableData.js.map
@@ -0,0 +1,3 @@
1
+ import type { Row } from './types/internal';
2
+ declare const _default: (rows: unknown[][]) => Row[];
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows) => {
4
+ return rows.map((cells) => {
5
+ return cells.map(String);
6
+ });
7
+ };
8
+ //# sourceMappingURL=stringifyTableData.js.map
@@ -0,0 +1,3 @@
1
+ import type { TableUserConfig } from './types/api';
2
+ declare const _default: (data: unknown[][], userConfig?: TableUserConfig) => string;
3
+ export default _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const alignTableData_1 = __importDefault(require("./alignTableData"));
7
+ const calculateCellWidthIndex_1 = __importDefault(require("./calculateCellWidthIndex"));
8
+ const calculateRowHeightIndex_1 = __importDefault(require("./calculateRowHeightIndex"));
9
+ const drawTable_1 = __importDefault(require("./drawTable"));
10
+ const makeConfig_1 = __importDefault(require("./makeConfig"));
11
+ const mapDataUsingRowHeightIndex_1 = __importDefault(require("./mapDataUsingRowHeightIndex"));
12
+ const padTableData_1 = __importDefault(require("./padTableData"));
13
+ const stringifyTableData_1 = __importDefault(require("./stringifyTableData"));
14
+ const truncateTableData_1 = __importDefault(require("./truncateTableData"));
15
+ const validateTableData_1 = __importDefault(require("./validateTableData"));
16
+ exports.default = (data, userConfig = {}) => {
17
+ validateTableData_1.default(data);
18
+ let rows = stringifyTableData_1.default(data);
19
+ const config = makeConfig_1.default(rows, userConfig);
20
+ rows = truncateTableData_1.default(rows, config);
21
+ const rowHeightIndex = calculateRowHeightIndex_1.default(rows, config);
22
+ rows = mapDataUsingRowHeightIndex_1.default(rows, rowHeightIndex, config);
23
+ rows = alignTableData_1.default(rows, config);
24
+ rows = padTableData_1.default(rows, config);
25
+ const cellWidthIndex = calculateCellWidthIndex_1.default(rows[0]);
26
+ return drawTable_1.default(rows, cellWidthIndex, rowHeightIndex, config);
27
+ };
28
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1,6 @@
1
+ import type { BaseConfig, Row } from './types/internal';
2
+ declare const _default: (rows: Row[], config: BaseConfig) => Row[];
3
+ /**
4
+ * @todo Make it work with ASCII content.
5
+ */
6
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_truncate_1 = __importDefault(require("lodash.truncate"));
7
+ /**
8
+ * @todo Make it work with ASCII content.
9
+ */
10
+ exports.default = (rows, config) => {
11
+ return rows.map((cells) => {
12
+ return cells.map((content, index) => {
13
+ return lodash_truncate_1.default(content, {
14
+ length: config.columns[index].truncate,
15
+ omission: '…',
16
+ });
17
+ });
18
+ });
19
+ };
20
+ //# sourceMappingURL=truncateTableData.js.map
@@ -0,0 +1,100 @@
1
+ export declare type DrawLinePredicate = (index: number, size: number) => boolean;
2
+ export declare type DrawVerticalLine = DrawLinePredicate;
3
+ export declare type DrawHorizontalLine = DrawLinePredicate;
4
+ export declare type BorderUserConfig = {
5
+ readonly topLeft?: string;
6
+ readonly topRight?: string;
7
+ readonly topBody?: string;
8
+ readonly topJoin?: string;
9
+ readonly bottomLeft?: string;
10
+ readonly bottomRight?: string;
11
+ readonly bottomBody?: string;
12
+ readonly bottomJoin?: string;
13
+ readonly bodyRight?: string;
14
+ readonly bodyLeft?: string;
15
+ readonly bodyJoin?: string;
16
+ readonly joinLeft?: string;
17
+ readonly joinRight?: string;
18
+ readonly joinBody?: string;
19
+ readonly joinJoin?: string;
20
+ };
21
+ export declare type BorderConfig = Required<BorderUserConfig>;
22
+ export declare type ColumnUserConfig = {
23
+ /**
24
+ * Cell content horizontal alignment (default: left)
25
+ */
26
+ readonly alignment?: 'center' | 'left' | 'right';
27
+ /**
28
+ * Column width (default: auto calculation based on the cell content)
29
+ */
30
+ readonly width?: number;
31
+ /**
32
+ * Number of characters are which the content will be truncated (default: Infinity)
33
+ */
34
+ readonly truncate?: number;
35
+ /**
36
+ * Cell content padding width left (default: 1)
37
+ */
38
+ readonly paddingLeft?: number;
39
+ /**
40
+ * Cell content padding width right (default: 1)
41
+ */
42
+ readonly paddingRight?: number;
43
+ /**
44
+ * If true, the text is broken at the nearest space or one of the special characters: "\|/_.,;-"
45
+ */
46
+ readonly wrapWord?: boolean;
47
+ };
48
+ export declare type BaseUserConfig = {
49
+ /**
50
+ * Custom border
51
+ */
52
+ readonly border?: BorderUserConfig;
53
+ /**
54
+ * Default values for all columns. Column specific settings overwrite the default values.
55
+ */
56
+ readonly columnDefault?: ColumnUserConfig;
57
+ /**
58
+ * Column specific configuration.
59
+ */
60
+ readonly columns?: Indexable<ColumnUserConfig>;
61
+ /**
62
+ * Used to tell whether to draw a vertical line.
63
+ * This callback is called for each non-content line of the table.
64
+ * The default behavior is to always return true.
65
+ */
66
+ readonly drawVerticalLine?: DrawVerticalLine;
67
+ };
68
+ export declare type TableUserConfig = BaseUserConfig & {
69
+ /**
70
+ * Used to tell whether to draw a horizontal line.
71
+ * This callback is called for each non-content line of the table.
72
+ * The default behavior is to always return true.
73
+ */
74
+ readonly drawHorizontalLine?: DrawHorizontalLine;
75
+ /**
76
+ * Horizontal lines inside the table are not drawn.
77
+ */
78
+ readonly singleLine?: boolean;
79
+ };
80
+ export declare type StreamUserConfig = BaseUserConfig & {
81
+ /**
82
+ * The number of columns
83
+ */
84
+ readonly columnCount: number;
85
+ /**
86
+ * Default values for all columns. Column specific settings overwrite the default values.
87
+ */
88
+ readonly columnDefault: ColumnUserConfig & {
89
+ /**
90
+ * The default width for each column
91
+ */
92
+ readonly width: number;
93
+ };
94
+ };
95
+ export declare type WritableStream = {
96
+ readonly write: (rows: string[]) => void;
97
+ };
98
+ export declare type Indexable<T> = {
99
+ readonly [index: number]: T;
100
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1,3 @@
1
+ import type { TableUserConfig } from './types/api';
2
+ declare const _default: (schemaId: string, config: TableUserConfig) => void;
3
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-expect-error
8
+ // eslint-disable-next-line import/no-unresolved
9
+ const validators_1 = __importDefault(require("./validators"));
10
+ exports.default = (schemaId, config) => {
11
+ const validate = validators_1.default[schemaId];
12
+ if (!validate(config)) {
13
+ const errors = validate.errors.map((error) => {
14
+ return {
15
+ message: error.message,
16
+ params: error.params,
17
+ schemaPath: error.schemaPath,
18
+ };
19
+ });
20
+ /* eslint-disable no-console */
21
+ console.log('config', config);
22
+ console.log('errors', errors);
23
+ /* eslint-enable no-console */
24
+ throw new Error('Invalid config.');
25
+ }
26
+ };
27
+ //# sourceMappingURL=validateConfig.js.map
@@ -0,0 +1,2 @@
1
+ declare const _default: (rows: unknown[][]) => void;
2
+ export default _default;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows) => {
4
+ if (!Array.isArray(rows)) {
5
+ throw new TypeError('Table data must be an array.');
6
+ }
7
+ if (rows.length === 0) {
8
+ throw new Error('Table must define at least one row.');
9
+ }
10
+ if (rows[0].length === 0) {
11
+ throw new Error('Table must define at least one column.');
12
+ }
13
+ const columnNumber = rows[0].length;
14
+ for (const row of rows) {
15
+ if (!Array.isArray(row)) {
16
+ throw new TypeError('Table row data must be an array.');
17
+ }
18
+ if (row.length !== columnNumber) {
19
+ throw new Error('Table must have a consistent number of cells.');
20
+ }
21
+ for (const cell of row) {
22
+ // eslint-disable-next-line no-control-regex
23
+ if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(cell)) {
24
+ throw new Error('Table data must not contain control characters.');
25
+ }
26
+ }
27
+ }
28
+ };
29
+ //# sourceMappingURL=validateTableData.js.map
@@ -14,6 +14,9 @@ const schema13 = {
14
14
  "columnDefault": {
15
15
  "$ref": "shared.json#/definitions/column"
16
16
  },
17
+ "drawVerticalLine": {
18
+ "typeof": "function"
19
+ },
17
20
  "drawHorizontalLine": {
18
21
  "typeof": "function"
19
22
  },
@@ -801,7 +804,7 @@ function validate43(data, {
801
804
  let errors = 0;
802
805
  if (data && typeof data == "object" && !Array.isArray(data)) {
803
806
  for (const key0 in data) {
804
- if (!(((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) {
807
+ if (!((((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawVerticalLine")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) {
805
808
  const err0 = {
806
809
  instancePath,
807
810
  schemaPath: "#/additionalProperties",
@@ -852,9 +855,26 @@ function validate43(data, {
852
855
  errors = vErrors.length;
853
856
  }
854
857
  }
858
+ if (data.drawVerticalLine !== undefined) {
859
+ if (typeof data.drawVerticalLine != "function") {
860
+ const err1 = {
861
+ instancePath: instancePath + "/drawVerticalLine",
862
+ schemaPath: "#/properties/drawVerticalLine/typeof",
863
+ keyword: "typeof",
864
+ params: {},
865
+ message: "should pass \"typeof\" keyword validation"
866
+ };
867
+ if (vErrors === null) {
868
+ vErrors = [err1];
869
+ } else {
870
+ vErrors.push(err1);
871
+ }
872
+ errors++;
873
+ }
874
+ }
855
875
  if (data.drawHorizontalLine !== undefined) {
856
876
  if (typeof data.drawHorizontalLine != "function") {
857
- const err1 = {
877
+ const err2 = {
858
878
  instancePath: instancePath + "/drawHorizontalLine",
859
879
  schemaPath: "#/properties/drawHorizontalLine/typeof",
860
880
  keyword: "typeof",
@@ -862,16 +882,16 @@ function validate43(data, {
862
882
  message: "should pass \"typeof\" keyword validation"
863
883
  };
864
884
  if (vErrors === null) {
865
- vErrors = [err1];
885
+ vErrors = [err2];
866
886
  } else {
867
- vErrors.push(err1);
887
+ vErrors.push(err2);
868
888
  }
869
889
  errors++;
870
890
  }
871
891
  }
872
892
  if (data.singleLine !== undefined) {
873
893
  if (typeof data.singleLine != "boolean") {
874
- const err2 = {
894
+ const err3 = {
875
895
  instancePath: instancePath + "/singleLine",
876
896
  schemaPath: "#/properties/singleLine/typeof",
877
897
  keyword: "typeof",
@@ -879,15 +899,15 @@ function validate43(data, {
879
899
  message: "should pass \"typeof\" keyword validation"
880
900
  };
881
901
  if (vErrors === null) {
882
- vErrors = [err2];
902
+ vErrors = [err3];
883
903
  } else {
884
- vErrors.push(err2);
904
+ vErrors.push(err3);
885
905
  }
886
906
  errors++;
887
907
  }
888
908
  }
889
909
  } else {
890
- const err3 = {
910
+ const err4 = {
891
911
  instancePath,
892
912
  schemaPath: "#/type",
893
913
  keyword: "type",
@@ -897,9 +917,9 @@ function validate43(data, {
897
917
  message: "must be object"
898
918
  };
899
919
  if (vErrors === null) {
900
- vErrors = [err3];
920
+ vErrors = [err4];
901
921
  } else {
902
- vErrors.push(err3);
922
+ vErrors.push(err4);
903
923
  }
904
924
  errors++;
905
925
  }
@@ -923,6 +943,9 @@ const schema20 = {
923
943
  },
924
944
  "columnCount": {
925
945
  "type": "number"
946
+ },
947
+ "drawVerticalLine": {
948
+ "typeof": "function"
926
949
  }
927
950
  },
928
951
  "additionalProperties": false
@@ -1400,7 +1423,7 @@ function validate69(data, {
1400
1423
  let errors = 0;
1401
1424
  if (data && typeof data == "object" && !Array.isArray(data)) {
1402
1425
  for (const key0 in data) {
1403
- if (!((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "columnCount"))) {
1426
+ if (!(((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "columnCount")) || (key0 === "drawVerticalLine"))) {
1404
1427
  const err0 = {
1405
1428
  instancePath,
1406
1429
  schemaPath: "#/additionalProperties",
@@ -1471,8 +1494,25 @@ function validate69(data, {
1471
1494
  errors++;
1472
1495
  }
1473
1496
  }
1497
+ if (data.drawVerticalLine !== undefined) {
1498
+ if (typeof data.drawVerticalLine != "function") {
1499
+ const err2 = {
1500
+ instancePath: instancePath + "/drawVerticalLine",
1501
+ schemaPath: "#/properties/drawVerticalLine/typeof",
1502
+ keyword: "typeof",
1503
+ params: {},
1504
+ message: "should pass \"typeof\" keyword validation"
1505
+ };
1506
+ if (vErrors === null) {
1507
+ vErrors = [err2];
1508
+ } else {
1509
+ vErrors.push(err2);
1510
+ }
1511
+ errors++;
1512
+ }
1513
+ }
1474
1514
  } else {
1475
- const err2 = {
1515
+ const err3 = {
1476
1516
  instancePath,
1477
1517
  schemaPath: "#/type",
1478
1518
  keyword: "type",
@@ -1482,9 +1522,9 @@ function validate69(data, {
1482
1522
  message: "must be object"
1483
1523
  };
1484
1524
  if (vErrors === null) {
1485
- vErrors = [err2];
1525
+ vErrors = [err3];
1486
1526
  } else {
1487
- vErrors.push(err2);
1527
+ vErrors.push(err3);
1488
1528
  }
1489
1529
  errors++;
1490
1530
  }
@@ -0,0 +1,9 @@
1
+ declare const _default: (cellValue: string, columnWidth: number, useWrapWord: boolean) => string[];
2
+ /**
3
+ * Wrap a single cell value into a list of lines
4
+ *
5
+ * Always wraps on newlines, for the remainder uses either word or string wrapping
6
+ * depending on user configuration.
7
+ *
8
+ */
9
+ export default _default;