@thoughtspot/ts-chart-sdk 0.0.2-alpha.8 → 1.0.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.
Files changed (144) hide show
  1. package/README.md +126 -50
  2. package/dist/ts-chart-sdk.d.ts +337 -31
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +3 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/main/custom-chart-context.d.ts +15 -3
  8. package/lib/main/custom-chart-context.d.ts.map +1 -1
  9. package/lib/main/custom-chart-context.js +45 -16
  10. package/lib/main/custom-chart-context.js.map +1 -1
  11. package/lib/main/custom-chart-context.spec.js +302 -4
  12. package/lib/main/custom-chart-context.spec.js.map +1 -1
  13. package/lib/main/logger.d.ts +13 -0
  14. package/lib/main/logger.d.ts.map +1 -0
  15. package/lib/main/logger.js +64 -0
  16. package/lib/main/logger.js.map +1 -0
  17. package/lib/main/logger.spec.d.ts +2 -0
  18. package/lib/main/logger.spec.d.ts.map +1 -0
  19. package/lib/main/logger.spec.js +88 -0
  20. package/lib/main/logger.spec.js.map +1 -0
  21. package/lib/main/util.d.ts +2 -0
  22. package/lib/main/util.d.ts.map +1 -1
  23. package/lib/main/util.js +11 -0
  24. package/lib/main/util.js.map +1 -1
  25. package/lib/main/util.spec.d.ts +2 -0
  26. package/lib/main/util.spec.d.ts.map +1 -0
  27. package/lib/main/util.spec.js +73 -0
  28. package/lib/main/util.spec.js.map +1 -0
  29. package/lib/react/use-custom-chart-context.d.ts.map +1 -1
  30. package/lib/react/use-custom-chart-context.js +3 -1
  31. package/lib/react/use-custom-chart-context.js.map +1 -1
  32. package/lib/react/use-custom-chart-context.spec.js +0 -1
  33. package/lib/react/use-custom-chart-context.spec.js.map +1 -1
  34. package/lib/react/use-custom-chart-context.util.d.ts.map +1 -1
  35. package/lib/react/use-custom-chart-context.util.js +5 -3
  36. package/lib/react/use-custom-chart-context.util.js.map +1 -1
  37. package/lib/types/answer-column.types.d.ts +15 -5
  38. package/lib/types/answer-column.types.d.ts.map +1 -1
  39. package/lib/types/answer-column.types.js +10 -3
  40. package/lib/types/answer-column.types.js.map +1 -1
  41. package/lib/types/chart-to-ts-event.types.d.ts +2 -0
  42. package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
  43. package/lib/types/chart-to-ts-event.types.js +1 -0
  44. package/lib/types/chart-to-ts-event.types.js.map +1 -1
  45. package/lib/types/common.types.d.ts +65 -5
  46. package/lib/types/common.types.d.ts.map +1 -1
  47. package/lib/types/common.types.js.map +1 -1
  48. package/lib/types/conditional-formatting.types.d.ts +1 -16
  49. package/lib/types/conditional-formatting.types.d.ts.map +1 -1
  50. package/lib/types/conditional-formatting.types.js.map +1 -1
  51. package/lib/types/configurator.types.d.ts +3 -1
  52. package/lib/types/configurator.types.d.ts.map +1 -1
  53. package/lib/types/number-formatting.types.d.ts +55 -0
  54. package/lib/types/number-formatting.types.d.ts.map +1 -0
  55. package/lib/types/number-formatting.types.js +23 -0
  56. package/lib/types/number-formatting.types.js.map +1 -0
  57. package/lib/types/ts-to-chart-event.types.d.ts +19 -6
  58. package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
  59. package/lib/types/ts-to-chart-event.types.js +1 -0
  60. package/lib/types/ts-to-chart-event.types.js.map +1 -1
  61. package/lib/types/visual-prop.types.d.ts +71 -3
  62. package/lib/types/visual-prop.types.d.ts.map +1 -1
  63. package/lib/types/visual-prop.types.js +32 -1
  64. package/lib/types/visual-prop.types.js.map +1 -1
  65. package/lib/utils/conditional-formatting/conditional-formatting.spec.js +2 -1
  66. package/lib/utils/conditional-formatting/conditional-formatting.spec.js.map +1 -1
  67. package/lib/utils/date-formatting.d.ts +85 -1
  68. package/lib/utils/date-formatting.d.ts.map +1 -1
  69. package/lib/utils/date-formatting.js +344 -9
  70. package/lib/utils/date-formatting.js.map +1 -1
  71. package/lib/utils/date-formatting.spec.js +303 -32
  72. package/lib/utils/date-formatting.spec.js.map +1 -1
  73. package/lib/utils/date-utils.d.ts +6 -0
  74. package/lib/utils/date-utils.d.ts.map +1 -0
  75. package/lib/utils/date-utils.js +20 -0
  76. package/lib/utils/date-utils.js.map +1 -0
  77. package/lib/utils/date-utils.spec.d.ts +2 -0
  78. package/lib/utils/date-utils.spec.d.ts.map +1 -0
  79. package/lib/utils/date-utils.spec.js +63 -0
  80. package/lib/utils/date-utils.spec.js.map +1 -0
  81. package/lib/utils/formatting-util.d.ts +10 -0
  82. package/lib/utils/formatting-util.d.ts.map +1 -0
  83. package/lib/utils/formatting-util.js +78 -0
  84. package/lib/utils/formatting-util.js.map +1 -0
  85. package/lib/utils/formatting-util.spec.d.ts +2 -0
  86. package/lib/utils/formatting-util.spec.d.ts.map +1 -0
  87. package/lib/utils/formatting-util.spec.js +247 -0
  88. package/lib/utils/formatting-util.spec.js.map +1 -0
  89. package/lib/utils/globalize-Initializer/globalize-utils.d.ts +16 -0
  90. package/lib/utils/globalize-Initializer/globalize-utils.d.ts.map +1 -0
  91. package/lib/utils/globalize-Initializer/globalize-utils.js +101 -0
  92. package/lib/utils/globalize-Initializer/globalize-utils.js.map +1 -0
  93. package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts +2 -0
  94. package/lib/utils/globalize-Initializer/globalize-utils.spec.d.ts.map +1 -0
  95. package/lib/utils/globalize-Initializer/globalize-utils.spec.js +149 -0
  96. package/lib/utils/globalize-Initializer/globalize-utils.spec.js.map +1 -0
  97. package/lib/utils/number-formatting/number-formatting-utils.d.ts +20 -0
  98. package/lib/utils/number-formatting/number-formatting-utils.d.ts.map +1 -0
  99. package/lib/utils/number-formatting/number-formatting-utils.js +159 -0
  100. package/lib/utils/number-formatting/number-formatting-utils.js.map +1 -0
  101. package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts +2 -0
  102. package/lib/utils/number-formatting/number-formatting-utils.spec.d.ts.map +1 -0
  103. package/lib/utils/number-formatting/number-formatting-utils.spec.js +221 -0
  104. package/lib/utils/number-formatting/number-formatting-utils.spec.js.map +1 -0
  105. package/lib/utils/number-formatting/number-formatting.d.ts +5 -0
  106. package/lib/utils/number-formatting/number-formatting.d.ts.map +1 -0
  107. package/lib/utils/number-formatting/number-formatting.js +128 -0
  108. package/lib/utils/number-formatting/number-formatting.js.map +1 -0
  109. package/lib/utils/number-formatting/number-formatting.spec.d.ts +2 -0
  110. package/lib/utils/number-formatting/number-formatting.spec.d.ts.map +1 -0
  111. package/lib/utils/number-formatting/number-formatting.spec.js +159 -0
  112. package/lib/utils/number-formatting/number-formatting.spec.js.map +1 -0
  113. package/package.json +5 -2
  114. package/src/index.ts +3 -0
  115. package/src/main/custom-chart-context.spec.ts +356 -6
  116. package/src/main/custom-chart-context.ts +182 -15
  117. package/src/main/logger.spec.ts +114 -0
  118. package/src/main/logger.ts +97 -0
  119. package/src/main/util.spec.ts +94 -0
  120. package/src/main/util.ts +20 -0
  121. package/src/react/use-custom-chart-context.spec.tsx +0 -1
  122. package/src/react/use-custom-chart-context.tsx +4 -1
  123. package/src/react/use-custom-chart-context.util.ts +6 -3
  124. package/src/types/answer-column.types.ts +29 -6
  125. package/src/types/chart-to-ts-event.types.ts +7 -0
  126. package/src/types/common.types.ts +103 -8
  127. package/src/types/conditional-formatting.types.ts +2 -17
  128. package/src/types/configurator.types.ts +15 -1
  129. package/src/types/number-formatting.types.ts +80 -0
  130. package/src/types/ts-to-chart-event.types.ts +54 -5
  131. package/src/types/visual-prop.types.ts +197 -3
  132. package/src/utils/conditional-formatting/conditional-formatting.spec.ts +2 -0
  133. package/src/utils/date-formatting.spec.ts +377 -32
  134. package/src/utils/date-formatting.ts +587 -14
  135. package/src/utils/date-utils.spec.ts +93 -0
  136. package/src/utils/date-utils.ts +69 -0
  137. package/src/utils/formatting-util.spec.ts +312 -0
  138. package/src/utils/formatting-util.ts +234 -0
  139. package/src/utils/globalize-Initializer/globalize-utils.spec.ts +192 -0
  140. package/src/utils/globalize-Initializer/globalize-utils.ts +216 -0
  141. package/src/utils/number-formatting/number-formatting-utils.spec.ts +296 -0
  142. package/src/utils/number-formatting/number-formatting-utils.ts +260 -0
  143. package/src/utils/number-formatting/number-formatting.spec.ts +243 -0
  144. package/src/utils/number-formatting/number-formatting.ts +264 -0
@@ -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
- console.log('Error in context initialization', e);
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
- console.log('Context is not initialized');
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
- console.log('Context is not initialized');
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
- console.log('Context is not initialized');
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,9 +1,23 @@
1
- import { ConditionalFormatting, Maybe } from './conditional-formatting.types';
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,
5
7
  MEASURE,
6
8
  ATTRIBUTE,
9
+ // Virtual columns that are measure name/value columns
10
+ VIRTUAL,
11
+ }
12
+
13
+ /**
14
+ * When the column is generated for the chart for creating views,
15
+ * on top of measure columns from the worksheet which are part of answer query.
16
+ */
17
+ export enum ChartSpecificColumnType {
18
+ UNKNOWN,
19
+ MEASURE_NAMES,
20
+ MEASURE_VALUES,
7
21
  }
8
22
 
9
23
  /**
@@ -68,9 +82,9 @@ export enum FormatType {
68
82
  * @version SDK: 0.1 | ThoughtSpot:
69
83
  */
70
84
  export enum CurrencyFormatType {
71
- USER_LOCALE,
72
- COLUMN,
73
- ISO_CODE,
85
+ USER_LOCALE = 'USER_LOCALE',
86
+ COLUMN = 'COLUMN',
87
+ ISO_CODE = 'ISO_CODE',
74
88
  }
75
89
 
76
90
  /**
@@ -171,7 +185,7 @@ export interface ChartColumn {
171
185
  */
172
186
  id: string;
173
187
  /**
174
- * Column name
188
+ * Column name property
175
189
  *
176
190
  * @version SDK: 0.1 | ThoughtSpot:
177
191
  */
@@ -222,10 +236,11 @@ export interface ChartColumn {
222
236
  /**
223
237
  * Column Properties of the columns
224
238
  *
225
- * @version SDK: 0.1 | ThoughtSpot:
239
+ * @version SDK: 0.0.2-alpha.15 | ThoughtSpot:
226
240
  */
227
241
  columnProperties?: {
228
242
  conditionalFormatting?: Maybe<ConditionalFormatting>;
243
+ numberFormatting?: Maybe<FormatConfig>;
229
244
  };
230
245
 
231
246
  /**
@@ -249,4 +264,12 @@ export interface ChartColumn {
249
264
  * @version SDK: 0.1 | ThoughtSpot: sdcwdc
250
265
  */
251
266
  calenderGuid?: string;
267
+
268
+ /**
269
+ * Type of arbitrary column, can be measure names or measure values
270
+ * also, unknown if regular column
271
+ *
272
+ * @version SDK: 0.1 | ThoughtSpot:
273
+ */
274
+ chartSpecificColumnType: ChartSpecificColumnType;
252
275
  }
@@ -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
- * Custom Font Faces type from TS.
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 CustomFontFaces = {
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
- customFontFaces?: Array<CustomFontFaces>;
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
@@ -262,4 +351,10 @@ export interface AppConfig {
262
351
  * @hidden
263
352
  */
264
353
  customCalendarConfig?: any; // this is to initialize custom calendar service
354
+
355
+ /**
356
+ * Unique identifier for the customer. This can be used as a way to maintain licensing by the
357
+ * third party developer
358
+ */
359
+ chartAppAccessToken?: string;
265
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. 2023
6
+ * Copyright: ThoughtSpot Inc. 2024
7
7
  */
8
8
 
9
- export type Maybe<T> = T | null;
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',
@@ -14,7 +14,7 @@
14
14
  * Copyright: ThoughtSpot Inc. 2023
15
15
  */
16
16
 
17
- import { CustomChartContext } from '../main/custom-chart-context';
17
+ import type { CustomChartContext } from '../main/custom-chart-context';
18
18
  import { ChartModel } from './common.types';
19
19
  /**
20
20
  *
@@ -70,6 +70,20 @@ export interface ChartConfigSection {
70
70
  * @version SDK: 0.1 | ThoughtSpot:
71
71
  */
72
72
  allowTimeSeriesColumns?: boolean;
73
+ /**
74
+ * Allow measure name Column on the Section
75
+ *
76
+ * @default true
77
+ * @version SDK: 0.1 | ThoughtSpot:
78
+ */
79
+ allowMeasureNameColumn?: boolean;
80
+ /**
81
+ * Allow measure value Column on the Section
82
+ *
83
+ * @default true
84
+ * @version SDK: 0.1 | ThoughtSpot:
85
+ */
86
+ allowMeasureValueColumn?: boolean;
73
87
  }
74
88
 
75
89
  /**
@@ -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,20 @@
1
- import { AllowedConfigurations } from '../main/custom-chart-context';
1
+ import type {
2
+ AllowedConfigurations,
3
+ ChartConfigParameters,
4
+ } from '../main/custom-chart-context';
2
5
  import { ChartColumn } from './answer-column.types';
3
- import { Point } from './chart-to-ts-event.types';
6
+ import type { Point } from './chart-to-ts-event.types';
4
7
  import {
5
8
  AppConfig,
6
9
  ChartConfig,
7
10
  ChartModel,
11
+ DataPointsArray,
8
12
  QueryData,
9
13
  ValidationResponse,
10
14
  VisualProps,
11
15
  } from './common.types';
12
- import { ChartConfigEditorDefinition } from './configurator.types';
13
- import { VisualPropEditorDefinition } from './visual-prop.types';
16
+ import type { ChartConfigEditorDefinition } from './configurator.types';
17
+ import type { VisualPropEditorDefinition } from './visual-prop.types';
14
18
 
15
19
  /**
16
20
  * All the events sent from the ThoughtSpot application to Custom Chart App
@@ -69,6 +73,10 @@ export enum TSToChartEvent {
69
73
  * @version SDK: 0.1 | ThoughtSpot:
70
74
  */
71
75
  AxisMenuActionClick = 'AxisMenuActionClick',
76
+ /**
77
+ * @version SDK: 0.2 | ThoughtSpot:
78
+ */
79
+ GetColumnData = 'GetColumnData',
72
80
  }
73
81
 
74
82
  /**
@@ -107,6 +115,10 @@ export interface TSToChartInternalEventsPayloadMap {
107
115
  payload: GetDataQueryPayload,
108
116
  ) => GetDataQueryResponsePayload;
109
117
 
118
+ [TSToChartEvent.GetColumnData]: (
119
+ payload: GetColumnDataPayload,
120
+ ) => GetColumnDataResponsePayload;
121
+
110
122
  [TSToChartEvent.ChartConfigValidate]: (
111
123
  payload: ChartConfigValidateEventPayload,
112
124
  ) => ValidationResponse;
@@ -206,6 +218,13 @@ export interface InitializeEventResponsePayload {
206
218
  * @version SDK: 0.1 | ThoughtSpot:
207
219
  */
208
220
  allowedConfigurations?: AllowedConfigurations;
221
+ /**
222
+ * Additional chart configuration parameters supported by TS UI. Ex: show/hide Measure Name/
223
+ * Value columns.
224
+ *
225
+ * @version SDK: 0.1 | ThoughtSpot:
226
+ */
227
+ chartConfigParameters?: ChartConfigParameters;
209
228
  }
210
229
 
211
230
  /**
@@ -216,12 +235,30 @@ export interface GetDataQueryPayload {
216
235
  config: ChartConfig[];
217
236
  }
218
237
 
238
+ export interface GetColumnDataPayload {
239
+ columnId: string;
240
+ }
241
+
242
+ /**
243
+ *
244
+ * @group ThoughtSpot to Chart Events
245
+ */
246
+ export interface QueryColumn extends ChartColumn {
247
+ /**
248
+ * Flag to identify if the column is a measure value,
249
+ * to be used along with MEASURE_NAME/MEASUE_VALUE column in the query
250
+ *
251
+ * @version SDK: 0.1 | ThoughtSpot:
252
+ */
253
+ isMeasureValue?: boolean;
254
+ }
255
+
219
256
  /**
220
257
  *
221
258
  * @group ThoughtSpot to Chart Events
222
259
  */
223
260
  export interface Query {
224
- queryColumns: ChartColumn[];
261
+ queryColumns: QueryColumn[];
225
262
  queryParams?: {
226
263
  offset?: number;
227
264
  size?: number;
@@ -236,6 +273,11 @@ export interface GetDataQueryResponsePayload {
236
273
  queries: Query[];
237
274
  }
238
275
 
276
+ export interface GetColumnDataResponsePayload {
277
+ // Marked as any as the data from columns can be of any type
278
+ data?: any[];
279
+ }
280
+
239
281
  /**
240
282
  *
241
283
  * @group ThoughtSpot to Chart Events
@@ -281,6 +323,13 @@ export interface VisualPropsValidateEventPayload {
281
323
  * @version SDK: 0.1 | ThoughtSpot:
282
324
  */
283
325
  visualProps: VisualProps;
326
+ /**
327
+ * used to identify active column for column level settings, empty string in case of overall
328
+ * chart settings
329
+ *
330
+ * @version SDK: 0.1 | ThoughtSpot:
331
+ */
332
+ activeColumnId?: string;
284
333
  }
285
334
 
286
335
  /**