@deephaven/jsapi-utils 0.12.1-beta.6

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 (59) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +23 -0
  3. package/dist/DateUtils.d.ts +82 -0
  4. package/dist/DateUtils.d.ts.map +1 -0
  5. package/dist/DateUtils.js +284 -0
  6. package/dist/DateUtils.js.map +1 -0
  7. package/dist/Formatter.d.ts +65 -0
  8. package/dist/Formatter.d.ts.map +1 -0
  9. package/dist/Formatter.js +166 -0
  10. package/dist/Formatter.js.map +1 -0
  11. package/dist/FormatterUtils.d.ts +24 -0
  12. package/dist/FormatterUtils.d.ts.map +1 -0
  13. package/dist/FormatterUtils.js +40 -0
  14. package/dist/FormatterUtils.js.map +1 -0
  15. package/dist/TableUtils.d.ts +194 -0
  16. package/dist/TableUtils.d.ts.map +1 -0
  17. package/dist/TableUtils.js +1326 -0
  18. package/dist/TableUtils.js.map +1 -0
  19. package/dist/formatters/BooleanColumnFormatter.d.ts +7 -0
  20. package/dist/formatters/BooleanColumnFormatter.d.ts.map +1 -0
  21. package/dist/formatters/BooleanColumnFormatter.js +26 -0
  22. package/dist/formatters/BooleanColumnFormatter.js.map +1 -0
  23. package/dist/formatters/CharColumnFormatter.d.ts +7 -0
  24. package/dist/formatters/CharColumnFormatter.d.ts.map +1 -0
  25. package/dist/formatters/CharColumnFormatter.js +15 -0
  26. package/dist/formatters/CharColumnFormatter.js.map +1 -0
  27. package/dist/formatters/DateTimeColumnFormatter.d.ts +40 -0
  28. package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -0
  29. package/dist/formatters/DateTimeColumnFormatter.js +123 -0
  30. package/dist/formatters/DateTimeColumnFormatter.js.map +1 -0
  31. package/dist/formatters/DecimalColumnFormatter.d.ts +64 -0
  32. package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -0
  33. package/dist/formatters/DecimalColumnFormatter.js +128 -0
  34. package/dist/formatters/DecimalColumnFormatter.js.map +1 -0
  35. package/dist/formatters/DefaultColumnFormatter.d.ts +6 -0
  36. package/dist/formatters/DefaultColumnFormatter.d.ts.map +1 -0
  37. package/dist/formatters/DefaultColumnFormatter.js +14 -0
  38. package/dist/formatters/DefaultColumnFormatter.js.map +1 -0
  39. package/dist/formatters/IntegerColumnFormatter.d.ts +60 -0
  40. package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -0
  41. package/dist/formatters/IntegerColumnFormatter.js +121 -0
  42. package/dist/formatters/IntegerColumnFormatter.js.map +1 -0
  43. package/dist/formatters/StringColumnFormatter.d.ts +7 -0
  44. package/dist/formatters/StringColumnFormatter.d.ts.map +1 -0
  45. package/dist/formatters/StringColumnFormatter.js +12 -0
  46. package/dist/formatters/StringColumnFormatter.js.map +1 -0
  47. package/dist/formatters/TableColumnFormatter.d.ts +44 -0
  48. package/dist/formatters/TableColumnFormatter.d.ts.map +1 -0
  49. package/dist/formatters/TableColumnFormatter.js +65 -0
  50. package/dist/formatters/TableColumnFormatter.js.map +1 -0
  51. package/dist/formatters/index.d.ts +10 -0
  52. package/dist/formatters/index.d.ts.map +1 -0
  53. package/dist/formatters/index.js +10 -0
  54. package/dist/formatters/index.js.map +1 -0
  55. package/dist/index.d.ts +6 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +6 -0
  58. package/dist/index.js.map +1 -0
  59. package/package.json +45 -0
@@ -0,0 +1,65 @@
1
+ import { DataType } from './TableUtils';
2
+ import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter, TableColumnFormat, TableColumnFormatter } from './formatters';
3
+ declare type ColumnName = string;
4
+ export interface FormattingRule {
5
+ columnType: string;
6
+ columnName: string;
7
+ format: TableColumnFormat;
8
+ }
9
+ export declare class Formatter {
10
+ /**
11
+ * Converts FormattingRule[] to Map
12
+ * @param columnFormattingRules Array or column formatting rules
13
+ * @returns Map of columnName-to-format Maps indexed by normalized dataType
14
+ */
15
+ static makeColumnFormatMap(columnFormattingRules: FormattingRule[]): Map<DataType, Map<ColumnName, TableColumnFormat>>;
16
+ /**
17
+ * Creates a column formatting rule
18
+ * @param columnType Normalized data type
19
+ * @param columnName Column name
20
+ * @param format Format object
21
+ */
22
+ static makeColumnFormattingRule(columnType: DataType, columnName: string, format: TableColumnFormat): FormattingRule;
23
+ /**
24
+ * @param columnFormattingRules Optional array of column formatting rules
25
+ * @param dateTimeOptions Optional object with DateTime configuration
26
+ * @param decimalFormatOptions Optional object with Decimal configuration
27
+ * @param integerFormatOptions Optional object with Integer configuration
28
+ * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
29
+ */
30
+ constructor(columnFormattingRules?: FormattingRule[], dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0], decimalFormatOptions?: ConstructorParameters<typeof DecimalColumnFormatter>[0], integerFormatOptions?: ConstructorParameters<typeof IntegerColumnFormatter>[0], truncateNumbersWithPound?: boolean);
31
+ defaultColumnFormatter: TableColumnFormatter;
32
+ typeFormatterMap: Map<DataType, TableColumnFormatter>;
33
+ columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;
34
+ truncateNumbersWithPound: boolean;
35
+ /**
36
+ * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
37
+ * @param columnType column type
38
+ * @param createIfNecessary create new entry if true
39
+ * @returns Map of format strings indexed by column name or undefined if it doesn't exist
40
+ */
41
+ getColumnFormatMapForType(columnType: string, createIfNecessary?: boolean): Map<string, TableColumnFormat> | undefined;
42
+ /**
43
+ * Gets a column format object for a given column type and name
44
+ * @param columnType column type
45
+ * @param columnName column name
46
+ * @returns format object or null for Default
47
+ */
48
+ getColumnFormat(columnType: string, columnName: string): TableColumnFormat | null;
49
+ getColumnTypeFormatter(columnType: string): TableColumnFormatter;
50
+ /**
51
+ * Gets formatted string for a given value, column type and name
52
+ * @param value Value to format
53
+ * @param columnType Column type used to determine the formatting settings
54
+ * @param columnName Column name used to determine the formatting settings
55
+ * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
56
+ */
57
+ getFormattedString(value: unknown, columnType: string, columnName?: string, formatOverride?: TableColumnFormat): string;
58
+ /**
59
+ * Gets the timeZone name
60
+ * @returns The time zone name E.g. America/New_York
61
+ */
62
+ get timeZone(): string;
63
+ }
64
+ export default Formatter;
65
+ //# sourceMappingURL=Formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Formatter.d.ts","sourceRoot":"","sources":["../src/Formatter.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,uBAAuB,EACvB,sBAAsB,EAEtB,sBAAsB,EAEtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB,aAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CACxB,qBAAqB,EAAE,cAAc,EAAE,GACtC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IAmBpD;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAC7B,UAAU,EAAE,QAAQ,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,GACxB,cAAc;IAQjB;;;;;;OAMG;gBAED,qBAAqB,GAAE,cAAc,EAAO,EAC5C,eAAe,CAAC,EAAE,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,EAC1E,oBAAoB,CAAC,EAAE,qBAAqB,CAC1C,OAAO,sBAAsB,CAC9B,CAAC,CAAC,CAAC,EACJ,oBAAoB,CAAC,EAAE,qBAAqB,CAC1C,OAAO,sBAAsB,CAC9B,CAAC,CAAC,CAAC,EACJ,wBAAwB,UAAQ;IAiClC,sBAAsB,EAAE,oBAAoB,CAAC;IAE7C,gBAAgB,EAAE,GAAG,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEtD,eAAe,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAE/D,wBAAwB,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;IACH,yBAAyB,CACvB,UAAU,EAAE,MAAM,EAClB,iBAAiB,UAAQ,GACxB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAY7C;;;;;OAKG;IACH,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,iBAAiB,GAAG,IAAI;IAK3B,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAUhE;;;;;;OAMG;IACH,kBAAkB,CAChB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,EACf,cAAc,CAAC,EAAE,iBAAiB,GACjC,MAAM;IAYT;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAKrB;CACF;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,166 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import TableUtils from "./TableUtils.js";
4
+ import { BooleanColumnFormatter, CharColumnFormatter, DateTimeColumnFormatter, DecimalColumnFormatter, DefaultColumnFormatter, IntegerColumnFormatter, StringColumnFormatter } from "./formatters/index.js";
5
+ export class Formatter {
6
+ /**
7
+ * Converts FormattingRule[] to Map
8
+ * @param columnFormattingRules Array or column formatting rules
9
+ * @returns Map of columnName-to-format Maps indexed by normalized dataType
10
+ */
11
+ static makeColumnFormatMap(columnFormattingRules) {
12
+ if (columnFormattingRules == null) {
13
+ return new Map();
14
+ }
15
+
16
+ return columnFormattingRules.reduce((map, next) => {
17
+ var dataType = TableUtils.getNormalizedType(next.columnType);
18
+
19
+ if (dataType === null) {
20
+ return map;
21
+ }
22
+
23
+ if (!map.has(dataType)) {
24
+ map.set(dataType, new Map());
25
+ }
26
+
27
+ var formatMap = map.get(dataType);
28
+ formatMap === null || formatMap === void 0 ? void 0 : formatMap.set(next.columnName, next.format);
29
+ return map;
30
+ }, new Map());
31
+ }
32
+ /**
33
+ * Creates a column formatting rule
34
+ * @param columnType Normalized data type
35
+ * @param columnName Column name
36
+ * @param format Format object
37
+ */
38
+
39
+
40
+ static makeColumnFormattingRule(columnType, columnName, format) {
41
+ return {
42
+ columnType,
43
+ columnName,
44
+ format
45
+ };
46
+ }
47
+ /**
48
+ * @param columnFormattingRules Optional array of column formatting rules
49
+ * @param dateTimeOptions Optional object with DateTime configuration
50
+ * @param decimalFormatOptions Optional object with Decimal configuration
51
+ * @param integerFormatOptions Optional object with Integer configuration
52
+ * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
53
+ */
54
+
55
+
56
+ constructor() {
57
+ var columnFormattingRules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
58
+ var dateTimeOptions = arguments.length > 1 ? arguments[1] : undefined;
59
+ var decimalFormatOptions = arguments.length > 2 ? arguments[2] : undefined;
60
+ var integerFormatOptions = arguments.length > 3 ? arguments[3] : undefined;
61
+ var truncateNumbersWithPound = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
62
+
63
+ _defineProperty(this, "defaultColumnFormatter", void 0);
64
+
65
+ _defineProperty(this, "typeFormatterMap", void 0);
66
+
67
+ _defineProperty(this, "columnFormatMap", void 0);
68
+
69
+ _defineProperty(this, "truncateNumbersWithPound", void 0);
70
+
71
+ // Formatting order:
72
+ // - columnFormatMap[type][name]
73
+ // - typeFormatterMap[type]
74
+ // - defaultColumnFormatter
75
+ this.defaultColumnFormatter = new DefaultColumnFormatter(); // Default formatters by data type
76
+
77
+ this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter(decimalFormatOptions)], [TableUtils.dataType.INT, new IntegerColumnFormatter(integerFormatOptions)], [TableUtils.dataType.STRING, new StringColumnFormatter()]]); // Formats indexed by data type and column name
78
+
79
+ this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
80
+ this.truncateNumbersWithPound = truncateNumbersWithPound;
81
+ }
82
+
83
+ /**
84
+ * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary
85
+ * @param columnType column type
86
+ * @param createIfNecessary create new entry if true
87
+ * @returns Map of format strings indexed by column name or undefined if it doesn't exist
88
+ */
89
+ getColumnFormatMapForType(columnType) {
90
+ var createIfNecessary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
91
+ var dataType = TableUtils.getNormalizedType(columnType);
92
+
93
+ if (dataType === null) {
94
+ return undefined;
95
+ }
96
+
97
+ if (createIfNecessary && !this.columnFormatMap.has(dataType)) {
98
+ this.columnFormatMap.set(dataType, new Map());
99
+ }
100
+
101
+ return this.columnFormatMap.get(dataType);
102
+ }
103
+ /**
104
+ * Gets a column format object for a given column type and name
105
+ * @param columnType column type
106
+ * @param columnName column name
107
+ * @returns format object or null for Default
108
+ */
109
+
110
+
111
+ getColumnFormat(columnType, columnName) {
112
+ var _columnFormatMap$get;
113
+
114
+ var columnFormatMap = this.getColumnFormatMapForType(columnType);
115
+ return (_columnFormatMap$get = columnFormatMap === null || columnFormatMap === void 0 ? void 0 : columnFormatMap.get(columnName)) !== null && _columnFormatMap$get !== void 0 ? _columnFormatMap$get : null;
116
+ }
117
+
118
+ getColumnTypeFormatter(columnType) {
119
+ var dataType = TableUtils.getNormalizedType(columnType);
120
+ var columnTypeFormatter = this.defaultColumnFormatter;
121
+
122
+ if (dataType) {
123
+ var _this$typeFormatterMa;
124
+
125
+ columnTypeFormatter = (_this$typeFormatterMa = this.typeFormatterMap.get(dataType)) !== null && _this$typeFormatterMa !== void 0 ? _this$typeFormatterMa : columnTypeFormatter;
126
+ }
127
+
128
+ return columnTypeFormatter;
129
+ }
130
+ /**
131
+ * Gets formatted string for a given value, column type and name
132
+ * @param value Value to format
133
+ * @param columnType Column type used to determine the formatting settings
134
+ * @param columnName Column name used to determine the formatting settings
135
+ * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap
136
+ */
137
+
138
+
139
+ getFormattedString(value, columnType) {
140
+ var columnName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
141
+ var formatOverride = arguments.length > 3 ? arguments[3] : undefined;
142
+
143
+ if (value == null) {
144
+ return '';
145
+ }
146
+
147
+ var formatter = this.getColumnTypeFormatter(columnType);
148
+ var format = formatOverride || this.getColumnFormat(columnType, columnName);
149
+ return formatter.format(value, format !== null && format !== void 0 ? format : undefined);
150
+ }
151
+ /**
152
+ * Gets the timeZone name
153
+ * @returns The time zone name E.g. America/New_York
154
+ */
155
+
156
+
157
+ get timeZone() {
158
+ var _formatter$dhTimeZone;
159
+
160
+ var formatter = this.typeFormatterMap.get(TableUtils.dataType.DATETIME);
161
+ return formatter === null || formatter === void 0 ? void 0 : (_formatter$dhTimeZone = formatter.dhTimeZone) === null || _formatter$dhTimeZone === void 0 ? void 0 : _formatter$dhTimeZone.id;
162
+ }
163
+
164
+ }
165
+ export default Formatter;
166
+ //# sourceMappingURL=Formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Formatter.ts"],"names":["TableUtils","BooleanColumnFormatter","CharColumnFormatter","DateTimeColumnFormatter","DecimalColumnFormatter","DefaultColumnFormatter","IntegerColumnFormatter","StringColumnFormatter","Formatter","makeColumnFormatMap","columnFormattingRules","Map","reduce","map","next","dataType","getNormalizedType","columnType","has","set","formatMap","get","columnName","format","makeColumnFormattingRule","constructor","dateTimeOptions","decimalFormatOptions","integerFormatOptions","truncateNumbersWithPound","defaultColumnFormatter","typeFormatterMap","BOOLEAN","CHAR","DATETIME","DECIMAL","INT","STRING","columnFormatMap","getColumnFormatMapForType","createIfNecessary","undefined","getColumnFormat","getColumnTypeFormatter","columnTypeFormatter","getFormattedString","value","formatOverride","formatter","timeZone","dhTimeZone","id"],"mappings":";;OAAOA,U;SAELC,sB,EACAC,mB,EACAC,uB,EACAC,sB,EACAC,sB,EACAC,sB,EACAC,qB;AAaF,OAAO,MAAMC,SAAN,CAAgB;AACrB;AACF;AACA;AACA;AACA;AAC4B,SAAnBC,mBAAmB,CACxBC,qBADwB,EAE2B;AACnD,QAAIA,qBAAqB,IAAI,IAA7B,EAAmC;AACjC,aAAO,IAAIC,GAAJ,EAAP;AACD;;AACD,WAAOD,qBAAqB,CAACE,MAAtB,CAA6B,CAACC,GAAD,EAAMC,IAAN,KAAe;AACjD,UAAMC,QAAQ,GAAGf,UAAU,CAACgB,iBAAX,CAA6BF,IAAI,CAACG,UAAlC,CAAjB;;AACA,UAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACrB,eAAOF,GAAP;AACD;;AAED,UAAI,CAACA,GAAG,CAACK,GAAJ,CAAQH,QAAR,CAAL,EAAwB;AACtBF,QAAAA,GAAG,CAACM,GAAJ,CAAQJ,QAAR,EAAkB,IAAIJ,GAAJ,EAAlB;AACD;;AACD,UAAMS,SAAS,GAAGP,GAAG,CAACQ,GAAJ,CAAQN,QAAR,CAAlB;AACAK,MAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAED,GAAX,CAAeL,IAAI,CAACQ,UAApB,EAAgCR,IAAI,CAACS,MAArC;AACA,aAAOV,GAAP;AACD,KAZM,EAYJ,IAAIF,GAAJ,EAZI,CAAP;AAaD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACiC,SAAxBa,wBAAwB,CAC7BP,UAD6B,EAE7BK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;AAED,QAAME,SAAS,GAAG,KAAKL,sBAAL,CAA4B1B,UAA5B,CAAlB;AACA,QAAMM,MAAM,GACVwB,cAAc,IAAI,KAAKL,eAAL,CAAqBzB,UAArB,EAAiCK,UAAjC,CADpB;AAGA,WAAO0B,SAAS,CAACzB,MAAV,CAAiBuB,KAAjB,EAAwBvB,MAAxB,aAAwBA,MAAxB,cAAwBA,MAAxB,GAAkCkB,SAAlC,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACc,MAARQ,QAAQ,GAAW;AAAA;;AACrB,QAAMD,SAAS,GAAG,KAAKjB,gBAAL,CAAsBV,GAAtB,CAChBrB,UAAU,CAACe,QAAX,CAAoBmB,QADJ,CAAlB;AAGA,WAAOc,SAAP,aAAOA,SAAP,gDAAOA,SAAS,CAAEE,UAAlB,0DAAO,sBAAuBC,EAA9B;AACD;;AApLoB;AAuLvB,eAAe3C,SAAf","sourcesContent":["import TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n StringColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\n\ntype ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: string;\n format: TableColumnFormat;\n}\n\nexport class Formatter {\n /**\n * Converts FormattingRule[] to Map\n * @param columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(\n columnFormattingRules: FormattingRule[]\n ): Map<DataType, Map<ColumnName, TableColumnFormat>> {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (dataType === null) {\n return map;\n }\n\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap?.set(next.columnName, next.format);\n return map;\n }, new Map<DataType, Map<ColumnName, TableColumnFormat>>());\n }\n\n /**\n * Creates a column formatting rule\n * @param columnType Normalized data type\n * @param columnName Column name\n * @param format Format object\n */\n static makeColumnFormattingRule(\n columnType: DataType,\n columnName: string,\n format: TableColumnFormat\n ): FormattingRule {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param columnFormattingRules Optional array of column formatting rules\n * @param dateTimeOptions Optional object with DateTime configuration\n * @param decimalFormatOptions Optional object with Decimal configuration\n * @param integerFormatOptions Optional object with Integer configuration\n * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end\n */\n constructor(\n columnFormattingRules: FormattingRule[] = [],\n dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0],\n decimalFormatOptions?: ConstructorParameters<\n typeof DecimalColumnFormatter\n >[0],\n integerFormatOptions?: ConstructorParameters<\n typeof IntegerColumnFormatter\n >[0],\n truncateNumbersWithPound = false\n ) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map<DataType, TableColumnFormatter>([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [\n TableUtils.dataType.DECIMAL,\n new DecimalColumnFormatter(decimalFormatOptions),\n ],\n [\n TableUtils.dataType.INT,\n new IntegerColumnFormatter(integerFormatOptions),\n ],\n [TableUtils.dataType.STRING, new StringColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n this.truncateNumbersWithPound = truncateNumbersWithPound;\n }\n\n defaultColumnFormatter: TableColumnFormatter;\n\n typeFormatterMap: Map<DataType, TableColumnFormatter>;\n\n columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;\n\n truncateNumbersWithPound: boolean;\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param columnType column type\n * @param createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(\n columnType: string,\n createIfNecessary = false\n ): Map<string, TableColumnFormat> | undefined {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType === null) {\n return undefined;\n }\n\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param columnType column type\n * @param columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(\n columnType: string,\n columnName: string\n ): TableColumnFormat | null {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n return columnFormatMap?.get(columnName) ?? null;\n }\n\n getColumnTypeFormatter(columnType: string): TableColumnFormatter {\n const dataType = TableUtils.getNormalizedType(columnType);\n let columnTypeFormatter = this.defaultColumnFormatter;\n if (dataType) {\n columnTypeFormatter =\n this.typeFormatterMap.get(dataType) ?? columnTypeFormatter;\n }\n return columnTypeFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param value Value to format\n * @param columnType Column type used to determine the formatting settings\n * @param columnName Column name used to determine the formatting settings\n * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value: unknown,\n columnType: string,\n columnName = '',\n formatOverride?: TableColumnFormat\n ): string {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format ?? undefined);\n }\n\n /**\n * Gets the timeZone name\n * @returns The time zone name E.g. America/New_York\n */\n get timeZone(): string {\n const formatter = this.typeFormatterMap.get(\n TableUtils.dataType.DATETIME\n ) as DateTimeColumnFormatter;\n return formatter?.dhTimeZone?.id;\n }\n}\n\nexport default Formatter;\n"],"file":"Formatter.js"}
@@ -0,0 +1,24 @@
1
+ import type { FormattingRule } from './Formatter';
2
+ import Formatter from './Formatter';
3
+ import { DateTimeColumnFormatter } from './formatters';
4
+ export declare class FormatterUtils {
5
+ static getColumnFormats(settings: {
6
+ formatter: FormattingRule[];
7
+ }): FormattingRule[];
8
+ static getDateTimeFormatterOptions(settings: {
9
+ timeZone: string;
10
+ defaultDateTimeFormat: string;
11
+ showTimeZone: boolean;
12
+ showTSeparator: boolean;
13
+ }): Required<ConstructorParameters<typeof DateTimeColumnFormatter>[0]>;
14
+ /**
15
+ * Check if the formatter has a custom format defined for the column name and type
16
+ * @param formatter Formatter to check
17
+ * @param columnName Column name
18
+ * @param columnType Column type
19
+ * @returns True, if a custom format is defined
20
+ */
21
+ static isCustomColumnFormatDefined(formatter: Formatter, columnName: string, columnType: string): boolean;
22
+ }
23
+ export default FormatterUtils;
24
+ //# sourceMappingURL=FormatterUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatterUtils.d.ts","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAwB,MAAM,cAAc,CAAC;AAE7E,qBAAa,cAAc;IACzB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE;QAChC,SAAS,EAAE,cAAc,EAAE,CAAC;KAC7B,GAAG,cAAc,EAAE;IAKpB,MAAM,CAAC,2BAA2B,CAAC,QAAQ,EAAE;QAC3C,QAAQ,EAAE,MAAM,CAAC;QACjB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,EAAE,OAAO,CAAC;KACzB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;IAetE;;;;;;OAMG;IACH,MAAM,CAAC,2BAA2B,CAChC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO;CAQX;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { TableColumnFormatter } from "./formatters/index.js";
2
+ export class FormatterUtils {
3
+ static getColumnFormats(settings) {
4
+ var {
5
+ formatter
6
+ } = settings;
7
+ return formatter;
8
+ }
9
+
10
+ static getDateTimeFormatterOptions(settings) {
11
+ var {
12
+ timeZone,
13
+ defaultDateTimeFormat,
14
+ showTimeZone,
15
+ showTSeparator
16
+ } = settings;
17
+ return {
18
+ timeZone,
19
+ defaultDateTimeFormatString: defaultDateTimeFormat,
20
+ showTimeZone,
21
+ showTSeparator
22
+ };
23
+ }
24
+ /**
25
+ * Check if the formatter has a custom format defined for the column name and type
26
+ * @param formatter Formatter to check
27
+ * @param columnName Column name
28
+ * @param columnType Column type
29
+ * @returns True, if a custom format is defined
30
+ */
31
+
32
+
33
+ static isCustomColumnFormatDefined(formatter, columnName, columnType) {
34
+ var columnFormat = formatter.getColumnFormat(columnType, columnName);
35
+ return columnFormat != null && (columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_PRESET || columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_CUSTOM);
36
+ }
37
+
38
+ }
39
+ export default FormatterUtils;
40
+ //# sourceMappingURL=FormatterUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/FormatterUtils.ts"],"names":["TableColumnFormatter","FormatterUtils","getColumnFormats","settings","formatter","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormat","showTimeZone","showTSeparator","defaultDateTimeFormatString","isCustomColumnFormatDefined","columnName","columnType","columnFormat","getColumnFormat","type","TYPE_CONTEXT_PRESET","TYPE_CONTEXT_CUSTOM"],"mappings":"SAEkCA,oB;AAElC,OAAO,MAAMC,cAAN,CAAqB;AACH,SAAhBC,gBAAgB,CAACC,QAAD,EAEF;AACnB,QAAM;AAAEC,MAAAA;AAAF,QAAgBD,QAAtB;AACA,WAAOC,SAAP;AACD;;AAEiC,SAA3BC,2BAA2B,CAACF,QAAD,EAKqC;AACrE,QAAM;AACJG,MAAAA,QADI;AAEJC,MAAAA,qBAFI;AAGJC,MAAAA,YAHI;AAIJC,MAAAA;AAJI,QAKFN,QALJ;AAMA,WAAO;AACLG,MAAAA,QADK;AAELI,MAAAA,2BAA2B,EAAEH,qBAFxB;AAGLC,MAAAA,YAHK;AAILC,MAAAA;AAJK,KAAP;AAMD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACoC,SAA3BE,2BAA2B,CAChCP,SADgC,EAEhCQ,UAFgC,EAGhCC,UAHgC,EAIvB;AACT,QAAMC,YAAY,GAAGV,SAAS,CAACW,eAAV,CAA0BF,UAA1B,EAAsCD,UAAtC,CAArB;AACA,WACEE,YAAY,IAAI,IAAhB,KACCA,YAAY,CAACE,IAAb,KAAsBhB,oBAAoB,CAACiB,mBAA3C,IACCH,YAAY,CAACE,IAAb,KAAsBhB,oBAAoB,CAACkB,mBAF7C,CADF;AAKD;;AA9CyB;AAiD5B,eAAejB,cAAf","sourcesContent":["import type { FormattingRule } from './Formatter';\nimport Formatter from './Formatter';\nimport { DateTimeColumnFormatter, TableColumnFormatter } from './formatters';\n\nexport class FormatterUtils {\n static getColumnFormats(settings: {\n formatter: FormattingRule[];\n }): FormattingRule[] {\n const { formatter } = settings;\n return formatter;\n }\n\n static getDateTimeFormatterOptions(settings: {\n timeZone: string;\n defaultDateTimeFormat: string;\n showTimeZone: boolean;\n showTSeparator: boolean;\n }): Required<ConstructorParameters<typeof DateTimeColumnFormatter>[0]> {\n const {\n timeZone,\n defaultDateTimeFormat,\n showTimeZone,\n showTSeparator,\n } = settings;\n return {\n timeZone,\n defaultDateTimeFormatString: defaultDateTimeFormat,\n showTimeZone,\n showTSeparator,\n };\n }\n\n /**\n * Check if the formatter has a custom format defined for the column name and type\n * @param formatter Formatter to check\n * @param columnName Column name\n * @param columnType Column type\n * @returns True, if a custom format is defined\n */\n static isCustomColumnFormatDefined(\n formatter: Formatter,\n columnName: string,\n columnType: string\n ): boolean {\n const columnFormat = formatter.getColumnFormat(columnType, columnName);\n return (\n columnFormat != null &&\n (columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_PRESET ||\n columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_CUSTOM)\n );\n }\n}\n\nexport default FormatterUtils;\n"],"file":"FormatterUtils.js"}
@@ -0,0 +1,194 @@
1
+ import { Type as FilterType, TypeValue as FilterTypeValue, OperatorValue as FilterOperatorValue } from '@deephaven/filters';
2
+ import { Column, FilterCondition, FilterValue, LongWrapper, Sort, Table, TreeTable } from '@deephaven/jsapi-shim';
3
+ import { CancelablePromise } from '@deephaven/utils';
4
+ declare type Values<T> = T[keyof T];
5
+ export declare type DataType = Values<typeof TableUtils.dataType>;
6
+ export declare type SortDirection = Values<typeof TableUtils.sortDirection>;
7
+ export declare type ReverseType = Values<typeof TableUtils.REVERSE_TYPE>;
8
+ export declare type AdvancedFilterItemType = {
9
+ selectedType: FilterTypeValue;
10
+ value: string;
11
+ };
12
+ /** Utility class to provide some functions for working with tables */
13
+ export declare class TableUtils {
14
+ static dataType: {
15
+ readonly BOOLEAN: "boolean";
16
+ readonly CHAR: "char";
17
+ readonly DATETIME: "datetime";
18
+ readonly DECIMAL: "decimal";
19
+ readonly INT: "int";
20
+ readonly STRING: "string";
21
+ };
22
+ static sortDirection: {
23
+ readonly ascending: "ASC";
24
+ readonly descending: "DESC";
25
+ readonly reverse: "REVERSE";
26
+ readonly none: null;
27
+ };
28
+ static REVERSE_TYPE: Readonly<{
29
+ readonly NONE: "none";
30
+ readonly PRE_SORT: "pre-sort";
31
+ readonly POST_SORT: "post-sort";
32
+ }>;
33
+ static NUMBER_REGEX: RegExp;
34
+ static getSortIndex(sort: Sort[], columnIndex: number): number | null;
35
+ /**
36
+ * @param tableSort The sorts from the table to get the sort from
37
+ * @param columnIndex The index of the column to get the sort for
38
+ * @return The sort for the column, or null if it's not sorted
39
+ */
40
+ static getSortForColumn(tableSort: Sort[], columnIndex: number): Sort | null;
41
+ static getFilterText(filter: FilterCondition): string | null;
42
+ /** Return the valid filter types for the column */
43
+ static getFilterTypes(columnType: string): FilterType[];
44
+ static getNextSort(table: Table, columnIndex: number): Sort | null;
45
+ static makeColumnSort(table: Table, columnIndex: number, direction: SortDirection, isAbs: boolean): Sort | null;
46
+ /**
47
+ * Toggles the sort for the specified column
48
+ * @param sorts The current sorts from IrisGrid.state
49
+ * @param table The table to apply the sort to
50
+ * @param columnIndex The column index to apply the sort to
51
+ * @param addToExisting Add this sort to the existing sort
52
+ */
53
+ static toggleSortForColumn(sorts: Sort[], table: Table, columnIndex: number, addToExisting?: boolean): Sort[];
54
+ static sortColumn(table: Table, modelColumn: number, direction: SortDirection, isAbs: boolean, addToExisting: boolean): Sort[];
55
+ /**
56
+ * Sets the sort for the given column *and* removes any reverses
57
+ * @param tableSort The current sorts from IrisGrid.state
58
+ * @param columnIndex The column index to apply the sort to
59
+ * @param sort The sort object to add
60
+ * @param addToExisting Add this sort to the existing sort
61
+ * @returns Returns the modified array of sorts - removing reverses
62
+ */
63
+ static setSortForColumn(tableSort: Sort[], columnIndex: number, sort: Sort | null, addToExisting?: boolean): Sort[];
64
+ static getNormalizedType(columnType: string): DataType | null;
65
+ static isLongType(columnType: string): boolean;
66
+ static isDateType(columnType: string): boolean;
67
+ static isNumberType(columnType: string): boolean;
68
+ static isIntegerType(columnType: string): boolean;
69
+ static isDecimalType(columnType: string): boolean;
70
+ static isBooleanType(columnType: string): boolean;
71
+ static isCharType(columnType: string): boolean;
72
+ static isStringType(columnType: string): boolean;
73
+ static isTextType(columnType: string): boolean;
74
+ /**
75
+ * Get base column type
76
+ * @param columnType Column type
77
+ * @returns Element type for array columns, original type for non-array columns
78
+ */
79
+ static getBaseType(columnType: string): string;
80
+ /**
81
+ * Check if the column types are compatible
82
+ * @param type1 Column type to check
83
+ * @param type2 Column type to check
84
+ * @returns True, if types are compatible
85
+ */
86
+ static isCompatibleType(type1: string, type2: string): boolean;
87
+ /**
88
+ * Create filter with the provided column and text. Handles multiple filters joined with && or ||
89
+ * @param column The column to set the filter on
90
+ * @param text The text string to create the filter from
91
+ * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York
92
+ * @returns Returns the created filter, null if text could not be parsed
93
+ */
94
+ static makeQuickFilter(column: Column, text: string, timeZone: string): FilterCondition | null;
95
+ /**
96
+ * Create filter with the provided column and text of one component (no multiple conditions)
97
+ * @param column The column to set the filter on
98
+ * @param text The text string to create the filter from
99
+ * @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York
100
+ * @returns Returns the created filter, null if text could not be parsed
101
+ */
102
+ static makeQuickFilterFromComponent(column: Column, text: string, timeZone: string): FilterCondition | null;
103
+ static makeQuickNumberFilter(column: Column, text: string): FilterCondition | null;
104
+ static makeQuickTextFilter(column: Column, text: string | null): FilterCondition | null;
105
+ static makeQuickBooleanFilter(column: Column, text: string): FilterCondition | null;
106
+ /**
107
+ * Builds a date filter parsed from the text string which may or may not include an operator.
108
+ * @param column The column to build the filter from, with or without a leading operator.
109
+ * @param text The date string text to parse.
110
+ * @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York
111
+ */
112
+ static makeQuickDateFilter(column: Column, text: string, timeZone: string): FilterCondition;
113
+ /**
114
+ * Builds a date filter parsed from the text string with the provided filter.
115
+ * @param column The column to build the filter from.
116
+ * @param text The date string text to parse, without an operator.
117
+ * @param operation The filter operation to use.
118
+ * @param timeZone The time zone to make this filter with. E.g. America/New_York
119
+ */
120
+ static makeQuickDateFilterWithOperation(column: Column, text: string, operation: string | undefined, timeZone: string): FilterCondition;
121
+ static makeQuickCharFilter(column: Column, text: string): FilterCondition | null;
122
+ /**
123
+ * @param filter The column filter to apply the range operation to
124
+ * @param operation The range operation to run
125
+ * @param value The value to use for the operation
126
+ * @returns The condition with the specified operation
127
+ */
128
+ static makeRangeFilterWithOperation(filter: FilterValue, operation: string, value: FilterValue): FilterCondition | null;
129
+ /**
130
+ * Wraps a table promise in a cancelable promise that will close the table if the promise is cancelled.
131
+ * Use in a component that loads a table, and call cancel when unmounting.
132
+ * @param table The table promise to wrap
133
+ */
134
+ static makeCancelableTablePromise(table: Promise<Table> | Table): CancelablePromise<Table>;
135
+ /**
136
+ * Make a cancelable promise for a one-shot table event with a timeout.
137
+ * @param table Table to listen for events on
138
+ * @param eventName Event to listen for
139
+ * @param timeout Event timeout in milliseconds, defaults to 0
140
+ * @param matcher Optional function to determine if the promise can be resolved or stays pending
141
+ * @returns Resolves with the event data
142
+ */
143
+ static makeCancelableTableEventPromise(table: Table | TreeTable, eventName: string, timeout?: number, matcher?: ((event: CustomEvent) => boolean) | null): CancelablePromise<CustomEvent>;
144
+ static makeAdvancedFilter(column: Column, options: {
145
+ filterItems: AdvancedFilterItemType[];
146
+ filterOperators: FilterOperatorValue[];
147
+ invertSelection: boolean;
148
+ selectedValues: string[];
149
+ }, timeZone: string): FilterCondition | null;
150
+ static removeCommas(value: string): string;
151
+ /**
152
+ * @param columnType The column type to make the filter value from.
153
+ * @param value The value to make the filter value from.
154
+ * @returns The FilterValue item for this column/value combination
155
+ */
156
+ static makeFilterValue(columnType: string, value: string): FilterValue;
157
+ /**
158
+ * Takes a value and converts it to an `dh.FilterValue`
159
+ *
160
+ * @param columnType The column type to make the filter value from.
161
+ * @param value The value to actually set
162
+ * @returns The FilterValue item for this column/value combination
163
+ */
164
+ static makeFilterRawValue(columnType: string, rawValue: unknown): FilterValue;
165
+ /**
166
+ * Converts a string value to a value appropriate for the column
167
+ * @param columnType The column type to make the value for
168
+ * @param text The string value to make a type for
169
+ * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York
170
+ */
171
+ static makeValue(columnType: string, text: string, timeZone: string): string | number | boolean | LongWrapper | null;
172
+ static makeBooleanValue(text: string, allowEmpty?: boolean): boolean | null;
173
+ static makeNumberValue(text: string): number | null;
174
+ static makeAdvancedValueFilter(column: Column, operation: FilterTypeValue, value: string, timeZone: string): FilterCondition;
175
+ /**
176
+ * Create a filter using the selected items
177
+ * Has a flag for invertSelection as we start from a "Select All" state and a user just deselects items.
178
+ * Since there may be millions of distinct items, it's easier to build an inverse filter.
179
+ * @param column The column to set the filter on
180
+ * @param selectedValues The values that are selected
181
+ * @param invertSelection Invert the selection (eg. All items are selected, then you deselect items)
182
+ * @returns Returns a `in` or `notIn` FilterCondition as necessary, or null if no filtering should be applied (everything selected)
183
+ */
184
+ static makeSelectValueFilter(column: Column, selectedValues: string[], invertSelection: boolean): FilterCondition | null;
185
+ static isTreeTable(table: unknown): table is TreeTable;
186
+ /**
187
+ * Copies the provided array, sorts by column name case insensitive, and returns the sorted array.
188
+ * @param columns The columns to sort
189
+ * @param isAscending Whether to sort ascending
190
+ */
191
+ static sortColumns(columns: Column[], isAscending?: boolean): Column[];
192
+ }
193
+ export default TableUtils;
194
+ //# sourceMappingURL=TableUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../src/TableUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,IAAI,UAAU,EAElB,SAAS,IAAI,eAAe,EAC5B,aAAa,IAAI,mBAAmB,EACrC,MAAM,oBAAoB,CAAC;AAE5B,OAAW,EACT,MAAM,EACN,eAAe,EACf,WAAW,EACX,WAAW,EAEX,IAAI,EACJ,KAAK,EACL,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAK1B,aAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5B,oBAAY,QAAQ,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC1D,oBAAY,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACpE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