@thoughtspot/ts-chart-sdk 0.0.2-alpha.2 → 0.0.2-alpha.4
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/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/main/custom-chart-context.spec.ts +118 -1
- package/src/main/custom-chart-context.ts +113 -8
- package/src/main/post-message-event-bridge.ts +1 -1
- package/src/test/test-conditional-formatting-utils.ts +95 -0
- package/src/types/answer-column.types.ts +63 -0
- package/src/types/common.types.ts +8 -0
- package/src/types/conditional-formatting.types.ts +172 -0
- package/src/types/configurator.types.ts +7 -0
- package/src/types/ts-to-chart-event.types.ts +2 -1
- package/src/types/visual-prop.types.ts +7 -0
- package/src/utils/conditional-formatting/conditional-formatting.spec.ts +415 -0
- package/src/utils/conditional-formatting/conditional-formatting.ts +229 -0
- package/lib/index.d.ts +0 -9
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -9
- package/lib/index.js.map +0 -1
- package/lib/main/custom-chart-context.d.ts +0 -54
- package/lib/main/custom-chart-context.d.ts.map +0 -1
- package/lib/main/custom-chart-context.js +0 -292
- package/lib/main/custom-chart-context.js.map +0 -1
- package/lib/main/custom-chart-context.spec.d.ts +0 -2
- package/lib/main/custom-chart-context.spec.d.ts.map +0 -1
- package/lib/main/custom-chart-context.spec.js +0 -518
- package/lib/main/custom-chart-context.spec.js.map +0 -1
- package/lib/main/post-message-event-bridge.d.ts +0 -6
- package/lib/main/post-message-event-bridge.d.ts.map +0 -1
- package/lib/main/post-message-event-bridge.js +0 -29
- package/lib/main/post-message-event-bridge.js.map +0 -1
- package/lib/main/post-message-event-bridge.spec.d.ts +0 -2
- package/lib/main/post-message-event-bridge.spec.d.ts.map +0 -1
- package/lib/main/post-message-event-bridge.spec.js +0 -117
- package/lib/main/post-message-event-bridge.spec.js.map +0 -1
- package/lib/main/util.d.ts +0 -2
- package/lib/main/util.d.ts.map +0 -1
- package/lib/main/util.js +0 -9
- package/lib/main/util.js.map +0 -1
- package/lib/react/mocks/custom-chart-context-mock.d.ts +0 -3
- package/lib/react/mocks/custom-chart-context-mock.d.ts.map +0 -1
- package/lib/react/mocks/custom-chart-context-mock.js +0 -94
- package/lib/react/mocks/custom-chart-context-mock.js.map +0 -1
- package/lib/react/use-custom-chart-context.d.ts +0 -4
- package/lib/react/use-custom-chart-context.d.ts.map +0 -1
- package/lib/react/use-custom-chart-context.js +0 -68
- package/lib/react/use-custom-chart-context.js.map +0 -1
- package/lib/react/use-custom-chart-context.spec.d.ts +0 -2
- package/lib/react/use-custom-chart-context.spec.d.ts.map +0 -1
- package/lib/react/use-custom-chart-context.spec.js +0 -318
- package/lib/react/use-custom-chart-context.spec.js.map +0 -1
- package/lib/react/use-custom-chart-context.util.d.ts +0 -6
- package/lib/react/use-custom-chart-context.util.d.ts.map +0 -1
- package/lib/react/use-custom-chart-context.util.js +0 -51
- package/lib/react/use-custom-chart-context.util.js.map +0 -1
- package/lib/react/use-custom-chart-types.d.ts +0 -23
- package/lib/react/use-custom-chart-types.d.ts.map +0 -1
- package/lib/react/use-custom-chart-types.js +0 -2
- package/lib/react/use-custom-chart-types.js.map +0 -1
- package/lib/test/test-utils.d.ts +0 -7
- package/lib/test/test-utils.d.ts.map +0 -1
- package/lib/test/test-utils.js +0 -11
- package/lib/test/test-utils.js.map +0 -1
- package/lib/types/answer-column.types.d.ts +0 -69
- package/lib/types/answer-column.types.d.ts.map +0 -1
- package/lib/types/answer-column.types.js +0 -56
- package/lib/types/answer-column.types.js.map +0 -1
- package/lib/types/chart-to-ts-event.types.d.ts +0 -98
- package/lib/types/chart-to-ts-event.types.d.ts.map +0 -1
- package/lib/types/chart-to-ts-event.types.js +0 -29
- package/lib/types/chart-to-ts-event.types.js.map +0 -1
- package/lib/types/common.types.d.ts +0 -52
- package/lib/types/common.types.d.ts.map +0 -1
- package/lib/types/common.types.js +0 -2
- package/lib/types/common.types.js.map +0 -1
- package/lib/types/configurator.types.d.ts +0 -15
- package/lib/types/configurator.types.d.ts.map +0 -1
- package/lib/types/configurator.types.js +0 -2
- package/lib/types/configurator.types.js.map +0 -1
- package/lib/types/ts-to-chart-event.types.d.ts +0 -94
- package/lib/types/ts-to-chart-event.types.d.ts.map +0 -1
- package/lib/types/ts-to-chart-event.types.js +0 -15
- package/lib/types/ts-to-chart-event.types.js.map +0 -1
- package/lib/types/visual-prop.types.d.ts +0 -73
- package/lib/types/visual-prop.types.d.ts.map +0 -1
- package/lib/types/visual-prop.types.js +0 -2
- package/lib/types/visual-prop.types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/ts-chart-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.2-alpha.
|
|
4
|
+
"version": "0.0.2-alpha.4",
|
|
5
5
|
"module": "lib/index",
|
|
6
6
|
"main": "lib/index",
|
|
7
7
|
"types": "lib/index",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
43
43
|
"@typescript-eslint/parser": "^5.59.5",
|
|
44
44
|
"dts-bundle": "^0.7.3",
|
|
45
|
-
"eslint": "
|
|
45
|
+
"eslint": "^8.56.0",
|
|
46
46
|
"eslint-config-airbnb-base": "15.0.0",
|
|
47
47
|
"eslint-config-prettier": "^6.9.0",
|
|
48
48
|
"eslint-import-resolver-typescript": "^2.0.0",
|
package/src/index.ts
CHANGED
|
@@ -6,3 +6,5 @@ export * from './types/chart-to-ts-event.types';
|
|
|
6
6
|
export * from './types/ts-to-chart-event.types';
|
|
7
7
|
export * from './main/custom-chart-context';
|
|
8
8
|
export * from './react/use-custom-chart-context';
|
|
9
|
+
export * from './types/conditional-formatting.types';
|
|
10
|
+
export * from './utils/conditional-formatting/conditional-formatting';
|
|
@@ -170,7 +170,124 @@ describe('CustomChartContext', () => {
|
|
|
170
170
|
eventProcessor = null;
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
test('
|
|
173
|
+
test('TSToChartEvent.ChartConfigValidate validation response testing', async () => {
|
|
174
|
+
// Define initial context with object definitions
|
|
175
|
+
customChartContext = new CustomChartContext({
|
|
176
|
+
getDefaultChartConfig,
|
|
177
|
+
getQueriesFromChartConfig,
|
|
178
|
+
renderChart,
|
|
179
|
+
visualPropEditorDefinition: { elements: [] },
|
|
180
|
+
chartConfigEditorDefinition: [],
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Trigger event processor with initial context
|
|
184
|
+
const responseWithInitialContext = await eventProcessor({
|
|
185
|
+
payload: mockInitializeContextPayload,
|
|
186
|
+
eventType: TSToChartEvent.ChartConfigValidate,
|
|
187
|
+
source: 'ts-host-app',
|
|
188
|
+
});
|
|
189
|
+
// Verify response with object definitions
|
|
190
|
+
expect(responseWithInitialContext).toStrictEqual({
|
|
191
|
+
isValid: true,
|
|
192
|
+
visualPropEditorDefinition: { elements: [] },
|
|
193
|
+
chartConfigEditorDefinition: [],
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Redefine context with function-returned definitions
|
|
197
|
+
customChartContext = new CustomChartContext({
|
|
198
|
+
getDefaultChartConfig,
|
|
199
|
+
getQueriesFromChartConfig,
|
|
200
|
+
renderChart,
|
|
201
|
+
visualPropEditorDefinition: () => {
|
|
202
|
+
return { elements: [] };
|
|
203
|
+
},
|
|
204
|
+
chartConfigEditorDefinition: () => {
|
|
205
|
+
return [
|
|
206
|
+
{
|
|
207
|
+
key: 'x',
|
|
208
|
+
columnSections: [{ label: 'x-axis', key: 'x' }],
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
// Trigger event processor with updated context
|
|
214
|
+
const responseWithUpdatedContext = await eventProcessor({
|
|
215
|
+
payload: mockInitializeContextPayload,
|
|
216
|
+
eventType: TSToChartEvent.ChartConfigValidate,
|
|
217
|
+
source: 'ts-host-app',
|
|
218
|
+
});
|
|
219
|
+
// Verify response with function-returned definitions
|
|
220
|
+
expect(responseWithUpdatedContext).toStrictEqual({
|
|
221
|
+
isValid: true,
|
|
222
|
+
visualPropEditorDefinition: { elements: [] },
|
|
223
|
+
chartConfigEditorDefinition: [
|
|
224
|
+
{
|
|
225
|
+
key: 'x',
|
|
226
|
+
columnSections: [{ label: 'x-axis', key: 'x' }],
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test('TSToChartEvent.validateVisualProps validation response testing', () => {
|
|
233
|
+
// Define initial context with object definitions
|
|
234
|
+
customChartContext = new CustomChartContext({
|
|
235
|
+
getDefaultChartConfig,
|
|
236
|
+
getQueriesFromChartConfig,
|
|
237
|
+
renderChart,
|
|
238
|
+
visualPropEditorDefinition: { elements: [] },
|
|
239
|
+
chartConfigEditorDefinition: [],
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Trigger event processor with initial context
|
|
243
|
+
const responseWithInitialContext = eventProcessor({
|
|
244
|
+
payload: mockInitializeContextPayload,
|
|
245
|
+
eventType: TSToChartEvent.VisualPropsValidate,
|
|
246
|
+
source: 'ts-host-app',
|
|
247
|
+
});
|
|
248
|
+
// Verify response with object definitions
|
|
249
|
+
expect(responseWithInitialContext).toStrictEqual({
|
|
250
|
+
isValid: true,
|
|
251
|
+
visualPropEditorDefinition: { elements: [] },
|
|
252
|
+
chartConfigEditorDefinition: [],
|
|
253
|
+
});
|
|
254
|
+
// Redefine context with function-returned definitions
|
|
255
|
+
customChartContext = new CustomChartContext({
|
|
256
|
+
getDefaultChartConfig,
|
|
257
|
+
getQueriesFromChartConfig,
|
|
258
|
+
renderChart,
|
|
259
|
+
visualPropEditorDefinition: () => {
|
|
260
|
+
return { elements: [] };
|
|
261
|
+
},
|
|
262
|
+
chartConfigEditorDefinition: () => {
|
|
263
|
+
return [
|
|
264
|
+
{
|
|
265
|
+
key: 'x',
|
|
266
|
+
columnSections: [{ label: 'x-axis', key: 'x' }],
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
// Trigger event processor with updated context
|
|
272
|
+
const responseWithFunctionReturnedValues = eventProcessor({
|
|
273
|
+
payload: mockInitializeContextPayload,
|
|
274
|
+
eventType: TSToChartEvent.VisualPropsValidate,
|
|
275
|
+
source: 'ts-host-app',
|
|
276
|
+
});
|
|
277
|
+
// Verify response with function-returned definitions
|
|
278
|
+
expect(responseWithFunctionReturnedValues).toStrictEqual({
|
|
279
|
+
isValid: true,
|
|
280
|
+
visualPropEditorDefinition: { elements: [] },
|
|
281
|
+
chartConfigEditorDefinition: [
|
|
282
|
+
{
|
|
283
|
+
key: 'x',
|
|
284
|
+
columnSections: [{ label: 'x-axis', key: 'x' }],
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('should not trigger post message if host is not accurate', async () => {
|
|
174
291
|
expect(mockInitMessage).toHaveBeenCalled();
|
|
175
292
|
|
|
176
293
|
// mock the event trigger for ChartConfigValidate
|
|
@@ -21,10 +21,14 @@ import {
|
|
|
21
21
|
AppConfig,
|
|
22
22
|
ChartConfig,
|
|
23
23
|
ChartModel,
|
|
24
|
+
SuccessValidationResponse,
|
|
24
25
|
ValidationResponse,
|
|
25
26
|
VisualProps,
|
|
26
27
|
} from '../types/common.types';
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
ChartConfigEditorDefinition,
|
|
30
|
+
ConfigEditorDefinitionSetter,
|
|
31
|
+
} from '../types/configurator.types';
|
|
28
32
|
import {
|
|
29
33
|
AxisMenuCustomActionPayload,
|
|
30
34
|
ChartConfigValidateEventPayload,
|
|
@@ -42,7 +46,10 @@ import {
|
|
|
42
46
|
VisualPropsUpdateEventPayload,
|
|
43
47
|
VisualPropsValidateEventPayload,
|
|
44
48
|
} from '../types/ts-to-chart-event.types';
|
|
45
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
VisualEditorDefinitionSetter,
|
|
51
|
+
VisualPropEditorDefinition,
|
|
52
|
+
} from '../types/visual-prop.types';
|
|
46
53
|
import {
|
|
47
54
|
globalThis,
|
|
48
55
|
initMessageListener,
|
|
@@ -116,7 +123,9 @@ export type CustomChartContextProps = {
|
|
|
116
123
|
*
|
|
117
124
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
118
125
|
*/
|
|
119
|
-
chartConfigEditorDefinition?:
|
|
126
|
+
chartConfigEditorDefinition?:
|
|
127
|
+
| ConfigEditorDefinitionSetter
|
|
128
|
+
| ChartConfigEditorDefinition[];
|
|
120
129
|
|
|
121
130
|
/**
|
|
122
131
|
* Definition to help edit/customize the visual properties from chart settings editor
|
|
@@ -127,12 +136,18 @@ export type CustomChartContextProps = {
|
|
|
127
136
|
* @returns {@link VisualPropEditorDefinition}
|
|
128
137
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
129
138
|
*/
|
|
130
|
-
visualPropEditorDefinition?:
|
|
139
|
+
visualPropEditorDefinition?:
|
|
140
|
+
| VisualEditorDefinitionSetter
|
|
141
|
+
| VisualPropEditorDefinition;
|
|
131
142
|
|
|
132
143
|
// Whether user wants thoughtspot default number and conditional formatting
|
|
133
144
|
allowedConfigurations?: AllowedConfigurations;
|
|
134
145
|
};
|
|
135
146
|
|
|
147
|
+
export type ValidationFunctions =
|
|
148
|
+
| CustomChartContextProps['validateVisualProps']
|
|
149
|
+
| CustomChartContextProps['validateConfig'];
|
|
150
|
+
|
|
136
151
|
/**
|
|
137
152
|
* Default configuration options for all the chart context properties
|
|
138
153
|
*/
|
|
@@ -379,6 +394,48 @@ export class CustomChartContext {
|
|
|
379
394
|
return processedPayload;
|
|
380
395
|
}
|
|
381
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Funtions return the chart config editor definition
|
|
399
|
+
* @param {ChartConfig[]} currentChartConfig
|
|
400
|
+
* @param {VisualProps}
|
|
401
|
+
* @returns {ChartConfigEditorDefinition[]}
|
|
402
|
+
*/
|
|
403
|
+
private getChartConfigEditorDefinition = (
|
|
404
|
+
currentState: Partial<ChartModel> = {},
|
|
405
|
+
) => {
|
|
406
|
+
if (_.isFunction(this.chartContextProps.chartConfigEditorDefinition)) {
|
|
407
|
+
return this.chartContextProps.chartConfigEditorDefinition(
|
|
408
|
+
{
|
|
409
|
+
...this.chartModel,
|
|
410
|
+
...currentState,
|
|
411
|
+
},
|
|
412
|
+
this,
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
return this.chartContextProps.chartConfigEditorDefinition;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Funtions returns the visual prop editor definition
|
|
420
|
+
* @param {ChartConfig[]} currentChartConfig
|
|
421
|
+
* @param {VisualProps}
|
|
422
|
+
* @returns {VisualPropEditorDefinition}
|
|
423
|
+
*/
|
|
424
|
+
private getVisualPropEditorDefinition = (
|
|
425
|
+
currentState: Partial<ChartModel> = {},
|
|
426
|
+
) => {
|
|
427
|
+
if (_.isFunction(this.chartContextProps.visualPropEditorDefinition)) {
|
|
428
|
+
return this.chartContextProps.visualPropEditorDefinition(
|
|
429
|
+
{
|
|
430
|
+
...this.chartModel,
|
|
431
|
+
...currentState,
|
|
432
|
+
},
|
|
433
|
+
this,
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return this.chartContextProps.visualPropEditorDefinition;
|
|
437
|
+
};
|
|
438
|
+
|
|
382
439
|
/**
|
|
383
440
|
* Function to store the axis menu custom action callback mapped with action id
|
|
384
441
|
* @param {[OpenAxisMenuEventPayload]} eventPayload Event payload bound
|
|
@@ -438,6 +495,24 @@ export class CustomChartContext {
|
|
|
438
495
|
}
|
|
439
496
|
}
|
|
440
497
|
|
|
498
|
+
private validationsResponseProcessor(
|
|
499
|
+
currentValidationState: Partial<ChartModel>,
|
|
500
|
+
validationResponse: ValidationResponse,
|
|
501
|
+
) {
|
|
502
|
+
const visualPropEditorDefinition = this.getVisualPropEditorDefinition(
|
|
503
|
+
currentValidationState,
|
|
504
|
+
);
|
|
505
|
+
const chartConfigEditorDefinition = this.getChartConfigEditorDefinition(
|
|
506
|
+
currentValidationState,
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
return {
|
|
510
|
+
...validationResponse,
|
|
511
|
+
visualPropEditorDefinition,
|
|
512
|
+
chartConfigEditorDefinition,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
441
516
|
/**
|
|
442
517
|
* Function to emit Chart to TS Events to the TS application.
|
|
443
518
|
|
|
@@ -530,13 +605,27 @@ export class CustomChartContext {
|
|
|
530
605
|
*/
|
|
531
606
|
this.onInternal(
|
|
532
607
|
TSToChartEvent.VisualPropsValidate,
|
|
533
|
-
(
|
|
608
|
+
(
|
|
609
|
+
payload: VisualPropsValidateEventPayload,
|
|
610
|
+
):
|
|
611
|
+
| (ValidationResponse & SuccessValidationResponse)
|
|
612
|
+
| ValidationResponse => {
|
|
534
613
|
if (this.chartContextProps.validateVisualProps) {
|
|
535
614
|
const validationResponse =
|
|
536
615
|
this.chartContextProps.validateVisualProps(
|
|
537
616
|
payload.visualProps,
|
|
538
617
|
this.chartModel,
|
|
539
618
|
);
|
|
619
|
+
if (validationResponse.isValid) {
|
|
620
|
+
const currentVisualState = {
|
|
621
|
+
visualProps: payload.visualProps,
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
return this.validationsResponseProcessor(
|
|
625
|
+
currentVisualState,
|
|
626
|
+
validationResponse,
|
|
627
|
+
);
|
|
628
|
+
}
|
|
540
629
|
return validationResponse;
|
|
541
630
|
}
|
|
542
631
|
// this will never be true
|
|
@@ -551,13 +640,29 @@ export class CustomChartContext {
|
|
|
551
640
|
*/
|
|
552
641
|
this.onInternal(
|
|
553
642
|
TSToChartEvent.ChartConfigValidate,
|
|
554
|
-
(
|
|
643
|
+
(
|
|
644
|
+
payload: ChartConfigValidateEventPayload,
|
|
645
|
+
):
|
|
646
|
+
| (ValidationResponse & SuccessValidationResponse)
|
|
647
|
+
| ValidationResponse => {
|
|
555
648
|
if (this.chartContextProps.validateConfig) {
|
|
556
649
|
const validationResponse =
|
|
557
650
|
this.chartContextProps.validateConfig(
|
|
558
651
|
payload.chartConfig,
|
|
559
652
|
this.chartModel,
|
|
560
653
|
);
|
|
654
|
+
if (validationResponse.isValid) {
|
|
655
|
+
const currentConfigState = {
|
|
656
|
+
config: {
|
|
657
|
+
...this.chartModel.config,
|
|
658
|
+
chartConfig: payload.chartConfig,
|
|
659
|
+
},
|
|
660
|
+
};
|
|
661
|
+
return this.validationsResponseProcessor(
|
|
662
|
+
currentConfigState,
|
|
663
|
+
validationResponse,
|
|
664
|
+
);
|
|
665
|
+
}
|
|
561
666
|
return validationResponse;
|
|
562
667
|
}
|
|
563
668
|
// this will never be true
|
|
@@ -789,9 +894,9 @@ export class CustomChartContext {
|
|
|
789
894
|
isConfigValid: isValid,
|
|
790
895
|
defaultChartConfig,
|
|
791
896
|
chartConfigEditorDefinition:
|
|
792
|
-
this.
|
|
897
|
+
this.getChartConfigEditorDefinition(),
|
|
793
898
|
visualPropEditorDefinition:
|
|
794
|
-
this.
|
|
899
|
+
this.getVisualPropEditorDefinition(),
|
|
795
900
|
allowedConfigurations:
|
|
796
901
|
this.chartContextProps.allowedConfigurations,
|
|
797
902
|
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file: Test Conditional Formatting Utils
|
|
3
|
+
*
|
|
4
|
+
* @author Yashvardhan Nehra <yashvardhan.nehra@thoughtspot.com>
|
|
5
|
+
*
|
|
6
|
+
* Copyright: ThoughtSpot Inc. 2023
|
|
7
|
+
*/
|
|
8
|
+
import {
|
|
9
|
+
BackgroundFormatTypes,
|
|
10
|
+
ConditionalFormattingComparisonTypes,
|
|
11
|
+
ConditionalMetric,
|
|
12
|
+
Operators,
|
|
13
|
+
} from '../types/conditional-formatting.types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a metric operator for conditional formatting.
|
|
17
|
+
*
|
|
18
|
+
* @param operator - The operator to use for the metric (e.g., LessThan, GreaterThan).
|
|
19
|
+
* @param lhsColumnId - (Optional) The ID of the left-hand side column.
|
|
20
|
+
* @param rhsColumnId - (Optional) The ID of the right-hand side column.
|
|
21
|
+
* @param comparisonParameterId - (Optional) The ID of the comparison parameter.
|
|
22
|
+
* @param comparisonType - The type of comparison to use (default is ValueBased).
|
|
23
|
+
* @returns A ConditionalMetric object configured with the specified parameters.
|
|
24
|
+
*/
|
|
25
|
+
export const createMetricOperator = (
|
|
26
|
+
operator: Operators,
|
|
27
|
+
lhsColumnId?: string,
|
|
28
|
+
rhsColumnId?: string,
|
|
29
|
+
comparisonParameterId?: string,
|
|
30
|
+
comparisonType = ConditionalFormattingComparisonTypes.ValueBased,
|
|
31
|
+
): ConditionalMetric => {
|
|
32
|
+
return {
|
|
33
|
+
solidBackgroundAttrs: {
|
|
34
|
+
color: '#000',
|
|
35
|
+
},
|
|
36
|
+
backgroundFormatType: 'SOLID' as BackgroundFormatTypes,
|
|
37
|
+
operator,
|
|
38
|
+
value: '200',
|
|
39
|
+
plotAsBand: false,
|
|
40
|
+
comparisonParameterId,
|
|
41
|
+
comparisonType,
|
|
42
|
+
lhsColumnId,
|
|
43
|
+
rhsColumnId,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates a between metric operator for conditional formatting.
|
|
49
|
+
*
|
|
50
|
+
* @param operator - The operator to use for the metric (e.g., IsBetween).
|
|
51
|
+
* @param min - The minimum value for the range (default is 100).
|
|
52
|
+
* @param max - The maximum value for the range (default is 200).
|
|
53
|
+
* @returns A ConditionalMetric object configured with the specified parameters.
|
|
54
|
+
*/
|
|
55
|
+
export const createBetweenMetricOperator = (
|
|
56
|
+
operator: Operators,
|
|
57
|
+
min = 100,
|
|
58
|
+
max = 200,
|
|
59
|
+
): ConditionalMetric => {
|
|
60
|
+
return {
|
|
61
|
+
backgroundFormatType: 'SOLID' as BackgroundFormatTypes,
|
|
62
|
+
solidBackgroundAttrs: {
|
|
63
|
+
color: '#000',
|
|
64
|
+
},
|
|
65
|
+
operator,
|
|
66
|
+
rangeValues: {
|
|
67
|
+
min,
|
|
68
|
+
max,
|
|
69
|
+
},
|
|
70
|
+
plotAsBand: false,
|
|
71
|
+
lhsColumnId: undefined,
|
|
72
|
+
rhsColumnId: undefined,
|
|
73
|
+
comparisonParameterId: undefined,
|
|
74
|
+
comparisonType: ConditionalFormattingComparisonTypes.ValueBased,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Creates an attribute operator for conditional formatting.
|
|
80
|
+
*
|
|
81
|
+
* @param operator - The operator to use for the attribute (e.g., Is, IsNot).
|
|
82
|
+
* @param comparisonType - (Optional) The type of comparison to use.
|
|
83
|
+
* @returns A ConditionalMetric object configured with the specified parameters.
|
|
84
|
+
*/
|
|
85
|
+
export const createAttributeOperator = (
|
|
86
|
+
operator: Operators,
|
|
87
|
+
comparisonType?: ConditionalFormattingComparisonTypes,
|
|
88
|
+
): ConditionalMetric => {
|
|
89
|
+
return {
|
|
90
|
+
backgroundFormatType: 'SOLID' as BackgroundFormatTypes,
|
|
91
|
+
operator,
|
|
92
|
+
value: 'check attribute',
|
|
93
|
+
comparisonType,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ConditionalFormatting, Maybe } from './conditional-formatting.types';
|
|
2
|
+
|
|
1
3
|
export enum ColumnType {
|
|
2
4
|
UNKNOWN,
|
|
3
5
|
MEASURE,
|
|
@@ -71,6 +73,51 @@ export enum CurrencyFormatType {
|
|
|
71
73
|
ISO_CODE,
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Type of aggregations applied on the column data
|
|
78
|
+
*
|
|
79
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
80
|
+
*/
|
|
81
|
+
export enum ColumnAggregationType {
|
|
82
|
+
AGGREGATE,
|
|
83
|
+
AGGREGATE_DISTINCT,
|
|
84
|
+
APPROX_AGGR_DISTINCT,
|
|
85
|
+
APPROX_AGGR_DISTINCT_MERGE,
|
|
86
|
+
APPROX_COUNT_DISTINCT,
|
|
87
|
+
AVERAGE,
|
|
88
|
+
COUNT,
|
|
89
|
+
COUNT_DISTINCT,
|
|
90
|
+
CUMULATIVE_AVERAGE,
|
|
91
|
+
CUMULATIVE_COUNT,
|
|
92
|
+
CUMULATIVE_MAX,
|
|
93
|
+
CUMULATIVE_MIN,
|
|
94
|
+
CUMULATIVE_SUM,
|
|
95
|
+
GROWTH,
|
|
96
|
+
MAX,
|
|
97
|
+
MEDIAN,
|
|
98
|
+
MIN,
|
|
99
|
+
MOVING_AVERAGE,
|
|
100
|
+
MOVING_COUNT,
|
|
101
|
+
MOVING_MAX,
|
|
102
|
+
MOVING_MIN,
|
|
103
|
+
MOVING_SUM,
|
|
104
|
+
NONE,
|
|
105
|
+
PERCENTILE,
|
|
106
|
+
RANK,
|
|
107
|
+
RANK_PERCENTILE,
|
|
108
|
+
SQL_BOOL_AGGREGATE_OP,
|
|
109
|
+
SQL_DATE_AGGREGATE_OP,
|
|
110
|
+
SQL_DATE_TIME_AGGREGATE_OP,
|
|
111
|
+
SQL_DOUBLE_AGGREGATE_OP,
|
|
112
|
+
SQL_INT_AGGREGATE_OP,
|
|
113
|
+
SQL_STRING_AGGREGATE_OP,
|
|
114
|
+
SQL_TIME_AGGREGATE_OP,
|
|
115
|
+
STD_DEVIATION,
|
|
116
|
+
SUM,
|
|
117
|
+
TABLE_AGGR,
|
|
118
|
+
VARIANCE,
|
|
119
|
+
}
|
|
120
|
+
|
|
74
121
|
/**
|
|
75
122
|
* Currency format for the column defined in the worksheet
|
|
76
123
|
*
|
|
@@ -171,4 +218,20 @@ export interface ChartColumn {
|
|
|
171
218
|
* @version SDK: 0.1 | ThoughtSpot:
|
|
172
219
|
*/
|
|
173
220
|
format?: ColumnFormat;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Column Properties of the columns
|
|
224
|
+
*
|
|
225
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
226
|
+
*/
|
|
227
|
+
columnProperties?: {
|
|
228
|
+
conditionalFormatting?: Maybe<ConditionalFormatting>;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Aggregation applied on the column data
|
|
233
|
+
*
|
|
234
|
+
* @version SDK: 0.1 | ThoughtSpot:
|
|
235
|
+
*/
|
|
236
|
+
columnAggregationType?: ColumnAggregationType;
|
|
174
237
|
}
|
|
@@ -7,6 +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
12
|
|
|
11
13
|
/**
|
|
12
14
|
* List of Columns for a dimension in the Custom Chart Config.
|
|
@@ -140,6 +142,12 @@ export interface ChartModel {
|
|
|
140
142
|
};
|
|
141
143
|
}
|
|
142
144
|
|
|
145
|
+
// Validation Response for valid config or visual props
|
|
146
|
+
export type SuccessValidationResponse = {
|
|
147
|
+
chartConfigEditorDefinition: ChartConfigEditorDefinition[];
|
|
148
|
+
visualPropEditorDefinition: VisualPropEditorDefinition;
|
|
149
|
+
};
|
|
150
|
+
|
|
143
151
|
// Generic Validation Response
|
|
144
152
|
export type ValidationResponse = {
|
|
145
153
|
isValid: boolean;
|