@thoughtspot/ts-chart-sdk 0.0.2-alpha.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -50
- package/dist/ts-chart-sdk.d.ts +330 -32
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/main/custom-chart-context.d.ts +17 -4
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +46 -16
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +302 -4
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/main/logger.d.ts +13 -0
- package/lib/main/logger.d.ts.map +1 -0
- package/lib/main/logger.js +64 -0
- package/lib/main/logger.js.map +1 -0
- package/lib/main/logger.spec.d.ts +2 -0
- package/lib/main/logger.spec.d.ts.map +1 -0
- package/lib/main/logger.spec.js +88 -0
- package/lib/main/logger.spec.js.map +1 -0
- package/lib/main/util.d.ts +2 -0
- package/lib/main/util.d.ts.map +1 -1
- package/lib/main/util.js +11 -0
- package/lib/main/util.js.map +1 -1
- package/lib/main/util.spec.d.ts +2 -0
- package/lib/main/util.spec.d.ts.map +1 -0
- package/lib/main/util.spec.js +73 -0
- package/lib/main/util.spec.js.map +1 -0
- package/lib/react/use-custom-chart-context.d.ts.map +1 -1
- package/lib/react/use-custom-chart-context.js +3 -1
- package/lib/react/use-custom-chart-context.js.map +1 -1
- package/lib/react/use-custom-chart-context.spec.js +0 -1
- package/lib/react/use-custom-chart-context.spec.js.map +1 -1
- package/lib/react/use-custom-chart-context.util.d.ts.map +1 -1
- package/lib/react/use-custom-chart-context.util.js +5 -3
- package/lib/react/use-custom-chart-context.util.js.map +1 -1
- package/lib/types/answer-column.types.d.ts +7 -4
- package/lib/types/answer-column.types.d.ts.map +1 -1
- package/lib/types/answer-column.types.js +3 -3
- package/lib/types/answer-column.types.js.map +1 -1
- package/lib/types/chart-to-ts-event.types.d.ts +2 -0
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +1 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/lib/types/common.types.d.ts +65 -6
- package/lib/types/common.types.d.ts.map +1 -1
- package/lib/types/common.types.js.map +1 -1
- package/lib/types/conditional-formatting.types.d.ts +1 -16
- package/lib/types/conditional-formatting.types.d.ts.map +1 -1
- package/lib/types/conditional-formatting.types.js.map +1 -1
- package/lib/types/configurator.types.d.ts +1 -1
- package/lib/types/configurator.types.d.ts.map +1 -1
- package/lib/types/number-formatting.types.d.ts +55 -0
- package/lib/types/number-formatting.types.d.ts.map +1 -0
- package/lib/types/number-formatting.types.js +23 -0
- package/lib/types/number-formatting.types.js.map +1 -0
- package/lib/types/ts-to-chart-event.types.d.ts +20 -6
- package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
- package/lib/types/ts-to-chart-event.types.js +1 -0
- package/lib/types/ts-to-chart-event.types.js.map +1 -1
- package/lib/types/visual-prop.types.d.ts +71 -3
- package/lib/types/visual-prop.types.d.ts.map +1 -1
- package/lib/types/visual-prop.types.js +32 -1
- package/lib/types/visual-prop.types.js.map +1 -1
- package/lib/utils/date-formatting.d.ts +85 -1
- package/lib/utils/date-formatting.d.ts.map +1 -1
- package/lib/utils/date-formatting.js +344 -9
- package/lib/utils/date-formatting.js.map +1 -1
- package/lib/utils/date-formatting.spec.js +301 -31
- package/lib/utils/date-formatting.spec.js.map +1 -1
- package/lib/utils/date-utils.d.ts +6 -0
- package/lib/utils/date-utils.d.ts.map +1 -0
- package/lib/utils/date-utils.js +20 -0
- package/lib/utils/date-utils.js.map +1 -0
- package/lib/utils/date-utils.spec.d.ts +2 -0
- package/lib/utils/date-utils.spec.d.ts.map +1 -0
- package/lib/utils/date-utils.spec.js +63 -0
- package/lib/utils/date-utils.spec.js.map +1 -0
- package/lib/utils/formatting-util.d.ts +10 -0
- package/lib/utils/formatting-util.d.ts.map +1 -0
- package/lib/utils/formatting-util.js +78 -0
- package/lib/utils/formatting-util.js.map +1 -0
- package/lib/utils/formatting-util.spec.d.ts +2 -0
- package/lib/utils/formatting-util.spec.d.ts.map +1 -0
- package/lib/utils/formatting-util.spec.js +247 -0
- package/lib/utils/formatting-util.spec.js.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.d.ts +16 -0
- package/lib/utils/globalize-Initializer/globalize-utils.d.ts.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.js +101 -0
- package/lib/utils/globalize-Initializer/globalize-utils.js.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts +2 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts.map +1 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.js +149 -0
- package/lib/utils/globalize-Initializer/globalize-utils.spec.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.d.ts +20 -0
- package/lib/utils/number-formatting/number-formatting-utils.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.js +159 -0
- package/lib/utils/number-formatting/number-formatting-utils.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts +2 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.js +221 -0
- package/lib/utils/number-formatting/number-formatting-utils.spec.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting.d.ts +5 -0
- package/lib/utils/number-formatting/number-formatting.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting.js +128 -0
- package/lib/utils/number-formatting/number-formatting.js.map +1 -0
- package/lib/utils/number-formatting/number-formatting.spec.d.ts +2 -0
- package/lib/utils/number-formatting/number-formatting.spec.d.ts.map +1 -0
- package/lib/utils/number-formatting/number-formatting.spec.js +159 -0
- package/lib/utils/number-formatting/number-formatting.spec.js.map +1 -0
- package/package.json +4 -1
- package/src/index.ts +3 -0
- package/src/main/custom-chart-context.spec.ts +356 -6
- package/src/main/custom-chart-context.ts +205 -16
- package/src/main/logger.spec.ts +114 -0
- package/src/main/logger.ts +97 -0
- package/src/main/util.spec.ts +94 -0
- package/src/main/util.ts +20 -0
- package/src/react/use-custom-chart-context.spec.tsx +0 -1
- package/src/react/use-custom-chart-context.tsx +4 -1
- package/src/react/use-custom-chart-context.util.ts +6 -3
- package/src/types/answer-column.types.ts +9 -6
- package/src/types/chart-to-ts-event.types.ts +7 -0
- package/src/types/common.types.ts +100 -10
- package/src/types/conditional-formatting.types.ts +2 -17
- package/src/types/configurator.types.ts +1 -1
- package/src/types/number-formatting.types.ts +80 -0
- package/src/types/ts-to-chart-event.types.ts +63 -5
- package/src/types/visual-prop.types.ts +197 -3
- package/src/utils/date-formatting.spec.ts +375 -32
- package/src/utils/date-formatting.ts +587 -14
- package/src/utils/date-utils.spec.ts +93 -0
- package/src/utils/date-utils.ts +69 -0
- package/src/utils/formatting-util.spec.ts +312 -0
- package/src/utils/formatting-util.ts +234 -0
- package/src/utils/globalize-Initializer/globalize-utils.spec.ts +192 -0
- package/src/utils/globalize-Initializer/globalize-utils.ts +216 -0
- package/src/utils/number-formatting/number-formatting-utils.spec.ts +296 -0
- package/src/utils/number-formatting/number-formatting-utils.ts +260 -0
- package/src/utils/number-formatting/number-formatting.spec.ts +243 -0
- package/src/utils/number-formatting/number-formatting.ts +264 -0
package/src/main/util.ts
CHANGED
|
@@ -9,3 +9,23 @@ export function timeout(promise: Promise<any>, ms: number, message?: string) {
|
|
|
9
9
|
}),
|
|
10
10
|
]);
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
export function handleMissingValue(
|
|
14
|
+
paramKey: string,
|
|
15
|
+
paramValue?: string | null,
|
|
16
|
+
): string {
|
|
17
|
+
if (paramKey === 'debug') {
|
|
18
|
+
return paramValue ?? 'false';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return paramValue ?? '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getQueryParam(url: string, paramName: string): string {
|
|
25
|
+
const urlObj = new URL(url);
|
|
26
|
+
const paramValue = handleMissingValue(
|
|
27
|
+
paramName,
|
|
28
|
+
urlObj.searchParams.get(paramName),
|
|
29
|
+
);
|
|
30
|
+
return paramValue;
|
|
31
|
+
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CustomChartContext,
|
|
13
13
|
CustomChartContextProps,
|
|
14
14
|
} from '../main/custom-chart-context';
|
|
15
|
+
import { create } from '../main/logger';
|
|
15
16
|
import { ChartModel } from '../types/common.types';
|
|
16
17
|
import {
|
|
17
18
|
ChartModelUpdateEventPayload,
|
|
@@ -28,6 +29,8 @@ import {
|
|
|
28
29
|
TSChartContextProps,
|
|
29
30
|
} from './use-custom-chart-types';
|
|
30
31
|
|
|
32
|
+
const logger = create('CustomChartContextHookSdk');
|
|
33
|
+
|
|
31
34
|
/**
|
|
32
35
|
* A custom hook to manage the Chart Context state and provide necessary
|
|
33
36
|
* chart-related functionality.
|
|
@@ -143,7 +146,7 @@ export const useChartContext = (
|
|
|
143
146
|
return true;
|
|
144
147
|
})
|
|
145
148
|
.catch((e) => {
|
|
146
|
-
|
|
149
|
+
logger.log('Error in context initialization', e);
|
|
147
150
|
});
|
|
148
151
|
};
|
|
149
152
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { CustomChartContext } from '../main/custom-chart-context';
|
|
3
|
+
import { create } from '../main/logger';
|
|
3
4
|
import {
|
|
4
5
|
ChartToTSEvent,
|
|
5
6
|
ChartToTSEventsPayloadMap,
|
|
@@ -14,6 +15,8 @@ import {
|
|
|
14
15
|
TSToChartEventOffListener,
|
|
15
16
|
} from './use-custom-chart-types';
|
|
16
17
|
|
|
18
|
+
const logger = create('CustomChartContextUtilSdk');
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
*
|
|
19
22
|
* @param ctx Custom Chart Context
|
|
@@ -31,7 +34,7 @@ export const emitter = (ctx: CustomChartContext): ChartToTSEventEmitters => {
|
|
|
31
34
|
...args: ChartToTSEventsPayloadMap[keyof ChartToTSEventsPayloadMap]
|
|
32
35
|
): Promise<void> => {
|
|
33
36
|
if (!ctx || _.isEmpty(ctx)) {
|
|
34
|
-
|
|
37
|
+
logger.log('Context is not initialized');
|
|
35
38
|
return Promise.reject(new Error('Context not initialized'));
|
|
36
39
|
}
|
|
37
40
|
return ctx.emitEvent(eventName, ...args);
|
|
@@ -60,7 +63,7 @@ export const eventListener = (
|
|
|
60
63
|
callbackFn: TSToChartEventsPayloadMap[keyof TSToChartEventsPayloadMap],
|
|
61
64
|
): Promise<void> => {
|
|
62
65
|
if (!ctx || _.isEmpty(ctx)) {
|
|
63
|
-
|
|
66
|
+
logger.log('Context is not initialized');
|
|
64
67
|
return Promise.reject(new Error('Context not initialized'));
|
|
65
68
|
}
|
|
66
69
|
ctx.on(eventName, callbackFn);
|
|
@@ -89,7 +92,7 @@ export const eventOffListener = (
|
|
|
89
92
|
|
|
90
93
|
acc[emitterKey] = (): Promise<void> => {
|
|
91
94
|
if (!ctx || _.isEmpty(ctx)) {
|
|
92
|
-
|
|
95
|
+
logger.log('Context is not initialized');
|
|
93
96
|
return Promise.reject(new Error('Context not initialized'));
|
|
94
97
|
}
|
|
95
98
|
ctx.off(eventName);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Maybe } from './common.types';
|
|
2
|
+
import { ConditionalFormatting } from './conditional-formatting.types';
|
|
3
|
+
import { FormatConfig } from './number-formatting.types';
|
|
2
4
|
|
|
3
5
|
export enum ColumnType {
|
|
4
6
|
UNKNOWN,
|
|
@@ -80,9 +82,9 @@ export enum FormatType {
|
|
|
80
82
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
81
83
|
*/
|
|
82
84
|
export enum CurrencyFormatType {
|
|
83
|
-
USER_LOCALE,
|
|
84
|
-
COLUMN,
|
|
85
|
-
ISO_CODE,
|
|
85
|
+
USER_LOCALE = 'USER_LOCALE',
|
|
86
|
+
COLUMN = 'COLUMN',
|
|
87
|
+
ISO_CODE = 'ISO_CODE',
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
@@ -183,7 +185,7 @@ export interface ChartColumn {
|
|
|
183
185
|
*/
|
|
184
186
|
id: string;
|
|
185
187
|
/**
|
|
186
|
-
* Column name
|
|
188
|
+
* Column name property
|
|
187
189
|
*
|
|
188
190
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
189
191
|
*/
|
|
@@ -234,10 +236,11 @@ export interface ChartColumn {
|
|
|
234
236
|
/**
|
|
235
237
|
* Column Properties of the columns
|
|
236
238
|
*
|
|
237
|
-
* @version SDK: 0.
|
|
239
|
+
* @version SDK: 0.0.2-alpha.15 | ThoughtSpot:
|
|
238
240
|
*/
|
|
239
241
|
columnProperties?: {
|
|
240
242
|
conditionalFormatting?: Maybe<ConditionalFormatting>;
|
|
243
|
+
numberFormatting?: Maybe<FormatConfig>;
|
|
241
244
|
};
|
|
242
245
|
|
|
243
246
|
/**
|
|
@@ -25,6 +25,7 @@ export enum ChartToTSEvent {
|
|
|
25
25
|
/**
|
|
26
26
|
* Render life cycle events
|
|
27
27
|
*/
|
|
28
|
+
InitStart = 'InitStart',
|
|
28
29
|
RenderStart = 'RenderStart',
|
|
29
30
|
RenderError = 'RenderError',
|
|
30
31
|
RenderComplete = 'RenderComplete',
|
|
@@ -72,6 +73,12 @@ export interface ChartToTSEventsPayloadMap {
|
|
|
72
73
|
*/
|
|
73
74
|
[ChartToTSEvent.CloseContextMenu]: [];
|
|
74
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Trigger to notify the Initialization start
|
|
78
|
+
*
|
|
79
|
+
* @version SDK: 0.2 | ThoughtSpot:
|
|
80
|
+
*/
|
|
81
|
+
[ChartToTSEvent.InitStart]: [];
|
|
75
82
|
/**
|
|
76
83
|
* Trigger to notify the render start
|
|
77
84
|
*
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ChartColumn } from './answer-column.types';
|
|
10
|
-
import { ChartConfigEditorDefinition } from './configurator.types';
|
|
11
|
-
import { VisualPropEditorDefinition } from './visual-prop.types';
|
|
10
|
+
import type { ChartConfigEditorDefinition } from './configurator.types';
|
|
11
|
+
import type { VisualPropEditorDefinition } from './visual-prop.types';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Defines types of features for which font can be customised with Custom style config used in TS.
|
|
@@ -17,6 +17,24 @@ import { VisualPropEditorDefinition } from './visual-prop.types';
|
|
|
17
17
|
* from customFontFaces
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
export type Maybe<T> = T | null;
|
|
21
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
22
|
+
|
|
23
|
+
export type Scalars = {
|
|
24
|
+
ID: string;
|
|
25
|
+
String: string;
|
|
26
|
+
Boolean: boolean;
|
|
27
|
+
Int: number;
|
|
28
|
+
Float: number;
|
|
29
|
+
FileUpload: unknown;
|
|
30
|
+
GUID: string;
|
|
31
|
+
JSON: {
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
JSONObject: unknown;
|
|
35
|
+
Long: unknown;
|
|
36
|
+
};
|
|
37
|
+
|
|
20
38
|
export enum CustomizableChartFeature {
|
|
21
39
|
X_AXIS_LABEL,
|
|
22
40
|
X_AXIS_TITLE,
|
|
@@ -170,10 +188,17 @@ export type SuccessValidationResponse = {
|
|
|
170
188
|
visualPropEditorDefinition: VisualPropEditorDefinition;
|
|
171
189
|
};
|
|
172
190
|
|
|
191
|
+
export type VisualPropError = {
|
|
192
|
+
propElementKey: string;
|
|
193
|
+
propElementType: string;
|
|
194
|
+
value: unknown;
|
|
195
|
+
};
|
|
196
|
+
|
|
173
197
|
// Generic Validation Response
|
|
174
198
|
export type ValidationResponse = {
|
|
175
199
|
isValid: boolean;
|
|
176
200
|
validationErrorMessage?: string[];
|
|
201
|
+
visualPropError?: VisualPropError;
|
|
177
202
|
};
|
|
178
203
|
|
|
179
204
|
/**
|
|
@@ -192,12 +217,14 @@ export type ValidationResponse = {
|
|
|
192
217
|
export type VisualProps = unknown;
|
|
193
218
|
|
|
194
219
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
220
|
+
* Font Faces type from TS.
|
|
221
|
+
* guid will be null in case of default Font types
|
|
222
|
+
* If a custom Font is added in Dev section on TS this guid can be used to Match
|
|
223
|
+
* the Font Face That needs to be applied to @link CustomizableChartFeature
|
|
197
224
|
*/
|
|
198
225
|
|
|
199
|
-
export type
|
|
200
|
-
guid: string;
|
|
226
|
+
export type TSFontFace = {
|
|
227
|
+
guid: string | null;
|
|
201
228
|
family?: string;
|
|
202
229
|
format?: string;
|
|
203
230
|
url?: string;
|
|
@@ -224,14 +251,76 @@ export type ChartSdkCustomStylingConfig = {
|
|
|
224
251
|
color?: string;
|
|
225
252
|
};
|
|
226
253
|
chartColorPalettes?: Array<{ colors: Array<string> }>;
|
|
254
|
+
numColorPalettes?: number;
|
|
227
255
|
disableColorRotation?: boolean;
|
|
228
256
|
chartFeatureToFontGuid?: Record<CustomizableChartFeature, string>;
|
|
229
|
-
|
|
257
|
+
fontFaces?: Array<TSFontFace>;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Defines a set of standardized date and datetime format strings used for
|
|
262
|
+
* displaying dates and times in various formats. Each format string represents
|
|
263
|
+
* a specific date or time pattern that can be used for localized display purposes.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
export interface DateFormats {
|
|
267
|
+
DATE_SHORT: string;
|
|
268
|
+
DATE_SHORT_2_DIGIT_YEAR: string;
|
|
269
|
+
DATE_SHORT_WITH_HOUR: string;
|
|
270
|
+
DATE_SHORT_WITH_HOUR_WITHOUT_YEAR: string;
|
|
271
|
+
DATE_SHORT_WITH_HOUR_24: string;
|
|
272
|
+
DATE_SHORT_WITH_HOUR_24_WITHOUT_YEAR: string;
|
|
273
|
+
DATETIME_SHORT: string;
|
|
274
|
+
DATETIME_SHORT_WITHOUT_YEAR: string;
|
|
275
|
+
DATETIME_24_SHORT: string;
|
|
276
|
+
DATETIME_24_SHORT_WITH_MILLIS: string;
|
|
277
|
+
DATETIME_24_SHORT_WITH_MILLIS_WITHOUT_YEAR: string;
|
|
278
|
+
DATETIME_SHORT_WITH_SECONDS: string;
|
|
279
|
+
DATETIME_SHORT_WITH_SECONDS_WITHOUT_YEAR: string;
|
|
280
|
+
DATETIME_SHORT_WITH_MILLIS: string;
|
|
281
|
+
DATETIME_SHORT_WITH_MILLIS_WITHOUT_YEAR: string;
|
|
282
|
+
QUARTER_WITH_YEAR: string;
|
|
283
|
+
QUARTER_WITH_2_DIGIT_YEAR: string;
|
|
284
|
+
DEFAULT_TIME_FORMAT: string;
|
|
285
|
+
MONTH_WITH_YEAR: string;
|
|
286
|
+
MONTH_WITH_DAY_AND_YEAR: string;
|
|
287
|
+
MONTH_WITH_2_DIGIT_YEAR: string;
|
|
288
|
+
DAY_WITH_MONTH: string;
|
|
289
|
+
DAY_WITH_MONTH_NUM: string;
|
|
290
|
+
QUARTER: string;
|
|
291
|
+
MONTH_ONLY: string;
|
|
292
|
+
DATETIME_WITH_SHORT_OFFSET: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Configuration object for date formats and settings in the Chart SDK.
|
|
297
|
+
* Provides locale-specific date and string formats, constants, and custom calendars.
|
|
298
|
+
*
|
|
299
|
+
* @type ChartSdkDateFormatsConfig
|
|
300
|
+
*
|
|
301
|
+
* @property tsLocaleBasedDateFormats - Optional. A record mapping locale identifiers to date format settings,
|
|
302
|
+
* each represented by a `DateFormats` object.
|
|
303
|
+
* @property tsLocaleBasedStringsFormats - Optional. A record mapping locale identifiers to localized string
|
|
304
|
+
* formats, where each format is represented by a string.
|
|
305
|
+
* @property tsDateConstants - Optional. A record mapping string keys to date-related constants, often used
|
|
306
|
+
* for standard date patterns or other fixed date-related values(mostly used to identify the case
|
|
307
|
+
* for backend proccessed date in case of MONTH_OF_YEAR,DAY_OF_WEEK).
|
|
308
|
+
* @property tsDefinedCustomCalenders - Optional. Custom calendar configurations, which have GUID of TS defined Custom calenders.
|
|
309
|
+
* @property defaultDataSourceId - Optional. The data source identifier for the date formats, used
|
|
310
|
+
* to specify the primary data source for TS defined custom calenders.
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
export type ChartSdkDateFormatsConfig = {
|
|
314
|
+
tsLocaleBasedDateFormats?: Record<string, DateFormats>;
|
|
315
|
+
tsLocaleBasedStringsFormats?: Record<string, string>;
|
|
316
|
+
tsDateConstants?: Record<string, string>;
|
|
317
|
+
tsDefinedCustomCalenders?: any;
|
|
318
|
+
defaultDataSourceId?: string;
|
|
230
319
|
};
|
|
231
320
|
|
|
232
321
|
export interface AppConfig {
|
|
233
322
|
styleConfig?: ChartSdkCustomStylingConfig;
|
|
234
|
-
|
|
323
|
+
dateFormatsConfig?: ChartSdkDateFormatsConfig;
|
|
235
324
|
appOptions?: {
|
|
236
325
|
isMobile?: boolean;
|
|
237
326
|
isPrintMode?: boolean; // export mode on/off
|
|
@@ -264,7 +353,8 @@ export interface AppConfig {
|
|
|
264
353
|
customCalendarConfig?: any; // this is to initialize custom calendar service
|
|
265
354
|
|
|
266
355
|
/**
|
|
267
|
-
* Unique identifier for the customer. This
|
|
356
|
+
* Unique identifier for the customer. This can be used as a way to maintain licensing by the
|
|
357
|
+
* third party developer
|
|
268
358
|
*/
|
|
269
|
-
|
|
359
|
+
chartAppAccessToken?: string;
|
|
270
360
|
}
|
|
@@ -3,30 +3,15 @@
|
|
|
3
3
|
* @fileoverview All CF types for the Custom Chart implementations
|
|
4
4
|
* @author Yashvardhan Nehra <yashvardhan.nehra@thoughtspot.com>
|
|
5
5
|
*
|
|
6
|
-
* Copyright: ThoughtSpot Inc.
|
|
6
|
+
* Copyright: ThoughtSpot Inc. 2024
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
9
|
+
import type { InputMaybe, Maybe, Scalars } from './common.types';
|
|
11
10
|
|
|
12
11
|
export type ConditionalFormatting = {
|
|
13
12
|
__typename?: 'ConditionalFormatting';
|
|
14
13
|
rows?: Maybe<Array<Maybe<ConditionalMetric>>>;
|
|
15
14
|
};
|
|
16
|
-
export type Scalars = {
|
|
17
|
-
ID: string;
|
|
18
|
-
String: string;
|
|
19
|
-
Boolean: boolean;
|
|
20
|
-
Int: number;
|
|
21
|
-
Float: number;
|
|
22
|
-
FileUpload: any;
|
|
23
|
-
GUID: string;
|
|
24
|
-
JSON: {
|
|
25
|
-
[key: string]: any;
|
|
26
|
-
};
|
|
27
|
-
JSONObject: any;
|
|
28
|
-
Long: any;
|
|
29
|
-
};
|
|
30
15
|
export declare enum BackgroundFormatTypes {
|
|
31
16
|
Gradient = 'GRADIENT',
|
|
32
17
|
Solid = 'SOLID',
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file: Number Formatting Types
|
|
3
|
+
* @author Yashvardhan Nehra <yashvardhan.nehra@thoughtspot.com>
|
|
4
|
+
*
|
|
5
|
+
* Copyright: ThoughtSpot Inc. 2024
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Maybe, Scalars } from './common.types';
|
|
9
|
+
|
|
10
|
+
export enum CategoryType {
|
|
11
|
+
Currency = 'CURRENCY',
|
|
12
|
+
Custom = 'CUSTOM',
|
|
13
|
+
Number = 'NUMBER',
|
|
14
|
+
Percentage = 'PERCENTAGE',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum Unit {
|
|
18
|
+
Auto = 'AUTO',
|
|
19
|
+
Billion = 'BILLION',
|
|
20
|
+
Million = 'MILLION',
|
|
21
|
+
None = 'NONE',
|
|
22
|
+
Thousands = 'THOUSANDS',
|
|
23
|
+
Trillion = 'TRILLION',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export enum NegativeValueFormat {
|
|
27
|
+
BracesNodash = 'BRACES_NODASH',
|
|
28
|
+
PrefixDash = 'PREFIX_DASH',
|
|
29
|
+
SuffixDash = 'SUFFIX_DASH',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type CurrencyFormatConfig = {
|
|
33
|
+
__typename?: 'CurrencyFormatConfig';
|
|
34
|
+
/** default to 2 */
|
|
35
|
+
decimals?: Maybe<Scalars['Float']>;
|
|
36
|
+
locale?: Maybe<Scalars['String']>;
|
|
37
|
+
/** default to false */
|
|
38
|
+
removeTrailingZeroes?: Maybe<Scalars['Boolean']>;
|
|
39
|
+
/** default to true */
|
|
40
|
+
toSeparateThousands?: Maybe<Scalars['Boolean']>;
|
|
41
|
+
/** default is MILLION */
|
|
42
|
+
unit?: Maybe<Unit>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type CustomFormatConfig = {
|
|
46
|
+
__typename?: 'CustomFormatConfig';
|
|
47
|
+
format?: Maybe<Scalars['String']>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type NumberFormatConfig = {
|
|
51
|
+
__typename?: 'NumberFormatConfig';
|
|
52
|
+
/** default to 2 */
|
|
53
|
+
decimals?: Maybe<Scalars['Float']>;
|
|
54
|
+
/** default to PREFIX_DASH */
|
|
55
|
+
negativeValueFormat?: Maybe<NegativeValueFormat>;
|
|
56
|
+
/** default to false */
|
|
57
|
+
removeTrailingZeroes?: Maybe<Scalars['Boolean']>;
|
|
58
|
+
/** default to true */
|
|
59
|
+
toSeparateThousands?: Maybe<Scalars['Boolean']>;
|
|
60
|
+
/** default is Auto */
|
|
61
|
+
unit?: Maybe<Unit>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type PercentageFormatConfig = {
|
|
65
|
+
__typename?: 'PercentageFormatConfig';
|
|
66
|
+
/** default to 2 */
|
|
67
|
+
decimals?: Maybe<Scalars['Float']>;
|
|
68
|
+
/** default to false */
|
|
69
|
+
removeTrailingZeroes?: Maybe<Scalars['Boolean']>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type FormatConfig = {
|
|
73
|
+
__typename?: 'FormatConfig';
|
|
74
|
+
category?: Maybe<CategoryType>;
|
|
75
|
+
currencyFormatConfig?: Maybe<CurrencyFormatConfig>;
|
|
76
|
+
customFormatConfig?: Maybe<CustomFormatConfig>;
|
|
77
|
+
isCategoryEditable?: Maybe<Scalars['Boolean']>;
|
|
78
|
+
numberFormatConfig?: Maybe<NumberFormatConfig>;
|
|
79
|
+
percentageFormatConfig?: Maybe<PercentageFormatConfig>;
|
|
80
|
+
};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
AllowedConfigurations,
|
|
3
|
+
ChartConfigParameters,
|
|
4
|
+
PersistedVisualPropKeys,
|
|
5
|
+
} from '../main/custom-chart-context';
|
|
2
6
|
import { ChartColumn } from './answer-column.types';
|
|
3
|
-
import { Point } from './chart-to-ts-event.types';
|
|
7
|
+
import type { Point } from './chart-to-ts-event.types';
|
|
4
8
|
import {
|
|
5
9
|
AppConfig,
|
|
6
10
|
ChartConfig,
|
|
7
11
|
ChartModel,
|
|
12
|
+
DataPointsArray,
|
|
8
13
|
QueryData,
|
|
9
14
|
ValidationResponse,
|
|
10
15
|
VisualProps,
|
|
11
16
|
} from './common.types';
|
|
12
|
-
import { ChartConfigEditorDefinition } from './configurator.types';
|
|
13
|
-
import { VisualPropEditorDefinition } from './visual-prop.types';
|
|
17
|
+
import type { ChartConfigEditorDefinition } from './configurator.types';
|
|
18
|
+
import type { VisualPropEditorDefinition } from './visual-prop.types';
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* All the events sent from the ThoughtSpot application to Custom Chart App
|
|
@@ -69,6 +74,10 @@ export enum TSToChartEvent {
|
|
|
69
74
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
70
75
|
*/
|
|
71
76
|
AxisMenuActionClick = 'AxisMenuActionClick',
|
|
77
|
+
/**
|
|
78
|
+
* @version SDK: 0.2 | ThoughtSpot:
|
|
79
|
+
*/
|
|
80
|
+
GetColumnData = 'GetColumnData',
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
/**
|
|
@@ -107,6 +116,10 @@ export interface TSToChartInternalEventsPayloadMap {
|
|
|
107
116
|
payload: GetDataQueryPayload,
|
|
108
117
|
) => GetDataQueryResponsePayload;
|
|
109
118
|
|
|
119
|
+
[TSToChartEvent.GetColumnData]: (
|
|
120
|
+
payload: GetColumnDataPayload,
|
|
121
|
+
) => GetColumnDataResponsePayload;
|
|
122
|
+
|
|
110
123
|
[TSToChartEvent.ChartConfigValidate]: (
|
|
111
124
|
payload: ChartConfigValidateEventPayload,
|
|
112
125
|
) => ValidationResponse;
|
|
@@ -206,6 +219,21 @@ export interface InitializeEventResponsePayload {
|
|
|
206
219
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
207
220
|
*/
|
|
208
221
|
allowedConfigurations?: AllowedConfigurations;
|
|
222
|
+
/**
|
|
223
|
+
* Key stored in persistedVisualPropKeys array will be preserved on changing the
|
|
224
|
+
* visualPropeditorDefinition, any other key (expect clientState) would not be preserved for visual props.
|
|
225
|
+
* ### NOTE: like clientState this variable should be a string, preferrably a result of JSON.stringify(<yourlocalClientState>)
|
|
226
|
+
* ### USE CASE: This is to maintain different clientSate for different custom charts developed by same TS custom chart developer.
|
|
227
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
228
|
+
*/
|
|
229
|
+
persistedVisualPropKeys?: PersistedVisualPropKeys;
|
|
230
|
+
/**
|
|
231
|
+
* Additional chart configuration parameters supported by TS UI. Ex: show/hide Measure Name/
|
|
232
|
+
* Value columns.
|
|
233
|
+
*
|
|
234
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
235
|
+
*/
|
|
236
|
+
chartConfigParameters?: ChartConfigParameters;
|
|
209
237
|
}
|
|
210
238
|
|
|
211
239
|
/**
|
|
@@ -216,12 +244,30 @@ export interface GetDataQueryPayload {
|
|
|
216
244
|
config: ChartConfig[];
|
|
217
245
|
}
|
|
218
246
|
|
|
247
|
+
export interface GetColumnDataPayload {
|
|
248
|
+
columnId: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* @group ThoughtSpot to Chart Events
|
|
254
|
+
*/
|
|
255
|
+
export interface QueryColumn extends ChartColumn {
|
|
256
|
+
/**
|
|
257
|
+
* Flag to identify if the column is a measure value,
|
|
258
|
+
* to be used along with MEASURE_NAME/MEASUE_VALUE column in the query
|
|
259
|
+
*
|
|
260
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
261
|
+
*/
|
|
262
|
+
isMeasureValue?: boolean;
|
|
263
|
+
}
|
|
264
|
+
|
|
219
265
|
/**
|
|
220
266
|
*
|
|
221
267
|
* @group ThoughtSpot to Chart Events
|
|
222
268
|
*/
|
|
223
269
|
export interface Query {
|
|
224
|
-
queryColumns:
|
|
270
|
+
queryColumns: QueryColumn[];
|
|
225
271
|
queryParams?: {
|
|
226
272
|
offset?: number;
|
|
227
273
|
size?: number;
|
|
@@ -236,6 +282,11 @@ export interface GetDataQueryResponsePayload {
|
|
|
236
282
|
queries: Query[];
|
|
237
283
|
}
|
|
238
284
|
|
|
285
|
+
export interface GetColumnDataResponsePayload {
|
|
286
|
+
// Marked as any as the data from columns can be of any type
|
|
287
|
+
data?: any[];
|
|
288
|
+
}
|
|
289
|
+
|
|
239
290
|
/**
|
|
240
291
|
*
|
|
241
292
|
* @group ThoughtSpot to Chart Events
|
|
@@ -281,6 +332,13 @@ export interface VisualPropsValidateEventPayload {
|
|
|
281
332
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
282
333
|
*/
|
|
283
334
|
visualProps: VisualProps;
|
|
335
|
+
/**
|
|
336
|
+
* used to identify active column for column level settings, empty string in case of overall
|
|
337
|
+
* chart settings
|
|
338
|
+
*
|
|
339
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
340
|
+
*/
|
|
341
|
+
activeColumnId?: string;
|
|
284
342
|
}
|
|
285
343
|
|
|
286
344
|
/**
|