Repository: thoughtspot/ts-chart-sdk
Pull request #113: SCAL-253522 Added labelTranslation
Author: login: yashvardhan-n
Created: 2025-05-05T08:03:08Z | Merged: 2025-05-07T08:40:11Z



Diff:
diff --git a/package-lock.json b/package-lock.json
index c29d2ee..3e89525 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
     "name": "@thoughtspot/ts-chart-sdk",
-    "version": "2.0.1",
+    "version": "2.0.2",
     "lockfileVersion": 3,
     "requires": true,
     "packages": {
         "": {
             "name": "@thoughtspot/ts-chart-sdk",
-            "version": "2.0.1",
+            "version": "2.0.2",
             "license": "ThoughtSpot Development Tools End User License Agreement",
             "dependencies": {
                 "cldr-data": "^36.0.2",
diff --git a/package.json b/package.json
index 10e619c..b90b765 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
     "name": "@thoughtspot/ts-chart-sdk",
     "private": false,
-    "version": "2.0.1",
+    "version": "2.0.2",
     "module": "lib/index",
     "main": "lib/index",
     "types": "lib/index",
diff --git a/src/types/common.types.ts b/src/types/common.types.ts
index a7d6d1c..4a6d648 100644
--- a/src/types/common.types.ts
+++ b/src/types/common.types.ts
@@ -195,10 +195,30 @@ export type VisualPropError = {
     value: unknown;
 };
 
+/**
+ * Represents a validation error message with its translation key.
+ * This type is used to provide localized error messages for validation failures.
+ * 
+ * @example
+ * ```typescript
+ * const validationError: ValidationErrorMessage = {
+ *   errorMessage: "Field is required",
+ *   errorTranslation: "REQUIRED_FIELD_ERROR"
+ * };
+ * ```
+ * 
+ * @property errorTranslation - The translation key that will be used to look up the translated error message
+ * @property errorMessage - The default error message that will be shown if translation is not available
+ */
+export type ValidationErrorMessage = {
+    errorTranslation: string;
+    errorMessage: string;
+};
+
 // Generic Validation Response
 export type ValidationResponse = {
     isValid: boolean;
-    validationErrorMessage?: string[];
+    validationErrorMessage?: string[] | ValidationErrorMessage[];
     visualPropError?: VisualPropError;
 };
 
diff --git a/src/types/configurator.types.ts b/src/types/configurator.types.ts
index 7ee4e1a..82f8888 100644
--- a/src/types/configurator.types.ts
+++ b/src/types/configurator.types.ts
@@ -34,6 +34,13 @@ export interface ChartConfigSection {
      */
     label: string;
 
+    /**
+     * Translation key for the label
+     *
+     * @version SDK: 2.0.2 | ThoughtSpot:
+     */
+    labelTranslation?: string;
+
     /**
      * In the UI, the following values will only prevent dropping unnecessary
      * columns on the section config or prevent users from opening a drop-down in case of
diff --git a/src/types/visual-prop.types.ts b/src/types/visual-prop.types.ts
index c13ddbc..44ec727 100644
--- a/src/types/visual-prop.types.ts
+++ b/src/types/visual-prop.types.ts
@@ -16,9 +16,55 @@ export type TSTooltipConfig = {
     columnIds: Array<string>;
 };
 
+/**
+ * Represents a value that needs to be translated in visual properties.
+ * This type is used when a value needs to be displayed in different languages
+ * or when the display value needs to be different from the actual value.
+ * 
+ * @example
+ * ```typescript
+ * const translatedValue: TranslatedValue = {
+ *   value: "show_all",
+ *   valueTranslation: "SHOW_ALL_LABELS"
+ * };
+ * ```
+ * 
+ * @property valueTranslation - The translation key that will be used to look up the translated text
+ * @property value - The actual value that will be used in the application logic
+ */
+export type TranslatedValue = { valueTranslation: string; value: string };
+
 type Value = string | boolean | number | object | any[];
 
-type ElementProperties = { [key: string]: Value };
+type ElementProperties = {
+    [key: string]: Value;
+} & {
+    labelTranslation?: VisualPropComponentTranslationKeys | string;
+};
+
+/**
+ * Enum for the keys of the answer properties.
+ *
+ * These are the keys you can use when `isAnswerProperty` is true.
+ *
+ * @enum {string}
+ */
+export enum AnswerPropertyKeys {
+    /** The name of the property */
+    NAME = 'name',
+    /** Sort configuration */
+    SORT_CONFIG = 'sortConfig',
+    /** Number formatter */
+    NUMBER_FORMATTER = 'numberFormatter',
+    /** Aggregation type */
+    SORT_ORDER_VALUE = 'aggregationType',
+    /** Time bucket */
+    SORT_ORDER_VALUE_VALUE = 'timeBucket',
+    /** Background property */
+    BACKGROUND = 'Background',
+    /** Handle missing values */
+    HANDLE_MISSING_VALUES = 'handleMissingValues',
+}
 
 export enum VisualPropComponentTranslationKeys {
     SHOW_ALL_LABELS = 'SHOW_ALL_LABELS',
@@ -269,7 +315,7 @@ export interface TextInputFormDetail {
      *
      * @version SDK: 0.2 | ThoughtSpot:
      */
-    labelTranslation?: VisualPropComponentTranslationKeys;
+    labelTranslation?: VisualPropComponentTranslationKeys | string;
 }
 
 /**
@@ -459,13 +505,13 @@ export interface RadioButtonFormDetail {
      *
      * @version SDK: 0.1 | ThoughtSpot:
      */
-    defaultValue?: string;
+    defaultValue?: string | TranslatedValue;
     /**
      * List of values to select from
      *
      * @version SDK: 0.1 | ThoughtSpot:
      */
-    values: string[];
+    values: string[] | TranslatedValue[];
     /**
      * Determines whether it should be disabled or not
      *
@@ -504,13 +550,13 @@ export interface DropDownFormDetail {
      *
      * @version SDK: 0.1 | ThoughtSpot:
      */
-    defaultValue?: string;
+    defaultValue?: string | TranslatedValue;
     /**
      * List of values to select from
      *
      * @version SDK: 0.1 | ThoughtSpot:
      */
-    values: string[];
+    values: string[] | TranslatedValue[];
     /**
      * Determines whether it should be disabled or not
      *


Reviews:
user: login: UtkarshRai12
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-07T07:16:20Z
user: login: UtkarshRai12
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-07T07:20:37Z
user: login: yashvardhan-n
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-05-07T07:41:13Z
user: login: UtkarshRai12
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-07T08:32:56Z

Review comments:
diff_hunk: @@ -195,10 +195,15 @@ export type VisualPropError = {
     value: unknown;
 };
 
+export type ValidationErrorMessage = {
+    errorTranslation: string;
+    errorMessage: string;
+};
+
path: src/types/common.types.ts
user: login: UtkarshRai12
body: can we add a typedoc on the what each property represent and how it will be used
created_at: 2025-05-07T07:16:19Z
author_association: COLLABORATOR
diff_hunk: @@ -8,6 +8,7 @@
  * Copyright: ThoughtSpot Inc. 2023
  */
 
+// eslint-disable-next-line prettier/prettier
path: src/types/visual-prop.types.ts
user: login: UtkarshRai12
body: why are we adding this?
created_at: 2025-05-07T07:20:37Z
author_association: COLLABORATOR
diff_hunk: @@ -195,10 +195,15 @@ export type VisualPropError = {
     value: unknown;
 };
 
+export type ValidationErrorMessage = {
+    errorTranslation: string;
+    errorMessage: string;
+};
+
path: src/types/common.types.ts
user: login: yashvardhan-n
body: ack
created_at: 2025-05-07T07:40:58Z
author_association: COLLABORATOR
diff_hunk: @@ -8,6 +8,7 @@
  * Copyright: ThoughtSpot Inc. 2023
  */
 
+// eslint-disable-next-line prettier/prettier
path: src/types/visual-prop.types.ts
user: login: yashvardhan-n
body: removed
created_at: 2025-05-07T07:41:11Z
author_association: COLLABORATOR

PR comments:
user: login: mnk-blr
created_at: 2025-05-05T08:03:32Z
body: ![](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)

### :tada: **Snyk checks have passed. No issues have been found so far.**

:white_check_mark: **security/snyk** check is complete. No issues have been found. [(View Details)](https://app.snyk.io/org/thoughtspot/pr-checks/3199c7dd-7c2a-4d6f-9a0e-377ba786e16b?refs=6221ef1e9e2215d21af46e8887ce6b2492a92afe&source=prChecksComment)

:white_check_mark: **license/snyk** check is complete. No issues have been found. [(View Details)](https://app.snyk.io/org/thoughtspot/pr-checks/3199c7dd-7c2a-4d6f-9a0e-377ba786e16b/license?refs=6221ef1e9e2215d21af46e8887ce6b2492a92afe&source=prChecksComment)



author_association: NONE
user: login: github-actions[bot]
created_at: 2025-05-05T08:04:39Z
body: <strong></strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `89%` | :white_check_mark: |
| src/main/custom-chart-context.ts | `88%` | :white_check_mark: |
| src/main/logger.ts | `88%` | :white_check_mark: |
| src/main/post-message-event-bridge.ts | `81%` | :white_check_mark: |
| src/react/use-custom-chart-context.tsx | `86%` | :white_check_mark: |
| src/react/mocks/custom-chart-context-mock.ts | `96%` | :white_check_mark: |
| src/utils/date-formatting.ts | `82%` | :white_check_mark: |
| src/utils/formatting-util.ts | `89%` | :white_check_mark: |
| src/utils/conditional-formatting/conditional-formatting.ts | `92%` | :white_check_mark: |
| src/utils/globalize-Initializer/globalize-utils.ts | `95%` | :white_check_mark: |
| src/utils/number-formatting/number-formatting-utils.ts | `98%` | :white_check_mark: |
| src/utils/number-formatting/number-formatting.ts | `90%` | :white_check_mark: |

_Minimum allowed coverage is `0%`_

<p align="right">Generated by :monkey: cobertura-action against 4dee33d74d06b6e96d9c85658bc55a8b36413289 </p>
author_association: NONE