@gridsuite/commons-ui 0.157.0 → 0.159.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/components/checkBoxList/CheckBoxListItem.js +1 -1
  2. package/dist/components/checkBoxList/CheckBoxListItemContent.js +1 -1
  3. package/dist/components/checkBoxList/DraggableCheckBoxListItem.js +1 -1
  4. package/dist/components/checkBoxList/DraggableCheckBoxListItemContent.js +1 -1
  5. package/dist/components/csvDownloader/use-csv-export.js +1 -1
  6. package/dist/components/customAGGrid/cell-renderers.js +1 -1
  7. package/dist/components/customAGGrid/separatorCellRenderer.js +1 -1
  8. package/dist/components/dialogs/elementSaveDialog/ElementSaveDialog.js +1 -1
  9. package/dist/components/directoryItemSelector/utils.js +2 -2
  10. package/dist/components/dnd-table/dnd-table-add-rows-dialog.js +1 -1
  11. package/dist/components/filter/FilterForm.js +1 -1
  12. package/dist/components/filter/HeaderFilterForm.js +1 -1
  13. package/dist/components/filter/expert/ExpertFilterForm.js +1 -1
  14. package/dist/components/filter/expert/expertFilterConstants.js +1 -1
  15. package/dist/components/filter/utils/filterFormUtils.js +1 -1
  16. package/dist/components/icons/EditNoteIcon.d.ts +3 -9
  17. package/dist/components/icons/EditNoteIcon.js +4 -12
  18. package/dist/components/icons/LeftPanelCloseIcon.d.ts +2 -7
  19. package/dist/components/icons/LeftPanelCloseIcon.js +3 -13
  20. package/dist/components/icons/LeftPanelOpenIcon.d.ts +2 -7
  21. package/dist/components/icons/LeftPanelOpenIcon.js +3 -13
  22. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +1 -1
  23. package/dist/components/inputs/reactHookForm/OverflowableChipWithHelperText.js +1 -1
  24. package/dist/components/inputs/reactHookForm/agGridTable/CustomAgGridTable.js +1 -1
  25. package/dist/components/inputs/reactHookForm/agGridTable/csvUploader/CsvUploader.js +1 -1
  26. package/dist/components/inputs/reactHookForm/chip-items-input.js +1 -1
  27. package/dist/components/inputs/reactQueryBuilder/CountryValueEditor.js +1 -1
  28. package/dist/components/inputs/reactQueryBuilder/ElementValueEditor.js +1 -1
  29. package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +1 -1
  30. package/dist/components/overflowableText/OverflowableText.js +1 -1
  31. package/dist/components/parameters/common/ProviderParam.js +1 -1
  32. package/dist/components/parameters/common/computing-type.d.ts +1 -0
  33. package/dist/components/parameters/common/computing-type.js +3 -0
  34. package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -1
  35. package/dist/components/parameters/common/limitreductions/limit-reductions-table-form.js +1 -1
  36. package/dist/components/parameters/common/name-element-editor/name-element-editor-form.js +1 -1
  37. package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +1 -1
  38. package/dist/components/parameters/common/utils.js +2 -2
  39. package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -1
  40. package/dist/components/parameters/common/widget/parameter-float.js +1 -1
  41. package/dist/components/parameters/common/widget/parameter-line-directory-items-input.js +1 -1
  42. package/dist/components/parameters/common/widget/parameter-line-slider.js +1 -1
  43. package/dist/components/parameters/loadflow/load-flow-general-parameters.js +1 -1
  44. package/dist/components/parameters/loadflow/load-flow-parameter-field.js +1 -1
  45. package/dist/components/parameters/loadflow/load-flow-parameters-content.js +1 -1
  46. package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +2 -2
  47. package/dist/components/parameters/loadflow/load-flow-parameters-form.js +1 -1
  48. package/dist/components/parameters/loadflow/load-flow-parameters-header.js +1 -1
  49. package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +1 -1
  50. package/dist/components/parameters/network-visualizations/network-area-diagram-parameters.js +1 -1
  51. package/dist/components/parameters/network-visualizations/network-visualizations-form.js +1 -1
  52. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-dialog.js +1 -1
  53. package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +1 -1
  54. package/dist/components/parameters/pcc-min/pcc-min-form-utils.js +1 -1
  55. package/dist/components/parameters/pcc-min/pcc-min-parameters-dialog.js +1 -1
  56. package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +1 -1
  57. package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -1
  58. package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +2 -2
  59. package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +1 -1
  60. package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +1 -1
  61. package/dist/components/parameters/sensi/columns-definitions.js +2 -2
  62. package/dist/components/parameters/sensi/sensitivity-Flow-parameters.js +1 -1
  63. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -1
  64. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -1
  65. package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +1 -1
  66. package/dist/components/parameters/sensi/table-cell.js +1 -1
  67. package/dist/components/parameters/sensi/utils.js +2 -2
  68. package/dist/components/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -1
  69. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +1 -1
  70. package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +1 -1
  71. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +32 -0
  72. package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +1 -1
  73. package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +1 -1
  74. package/dist/components/parameters/voltage-init/general-parameters.js +1 -1
  75. package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +1 -1
  76. package/dist/components/parameters/voltage-init/voltage-init-parameters-dialog.js +1 -1
  77. package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +1 -1
  78. package/dist/hooks/use-unique-name-validation.js +1 -1
  79. package/dist/hooks/useConfidentialityWarning.js +1 -1
  80. package/dist/hooks/useModificationLabelComputer.js +1 -1
  81. package/dist/index.js +5 -4
  82. package/dist/services/config.js +1 -1
  83. package/dist/services/index.js +3 -2
  84. package/dist/services/utils.d.ts +8 -2
  85. package/dist/services/utils.js +61 -35
  86. package/dist/utils/error.js +2 -5
  87. package/dist/utils/index.js +2 -2
  88. package/dist/utils/types/CustomError.d.ts +2 -5
  89. package/dist/utils/types/CustomError.js +3 -14
  90. package/dist/utils/types/ProblemDetailError.d.ts +5 -2
  91. package/dist/utils/types/ProblemDetailError.js +14 -3
  92. package/dist/utils/types/index.js +2 -2
  93. package/package.json +1 -1
@@ -3,13 +3,6 @@ import { ProblemDetailError } from "../utils/types/ProblemDetailError.js";
3
3
  import { NetworkTimeoutError } from "../utils/types/NetworkTimeoutError.js";
4
4
  import { CustomError } from "../utils/types/CustomError.js";
5
5
  const DEFAULT_TIMEOUT_MS = 5e4;
6
- const parseError = (text) => {
7
- try {
8
- return JSON.parse(text);
9
- } catch {
10
- return null;
11
- }
12
- };
13
6
  const ensureSignal = (init) => {
14
7
  if (init?.signal) return init;
15
8
  const timeoutMs = typeof init?.timeoutMs === "number" ? init.timeoutMs : DEFAULT_TIMEOUT_MS;
@@ -28,35 +21,67 @@ const prepareRequest = (init, token) => {
28
21
  initWithSignal.headers.append("Authorization", `Bearer ${tokenCopy}`);
29
22
  return initWithSignal;
30
23
  };
31
- const convertToCustomError = (textError) => {
32
- const errorJson = parseError(textError);
33
- if (errorJson?.server && errorJson?.timestamp && errorJson?.traceId && errorJson?.detail) {
34
- let date = /* @__PURE__ */ new Date();
35
- try {
36
- date = new Date(errorJson.timestamp);
37
- } catch {
38
- }
24
+ const isProblemDetail = (error) => {
25
+ if (typeof error !== "object" || error === null) {
26
+ return false;
27
+ }
28
+ const e = error;
29
+ return typeof e.status === "number" && typeof e.server === "string" && typeof e.timestamp === "string" && typeof e.traceId === "string" && typeof e.detail === "string";
30
+ };
31
+ const parseError = (errorTxt) => {
32
+ let error;
33
+ try {
34
+ error = JSON.parse(errorTxt);
35
+ } catch {
36
+ return new Error(errorTxt);
37
+ }
38
+ if (isProblemDetail(error)) {
39
39
  return new ProblemDetailError(
40
- errorJson.detail,
41
- errorJson.server,
42
- date,
43
- errorJson.traceId,
44
- errorJson.status,
45
- errorJson.businessErrorCode,
46
- errorJson.businessErrorValues
40
+ error.status,
41
+ error.detail,
42
+ error.server,
43
+ error.timestamp,
44
+ error.traceId,
45
+ error.businessErrorCode,
46
+ error.businessErrorValues
47
47
  );
48
48
  }
49
- return new CustomError(
50
- errorJson.detail,
51
- errorJson.status,
52
- errorJson.businessErrorCode,
53
- errorJson.businessErrorValues
54
- );
49
+ return new Error(errorTxt);
55
50
  };
56
- const handleError = (response) => {
57
- return response.text().then((text) => {
58
- throw convertToCustomError(text);
59
- });
51
+ const handleNotOkResponse = async (response) => {
52
+ let bodyText;
53
+ try {
54
+ bodyText = await response.text();
55
+ } catch (error) {
56
+ throw new CustomError(response.status, "Error in error: unable to read response body", {
57
+ cause: error
58
+ });
59
+ }
60
+ const contentType = response.headers.get("content-type") ?? "";
61
+ if (!contentType.includes("application/json") && !contentType.includes("application/problem+json")) {
62
+ throw new CustomError(response.status, bodyText);
63
+ }
64
+ let body;
65
+ try {
66
+ body = JSON.parse(bodyText);
67
+ } catch (error) {
68
+ throw new CustomError(response.status, `Error in error: unable to parse json response from text
69
+ ${bodyText}`, {
70
+ cause: error
71
+ });
72
+ }
73
+ if (isProblemDetail(body)) {
74
+ throw new ProblemDetailError(
75
+ body.status,
76
+ body.detail,
77
+ body.server,
78
+ body.timestamp,
79
+ body.traceId,
80
+ body.businessErrorCode,
81
+ body.businessErrorValues
82
+ );
83
+ }
84
+ throw new CustomError(response.status, bodyText);
60
85
  };
61
86
  const handleTimeoutError = (error) => {
62
87
  if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
@@ -65,7 +90,7 @@ const handleTimeoutError = (error) => {
65
90
  throw error;
66
91
  };
67
92
  const safeFetch = (url, initCopy) => {
68
- return fetch(url, initCopy).then((response) => response.ok ? response : handleError(response)).catch(handleTimeoutError);
93
+ return fetch(url, initCopy).then((response) => response.ok ? response : handleNotOkResponse(response)).catch(handleTimeoutError);
69
94
  };
70
95
  const backendFetch = (url, init, token) => {
71
96
  const initCopy = prepareRequest(init, token);
@@ -91,6 +116,7 @@ export {
91
116
  backendFetchFile,
92
117
  backendFetchJson,
93
118
  backendFetchText,
94
- convertToCustomError,
95
- getRequestParamFromList
119
+ getRequestParamFromList,
120
+ handleNotOkResponse,
121
+ parseError
96
122
  };
@@ -1,7 +1,5 @@
1
- import { ProblemDetailError } from "./types/ProblemDetailError.js";
1
+ import { ProblemDetailError, formatMessageValues } from "./types/ProblemDetailError.js";
2
2
  import { NetworkTimeoutError } from "./types/NetworkTimeoutError.js";
3
- import { formatMessageValues } from "./types/CustomError.js";
4
- import "./types/equipmentType.js";
5
3
  function catchErrorHandler(error, callback) {
6
4
  if (error instanceof Object && "message" in error && typeof error.message === "string") {
7
5
  callback(error.message);
@@ -30,8 +28,7 @@ function snackWithFallback(snackError, error, headerInputs) {
30
28
  messageValues: {
31
29
  message: error.message,
32
30
  serverName: error.serverName,
33
- timestamp: error.timestamp.toLocaleString(),
34
- // It would require refactoring to adapt with GS language so we keep it like that for now
31
+ timestamp: error.timestamp,
35
32
  traceId: error.traceId
36
33
  },
37
34
  ...headerInputs
@@ -14,8 +14,8 @@ import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentT
14
14
  import { copyToClipboard } from "./navigator-clipboard.js";
15
15
  import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./constants/notificationsProvider.js";
16
16
  import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./styles.js";
17
- import { CustomError, formatMessageValues } from "./types/CustomError.js";
18
- import { ProblemDetailError } from "./types/ProblemDetailError.js";
17
+ import { CustomError } from "./types/CustomError.js";
18
+ import { ProblemDetailError, formatMessageValues } from "./types/ProblemDetailError.js";
19
19
  import { NetworkTimeoutError } from "./types/NetworkTimeoutError.js";
20
20
  import { ElementType } from "./types/elementType.js";
21
21
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./types/equipmentType.js";
@@ -1,13 +1,10 @@
1
1
  /**
2
- * Copyright (c) 2025, RTE (http://www.rte-france.com)
2
+ * Copyright (c) 2026, RTE (http://www.rte-france.com)
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public
4
4
  * License, v. 2.0. If a copy of the MPL was not distributed with this
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export declare class CustomError extends Error {
8
8
  status: number;
9
- businessErrorCode?: string;
10
- businessErrorValues?: Record<string, unknown>;
11
- constructor(message: string, status: number, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
9
+ constructor(status: number, message: string, options?: ErrorOptions);
12
10
  }
13
- export declare function formatMessageValues(properties: Record<string, unknown>): Record<string, string>;
@@ -1,20 +1,9 @@
1
1
  class CustomError extends Error {
2
- constructor(message, status, businessErrorCode, businessErrorValues) {
3
- super(message);
2
+ constructor(status, message, options) {
3
+ super(message, options);
4
4
  this.status = status;
5
- this.businessErrorCode = businessErrorCode;
6
- this.businessErrorValues = businessErrorValues;
7
5
  }
8
6
  }
9
- function formatMessageValues(properties) {
10
- return Object.fromEntries(
11
- Object.entries(properties).map(([key, value]) => [
12
- key,
13
- typeof value === "object" && value !== null ? JSON.stringify(value) : String(value)
14
- ])
15
- );
16
- }
17
7
  export {
18
- CustomError,
19
- formatMessageValues
8
+ CustomError
20
9
  };
@@ -1,7 +1,10 @@
1
1
  import { CustomError } from './CustomError';
2
2
  export declare class ProblemDetailError extends CustomError {
3
3
  serverName: string;
4
- timestamp: Date;
4
+ timestamp: string;
5
5
  traceId: string;
6
- constructor(message: string, serverName: string, timestamp: Date, traceId: string, status: number, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
6
+ businessErrorCode?: string;
7
+ businessErrorValues?: Record<string, unknown>;
8
+ constructor(status: number, message: string, serverName: string, timestamp: string, traceId: string, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
7
9
  }
10
+ export declare function formatMessageValues(properties: Record<string, unknown>): Record<string, string>;
@@ -1,12 +1,23 @@
1
1
  import { CustomError } from "./CustomError.js";
2
2
  class ProblemDetailError extends CustomError {
3
- constructor(message, serverName, timestamp, traceId, status, businessErrorCode, businessErrorValues) {
4
- super(message, status, businessErrorCode, businessErrorValues);
3
+ constructor(status, message, serverName, timestamp, traceId, businessErrorCode, businessErrorValues) {
4
+ super(status, message);
5
5
  this.serverName = serverName;
6
6
  this.timestamp = timestamp;
7
7
  this.traceId = traceId;
8
+ this.businessErrorCode = businessErrorCode;
9
+ this.businessErrorValues = businessErrorValues;
8
10
  }
9
11
  }
12
+ function formatMessageValues(properties) {
13
+ return Object.fromEntries(
14
+ Object.entries(properties).map(([key, value]) => [
15
+ key,
16
+ typeof value === "object" && value !== null ? JSON.stringify(value) : String(value)
17
+ ])
18
+ );
19
+ }
10
20
  export {
11
- ProblemDetailError
21
+ ProblemDetailError,
22
+ formatMessageValues
12
23
  };
@@ -1,5 +1,5 @@
1
- import { CustomError, formatMessageValues } from "./CustomError.js";
2
- import { ProblemDetailError } from "./ProblemDetailError.js";
1
+ import { CustomError } from "./CustomError.js";
2
+ import { ProblemDetailError, formatMessageValues } from "./ProblemDetailError.js";
3
3
  import { NetworkTimeoutError } from "./NetworkTimeoutError.js";
4
4
  import { ElementType } from "./elementType.js";
5
5
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./equipmentType.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.157.0",
3
+ "version": "0.159.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",