@deephaven/jsapi-utils 0.38.1-beta.5 → 0.38.1-beta.9
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.
- package/dist/Formatter.d.ts +3 -1
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +8 -7
- package/dist/Formatter.js.map +1 -1
- package/dist/FormatterUtils.d.ts +1 -1
- package/dist/FormatterUtils.js.map +1 -1
- package/dist/SessionUtils.d.ts +3 -3
- package/dist/SessionUtils.d.ts.map +1 -1
- package/dist/SessionUtils.js +2 -2
- package/dist/SessionUtils.js.map +1 -1
- package/dist/TableUtils.d.ts +40 -40
- package/dist/TableUtils.d.ts.map +1 -1
- package/dist/TableUtils.js +91 -74
- package/dist/TableUtils.js.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.d.ts +5 -3
- package/dist/formatters/DateTimeColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DateTimeColumnFormatter.js +8 -5
- package/dist/formatters/DateTimeColumnFormatter.js.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.d.ts +5 -2
- package/dist/formatters/DecimalColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/DecimalColumnFormatter.js +8 -5
- package/dist/formatters/DecimalColumnFormatter.js.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.d.ts +5 -2
- package/dist/formatters/IntegerColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/IntegerColumnFormatter.js +8 -5
- package/dist/formatters/IntegerColumnFormatter.js.map +1 -1
- package/dist/formatters/TableColumnFormatter.d.ts +3 -1
- package/dist/formatters/TableColumnFormatter.d.ts.map +1 -1
- package/dist/formatters/TableColumnFormatter.js +2 -1
- package/dist/formatters/TableColumnFormatter.js.map +1 -1
- package/package.json +8 -8
package/dist/Formatter.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
1
2
|
import { DataType } from './TableUtils';
|
|
2
3
|
import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter, TableColumnFormat, TableColumnFormatter } from './formatters';
|
|
3
4
|
export type ColumnName = string;
|
|
@@ -21,13 +22,14 @@ export declare class Formatter {
|
|
|
21
22
|
*/
|
|
22
23
|
static makeColumnFormattingRule(columnType: DataType, columnName: ColumnName, format: TableColumnFormat): FormattingRule;
|
|
23
24
|
/**
|
|
25
|
+
* @param dh JSAPI instance
|
|
24
26
|
* @param columnFormattingRules Optional array of column formatting rules
|
|
25
27
|
* @param dateTimeOptions Optional object with DateTime configuration
|
|
26
28
|
* @param decimalFormatOptions Optional object with Decimal configuration
|
|
27
29
|
* @param integerFormatOptions Optional object with Integer configuration
|
|
28
30
|
* @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
|
|
29
31
|
*/
|
|
30
|
-
constructor(columnFormattingRules?: FormattingRule[], dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[
|
|
32
|
+
constructor(dh: DhType, columnFormattingRules?: FormattingRule[], dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[1], decimalFormatOptions?: ConstructorParameters<typeof DecimalColumnFormatter>[1], integerFormatOptions?: ConstructorParameters<typeof IntegerColumnFormatter>[1], truncateNumbersWithPound?: boolean);
|
|
31
33
|
defaultColumnFormatter: TableColumnFormatter;
|
|
32
34
|
typeFormatterMap: Map<DataType, TableColumnFormatter>;
|
|
33
35
|
columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;
|
package/dist/Formatter.d.ts.map
CHANGED
|
@@ -1 +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,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
44
|
/**
|
|
45
|
+
* @param dh JSAPI instance
|
|
45
46
|
* @param columnFormattingRules Optional array of column formatting rules
|
|
46
47
|
* @param dateTimeOptions Optional object with DateTime configuration
|
|
47
48
|
* @param decimalFormatOptions Optional object with Decimal configuration
|
|
48
49
|
* @param integerFormatOptions Optional object with Integer configuration
|
|
49
50
|
* @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end
|
|
50
51
|
*/
|
|
51
|
-
constructor() {
|
|
52
|
-
var columnFormattingRules = arguments.length >
|
|
53
|
-
var dateTimeOptions = arguments.length >
|
|
54
|
-
var decimalFormatOptions = arguments.length >
|
|
55
|
-
var integerFormatOptions = arguments.length >
|
|
56
|
-
var truncateNumbersWithPound = arguments.length >
|
|
52
|
+
constructor(dh) {
|
|
53
|
+
var columnFormattingRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
54
|
+
var dateTimeOptions = arguments.length > 2 ? arguments[2] : undefined;
|
|
55
|
+
var decimalFormatOptions = arguments.length > 3 ? arguments[3] : undefined;
|
|
56
|
+
var integerFormatOptions = arguments.length > 4 ? arguments[4] : undefined;
|
|
57
|
+
var truncateNumbersWithPound = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
57
58
|
_defineProperty(this, "defaultColumnFormatter", void 0);
|
|
58
59
|
_defineProperty(this, "typeFormatterMap", void 0);
|
|
59
60
|
_defineProperty(this, "columnFormatMap", void 0);
|
|
@@ -66,7 +67,7 @@ export class Formatter {
|
|
|
66
67
|
this.defaultColumnFormatter = new DefaultColumnFormatter();
|
|
67
68
|
|
|
68
69
|
// Default formatters by data type
|
|
69
|
-
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()]]);
|
|
70
|
+
this.typeFormatterMap = new Map([[TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()], [TableUtils.dataType.CHAR, new CharColumnFormatter()], [TableUtils.dataType.DATETIME, new DateTimeColumnFormatter(dh, dateTimeOptions)], [TableUtils.dataType.DECIMAL, new DecimalColumnFormatter(dh, decimalFormatOptions)], [TableUtils.dataType.INT, new IntegerColumnFormatter(dh, integerFormatOptions)], [TableUtils.dataType.STRING, new StringColumnFormatter()]]);
|
|
70
71
|
|
|
71
72
|
// Formats indexed by data type and column name
|
|
72
73
|
this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);
|
package/dist/Formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formatter.js","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"],"sources":["../src/Formatter.ts"],"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\nexport type ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: ColumnName;\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: ColumnName,\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: ColumnName\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?: Partial<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"],"mappings":";;;OAAOA,UAAU;AAAA,SAEfC,sBAAsB,EACtBC,mBAAmB,EACnBC,uBAAuB,EACvBC,sBAAsB,EACtBC,sBAAsB,EACtBC,sBAAsB,EACtBC,qBAAqB;AAavB,OAAO,MAAMC,SAAS,CAAC;EACrB;AACF;AACA;AACA;AACA;EACE,OAAOC,mBAAmB,CACxBC,qBAAuC,EACY;IACnD,IAAIA,qBAAqB,IAAI,IAAI,EAAE;MACjC,OAAO,IAAIC,GAAG,EAAE;IAClB;IACA,OAAOD,qBAAqB,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;MACjD,IAAMC,QAAQ,GAAGf,UAAU,CAACgB,iBAAiB,CAACF,IAAI,CAACG,UAAU,CAAC;MAC9D,IAAIF,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAOF,GAAG;MACZ;MAEA,IAAI,CAACA,GAAG,CAACK,GAAG,CAACH,QAAQ,CAAC,EAAE;QACtBF,GAAG,CAACM,GAAG,CAACJ,QAAQ,EAAE,IAAIJ,GAAG,EAAE,CAAC;MAC9B;MACA,IAAMS,SAAS,GAAGP,GAAG,CAACQ,GAAG,CAACN,QAAQ,CAAC;MACnCK,SAAS,aA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CAChBC,KAAc,EACd7B,UAAkB,EAGV;IAAA,IAFRK,UAAU,uEAAG,EAAE;IAAA,IACfyB,cAA2C;IAE3C,IAAID,KAAK,IAAI,IAAI,EAAE;MACjB,OAAO,EAAE;IACX;IAEA,IAAME,SAAS,GAAG,IAAI,CAACL,sBAAsB,CAAC1B,UAAU,CAAC;IACzD,IAAMM,MAAM,GACVwB,cAAc,IAAI,IAAI,CAACL,eAAe,CAACzB,UAAU,EAAEK,UAAU,CAAC;IAEhE,OAAO0B,SAAS,CAACzB,MAAM,CAACuB,KAAK,EAAEvB,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIkB,SAAS,CAAC;EACrD;;EAEA;AACF;AACA;AACA;EACE,IAAIQ,QAAQ,GAAW;IAAA;IACrB,IAAMD,SAAS,GAAG,IAAI,CAACjB,gBAAgB,CAACV,GAAG,CACzCrB,UAAU,CAACe,QAAQ,CAACmB,QAAQ,CACF;IAC5B,OAAOc,SAAS,aAATA,SAAS,gDAATA,SAAS,CAAEE,UAAU,0DAArB,sBAAuBC,EAAE;EAClC;AACF;AAEA,eAAe3C,SAAS"}
|
|
1
|
+
{"version":3,"file":"Formatter.js","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","dh","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"],"sources":["../src/Formatter.ts"],"sourcesContent":["import type { dh as DhType } from '@deephaven/jsapi-types';\nimport 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\nexport type ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: ColumnName;\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: ColumnName,\n format: TableColumnFormat\n ): FormattingRule {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param dh JSAPI instance\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 dh: DhType,\n columnFormattingRules: FormattingRule[] = [],\n dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[1],\n decimalFormatOptions?: ConstructorParameters<\n typeof DecimalColumnFormatter\n >[1],\n integerFormatOptions?: ConstructorParameters<\n typeof IntegerColumnFormatter\n >[1],\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(dh, dateTimeOptions),\n ],\n [\n TableUtils.dataType.DECIMAL,\n new DecimalColumnFormatter(dh, decimalFormatOptions),\n ],\n [\n TableUtils.dataType.INT,\n new IntegerColumnFormatter(dh, 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: ColumnName\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?: Partial<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"],"mappings":";;;OACOA,UAAU;AAAA,SAEfC,sBAAsB,EACtBC,mBAAmB,EACnBC,uBAAuB,EACvBC,sBAAsB,EACtBC,sBAAsB,EACtBC,sBAAsB,EACtBC,qBAAqB;AAavB,OAAO,MAAMC,SAAS,CAAC;EACrB;AACF;AACA;AACA;AACA;EACE,OAAOC,mBAAmB,CACxBC,qBAAuC,EACY;IACnD,IAAIA,qBAAqB,IAAI,IAAI,EAAE;MACjC,OAAO,IAAIC,GAAG,EAAE;IAClB;IACA,OAAOD,qBAAqB,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;MACjD,IAAMC,QAAQ,GAAGf,UAAU,CAACgB,iBAAiB,CAACF,IAAI,CAACG,UAAU,CAAC;MAC9D,IAAIF,QAAQ,KAAK,I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,GAAGf,UAAU,CAACgB,iBAAiB,CAACC,UAAU,CAAC;IACzD,IAAI4B,mBAAmB,GAAG,IAAI,CAACd,sBAAsB;IACrD,IAAIhB,QAAQ,EAAE;MAAA;MACZ8B,mBAAmB,4BACjB,IAAI,CAACb,gBAAgB,CAACX,GAAG,CAACN,QAAQ,CAAC,yEAAI8B,mBAAmB;IAC9D;IACA,OAAOA,mBAAmB;EAC5B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,kBAAkB,CAChBC,KAAc,EACd9B,UAAkB,EAGV;IAAA,IAFRK,UAAU,uEAAG,EAAE;IAAA,IACf0B,cAA2C;IAE3C,IAAID,KAAK,IAAI,IAAI,EAAE;MACjB,OAAO,EAAE;IACX;IAEA,IAAME,SAAS,GAAG,IAAI,CAACL,sBAAsB,CAAC3B,UAAU,CAAC;IACzD,IAAMM,MAAM,GACVyB,cAAc,IAAI,IAAI,CAACL,eAAe,CAAC1B,UAAU,EAAEK,UAAU,CAAC;IAEhE,OAAO2B,SAAS,CAAC1B,MAAM,CAACwB,KAAK,EAAExB,MAAM,aAANA,MAAM,cAANA,MAAM,GAAImB,SAAS,CAAC;EACrD;;EAEA;AACF;AACA;AACA;EACE,IAAIQ,QAAQ,GAAW;IAAA;IACrB,IAAMD,SAAS,GAAG,IAAI,CAACjB,gBAAgB,CAACX,GAAG,CACzCrB,UAAU,CAACe,QAAQ,CAACoB,QAAQ,CACF;IAC5B,OAAOc,SAAS,aAATA,SAAS,gDAATA,SAAS,CAAEE,UAAU,0DAArB,sBAAuBC,EAAE;EAClC;AACF;AAEA,eAAe5C,SAAS"}
|
package/dist/FormatterUtils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import Formatter from './Formatter';
|
|
|
3
3
|
import { DateTimeColumnFormatter } from './formatters';
|
|
4
4
|
import { ColumnFormatSettings, DateTimeFormatSettings } from './Settings';
|
|
5
5
|
export declare function getColumnFormats(settings?: ColumnFormatSettings): FormattingRule[] | undefined;
|
|
6
|
-
export declare function getDateTimeFormatterOptions(settings?: DateTimeFormatSettings | null): ConstructorParameters<typeof DateTimeColumnFormatter>[
|
|
6
|
+
export declare function getDateTimeFormatterOptions(settings?: DateTimeFormatSettings | null): ConstructorParameters<typeof DateTimeColumnFormatter>[1];
|
|
7
7
|
/**
|
|
8
8
|
* Check if the formatter has a custom format defined for the column name and type
|
|
9
9
|
* @param formatter Formatter to check
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterUtils.js","names":["TableColumnFormatter","getColumnFormats","settings","formatter","undefined","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormatString","defaultDateTimeFormat","showTimeZone","showTSeparator","isCustomColumnFormatDefined","columnName","columnType","columnFormat","getColumnFormat","type","TYPE_CONTEXT_PRESET","TYPE_CONTEXT_CUSTOM"],"sources":["../src/FormatterUtils.ts"],"sourcesContent":["import type { FormattingRule } from './Formatter';\nimport Formatter from './Formatter';\nimport { DateTimeColumnFormatter, TableColumnFormatter } from './formatters';\nimport { ColumnFormatSettings, DateTimeFormatSettings } from './Settings';\n\nexport function getColumnFormats(\n settings?: ColumnFormatSettings\n): FormattingRule[] | undefined {\n if (settings && settings.formatter) {\n const { formatter } = settings;\n return formatter;\n }\n return undefined;\n}\n\nexport function getDateTimeFormatterOptions(\n settings?: DateTimeFormatSettings | null\n): ConstructorParameters<typeof DateTimeColumnFormatter>[
|
|
1
|
+
{"version":3,"file":"FormatterUtils.js","names":["TableColumnFormatter","getColumnFormats","settings","formatter","undefined","getDateTimeFormatterOptions","timeZone","defaultDateTimeFormatString","defaultDateTimeFormat","showTimeZone","showTSeparator","isCustomColumnFormatDefined","columnName","columnType","columnFormat","getColumnFormat","type","TYPE_CONTEXT_PRESET","TYPE_CONTEXT_CUSTOM"],"sources":["../src/FormatterUtils.ts"],"sourcesContent":["import type { FormattingRule } from './Formatter';\nimport Formatter from './Formatter';\nimport { DateTimeColumnFormatter, TableColumnFormatter } from './formatters';\nimport { ColumnFormatSettings, DateTimeFormatSettings } from './Settings';\n\nexport function getColumnFormats(\n settings?: ColumnFormatSettings\n): FormattingRule[] | undefined {\n if (settings && settings.formatter) {\n const { formatter } = settings;\n return formatter;\n }\n return undefined;\n}\n\nexport function getDateTimeFormatterOptions(\n settings?: DateTimeFormatSettings | null\n): ConstructorParameters<typeof DateTimeColumnFormatter>[1] {\n return {\n timeZone: settings?.timeZone,\n defaultDateTimeFormatString: settings?.defaultDateTimeFormat,\n showTimeZone: settings?.showTimeZone,\n showTSeparator: settings?.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 */\nexport function 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\nexport default {\n getColumnFormats,\n getDateTimeFormatterOptions,\n isCustomColumnFormatDefined,\n};\n"],"mappings":"SAEkCA,oBAAoB;AAGtD,OAAO,SAASC,gBAAgB,CAC9BC,QAA+B,EACD;EAC9B,IAAIA,QAAQ,IAAIA,QAAQ,CAACC,SAAS,EAAE;IAClC,IAAM;MAAEA;IAAU,CAAC,GAAGD,QAAQ;IAC9B,OAAOC,SAAS;EAClB;EACA,OAAOC,SAAS;AAClB;AAEA,OAAO,SAASC,2BAA2B,CACzCH,QAAwC,EACkB;EAC1D,OAAO;IACLI,QAAQ,EAAEJ,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,QAAQ;IAC5BC,2BAA2B,EAAEL,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM,qBAAqB;IAC5DC,YAAY,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO,YAAY;IACpCC,cAAc,EAAER,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEQ;EAC5B,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2B,CACzCR,SAAoB,EACpBS,UAAkB,EAClBC,UAAkB,EACT;EACT,IAAMC,YAAY,GAAGX,SAAS,CAACY,eAAe,CAACF,UAAU,EAAED,UAAU,CAAC;EACtE,OACEE,YAAY,IAAI,IAAI,KACnBA,YAAY,CAACE,IAAI,KAAKhB,oBAAoB,CAACiB,mBAAmB,IAC7DH,YAAY,CAACE,IAAI,KAAKhB,oBAAoB,CAACkB,mBAAmB,CAAC;AAErE;AAEA,eAAe;EACbjB,gBAAgB;EAChBI,2BAA2B;EAC3BM;AACF,CAAC"}
|
package/dist/SessionUtils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectOptions, CoreClient, IdeConnection, IdeSession } from '@deephaven/jsapi-types';
|
|
1
|
+
import type { ConnectOptions, CoreClient, dh as DhType, IdeConnection, IdeSession } from '@deephaven/jsapi-types';
|
|
2
2
|
export interface SessionConfig {
|
|
3
3
|
type: string;
|
|
4
4
|
id: string;
|
|
@@ -16,13 +16,13 @@ export interface SessionWrapper {
|
|
|
16
16
|
/**
|
|
17
17
|
* @returns New connection to the server
|
|
18
18
|
*/
|
|
19
|
-
export declare function createConnection(websocketUrl: string): IdeConnection;
|
|
19
|
+
export declare function createConnection(dh: DhType, websocketUrl: string): IdeConnection;
|
|
20
20
|
/**
|
|
21
21
|
* Create a new session using the default URL
|
|
22
22
|
* @returns A session and config that is ready to use
|
|
23
23
|
*/
|
|
24
24
|
export declare function createSessionWrapper(connection: IdeConnection, details: SessionDetails): Promise<SessionWrapper>;
|
|
25
|
-
export declare function createCoreClient(websocketUrl: string, options?: ConnectOptions): CoreClient;
|
|
25
|
+
export declare function createCoreClient(dh: DhType, websocketUrl: string, options?: ConnectOptions): CoreClient;
|
|
26
26
|
export declare function getSessionDetails(): Promise<SessionDetails>;
|
|
27
27
|
export declare function loadSessionWrapper(connection: IdeConnection, sessionDetails: SessionDetails): Promise<SessionWrapper | undefined>;
|
|
28
28
|
//# sourceMappingURL=SessionUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionUtils.d.ts","sourceRoot":"","sources":["../src/SessionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,EACX,MAAM,wBAAwB,CAAC;AAWhC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"SessionUtils.d.ts","sourceRoot":"","sources":["../src/SessionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,EAAE,IAAI,MAAM,EACZ,aAAa,EACb,UAAU,EACX,MAAM,wBAAwB,CAAC;AAWhC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,GACnB,aAAa,CAIf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CA2BzB;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAIZ;AAcD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CAOjE;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,aAAa,EACzB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAWrC"}
|
package/dist/SessionUtils.js
CHANGED
|
@@ -8,7 +8,7 @@ var log = Log.module('SessionUtils');
|
|
|
8
8
|
/**
|
|
9
9
|
* @returns New connection to the server
|
|
10
10
|
*/
|
|
11
|
-
export function createConnection(websocketUrl) {
|
|
11
|
+
export function createConnection(dh, websocketUrl) {
|
|
12
12
|
log.info("Starting connection to '".concat(websocketUrl, "'..."));
|
|
13
13
|
return new dh.IdeConnection(websocketUrl);
|
|
14
14
|
}
|
|
@@ -45,7 +45,7 @@ function _createSessionWrapper() {
|
|
|
45
45
|
});
|
|
46
46
|
return _createSessionWrapper.apply(this, arguments);
|
|
47
47
|
}
|
|
48
|
-
export function createCoreClient(websocketUrl, options) {
|
|
48
|
+
export function createCoreClient(dh, websocketUrl, options) {
|
|
49
49
|
log.info('createCoreClient', websocketUrl);
|
|
50
50
|
return new dh.CoreClient(websocketUrl, options);
|
|
51
51
|
}
|
package/dist/SessionUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionUtils.js","names":["requestParentResponse","SESSION_DETAILS_REQUEST","Log","shortid","NoConsolesError","isNoConsolesError","log","module","createConnection","
|
|
1
|
+
{"version":3,"file":"SessionUtils.js","names":["requestParentResponse","SESSION_DETAILS_REQUEST","Log","shortid","NoConsolesError","isNoConsolesError","log","module","createConnection","dh","websocketUrl","info","IdeConnection","createSessionWrapper","connection","details","types","getConsoleTypes","length","type","session","startSession","config","id","generate","createCoreClient","options","CoreClient","isSessionDetails","obj","requestParentSessionDetails","response","Error","getSessionDetails","searchParams","URLSearchParams","window","location","search","get","loadSessionWrapper","sessionDetails","sessionWrapper","e"],"sources":["../src/SessionUtils.ts"],"sourcesContent":["import type {\n ConnectOptions,\n CoreClient,\n dh as DhType,\n IdeConnection,\n IdeSession,\n} from '@deephaven/jsapi-types';\nimport {\n requestParentResponse,\n SESSION_DETAILS_REQUEST,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport shortid from 'shortid';\nimport NoConsolesError, { isNoConsolesError } from './NoConsolesError';\n\nconst log = Log.module('SessionUtils');\n\nexport interface SessionConfig {\n type: string;\n id: string;\n}\n\nexport interface SessionDetails {\n workerName?: string;\n processInfoId?: string;\n}\n\nexport interface SessionWrapper {\n session: IdeSession;\n connection: IdeConnection;\n config: SessionConfig;\n details?: SessionDetails;\n}\n\n/**\n * @returns New connection to the server\n */\nexport function createConnection(\n dh: DhType,\n websocketUrl: string\n): IdeConnection {\n log.info(`Starting connection to '${websocketUrl}'...`);\n\n return new dh.IdeConnection(websocketUrl);\n}\n\n/**\n * Create a new session using the default URL\n * @returns A session and config that is ready to use\n */\nexport async function createSessionWrapper(\n connection: IdeConnection,\n details: SessionDetails\n): Promise<SessionWrapper> {\n log.info('Getting console types...');\n\n const types = await connection.getConsoleTypes();\n\n if (types.length === 0) {\n throw new NoConsolesError('No console types available');\n }\n\n log.info('Available types:', types);\n\n const type = types[0];\n\n log.info('Starting session with type', type);\n\n const session = await connection.startSession(type);\n\n const config = { type, id: shortid.generate() };\n\n log.info('Console session established', config);\n\n return {\n session,\n config,\n connection,\n details,\n };\n}\n\nexport function createCoreClient(\n dh: DhType,\n websocketUrl: string,\n options?: ConnectOptions\n): CoreClient {\n log.info('createCoreClient', websocketUrl);\n\n return new dh.CoreClient(websocketUrl, options);\n}\n\nfunction isSessionDetails(obj: unknown): obj is SessionDetails {\n return obj != null && typeof obj === 'object';\n}\n\nasync function requestParentSessionDetails(): Promise<SessionDetails> {\n const response = await requestParentResponse(SESSION_DETAILS_REQUEST);\n if (!isSessionDetails(response)) {\n throw new Error(`Unexpected session details response: ${response}`);\n }\n return response;\n}\n\nexport async function getSessionDetails(): Promise<SessionDetails> {\n const searchParams = new URLSearchParams(window.location.search);\n switch (searchParams.get('authProvider')) {\n case 'parent':\n return requestParentSessionDetails();\n }\n return {};\n}\n\nexport async function loadSessionWrapper(\n connection: IdeConnection,\n sessionDetails: SessionDetails\n): Promise<SessionWrapper | undefined> {\n let sessionWrapper: SessionWrapper | undefined;\n try {\n sessionWrapper = await createSessionWrapper(connection, sessionDetails);\n } catch (e) {\n // Consoles may be disabled on the server, but we should still be able to start up and open existing objects\n if (!isNoConsolesError(e)) {\n throw e;\n }\n }\n return sessionWrapper;\n}\n"],"mappings":";;AAOA,SACEA,qBAAqB,EACrBC,uBAAuB,QAClB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,OAAOC,OAAO,MAAM,SAAS;AAAC,OACvBC,eAAe,IAAIC,iBAAiB;AAE3C,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAM,CAAC,cAAc,CAAC;AAmBtC;AACA;AACA;AACA,OAAO,SAASC,gBAAgB,CAC9BC,EAAU,EACVC,YAAoB,EACL;EACfJ,GAAG,CAACK,IAAI,mCAA4BD,YAAY,UAAO;EAEvD,OAAO,IAAID,EAAE,CAACG,aAAa,CAACF,YAAY,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA,gBAAsBG,oBAAoB;EAAA;AAAA;AA8BzC;EAAA,0CA9BM,WACLC,UAAyB,EACzBC,OAA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E;IACA,OAAOA,QAAQ;EACjB,CAAC;EAAA;AAAA;AAED,gBAAsBE,iBAAiB;EAAA;AAAA;AAOtC;EAAA,uCAPM,aAA4D;IACjE,IAAMC,YAAY,GAAG,IAAIC,eAAe,CAACC,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC;IAChE,QAAQJ,YAAY,CAACK,GAAG,CAAC,cAAc,CAAC;MACtC,KAAK,QAAQ;QACX,OAAOT,2BAA2B,EAAE;IAAC;IAEzC,OAAO,CAAC,CAAC;EACX,CAAC;EAAA;AAAA;AAED,gBAAsBU,kBAAkB;EAAA;AAAA;AAcvC;EAAA,wCAdM,WACL1B,UAAyB,EACzB2B,cAA8B,EACO;IACrC,IAAIC,cAA0C;IAC9C,IAAI;MACFA,cAAc,SAAS7B,oBAAoB,CAACC,UAAU,EAAE2B,cAAc,CAAC;IACzE,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV;MACA,IAAI,CAACtC,iBAAiB,CAACsC,CAAC,CAAC,EAAE;QACzB,MAAMA,CAAC;MACT;IACF;IACA,OAAOD,cAAc;EACvB,CAAC;EAAA;AAAA"}
|
package/dist/TableUtils.d.ts
CHANGED
|
@@ -66,45 +66,6 @@ export declare class TableUtils {
|
|
|
66
66
|
* event
|
|
67
67
|
*/
|
|
68
68
|
static executeAndWaitForEvent: <T extends Table | TreeTable>(exec: (maybeTable: T | null | undefined) => void, table: T | null | undefined, eventType: string, timeout?: number) => Promise<T | null>;
|
|
69
|
-
/**
|
|
70
|
-
* Apply custom columns to a given table. Return a Promise that resolves with
|
|
71
|
-
* the table once the dh.Table.EVENT_CUSTOMCOLUMNSCHANGED event has fired.
|
|
72
|
-
* @param table The table to apply custom columns to.
|
|
73
|
-
* @param columns The list of column expressions or definitions to apply.
|
|
74
|
-
* @returns A Promise that will be resolved with the given table after the
|
|
75
|
-
* columns are applied.
|
|
76
|
-
*/
|
|
77
|
-
static applyCustomColumns(table: Table | null | undefined, columns: (string | CustomColumn)[], timeout?: number): Promise<Table | null>;
|
|
78
|
-
/**
|
|
79
|
-
* Apply filters to a given table.
|
|
80
|
-
* @param table Table to apply filters to
|
|
81
|
-
* @param filters Filters to apply
|
|
82
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
83
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
84
|
-
* @returns a Promise to the Table that resolves after the next
|
|
85
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
86
|
-
*/
|
|
87
|
-
static applyFilter<T extends Table | TreeTable>(table: T | null | undefined, filters: FilterCondition[], timeout?: number): Promise<T | null>;
|
|
88
|
-
/**
|
|
89
|
-
* Apply a filter to a table that won't match anything.
|
|
90
|
-
* @table The table to apply the filter to
|
|
91
|
-
* @columnName The name of the column to apploy the filter to
|
|
92
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
93
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
94
|
-
* @returns a Promise to the Table that resolves after the next
|
|
95
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
96
|
-
*/
|
|
97
|
-
static applyNeverFilter<T extends Table | TreeTable>(table: T | null | undefined, columnName: string, timeout?: number): Promise<T | null>;
|
|
98
|
-
/**
|
|
99
|
-
* Apply sorts to a given Table.
|
|
100
|
-
* @param table The table to apply sorts to
|
|
101
|
-
* @param sorts The sorts to apply
|
|
102
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
103
|
-
* dh.Table.EVENT_SORTCHANGED event
|
|
104
|
-
* @returns a Promise to the Table that resolves after the next
|
|
105
|
-
* dh.Table.EVENT_SORTCHANGED event
|
|
106
|
-
*/
|
|
107
|
-
static applySort<T extends Table | TreeTable>(table: T | null | undefined, sorts: Sort[], timeout?: number): Promise<T | null>;
|
|
108
69
|
static getSortIndex(sort: readonly Sort[], columnName: ColumnName): number | null;
|
|
109
70
|
/**
|
|
110
71
|
* @param tableSort The sorts from the table to get the sort from
|
|
@@ -238,11 +199,50 @@ export declare class TableUtils {
|
|
|
238
199
|
makeQuickCharFilter(column: Column, text: string): FilterCondition | null;
|
|
239
200
|
makeAdvancedFilter(column: Column, options: AdvancedFilterOptions, timeZone: string): FilterCondition | null;
|
|
240
201
|
makeAdvancedValueFilter(column: Column, operation: FilterTypeValue, value: string, timeZone: string): FilterCondition | null;
|
|
202
|
+
/**
|
|
203
|
+
* Apply a filter to a table that won't match anything.
|
|
204
|
+
* @table The table to apply the filter to
|
|
205
|
+
* @columnName The name of the column to apploy the filter to
|
|
206
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
207
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
208
|
+
* @returns a Promise to the Table that resolves after the next
|
|
209
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
210
|
+
*/
|
|
211
|
+
applyNeverFilter<T extends Table | TreeTable>(table: T | null | undefined, columnName: string, timeout?: number): Promise<T | null>;
|
|
212
|
+
/**
|
|
213
|
+
* Apply custom columns to a given table. Return a Promise that resolves with
|
|
214
|
+
* the table once the dh.Table.EVENT_CUSTOMCOLUMNSCHANGED event has fired.
|
|
215
|
+
* @param table The table to apply custom columns to.
|
|
216
|
+
* @param columns The list of column expressions or definitions to apply.
|
|
217
|
+
* @returns A Promise that will be resolved with the given table after the
|
|
218
|
+
* columns are applied.
|
|
219
|
+
*/
|
|
220
|
+
applyCustomColumns(table: Table | null | undefined, columns: (string | CustomColumn)[], timeout?: number): Promise<Table | null>;
|
|
221
|
+
/**
|
|
222
|
+
* Apply filters to a given table.
|
|
223
|
+
* @param table Table to apply filters to
|
|
224
|
+
* @param filters Filters to apply
|
|
225
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
226
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
227
|
+
* @returns a Promise to the Table that resolves after the next
|
|
228
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
229
|
+
*/
|
|
230
|
+
applyFilter<T extends Table | TreeTable>(table: T | null | undefined, filters: FilterCondition[], timeout?: number): Promise<T | null>;
|
|
231
|
+
/**
|
|
232
|
+
* Apply sorts to a given Table.
|
|
233
|
+
* @param table The table to apply sorts to
|
|
234
|
+
* @param sorts The sorts to apply
|
|
235
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
236
|
+
* dh.Table.EVENT_SORTCHANGED event
|
|
237
|
+
* @returns a Promise to the Table that resolves after the next
|
|
238
|
+
* dh.Table.EVENT_SORTCHANGED event
|
|
239
|
+
*/
|
|
240
|
+
applySort<T extends Table | TreeTable>(table: T | null | undefined, sorts: Sort[], timeout?: number): Promise<T | null>;
|
|
241
241
|
/**
|
|
242
242
|
* Create a filter condition that results in zero results for a given column
|
|
243
243
|
* @param column
|
|
244
244
|
*/
|
|
245
|
-
|
|
245
|
+
makeNeverFilter(column: Column): FilterCondition;
|
|
246
246
|
/**
|
|
247
247
|
* @param columnType The column type to make the filter value from.
|
|
248
248
|
* @param value The value to make the filter value from.
|
package/dist/TableUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableUtils.d.ts","sourceRoot":"","sources":["../src/TableUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,IAAI,eAAe,EAC5B,aAAa,IAAI,mBAAmB,EACrC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,EAAE,IAAI,MAAM,EACZ,eAAe,EACf,WAAW,EACX,WAAW,EAEX,IAAI,EACJ,KAAK,EACL,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,MAA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AI;IA2BjD;;;;;;;;OAQG;IACH,qBAAqB,CAAC,OAAO,SAAS,OAAO,EAC3C,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,OAAO,EAAE,EACzB,eAAe,EAAE,OAAO,GACvB,OAAO,SAAS,IAAI,GAAG,eAAe,GAAG,IAAI,GAAG,eAAe;CA2DnE;AAED,eAAe,UAAU,CAAC"}
|
package/dist/TableUtils.js
CHANGED
|
@@ -25,78 +25,6 @@ export class TableUtils {
|
|
|
25
25
|
* event
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Apply custom columns to a given table. Return a Promise that resolves with
|
|
30
|
-
* the table once the dh.Table.EVENT_CUSTOMCOLUMNSCHANGED event has fired.
|
|
31
|
-
* @param table The table to apply custom columns to.
|
|
32
|
-
* @param columns The list of column expressions or definitions to apply.
|
|
33
|
-
* @returns A Promise that will be resolved with the given table after the
|
|
34
|
-
* columns are applied.
|
|
35
|
-
*/
|
|
36
|
-
static applyCustomColumns(table, columns) {
|
|
37
|
-
var _arguments = arguments;
|
|
38
|
-
return _asyncToGenerator(function* () {
|
|
39
|
-
var timeout = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
40
|
-
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applyCustomColumns(columns), table, dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, timeout);
|
|
41
|
-
})();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Apply filters to a given table.
|
|
46
|
-
* @param table Table to apply filters to
|
|
47
|
-
* @param filters Filters to apply
|
|
48
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
49
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
50
|
-
* @returns a Promise to the Table that resolves after the next
|
|
51
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
52
|
-
*/
|
|
53
|
-
static applyFilter(table, filters) {
|
|
54
|
-
var _arguments2 = arguments;
|
|
55
|
-
return _asyncToGenerator(function* () {
|
|
56
|
-
var timeout = _arguments2.length > 2 && _arguments2[2] !== undefined ? _arguments2[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
57
|
-
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applyFilter(filters), table, dh.Table.EVENT_FILTERCHANGED, timeout);
|
|
58
|
-
})();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Apply a filter to a table that won't match anything.
|
|
63
|
-
* @table The table to apply the filter to
|
|
64
|
-
* @columnName The name of the column to apploy the filter to
|
|
65
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
66
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
67
|
-
* @returns a Promise to the Table that resolves after the next
|
|
68
|
-
* dh.Table.EVENT_FILTERCHANGED event
|
|
69
|
-
*/
|
|
70
|
-
static applyNeverFilter(table, columnName) {
|
|
71
|
-
var _arguments3 = arguments;
|
|
72
|
-
return _asyncToGenerator(function* () {
|
|
73
|
-
var timeout = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
74
|
-
if (table == null) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
var column = table.findColumn(columnName);
|
|
78
|
-
var filters = [TableUtils.makeNeverFilter(column)];
|
|
79
|
-
yield TableUtils.applyFilter(table, filters, timeout);
|
|
80
|
-
return table;
|
|
81
|
-
})();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Apply sorts to a given Table.
|
|
86
|
-
* @param table The table to apply sorts to
|
|
87
|
-
* @param sorts The sorts to apply
|
|
88
|
-
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
89
|
-
* dh.Table.EVENT_SORTCHANGED event
|
|
90
|
-
* @returns a Promise to the Table that resolves after the next
|
|
91
|
-
* dh.Table.EVENT_SORTCHANGED event
|
|
92
|
-
*/
|
|
93
|
-
static applySort(table, sorts) {
|
|
94
|
-
var _arguments4 = arguments;
|
|
95
|
-
return _asyncToGenerator(function* () {
|
|
96
|
-
var timeout = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
97
|
-
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applySort(sorts), table, dh.Table.EVENT_SORTCHANGED, timeout);
|
|
98
|
-
})();
|
|
99
|
-
}
|
|
100
28
|
static getSortIndex(sort, columnName) {
|
|
101
29
|
for (var i = 0; i < sort.length; i += 1) {
|
|
102
30
|
var _s$column;
|
|
@@ -1078,11 +1006,100 @@ export class TableUtils {
|
|
|
1078
1006
|
}
|
|
1079
1007
|
}
|
|
1080
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
* Apply a filter to a table that won't match anything.
|
|
1011
|
+
* @table The table to apply the filter to
|
|
1012
|
+
* @columnName The name of the column to apploy the filter to
|
|
1013
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
1014
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
1015
|
+
* @returns a Promise to the Table that resolves after the next
|
|
1016
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
1017
|
+
*/
|
|
1018
|
+
applyNeverFilter(table, columnName) {
|
|
1019
|
+
var _arguments = arguments,
|
|
1020
|
+
_this = this;
|
|
1021
|
+
return _asyncToGenerator(function* () {
|
|
1022
|
+
var timeout = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
1023
|
+
if (table == null) {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
var column = table.findColumn(columnName);
|
|
1027
|
+
var filters = [_this.makeNeverFilter(column)];
|
|
1028
|
+
yield _this.applyFilter(table, filters, timeout);
|
|
1029
|
+
return table;
|
|
1030
|
+
})();
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Apply custom columns to a given table. Return a Promise that resolves with
|
|
1035
|
+
* the table once the dh.Table.EVENT_CUSTOMCOLUMNSCHANGED event has fired.
|
|
1036
|
+
* @param table The table to apply custom columns to.
|
|
1037
|
+
* @param columns The list of column expressions or definitions to apply.
|
|
1038
|
+
* @returns A Promise that will be resolved with the given table after the
|
|
1039
|
+
* columns are applied.
|
|
1040
|
+
*/
|
|
1041
|
+
applyCustomColumns(table, columns) {
|
|
1042
|
+
var _arguments2 = arguments,
|
|
1043
|
+
_this2 = this;
|
|
1044
|
+
return _asyncToGenerator(function* () {
|
|
1045
|
+
var timeout = _arguments2.length > 2 && _arguments2[2] !== undefined ? _arguments2[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
1046
|
+
var {
|
|
1047
|
+
dh
|
|
1048
|
+
} = _this2;
|
|
1049
|
+
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applyCustomColumns(columns), table, dh.Table.EVENT_CUSTOMCOLUMNSCHANGED, timeout);
|
|
1050
|
+
})();
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Apply filters to a given table.
|
|
1055
|
+
* @param table Table to apply filters to
|
|
1056
|
+
* @param filters Filters to apply
|
|
1057
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
1058
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
1059
|
+
* @returns a Promise to the Table that resolves after the next
|
|
1060
|
+
* dh.Table.EVENT_FILTERCHANGED event
|
|
1061
|
+
*/
|
|
1062
|
+
applyFilter(table, filters) {
|
|
1063
|
+
var _arguments3 = arguments,
|
|
1064
|
+
_this3 = this;
|
|
1065
|
+
return _asyncToGenerator(function* () {
|
|
1066
|
+
var timeout = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
1067
|
+
var {
|
|
1068
|
+
dh
|
|
1069
|
+
} = _this3;
|
|
1070
|
+
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applyFilter(filters), table, dh.Table.EVENT_FILTERCHANGED, timeout);
|
|
1071
|
+
})();
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Apply sorts to a given Table.
|
|
1076
|
+
* @param table The table to apply sorts to
|
|
1077
|
+
* @param sorts The sorts to apply
|
|
1078
|
+
* @param timeout Timeout before cancelling the promise that waits for the next
|
|
1079
|
+
* dh.Table.EVENT_SORTCHANGED event
|
|
1080
|
+
* @returns a Promise to the Table that resolves after the next
|
|
1081
|
+
* dh.Table.EVENT_SORTCHANGED event
|
|
1082
|
+
*/
|
|
1083
|
+
applySort(table, sorts) {
|
|
1084
|
+
var _arguments4 = arguments,
|
|
1085
|
+
_this4 = this;
|
|
1086
|
+
return _asyncToGenerator(function* () {
|
|
1087
|
+
var timeout = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : TableUtils.APPLY_TABLE_CHANGE_TIMEOUT_MS;
|
|
1088
|
+
var {
|
|
1089
|
+
dh
|
|
1090
|
+
} = _this4;
|
|
1091
|
+
return TableUtils.executeAndWaitForEvent(t => t === null || t === void 0 ? void 0 : t.applySort(sorts), table, dh.Table.EVENT_SORTCHANGED, timeout);
|
|
1092
|
+
})();
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1081
1095
|
/**
|
|
1082
1096
|
* Create a filter condition that results in zero results for a given column
|
|
1083
1097
|
* @param column
|
|
1084
1098
|
*/
|
|
1085
|
-
|
|
1099
|
+
makeNeverFilter(column) {
|
|
1100
|
+
var {
|
|
1101
|
+
dh
|
|
1102
|
+
} = this;
|
|
1086
1103
|
var value = null;
|
|
1087
1104
|
if (TableUtils.isTextType(column.type)) {
|
|
1088
1105
|
// Use 'a' so that it can work for String or Character types
|
|
@@ -1193,7 +1210,7 @@ export class TableUtils {
|
|
|
1193
1210
|
// KLUDGE: Return a conflicting filter to show no results.
|
|
1194
1211
|
// Could recognize this situation at a higher or lower level and pause updates on the
|
|
1195
1212
|
// table, but this situation should be rare and that wouldn't be much gains for some added complexity
|
|
1196
|
-
return
|
|
1213
|
+
return this.makeNeverFilter(column);
|
|
1197
1214
|
}
|
|
1198
1215
|
var values = [];
|
|
1199
1216
|
var isNullSelected = false;
|