langsmith 0.5.16 → 0.5.18

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 (138) hide show
  1. package/dist/anonymizer/index.cjs +46 -20
  2. package/dist/anonymizer/index.js +46 -17
  3. package/dist/client.cjs +112 -143
  4. package/dist/client.d.ts +19 -40
  5. package/dist/client.js +112 -143
  6. package/dist/experimental/anthropic/index.cjs +4 -1
  7. package/dist/experimental/anthropic/index.js +4 -1
  8. package/dist/experimental/vercel/index.cjs +1 -0
  9. package/dist/experimental/vercel/index.js +1 -0
  10. package/dist/experimental/vercel/middleware.cjs +2 -0
  11. package/dist/experimental/vercel/middleware.js +2 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/schemas.d.ts +1 -3
  16. package/dist/utils/chalk/source/index.cjs +187 -0
  17. package/dist/utils/chalk/source/index.d.ts +19 -0
  18. package/dist/utils/chalk/source/index.js +173 -0
  19. package/dist/utils/chalk/source/utilities.cjs +35 -0
  20. package/dist/utils/chalk/source/utilities.d.ts +2 -0
  21. package/dist/utils/chalk/source/utilities.js +31 -0
  22. package/dist/utils/chalk/source/vendor/ansi-styles/index.cjs +193 -0
  23. package/dist/utils/chalk/source/vendor/ansi-styles/index.d.ts +58 -0
  24. package/dist/utils/chalk/source/vendor/ansi-styles/index.js +190 -0
  25. package/dist/utils/chalk/source/vendor/supports-color/browser.cjs +31 -0
  26. package/dist/utils/chalk/source/vendor/supports-color/browser.d.ts +15 -0
  27. package/dist/utils/chalk/source/vendor/supports-color/browser.js +29 -0
  28. package/dist/utils/chalk/source/vendor/supports-color/index.cjs +155 -0
  29. package/dist/utils/chalk/source/vendor/supports-color/index.d.ts +21 -0
  30. package/dist/utils/chalk/source/vendor/supports-color/index.js +149 -0
  31. package/dist/utils/console-table-printer/index.cjs +11 -0
  32. package/dist/utils/console-table-printer/index.d.ts +4 -0
  33. package/dist/utils/console-table-printer/index.js +3 -0
  34. package/dist/utils/console-table-printer/src/console-table-printer.cjs +42 -0
  35. package/dist/utils/console-table-printer/src/console-table-printer.d.ts +14 -0
  36. package/dist/utils/console-table-printer/src/console-table-printer.js +36 -0
  37. package/dist/utils/console-table-printer/src/internalTable/input-converter.cjs +25 -0
  38. package/dist/utils/console-table-printer/src/internalTable/input-converter.d.ts +6 -0
  39. package/dist/utils/console-table-printer/src/internalTable/input-converter.js +20 -0
  40. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.cjs +142 -0
  41. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.d.ts +6 -0
  42. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.js +133 -0
  43. package/dist/utils/console-table-printer/src/internalTable/internal-table.cjs +186 -0
  44. package/dist/utils/console-table-printer/src/internalTable/internal-table.d.ts +31 -0
  45. package/dist/utils/console-table-printer/src/internalTable/internal-table.js +184 -0
  46. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.cjs +53 -0
  47. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.d.ts +3 -0
  48. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.js +48 -0
  49. package/dist/utils/console-table-printer/src/models/common.cjs +2 -0
  50. package/dist/utils/console-table-printer/src/models/common.d.ts +14 -0
  51. package/dist/utils/console-table-printer/src/models/common.js +1 -0
  52. package/dist/utils/console-table-printer/src/models/external-table.cjs +2 -0
  53. package/dist/utils/console-table-printer/src/models/external-table.d.ts +99 -0
  54. package/dist/utils/console-table-printer/src/models/external-table.js +1 -0
  55. package/dist/utils/console-table-printer/src/models/internal-table.cjs +2 -0
  56. package/dist/utils/console-table-printer/src/models/internal-table.d.ts +24 -0
  57. package/dist/utils/console-table-printer/src/models/internal-table.js +1 -0
  58. package/dist/utils/console-table-printer/src/utils/colored-console-line.cjs +43 -0
  59. package/dist/utils/console-table-printer/src/utils/colored-console-line.d.ts +12 -0
  60. package/dist/utils/console-table-printer/src/utils/colored-console-line.js +39 -0
  61. package/dist/utils/console-table-printer/src/utils/console-utils.cjs +23 -0
  62. package/dist/utils/console-table-printer/src/utils/console-utils.d.ts +3 -0
  63. package/dist/utils/console-table-printer/src/utils/console-utils.js +18 -0
  64. package/dist/utils/console-table-printer/src/utils/string-utils.cjs +68 -0
  65. package/dist/utils/console-table-printer/src/utils/string-utils.d.ts +4 -0
  66. package/dist/utils/console-table-printer/src/utils/string-utils.js +62 -0
  67. package/dist/utils/console-table-printer/src/utils/table-constants.cjs +55 -0
  68. package/dist/utils/console-table-printer/src/utils/table-constants.d.ts +11 -0
  69. package/dist/utils/console-table-printer/src/utils/table-constants.js +52 -0
  70. package/dist/utils/console-table-printer/src/utils/table-helpers.cjs +101 -0
  71. package/dist/utils/console-table-printer/src/utils/table-helpers.d.ts +29 -0
  72. package/dist/utils/console-table-printer/src/utils/table-helpers.js +88 -0
  73. package/dist/utils/jestlike/reporter.cjs +23 -23
  74. package/dist/utils/jestlike/reporter.js +2 -2
  75. package/dist/utils/prompts.cjs +0 -10
  76. package/dist/utils/prompts.d.ts +0 -1
  77. package/dist/utils/prompts.js +0 -9
  78. package/dist/utils/simple-wcswidth/index.cjs +10 -0
  79. package/dist/utils/simple-wcswidth/index.d.ts +3 -0
  80. package/dist/utils/simple-wcswidth/index.js +3 -0
  81. package/dist/utils/simple-wcswidth/src/binary-search.cjs +24 -0
  82. package/dist/utils/simple-wcswidth/src/binary-search.d.ts +3 -0
  83. package/dist/utils/simple-wcswidth/src/binary-search.js +22 -0
  84. package/dist/utils/simple-wcswidth/src/models.cjs +2 -0
  85. package/dist/utils/simple-wcswidth/src/models.d.ts +4 -0
  86. package/dist/utils/simple-wcswidth/src/models.js +1 -0
  87. package/dist/utils/simple-wcswidth/src/non-spacing-chars.cjs +149 -0
  88. package/dist/utils/simple-wcswidth/src/non-spacing-chars.d.ts +3 -0
  89. package/dist/utils/simple-wcswidth/src/non-spacing-chars.js +147 -0
  90. package/dist/utils/simple-wcswidth/src/wcswidth.cjs +20 -0
  91. package/dist/utils/simple-wcswidth/src/wcswidth.d.ts +2 -0
  92. package/dist/utils/simple-wcswidth/src/wcswidth.js +15 -0
  93. package/dist/utils/simple-wcswidth/src/wcwidth.cjs +67 -0
  94. package/dist/utils/simple-wcswidth/src/wcwidth.d.ts +2 -0
  95. package/dist/utils/simple-wcswidth/src/wcwidth.js +62 -0
  96. package/package.json +5 -7
  97. package/dist/utils/lodash/assignValue.cjs +0 -29
  98. package/dist/utils/lodash/assignValue.d.ts +0 -10
  99. package/dist/utils/lodash/assignValue.js +0 -24
  100. package/dist/utils/lodash/baseAssignValue.cjs +0 -25
  101. package/dist/utils/lodash/baseAssignValue.d.ts +0 -11
  102. package/dist/utils/lodash/baseAssignValue.js +0 -23
  103. package/dist/utils/lodash/baseSet.cjs +0 -50
  104. package/dist/utils/lodash/baseSet.d.ts +0 -12
  105. package/dist/utils/lodash/baseSet.js +0 -45
  106. package/dist/utils/lodash/castPath.cjs +0 -22
  107. package/dist/utils/lodash/castPath.d.ts +0 -10
  108. package/dist/utils/lodash/castPath.js +0 -17
  109. package/dist/utils/lodash/eq.cjs +0 -36
  110. package/dist/utils/lodash/eq.d.ts +0 -32
  111. package/dist/utils/lodash/eq.js +0 -34
  112. package/dist/utils/lodash/getTag.cjs +0 -18
  113. package/dist/utils/lodash/getTag.d.ts +0 -9
  114. package/dist/utils/lodash/getTag.js +0 -16
  115. package/dist/utils/lodash/isIndex.cjs +0 -25
  116. package/dist/utils/lodash/isIndex.d.ts +0 -10
  117. package/dist/utils/lodash/isIndex.js +0 -23
  118. package/dist/utils/lodash/isKey.cjs +0 -34
  119. package/dist/utils/lodash/isKey.d.ts +0 -10
  120. package/dist/utils/lodash/isKey.js +0 -29
  121. package/dist/utils/lodash/isObject.cjs +0 -31
  122. package/dist/utils/lodash/isObject.d.ts +0 -25
  123. package/dist/utils/lodash/isObject.js +0 -29
  124. package/dist/utils/lodash/isSymbol.cjs +0 -28
  125. package/dist/utils/lodash/isSymbol.d.ts +0 -17
  126. package/dist/utils/lodash/isSymbol.js +0 -23
  127. package/dist/utils/lodash/memoizeCapped.cjs +0 -65
  128. package/dist/utils/lodash/memoizeCapped.d.ts +0 -50
  129. package/dist/utils/lodash/memoizeCapped.js +0 -63
  130. package/dist/utils/lodash/set.cjs +0 -41
  131. package/dist/utils/lodash/set.d.ts +0 -32
  132. package/dist/utils/lodash/set.js +0 -36
  133. package/dist/utils/lodash/stringToPath.cjs +0 -49
  134. package/dist/utils/lodash/stringToPath.d.ts +0 -12
  135. package/dist/utils/lodash/stringToPath.js +0 -44
  136. package/dist/utils/lodash/toKey.cjs +0 -24
  137. package/dist/utils/lodash/toKey.d.ts +0 -9
  138. package/dist/utils/lodash/toKey.js +0 -19
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const colored_console_line_js_1 = require("../utils/colored-console-line.cjs");
4
+ const table_constants_js_1 = require("../utils/table-constants.cjs");
5
+ const table_helpers_js_1 = require("../utils/table-helpers.cjs");
6
+ const input_converter_js_1 = require("./input-converter.cjs");
7
+ const internal_table_printer_js_1 = require("./internal-table-printer.cjs");
8
+ const DEFAULT_ROW_SORT_FUNC = () => 0;
9
+ const DEFAULT_ROW_FILTER_FUNC = () => true;
10
+ class TableInternal {
11
+ initSimple(columns) {
12
+ this.columns = columns.map((column) => ({
13
+ name: column,
14
+ title: column,
15
+ alignment: table_constants_js_1.DEFAULT_ROW_ALIGNMENT,
16
+ }));
17
+ }
18
+ initDetailed(options) {
19
+ this.title = options?.title || this.title;
20
+ this.tableStyle = {
21
+ ...this.tableStyle,
22
+ ...options?.style,
23
+ };
24
+ this.sortFunction = options?.sort || this.sortFunction;
25
+ this.filterFunction = options?.filter || this.filterFunction;
26
+ this.enabledColumns = options?.enabledColumns || this.enabledColumns;
27
+ this.disabledColumns = options?.disabledColumns || this.disabledColumns;
28
+ this.computedColumns = options?.computedColumns || this.computedColumns;
29
+ this.columns =
30
+ options?.columns?.map((column) => (0, input_converter_js_1.rawColumnToInternalColumn)(column, options?.defaultColumnOptions)) || this.columns;
31
+ this.rowSeparator = options?.rowSeparator || this.rowSeparator;
32
+ this.charLength = options?.charLength || this.charLength;
33
+ this.defaultColumnOptions =
34
+ options?.defaultColumnOptions || this.defaultColumnOptions;
35
+ if (options?.shouldDisableColors) {
36
+ this.colorMap = {};
37
+ }
38
+ else if (options?.colorMap) {
39
+ this.colorMap = { ...this.colorMap, ...options.colorMap };
40
+ }
41
+ if (options.rows !== undefined) {
42
+ this.addRows(options.rows);
43
+ }
44
+ }
45
+ constructor(options) {
46
+ Object.defineProperty(this, "title", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "tableStyle", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "columns", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "rows", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: void 0
69
+ });
70
+ Object.defineProperty(this, "filterFunction", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: void 0
75
+ });
76
+ Object.defineProperty(this, "sortFunction", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: void 0
81
+ });
82
+ Object.defineProperty(this, "enabledColumns", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: void 0
87
+ });
88
+ Object.defineProperty(this, "disabledColumns", {
89
+ enumerable: true,
90
+ configurable: true,
91
+ writable: true,
92
+ value: void 0
93
+ });
94
+ Object.defineProperty(this, "computedColumns", {
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true,
98
+ value: void 0
99
+ });
100
+ Object.defineProperty(this, "rowSeparator", {
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true,
104
+ value: void 0
105
+ });
106
+ Object.defineProperty(this, "colorMap", {
107
+ enumerable: true,
108
+ configurable: true,
109
+ writable: true,
110
+ value: void 0
111
+ });
112
+ Object.defineProperty(this, "charLength", {
113
+ enumerable: true,
114
+ configurable: true,
115
+ writable: true,
116
+ value: void 0
117
+ });
118
+ Object.defineProperty(this, "defaultColumnOptions", {
119
+ enumerable: true,
120
+ configurable: true,
121
+ writable: true,
122
+ value: void 0
123
+ });
124
+ Object.defineProperty(this, "transforms", {
125
+ enumerable: true,
126
+ configurable: true,
127
+ writable: true,
128
+ value: void 0
129
+ });
130
+ // default construction
131
+ this.rows = [];
132
+ this.columns = [];
133
+ this.title = undefined;
134
+ this.tableStyle = table_constants_js_1.DEFAULT_TABLE_STYLE;
135
+ this.filterFunction = DEFAULT_ROW_FILTER_FUNC;
136
+ this.sortFunction = DEFAULT_ROW_SORT_FUNC;
137
+ this.enabledColumns = [];
138
+ this.disabledColumns = [];
139
+ this.computedColumns = [];
140
+ this.rowSeparator = table_constants_js_1.DEFAULT_ROW_SEPARATOR;
141
+ this.colorMap = colored_console_line_js_1.DEFAULT_COLOR_MAP;
142
+ this.charLength = {};
143
+ this.defaultColumnOptions = undefined;
144
+ this.transforms = {};
145
+ if (options instanceof Array) {
146
+ this.initSimple(options);
147
+ }
148
+ else if (typeof options === 'object') {
149
+ this.initDetailed(options);
150
+ }
151
+ }
152
+ createColumnFromRow(text) {
153
+ const colNames = this.columns.map((col) => col.name);
154
+ Object.keys(text).forEach((key) => {
155
+ if (!colNames.includes(key)) {
156
+ this.columns.push((0, input_converter_js_1.rawColumnToInternalColumn)((0, table_helpers_js_1.createColumFromOnlyName)(key), this.defaultColumnOptions));
157
+ }
158
+ });
159
+ }
160
+ addColumn(textOrObj) {
161
+ const columnOptionsFromInput = typeof textOrObj === 'string'
162
+ ? (0, table_helpers_js_1.createColumFromOnlyName)(textOrObj)
163
+ : textOrObj;
164
+ this.columns.push((0, input_converter_js_1.rawColumnToInternalColumn)(columnOptionsFromInput, this.defaultColumnOptions));
165
+ }
166
+ addColumns(toBeInsertedColumns) {
167
+ toBeInsertedColumns.forEach((toBeInsertedColumn) => {
168
+ this.addColumn(toBeInsertedColumn);
169
+ });
170
+ }
171
+ addRow(text, options) {
172
+ this.createColumnFromRow(text);
173
+ this.rows.push((0, table_helpers_js_1.createRow)(options?.color || table_constants_js_1.DEFAULT_ROW_FONT_COLOR, text, options?.separator !== undefined
174
+ ? options?.separator
175
+ : this.rowSeparator));
176
+ }
177
+ addRows(toBeInsertedRows, options) {
178
+ toBeInsertedRows.forEach((toBeInsertedRow) => {
179
+ this.addRow(toBeInsertedRow, options);
180
+ });
181
+ }
182
+ renderTable() {
183
+ return (0, internal_table_printer_js_1.renderTable)(this);
184
+ }
185
+ }
186
+ exports.default = TableInternal;
@@ -0,0 +1,31 @@
1
+ import { CharLengthDict, Dictionary, Row } from '../models/common.js';
2
+ import { ColumnOptionsRaw, ComplexOptions, ComputedColumn, DefaultColumnOptions, RowFilterFunction, RowSortFunction, Valuetransform } from '../models/external-table.js';
3
+ import { Column, TableStyleDetails } from '../models/internal-table.js';
4
+ import { ColorMap } from '../utils/colored-console-line.js';
5
+ import { RowOptions } from '../utils/table-helpers.js';
6
+ declare class TableInternal {
7
+ title?: string;
8
+ tableStyle: TableStyleDetails;
9
+ columns: Column[];
10
+ rows: Row[];
11
+ filterFunction: RowFilterFunction;
12
+ sortFunction: RowSortFunction;
13
+ enabledColumns: string[];
14
+ disabledColumns: string[];
15
+ computedColumns: ComputedColumn[];
16
+ rowSeparator: boolean;
17
+ colorMap: ColorMap;
18
+ charLength: CharLengthDict;
19
+ defaultColumnOptions?: DefaultColumnOptions;
20
+ transforms?: Record<string, Valuetransform>;
21
+ initSimple(columns: string[]): void;
22
+ initDetailed(options: ComplexOptions): void;
23
+ constructor(options?: ComplexOptions | string[]);
24
+ createColumnFromRow(text: Dictionary): void;
25
+ addColumn(textOrObj: string | ComputedColumn | ColumnOptionsRaw): void;
26
+ addColumns(toBeInsertedColumns: string[] | ColumnOptionsRaw[]): void;
27
+ addRow(text: Dictionary, options?: RowOptions): void;
28
+ addRows(toBeInsertedRows: Dictionary[], options?: RowOptions): void;
29
+ renderTable(): string;
30
+ }
31
+ export default TableInternal;
@@ -0,0 +1,184 @@
1
+ import { DEFAULT_COLOR_MAP } from '../utils/colored-console-line.js';
2
+ import { DEFAULT_TABLE_STYLE, DEFAULT_ROW_ALIGNMENT, DEFAULT_ROW_FONT_COLOR, DEFAULT_ROW_SEPARATOR, } from '../utils/table-constants.js';
3
+ import { createColumFromOnlyName, createRow, } from '../utils/table-helpers.js';
4
+ import { rawColumnToInternalColumn } from './input-converter.js';
5
+ import { renderTable } from './internal-table-printer.js';
6
+ const DEFAULT_ROW_SORT_FUNC = () => 0;
7
+ const DEFAULT_ROW_FILTER_FUNC = () => true;
8
+ class TableInternal {
9
+ initSimple(columns) {
10
+ this.columns = columns.map((column) => ({
11
+ name: column,
12
+ title: column,
13
+ alignment: DEFAULT_ROW_ALIGNMENT,
14
+ }));
15
+ }
16
+ initDetailed(options) {
17
+ this.title = options?.title || this.title;
18
+ this.tableStyle = {
19
+ ...this.tableStyle,
20
+ ...options?.style,
21
+ };
22
+ this.sortFunction = options?.sort || this.sortFunction;
23
+ this.filterFunction = options?.filter || this.filterFunction;
24
+ this.enabledColumns = options?.enabledColumns || this.enabledColumns;
25
+ this.disabledColumns = options?.disabledColumns || this.disabledColumns;
26
+ this.computedColumns = options?.computedColumns || this.computedColumns;
27
+ this.columns =
28
+ options?.columns?.map((column) => rawColumnToInternalColumn(column, options?.defaultColumnOptions)) || this.columns;
29
+ this.rowSeparator = options?.rowSeparator || this.rowSeparator;
30
+ this.charLength = options?.charLength || this.charLength;
31
+ this.defaultColumnOptions =
32
+ options?.defaultColumnOptions || this.defaultColumnOptions;
33
+ if (options?.shouldDisableColors) {
34
+ this.colorMap = {};
35
+ }
36
+ else if (options?.colorMap) {
37
+ this.colorMap = { ...this.colorMap, ...options.colorMap };
38
+ }
39
+ if (options.rows !== undefined) {
40
+ this.addRows(options.rows);
41
+ }
42
+ }
43
+ constructor(options) {
44
+ Object.defineProperty(this, "title", {
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true,
48
+ value: void 0
49
+ });
50
+ Object.defineProperty(this, "tableStyle", {
51
+ enumerable: true,
52
+ configurable: true,
53
+ writable: true,
54
+ value: void 0
55
+ });
56
+ Object.defineProperty(this, "columns", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
62
+ Object.defineProperty(this, "rows", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
68
+ Object.defineProperty(this, "filterFunction", {
69
+ enumerable: true,
70
+ configurable: true,
71
+ writable: true,
72
+ value: void 0
73
+ });
74
+ Object.defineProperty(this, "sortFunction", {
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true,
78
+ value: void 0
79
+ });
80
+ Object.defineProperty(this, "enabledColumns", {
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true,
84
+ value: void 0
85
+ });
86
+ Object.defineProperty(this, "disabledColumns", {
87
+ enumerable: true,
88
+ configurable: true,
89
+ writable: true,
90
+ value: void 0
91
+ });
92
+ Object.defineProperty(this, "computedColumns", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
98
+ Object.defineProperty(this, "rowSeparator", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: void 0
103
+ });
104
+ Object.defineProperty(this, "colorMap", {
105
+ enumerable: true,
106
+ configurable: true,
107
+ writable: true,
108
+ value: void 0
109
+ });
110
+ Object.defineProperty(this, "charLength", {
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true,
114
+ value: void 0
115
+ });
116
+ Object.defineProperty(this, "defaultColumnOptions", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: void 0
121
+ });
122
+ Object.defineProperty(this, "transforms", {
123
+ enumerable: true,
124
+ configurable: true,
125
+ writable: true,
126
+ value: void 0
127
+ });
128
+ // default construction
129
+ this.rows = [];
130
+ this.columns = [];
131
+ this.title = undefined;
132
+ this.tableStyle = DEFAULT_TABLE_STYLE;
133
+ this.filterFunction = DEFAULT_ROW_FILTER_FUNC;
134
+ this.sortFunction = DEFAULT_ROW_SORT_FUNC;
135
+ this.enabledColumns = [];
136
+ this.disabledColumns = [];
137
+ this.computedColumns = [];
138
+ this.rowSeparator = DEFAULT_ROW_SEPARATOR;
139
+ this.colorMap = DEFAULT_COLOR_MAP;
140
+ this.charLength = {};
141
+ this.defaultColumnOptions = undefined;
142
+ this.transforms = {};
143
+ if (options instanceof Array) {
144
+ this.initSimple(options);
145
+ }
146
+ else if (typeof options === 'object') {
147
+ this.initDetailed(options);
148
+ }
149
+ }
150
+ createColumnFromRow(text) {
151
+ const colNames = this.columns.map((col) => col.name);
152
+ Object.keys(text).forEach((key) => {
153
+ if (!colNames.includes(key)) {
154
+ this.columns.push(rawColumnToInternalColumn(createColumFromOnlyName(key), this.defaultColumnOptions));
155
+ }
156
+ });
157
+ }
158
+ addColumn(textOrObj) {
159
+ const columnOptionsFromInput = typeof textOrObj === 'string'
160
+ ? createColumFromOnlyName(textOrObj)
161
+ : textOrObj;
162
+ this.columns.push(rawColumnToInternalColumn(columnOptionsFromInput, this.defaultColumnOptions));
163
+ }
164
+ addColumns(toBeInsertedColumns) {
165
+ toBeInsertedColumns.forEach((toBeInsertedColumn) => {
166
+ this.addColumn(toBeInsertedColumn);
167
+ });
168
+ }
169
+ addRow(text, options) {
170
+ this.createColumnFromRow(text);
171
+ this.rows.push(createRow(options?.color || DEFAULT_ROW_FONT_COLOR, text, options?.separator !== undefined
172
+ ? options?.separator
173
+ : this.rowSeparator));
174
+ }
175
+ addRows(toBeInsertedRows, options) {
176
+ toBeInsertedRows.forEach((toBeInsertedRow) => {
177
+ this.addRow(toBeInsertedRow, options);
178
+ });
179
+ }
180
+ renderTable() {
181
+ return renderTable(this);
182
+ }
183
+ }
184
+ export default TableInternal;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preProcessRows = exports.preProcessColumns = void 0;
4
+ const table_helpers_js_1 = require("../utils/table-helpers.cjs");
5
+ // All these functions are ran when renderTable/printTable is called
6
+ const createComputedColumnsIfNecessary = (table) => {
7
+ if (table.computedColumns.length) {
8
+ table.computedColumns.forEach((computedColumn) => {
9
+ // This can happen if renderTable/printTable is called multiple times
10
+ const isColumnAlreadyExists = table.columns.some((col) => col.name === computedColumn.name);
11
+ if (isColumnAlreadyExists) {
12
+ return;
13
+ }
14
+ table.addColumn({
15
+ ...computedColumn,
16
+ ...table.defaultColumnOptions,
17
+ });
18
+ table.rows.forEach((row, index, rowsArray) => {
19
+ const arrayRowText = rowsArray.map((elemInRowsArray) => elemInRowsArray.text);
20
+ row.text[computedColumn.name] = computedColumn.function(row.text, index, arrayRowText);
21
+ });
22
+ });
23
+ }
24
+ };
25
+ const disableColumnsIfNecessary = (table) => {
26
+ if (table.enabledColumns.length) {
27
+ table.columns = table.columns.filter((col) => table.enabledColumns.includes(col.name));
28
+ }
29
+ };
30
+ const enableColumnsIfNecessary = (table) => {
31
+ if (table.disabledColumns.length) {
32
+ table.columns = table.columns.filter((col) => !table.disabledColumns.includes(col.name));
33
+ }
34
+ };
35
+ const findColumnWidth = (table) => {
36
+ table.columns.forEach((column) => {
37
+ column.length = (0, table_helpers_js_1.findLenOfColumn)(column, table.rows, table.charLength);
38
+ });
39
+ };
40
+ const preProcessColumns = (table) => {
41
+ createComputedColumnsIfNecessary(table);
42
+ enableColumnsIfNecessary(table);
43
+ disableColumnsIfNecessary(table);
44
+ findColumnWidth(table);
45
+ };
46
+ exports.preProcessColumns = preProcessColumns;
47
+ const preProcessRows = (table) => {
48
+ const newRows = table.rows
49
+ .filter((r) => table.filterFunction(r.text))
50
+ .sort((r1, r2) => table.sortFunction(r1.text, r2.text));
51
+ table.rows = newRows;
52
+ };
53
+ exports.preProcessRows = preProcessRows;
@@ -0,0 +1,3 @@
1
+ import TableInternal from './internal-table.js';
2
+ export declare const preProcessColumns: (table: TableInternal) => void;
3
+ export declare const preProcessRows: (table: TableInternal) => void;
@@ -0,0 +1,48 @@
1
+ import { findLenOfColumn } from '../utils/table-helpers.js';
2
+ // All these functions are ran when renderTable/printTable is called
3
+ const createComputedColumnsIfNecessary = (table) => {
4
+ if (table.computedColumns.length) {
5
+ table.computedColumns.forEach((computedColumn) => {
6
+ // This can happen if renderTable/printTable is called multiple times
7
+ const isColumnAlreadyExists = table.columns.some((col) => col.name === computedColumn.name);
8
+ if (isColumnAlreadyExists) {
9
+ return;
10
+ }
11
+ table.addColumn({
12
+ ...computedColumn,
13
+ ...table.defaultColumnOptions,
14
+ });
15
+ table.rows.forEach((row, index, rowsArray) => {
16
+ const arrayRowText = rowsArray.map((elemInRowsArray) => elemInRowsArray.text);
17
+ row.text[computedColumn.name] = computedColumn.function(row.text, index, arrayRowText);
18
+ });
19
+ });
20
+ }
21
+ };
22
+ const disableColumnsIfNecessary = (table) => {
23
+ if (table.enabledColumns.length) {
24
+ table.columns = table.columns.filter((col) => table.enabledColumns.includes(col.name));
25
+ }
26
+ };
27
+ const enableColumnsIfNecessary = (table) => {
28
+ if (table.disabledColumns.length) {
29
+ table.columns = table.columns.filter((col) => !table.disabledColumns.includes(col.name));
30
+ }
31
+ };
32
+ const findColumnWidth = (table) => {
33
+ table.columns.forEach((column) => {
34
+ column.length = findLenOfColumn(column, table.rows, table.charLength);
35
+ });
36
+ };
37
+ export const preProcessColumns = (table) => {
38
+ createComputedColumnsIfNecessary(table);
39
+ enableColumnsIfNecessary(table);
40
+ disableColumnsIfNecessary(table);
41
+ findColumnWidth(table);
42
+ };
43
+ export const preProcessRows = (table) => {
44
+ const newRows = table.rows
45
+ .filter((r) => table.filterFunction(r.text))
46
+ .sort((r1, r2) => table.sortFunction(r1.text, r2.text));
47
+ table.rows = newRows;
48
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { ALIGNMENTS, COLORS } from '../utils/table-constants.js';
2
+ export type ALIGNMENT = (typeof ALIGNMENTS)[number];
3
+ export type COLOR = (typeof COLORS)[number];
4
+ export interface Dictionary {
5
+ [key: string]: any;
6
+ }
7
+ export interface CharLengthDict {
8
+ [key: string]: number;
9
+ }
10
+ export interface Row {
11
+ color: COLOR;
12
+ separator: boolean;
13
+ text: Dictionary;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,99 @@
1
+ import { ColorMap } from '../utils/colored-console-line.js';
2
+ import { ALIGNMENT, CharLengthDict, COLOR, Dictionary } from './common.js';
3
+ import { TableStyleDetails as InternalTableStyleDetails } from './internal-table.js';
4
+ export { ALIGNMENT, COLOR };
5
+ export type TableStyleDetails = Partial<InternalTableStyleDetails>;
6
+ export type CellValue = string | number | boolean | undefined | null;
7
+ export type Valuetransform = (cellValue: CellValue) => CellValue;
8
+ /**
9
+ * Configuration options for a table column
10
+ */
11
+ export interface ColumnOptionsRaw {
12
+ /** Unique identifier for the column */
13
+ name: string;
14
+ /** Display name for the column header. If not provided, uses the name property */
15
+ title?: string;
16
+ /** Text alignment within the column: 'left', 'center', or 'right' */
17
+ alignment?: ALIGNMENT;
18
+ /** Text color for the column content */
19
+ color?: COLOR;
20
+ /** Maximum length of text in the column. Longer text will be wrapped to multiple lines */
21
+ maxLen?: number;
22
+ /** Minimum length of text in the column. Shorter text will be padded with spaces */
23
+ minLen?: number;
24
+ /** Value transform, For example 2.00000 => 2.0 */
25
+ transform?: Valuetransform;
26
+ }
27
+ /**
28
+ * Configuration for a computed column that generates values dynamically
29
+ */
30
+ export interface ComputedColumn extends ColumnOptionsRaw {
31
+ /** Function that computes the column value for each row
32
+ * @param arg0 - The current row data object
33
+ * @param index - The index of the current row in the data array
34
+ * @param array - The complete array of row data
35
+ * @returns The computed value for this column
36
+ */
37
+ function: (arg0: Dictionary, index: number, array: Dictionary[]) => CellValue;
38
+ }
39
+ /**
40
+ * Function type for sorting table rows
41
+ * @param row1 - First row to compare
42
+ * @param row2 - Second row to compare
43
+ * @returns Negative number if row1 should come before row2, positive if row2 should come before row1, 0 if equal
44
+ */
45
+ export type RowSortFunction = (row1: Dictionary, row2: Dictionary) => number;
46
+ /**
47
+ * Function type for filtering table rows
48
+ * @param row - The row data to evaluate
49
+ * @returns True if the row should be included, false if it should be filtered out
50
+ */
51
+ export type RowFilterFunction = (row: Dictionary) => boolean;
52
+ /**
53
+ * Default styling options applied to all columns unless overridden
54
+ */
55
+ export interface DefaultColumnOptions {
56
+ /** Default text alignment for all columns */
57
+ alignment?: ALIGNMENT;
58
+ /** Default text color for all columns */
59
+ color?: COLOR;
60
+ /** Default title prefix for all columns */
61
+ title?: string;
62
+ /** Default maximum length for all columns */
63
+ maxLen?: number;
64
+ /** Default minimum length for all columns */
65
+ minLen?: number;
66
+ }
67
+ /**
68
+ * Complete configuration options for table creation and styling
69
+ */
70
+ export interface ComplexOptions {
71
+ /** Table styling configuration including borders and colors */
72
+ style?: TableStyleDetails;
73
+ /** Title displayed at the top of the table */
74
+ title?: string;
75
+ /** Array of column configurations */
76
+ columns?: ColumnOptionsRaw[];
77
+ /** Initial data rows for the table */
78
+ rows?: Dictionary[];
79
+ /** Function to sort rows before display */
80
+ sort?: RowSortFunction;
81
+ /** Function to filter rows before display */
82
+ filter?: RowFilterFunction;
83
+ /** Array of column names to include (all others will be hidden) */
84
+ enabledColumns?: string[];
85
+ /** Array of column names to exclude (these will always be hidden) */
86
+ disabledColumns?: string[];
87
+ /** Array of computed columns that generate values dynamically */
88
+ computedColumns?: ComputedColumn[];
89
+ /** Whether to add separator lines between rows */
90
+ rowSeparator?: boolean;
91
+ /** Whether to disable color output (useful for non-color terminals) */
92
+ shouldDisableColors?: boolean;
93
+ /** Custom color mapping for special characters or values */
94
+ colorMap?: ColorMap;
95
+ /** Custom character length mapping for special characters (e.g., emojis) */
96
+ charLength?: CharLengthDict;
97
+ /** Default options applied to all columns unless overridden */
98
+ defaultColumnOptions?: DefaultColumnOptions;
99
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ import { ALIGNMENT, COLOR } from './common.js';
2
+ import { Valuetransform } from './external-table.js';
3
+ export interface Column {
4
+ name: string;
5
+ title: string;
6
+ alignment?: ALIGNMENT;
7
+ color?: COLOR;
8
+ length?: number;
9
+ minLen?: number;
10
+ maxLen?: number;
11
+ transform?: Valuetransform;
12
+ }
13
+ type TableLineDetailsKeys = 'left' | 'right' | 'mid' | 'other';
14
+ export type TableLineDetails = {
15
+ [key in TableLineDetailsKeys]: string;
16
+ };
17
+ export type TableStyleDetails = {
18
+ headerTop: TableLineDetails;
19
+ headerBottom: TableLineDetails;
20
+ tableBottom: TableLineDetails;
21
+ vertical: string;
22
+ rowSeparator: TableLineDetails;
23
+ };
24
+ export {};