From 6ea0bfa5d33b9c6aaaf50ebd044c005566533873 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Wed, 22 May 2024 02:09:01 +0530 Subject: [PATCH] refactor: Add ADX_LANGUAGECODE and ADX_WEBSITE_LANGUAGE constants --- src/common/copilot/constants.ts | 2 ++ src/common/copilot/dataverseMetadata.ts | 7 +++---- src/web/client/schema/constants.ts | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/common/copilot/constants.ts b/src/common/copilot/constants.ts index e9f0adc4..7d409084 100644 --- a/src/common/copilot/constants.ts +++ b/src/common/copilot/constants.ts @@ -32,6 +32,8 @@ export const THUMBS_UP = 'thumbsUp'; export const THUMBS_DOWN = 'thumbsDown'; export const ADX_ENTITYFORM = "adx_entityform"; export const ADX_ENTITYLIST = "adx_entitylist"; +export const ADX_LANGUAGECODE = "adx_languagecode"; +export const ADX_WEBSITE_LANGUAGE = "adx_website_language"; export const ATTRIBUTE_DESCRIPTION = 'description'; export const ATTRIBUTE_DATAFIELD_NAME = 'datafieldname'; export const ATTRIBUTE_CLASSID = 'classid'; diff --git a/src/common/copilot/dataverseMetadata.ts b/src/common/copilot/dataverseMetadata.ts index 89edd875..fed8e73c 100644 --- a/src/common/copilot/dataverseMetadata.ts +++ b/src/common/copilot/dataverseMetadata.ts @@ -12,9 +12,8 @@ import { sendTelemetryEvent } from "./telemetry/copilotTelemetry"; import { CopilotDataverseMetadataFailureEvent, CopilotDataverseMetadataSuccessEvent, CopilotGetEntityFailureEvent, CopilotGetLanguageCodeFailureEvent, CopilotGetLanguageCodeSuccessEvent, CopilotYamlParsingFailureEvent } from "./telemetry/telemetryConstants"; import { getEntityMetadata, getDefaultLanguageCodeWeb } from "../../web/client/utilities/fileAndEntityUtil"; import { DOMParser } from "@xmldom/xmldom"; -import { ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants"; +import { ADX_LANGUAGECODE, ADX_WEBSITE_LANGUAGE, ATTRIBUTE_CLASSID, ATTRIBUTE_DATAFIELD_NAME, ATTRIBUTE_DESCRIPTION, ControlClassIdMap, SYSTEFORMS_API_PATH } from "./constants"; import { findWebsiteYAML, getUserAgent } from "../utilities/Utils"; -import { EntityMetadataKeyAdx } from "../../web/client/schema/constants"; declare const IS_DESKTOP: string | undefined; @@ -260,7 +259,7 @@ async function fetchLanguageCodeId(): Promise { const yamlContent = await readWebsiteYAML(activeFilePath); if (yamlContent) { const parsedYAML = yaml.parse(yamlContent); - const languageCodeId = parsedYAML[EntityMetadataKeyAdx.LANGUAGE_ID]; + const languageCodeId = parsedYAML[ADX_WEBSITE_LANGUAGE]; return languageCodeId; } else { return ""; @@ -311,7 +310,7 @@ async function fetchLanguageCodeFromAPI( orgUrl: orgUrl, }); - return matchingLanguage?.[EntityMetadataKeyAdx.LANGUAGE_NAME_CODE] ?? vscode.env.language; + return matchingLanguage?.[ADX_LANGUAGECODE] ?? vscode.env.language; } catch (error) { sendTelemetryEvent(telemetry, { eventName: CopilotGetLanguageCodeFailureEvent, diff --git a/src/web/client/schema/constants.ts b/src/web/client/schema/constants.ts index 751bec99..1ef4c6c5 100644 --- a/src/web/client/schema/constants.ts +++ b/src/web/client/schema/constants.ts @@ -87,6 +87,4 @@ export enum EntityMetadataKeyCore { export enum EntityMetadataKeyAdx { ENTITY_LOGICAL_NAME = "adx_entityname", FORM_LOGICAL_NAME = "adx_formname", - LANGUAGE_NAME_CODE = "adx_languagecode", - LANGUAGE_ID = "adx_website_language" }