You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "yesamer (via GitHub)" <gi...@apache.org> on 2024/12/12 15:12:14 UTC

[PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

yesamer opened a new pull request, #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802

   Fixes https://github.com/apache/incubator-kie-issues/issues/1684


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1883510773


##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );
   }
 }
 
-export async function validateDMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateDMN(serviceURL: URL, dmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.DMNValidationResponse[] = await validationRequests.validateDMN(
       serviceURL,
-      kieFile
+      dmnFile
     );
     return createDMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE DMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message
+    );

Review Comment:
   shouldn't we use `dmnFile` here?



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );

Review Comment:
   shouldn't we use `bpmnFile` here?



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);

Review Comment:
   similar comment about formatting placeholders like `%s`



##########
packages/extended-services-vscode-extension/src/extension/extension-browser.ts:
##########
@@ -67,43 +70,57 @@ function initializeVSCodeElements() {
 }
 
 function startExtendedServices(): void {
+  console.debug("[Extended Services Extension] Starting Extended Service");
   try {
-    statusBarItem.show();
     configuration = fetchConfiguration();
   } catch (error) {
-    stopExtendedServices();
-    vscode.window.showErrorMessage("An error happened while trying to start the Extended Services: " + error.message);
+    console.error("[Extended Services Extension] Extension configuration is wrong: " + error.message);

Review Comment:
   `%s` comment



##########
packages/extended-services-vscode-extension/src/extension/extension-main.ts:
##########
@@ -43,16 +43,19 @@ let configurationWatcher: ConfigurationWatcher;
 let connection: Connection;
 let localService: LocalExtendedServices;
 
-let userDisconnected: boolean = false;
+/* Determines if the extension is corrected with the Extended Services Backend */

Review Comment:
   ```suggestion
   /* Determines if the extension is connected with the Extended Services Backend */
   ```



##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   yes, it is important to have an option to configure the url of extended services, users report issues about it https://github.com/apache/incubator-kie-tools/issues/2759



##########
packages/extended-services-vscode-extension/src/extension/extension-browser.ts:
##########
@@ -67,43 +70,57 @@ function initializeVSCodeElements() {
 }
 
 function startExtendedServices(): void {
+  console.debug("[Extended Services Extension] Starting Extended Service");
   try {
-    statusBarItem.show();
     configuration = fetchConfiguration();
   } catch (error) {
-    stopExtendedServices();
-    vscode.window.showErrorMessage("An error happened while trying to start the Extended Services: " + error.message);
+    console.error("[Extended Services Extension] Extension configuration is wrong: " + error.message);

Review Comment:
   it is in whole PR, please let me know if you like that more, as it is usual shorter than manually concatenating string for the message



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );
   }
 }
 
-export async function validateDMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateDMN(serviceURL: URL, dmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.DMNValidationResponse[] = await validationRequests.validateDMN(
       serviceURL,
-      kieFile
+      dmnFile
     );
     return createDMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE DMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message);

Review Comment:
   similar comment about formatting placeholders `%s`



##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,31 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);

Review Comment:
   `warn` should support formatting placeholders:
   ```
   console.warn("Property: %s is missing, using the default: %s", property, defaultValue);
   ```
   
   maybe even:
   ```
   console.warn("Property: '%s' is missing, using the default: '%s'", property, defaultValue);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2547832282

   @jomarko 
   01
   I updated all the references to use the plural form
   
   02
   Yes, the user can close the connection using a button in the bottom bar of the editor.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917863865


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   @yesamer You're right, I had (and still have) the same concern, but honestly, I didn't find a solution to avoid this duplication. The ideal solution should be to retrieve the values from the package.json, I have to admin I didn't investigate if this is possible or not.



##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   @yesamer You're right, I had (and still have) the same concern, but honestly, I didn't find a solution to avoid this duplication. The ideal solution should be to retrieve the values from the package.json, I have to admit I didn't investigate if this is possible or not.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2582806025

   @jomarko I fixed the first use case you reported,  **Closing the model file**.
   The second scenario, **Disable Autorun and use URL**, works correctly in my local
   
   https://github.com/user-attachments/assets/4887c612-2ed4-4534-a32c-152f6efa45b6
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2594985357

   @jomarko Thank you for the review, it's indeed strange the Extension info is not updated. I checked, and the default value is correct in the package.json.
   Regarding your proposal with the ICON, I agree with you that should be revisited, together with other components.
   We agreed with @tiagobento to invest more time on this extension in the future, based on our priorities, so it makes sense to keep track of all elements/behavior you already found during this PR review.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1883850601


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,31 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);

Review Comment:
   I totally agree it is a personal preference. However, if there is an option, that has significant pros, like performance or security, maybe we should opt for it. Not saying there is such, just saying we have aspects that can help us to decide.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886792003


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,31 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);

Review Comment:
   Done, thank you both.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886784088


##########
packages/extended-services-vscode-extension/src/extension/extension-main.ts:
##########
@@ -43,16 +43,19 @@ let configurationWatcher: ConfigurationWatcher;
 let connection: Connection;
 let localService: LocalExtendedServices;
 
-let userDisconnected: boolean = false;
+/* Determines if the extension is corrected with the Extended Services Backend */

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1890253344


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @ljmotta 
   - Do you have an example for that? I mean, I added the plugin entry for both `web` and `node` https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-1768335dedd5cfa5e1b3830bb3b6c504f1d316dea21de55738df74f7f19c27a5R52
   To create a single entry for the plugin, which `target` and `entry` should I use?
   - You're right, considering extended-services-java always uses `http`, we are safe here :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2583290161

   @jomarko I'm not sure if using `0.0.0.0` is correct here, please try with `localhost`.
   
   @yesamer Please let me kwown when the PR is ready for another review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1905460235


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,48 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value: T | null = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value == defaultValue;
   }
+  return value;
+};

Review Comment:
   @ljmotta Thank you, I committed your suggested change, I'll update the comment and the property name 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1882932215


##########
packages/extended-services-vscode-extension/src/requests/ValidationRequests.ts:
##########
@@ -75,6 +74,14 @@ export async function validateBPMN(
   try {
     return validate(serviceURL, kieFile, "/jitbpmn/validate", validationresponse.parseBPMNValidationResponse);
   } catch (error) {
+    console.error(
+      "[Extended Services Extension] An error happened while trying to validate " +
+        kieFile +
+        " from serviceUrl " +
+        serviceURL +
+        ": " +
+        error
+    );

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886791459


##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );
   }
 }
 
-export async function validateDMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateDMN(serviceURL: URL, dmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.DMNValidationResponse[] = await validationRequests.validateDMN(
       serviceURL,
-      kieFile
+      dmnFile
     );
     return createDMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE DMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message);

Review Comment:
   Done



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886909436


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @yesamer That's true. the `defaultEnvJson` is used with the webpack transform + `fetch`, which isn't the case here. Now, you could use the webpack's `EnvironmentPlugin` to set env variables. The `online-editor` uses this approach to set some values inside the codebase. Take a look into the `online-editor/webpack.config.ts`, and search for `EnvironmentPlugin`. The `WEBPACK_REPLACE__*` values are the ones used in the codebase.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886923687


##########
packages/extended-services-vscode-extension/env/index.js:
##########


Review Comment:
   @yesamer To set `env` variables that **must** have the same values of other package, please use the available composite feature. You can take a look into the `dmn-editor/env/index.js` file, where we load multiple env files.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886782849


##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );

Review Comment:
   done



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,32 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate BPMN file: " + kieFile + " with error: " + error.message
+    );
   }
 }
 
-export async function validateDMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateDMN(serviceURL: URL, dmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.DMNValidationResponse[] = await validationRequests.validateDMN(
       serviceURL,
-      kieFile
+      dmnFile
     );
     return createDMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE DMN ERROR - " + error.message);
+    console.error("An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message);
+    throw new Error(
+      "An error happened while trying to validate DMN file: " + kieFile + " with error: " + error.message
+    );

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886863027


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @ljmotta In the examples I checked, the env variables are accessed using the _useEnv()_ hook, but in this case, we are not managing a React app. How can I access to env variable from "plain" typescript?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1886892628


##########
packages/extended-services-vscode-extension/src/extension/extension-browser.ts:
##########
@@ -67,43 +70,57 @@ function initializeVSCodeElements() {
 }
 
 function startExtendedServices(): void {
+  console.debug("[Extended Services Extension] Starting Extended Service");
   try {
-    statusBarItem.show();
     configuration = fetchConfiguration();
   } catch (error) {
-    stopExtendedServices();
-    vscode.window.showErrorMessage("An error happened while trying to start the Extended Services: " + error.message);
+    console.error("[Extended Services Extension] Extension configuration is wrong: " + error.message);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917865850


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   @jomarko ^^ :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2569174044

   ### Closing the model file
   Hi @yesamer or anyone, should closing the dmn/bpmn file to close also the message in problems tab? Currently it seems the problems tab is not cleared if model file is closed. Is that an expected behavior?
   ![Screenshot 2025-01-03 132148](https://github.com/user-attachments/assets/ad825234-f0e9-431f-9e96-b8ed89876ff9)
   
   ### Disable Autorun and use URL
   Once I disabled the autorun and started extended services as `pnpm -F @kie-tools/extended-services-java start` I was not able to connect VSCode extended services extension to the extended services instance.
   ![Screenshot 2025-01-03 133741](https://github.com/user-attachments/assets/aa9b6613-9915-414b-a1e8-0dfde766ddff)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1887236993


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @ljmotta It should be done, there are two points to discuss:
   - I added EnvironmentPlugin in both [extension-main](https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-1768335dedd5cfa5e1b3830bb3b6c504f1d316dea21de55738df74f7f19c27a5R53) and [extension-browser](https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-1768335dedd5cfa5e1b3830bb3b6c504f1d316dea21de55738df74f7f19c27a5R65). There's a way to define that once?
   - Currently, the host and the post are parametrized, In my opinion, it would be better to have the entire URL as a parameter. E.g. http protocol is hardcoded, what if the user provides its own instance using https?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2583292520

   @ljmotta Yes, please :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917767813


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T

Review Comment:
   Why do we need to have also `defaultValue` parameter here? the three configurations related to this PR in `extended-services-vscode-extension/package.json`. Do we use `getConfigurationPropertyValue` also for loading configurations that do not have default value specified?



##########
packages/extended-services-vscode-extension/src/Validator.ts:
##########
@@ -49,26 +49,28 @@ function createDMNDiagnostics(validationResponses: validationResponse.DMNValidat
   });
 }
 
-export async function validateBPMN(serviceURL: URL, kieFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
+export async function validateBPMN(serviceURL: URL, bpmnFile: kieFile.KieFile): Promise<vscode.Diagnostic[]> {
   try {
     const validationResponses: validationResponse.BPMNValidationResponse[] = await validationRequests.validateBPMN(
       serviceURL,
-      kieFile
+      bpmnFile
     );
     return createBPMNDiagnostics(validationResponses);
   } catch (error) {
-    throw new Error("VALIDATE BPMN ERROR - " + error.message);
+    console.error(`An error occured while trying to validate DMN file: ${bpmnFile} with error: ${error.message}`);
+    throw new Error(`An error occured while trying to validate DMN file: ${bpmnFile} with error: ${error.message}`);

Review Comment:
   ```suggestion
       console.error(`An error occured while trying to validate BPMN file: ${bpmnFile} with error: ${error.message}`);
       throw new Error(`An error occured while trying to validate BPMN file: ${bpmnFile} with error: ${error.message}`);
   ```



##########
packages/extended-services-vscode-extension/src/extension/extension-browser.ts:
##########
@@ -67,60 +70,71 @@ function initializeVSCodeElements() {
 }
 
 function startExtendedServices(): void {
+  console.debug("[Extended Services Extension] Starting Extended Service");
   try {
-    statusBarItem.show();
     configuration = fetchConfiguration();
   } catch (error) {
-    stopExtendedServices();
-    vscode.window.showErrorMessage("An error happened while trying to start the Extended Services: " + error.message);
+    console.error(`[Extended Services Extension] Extension configuration is wrong: ${error.message}`);
+    vscode.window.showErrorMessage(
+      `Extension configuration is wrong: ${error.message}. Please fix your local extension's setting`
+    );
     return;
   }
 
   try {
-    connection.start(configuration.extendedServicesURL, configuration.connectionHeartbeatIntervalinSecs);
+    console.debug(
+      `[Extended Services Extension] Connecting with the Extended Services located: ${configuration.extendedServicesURL}`
+    );
+    connection.start(configuration.extendedServicesURL, configuration.connectionHeartbeatIntervalInSecs);
   } catch (error) {
     stopExtendedServices();
-    vscode.window.showErrorMessage("An error happened while trying to connect to the service:" + error.message);
+    console.error(
+      `[Extended Services Extension] An error happened while trying to start the local service: ${error.message}`
+    );
+    vscode.window.showErrorMessage(`An error happened while trying to start the local service: ${error.message}`);
   }
 }
 
 function stopExtendedServices() {
+  console.debug("[Extended Services Extension] Stopping Extended Service");
+  /* Invalidating immediatly the current connection, so any request coming when shutting down is not served */
+  isConnected = false;
   configuration = null;
   connection.stop();
 }
 
-async function validate(configuration: Configuration) {
+async function validate(extendedServicesURL: URL) {
   diagnosticCollection.clear();
 
   const bpmnFiles: KieFile[] = await kiefilesfetcher.findActiveKieFiles([kiefilesfetcher.bpmnDocumentFilter]);
   const dmnFiles: KieFile[] = await kiefilesfetcher.findActiveKieFiles([kiefilesfetcher.dmnDocumentFilter]);
 
   for (const bpmnFile of bpmnFiles) {
     try {
-      const bpmnDiagnostics: vscode.Diagnostic[] = await validator.validateBPMN(
-        configuration.extendedServicesURL,
-        bpmnFile
-      );
+      console.debug(`[Extended Services Extension] Validating DMN file: ${bpmnFile.uri.path}`);

Review Comment:
   ```suggestion
         console.debug(`[Extended Services Extension] Validating BPMN file: ${bpmnFile.uri.path}`);
   ```



##########
packages/extended-services-vscode-extension/src/requests/PingRequest.ts:
##########
@@ -23,6 +23,7 @@ export async function ping(extendedServicesURL: URL): Promise<pingresponse.PingR
   const url = new URL("/ping", extendedServicesURL);
 
   try {
+    console.debug("[Extended Services Extension] Pinging: " + url.toString());

Review Comment:
   maybe we could improve the variable name. what is your opinion about `extendedServicesPingURL`?



##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   related to question above, to me it seems that `true` and `10` and duplicated values that are already set in package.json what is vulnerable to get out of sync and then potentially make debugging and solving issues more difficult



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1888440548


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @yesamer 
    - If you need to use in both, you can set the env variables in the `commonConfig` variable.
    - Good point. I'm not familiar on how the user set/use the Extended Services in the VS Code extension. Is it a embeded Extended Services or the user need to manually start the server? For the `extended-services-java` it will always use `http`. If the user wants to deploy it, the user will need to make the necessary adjustments to make it available through `https`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2587106097

   Deferring my review to @jomarko, feel free to merge when approved by him and green! Thanks for the great effort here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917863865


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   @jomarko  You're right, I had (and still have) the same concern, but honestly, I didn't find a solution to avoid this duplication. The ideal solution should be to retrieve the values from the package.json, I have to admit I didn't investigate if this is possible or not.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917863620


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T
+): T => {
+  let value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value === null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value = defaultValue;
   }
+  return value;
+};
 
-  try {
-    extendedServicesURL = fetchExtendedServicesURL();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
+export function fetchConfiguration(): Configuration {
+  const enableAutoRun = getConfigurationPropertyValue<boolean>(enableAutoRunID, true);
+  const connectionHeartbeatIntervalInSecs = getConfigurationPropertyValue<number>(
+    connectionHeartbeatIntervalInSecsID,
+    10
+  );

Review Comment:
   resolved because of https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917863297



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#issuecomment-2577999623

   @jomarko 
   /cc @ljmotta @tiagobento 
   
   I'm double-checking the behavior you reported. However, I'm not fully aware of the expected behavior of this feature, so my goal is to implement a minimal use-case scenario for this extension. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1882613657


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   We should use the `env` value instead of hardcoding. To do so, take a look into the `build/defaultEnvJson.ts` file in some packages (e.g. `online-editor`).



##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,30 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (!value) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);
   }
+  return value || defaultValue;
+};

Review Comment:
   I'm not sure if I followed. `T` can be a `boolean`, `number` or `string`. If is a `boolean` it will always be `true`, as it is the default value. For `number`, can't be `0`, and `string` can't be `""`? Or `value` can't be `undefined`? The `(!value)` can be tricky, please, make it explicity.



##########
packages/extended-services-vscode-extension/src/requests/ValidationRequests.ts:
##########
@@ -75,6 +74,14 @@ export async function validateBPMN(
   try {
     return validate(serviceURL, kieFile, "/jitbpmn/validate", validationresponse.parseBPMNValidationResponse);
   } catch (error) {
+    console.error(
+      "[Extended Services Extension] An error happened while trying to validate " +
+        kieFile +
+        " from serviceUrl " +
+        serviceURL +
+        ": " +
+        error
+    );

Review Comment:
   You could change to `bpmnFile` as you did in another file. :wink:
   
   The same applies for the `validateDMN`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1882927780


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,30 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (!value) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);
   }
+  return value || defaultValue;
+};

Review Comment:
   > T can be a boolean, number or string. If is a boolean it will always be true, as it is the default value. For number, can't be 0, and string can't be ""
   
   So, if the user explicitly removes the property the default value is always returned? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1899598305


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,48 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value: T | null = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
+    value == defaultValue;
   }
+  return value;
+};

Review Comment:
   @yesamer I just have one comment related to this method, here is a suggestion of improvement. Also, I'm fixing two things here, the first double equals (`==`) to triple equals, and the second double equals should be an attribution.
   
   ```suggestion
   // Place on top of the file or on another file
   // I don't think this is a suitable name, it's just to exemplify
   type Property = string | number | boolean
   
   const getConfigurationPropertyValue = <T extends Property | null>(property: string, defaultValue: T): T => {
     const value = vscode.workspace.getConfiguration().get(property) as T;
     if (value === null) {
       console.warn(`Property: ${property} is missing, using the default: ${defaultValue}`);
       value = defaultValue;
     }
     return value;
   };
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917861431


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T

Review Comment:
   Those configuration parameters are loaded from the extension's setting, and these values can be accidentally erased by the user. Despite we could argue this is a low-probability scenario, I guess it's worth ensuring the extension can effectively work in most of the scenarios.
   
   <img width="599" alt="Screenshot 2025-01-16 at 08 13 40" src="https://github.com/user-attachments/assets/fd8a1d61-cb13-4209-9551-0b8b11bd7c37" />
   
   Does make sense?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer merged PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917863297


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T

Review Comment:
   ok, I understand now, thank you



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917861431


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,81 +19,53 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalInSecsID = "extendedServices.connectionHeartbeatIntervalInSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+
+type ConfigurationProperty = string | number | boolean;
 
 export class Configuration {
   readonly enableAutoRun: boolean;
-  readonly connectionHeartbeatIntervalinSecs: number;
+  readonly connectionHeartbeatIntervalInSecs: number;
   readonly extendedServicesURL: URL;
 
-  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalinSecs: number, extendedServicesURL: URL) {
+  constructor(enableAutoRun: boolean, connectionHeartbeatIntervalInSecs: number, extendedServicesURL: URL) {
     this.enableAutoRun = enableAutoRun;
-    this.connectionHeartbeatIntervalinSecs = connectionHeartbeatIntervalinSecs;
+    this.connectionHeartbeatIntervalInSecs = connectionHeartbeatIntervalInSecs;
     this.extendedServicesURL = extendedServicesURL;
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("URL configuration not found");
-  }
-
+  const defaultExtendedServicesURL = `http://${process.env.WEBPACK_REPLACE__extendedServicesUrlHost}:${process.env.WEBPACK_REPLACE__extendedServicesUrlPort}`;
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error(`URL configuration ${extendedServicesURL} is invalid: ${error.message}`);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T extends ConfigurationProperty | null>(
+  property: string,
+  defaultValue: T

Review Comment:
   @jomarko Those configuration parameters are loaded from the extension's setting, and these values can be accidentally erased by the user. Despite we could argue this is a low-probability scenario, I guess it's worth ensuring the extension can effectively work in most of the scenarios.
   
   <img width="599" alt="Screenshot 2025-01-16 at 08 13 40" src="https://github.com/user-attachments/assets/fd8a1d61-cb13-4209-9551-0b8b11bd7c37" />
   
   Does make sense?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1917851168


##########
packages/extended-services-vscode-extension/src/requests/PingRequest.ts:
##########
@@ -23,6 +23,7 @@ export async function ping(extendedServicesURL: URL): Promise<pingresponse.PingR
   const url = new URL("/ping", extendedServicesURL);
 
   try {
+    console.debug("[Extended Services Extension] Pinging: " + url.toString());

Review Comment:
   @jomarko Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1883827266


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,30 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (!value) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);
   }
+  return value || defaultValue;
+};

Review Comment:
   @yesamer I just considered the calls to this method. We have just 3 on this file, each one of them with T equals to `boolean`, `number` or `string`. The `if` will be `true` for the cases I listed, and we will have the log. Additionally, the return will always go to the default value for the same cases:
   
   ```sh
   > "" || "my_default_value"
   'my_default_value'
   > 0 || 25
   25
   > false || true
   true
   ```
   
   If the `value` (has the type `T` due your casting) can have a different type, please make it explicity. Something like: `T | null` or `T | undefined`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1882901903


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -19,9 +19,10 @@
 
 import * as vscode from "vscode";
 
-export const enableAutoRunID: string = "extendedServices.enableAutorun";
-export const connectionHeartbeatIntervalinSecsID: string = "extendedServices.connectionHeartbeatIntervalinSecs";
-export const extendedServicesURLID: string = "extendedServices.extendedServicesURL";
+export const enableAutoRunID = "extendedServices.enableAutorun";
+export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs";
+export const extendedServicesURLID = "extendedServices.extendedServicesURL";
+const defaultExtendedServicesURL = "http://localhost:21345";

Review Comment:
   @ljmotta It's a good point. I would like to retrieve that default value directly from the configuration here https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-153d43651b25ee3120020fae349c9e8ed99ccf90aa15995784702244decf9499R91 to avoid duplication and a single place for that property value, do you think is a valid alternative should I consider?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#1694: Apache KIE Extended Services extension issues [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #2802:
URL: https://github.com/apache/incubator-kie-tools/pull/2802#discussion_r1883831697


##########
packages/extended-services-vscode-extension/src/configurations/Configuration.ts:
##########
@@ -35,65 +36,31 @@ export class Configuration {
   }
 }
 
-function fetchEnableAutoRun(): boolean {
-  const enableAutoRun = vscode.workspace.getConfiguration().get<boolean>(enableAutoRunID);
-  if (!enableAutoRun) {
-    throw new Error("Enable Auto Run configuration not found");
-  }
-  return enableAutoRun;
-}
-
-function fetchConnectionHeartbeatIntervalinSecs(): number {
-  const connectionHeartbeatIntervalinSecs = vscode.workspace
-    .getConfiguration()
-    .get<number>(connectionHeartbeatIntervalinSecsID);
-  if (!connectionHeartbeatIntervalinSecs) {
-    throw new Error("Connection Heartbeat Interval configuration not found");
-  }
-
-  return connectionHeartbeatIntervalinSecs;
-}
-
 function fetchExtendedServicesURL(): URL {
-  const extendedServicesURL = vscode.workspace.getConfiguration().get<string>(extendedServicesURLID);
-  if (!extendedServicesURL) {
-    throw new Error("Extended Services URL configuration not found");
-  }
-
+  const extendedServicesURL = getConfigurationPropertyValue<string>(extendedServicesURLID, defaultExtendedServicesURL);
   try {
     return new URL(extendedServicesURL);
   } catch (error) {
-    throw new Error("Invalid service URL:" + error.message);
+    throw new Error("The provided Extended Services URL " + extendedServicesURL + " is invalid: " + error.message);
   }
 }
 
-export function fetchConfiguration(): Configuration {
-  let errorMessages: string[] = [];
-  let enableAutoRun: any;
-  let connectionHeartbeatIntervalinSecs: any;
-  let extendedServicesURL: any;
-
-  try {
-    enableAutoRun = fetchEnableAutoRun();
-  } catch (error) {
-    errorMessages.push(error.message);
-  }
-
-  try {
-    connectionHeartbeatIntervalinSecs = fetchConnectionHeartbeatIntervalinSecs();
-  } catch (error) {
-    errorMessages.push(error.message);
+const getConfigurationPropertyValue = <T>(property: string, defaultValue: T): T => {
+  const value = vscode.workspace.getConfiguration().get(property) as T;
+  if (value == null) {
+    console.warn("Property: " + property + " is missing, using the default: " + defaultValue);

Review Comment:
   I'm inclined to think it would be better to use template strings with the backtick:
   
   ```ts
   `Property: ${property} is missing, using the default: ${defaultValue}` 
   ```
   
   But this is a personal preference. As we don't have a standard for this any option is ok.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org