@gridsuite/commons-ui 0.156.0 → 0.158.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 (97) 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/DirectoryItemSelector.d.ts +1 -1
  10. package/dist/components/directoryItemSelector/DirectoryItemSelector.js +15 -6
  11. package/dist/components/directoryItemSelector/utils.js +2 -2
  12. package/dist/components/dnd-table/dnd-table-add-rows-dialog.js +1 -1
  13. package/dist/components/filter/FilterForm.js +4 -1
  14. package/dist/components/filter/HeaderFilterForm.js +1 -1
  15. package/dist/components/filter/expert/ExpertFilterForm.js +4 -4
  16. package/dist/components/filter/expert/expertFilterConstants.js +1 -1
  17. package/dist/components/filter/utils/filterFormUtils.js +1 -1
  18. package/dist/components/index.js +2 -2
  19. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +1 -1
  20. package/dist/components/inputs/reactHookForm/OverflowableChipWithHelperText.js +1 -1
  21. package/dist/components/inputs/reactHookForm/agGridTable/CustomAgGridTable.js +1 -1
  22. package/dist/components/inputs/reactHookForm/agGridTable/csvUploader/CsvUploader.js +1 -1
  23. package/dist/components/inputs/reactHookForm/chip-items-input.js +1 -1
  24. package/dist/components/inputs/reactQueryBuilder/CountryValueEditor.js +1 -1
  25. package/dist/components/inputs/reactQueryBuilder/ElementValueEditor.js +1 -1
  26. package/dist/components/inputs/reactQueryBuilder/OperatorSelector.js +1 -1
  27. package/dist/components/overflowableText/OverflowableText.js +1 -1
  28. package/dist/components/parameters/common/ProviderParam.js +1 -1
  29. package/dist/components/parameters/common/computing-type.d.ts +1 -0
  30. package/dist/components/parameters/common/computing-type.js +3 -0
  31. package/dist/components/parameters/common/limitreductions/limit-reduction-table-cell.js +1 -1
  32. package/dist/components/parameters/common/limitreductions/limit-reductions-table-form.js +1 -1
  33. package/dist/components/parameters/common/name-element-editor/name-element-editor-form.js +1 -1
  34. package/dist/components/parameters/common/name-element-editor/name-element-editor-utils.js +1 -1
  35. package/dist/components/parameters/common/utils.js +2 -2
  36. package/dist/components/parameters/common/voltage-level-table/custom-voltage-level-table-cell.js +1 -1
  37. package/dist/components/parameters/common/widget/parameter-float.js +1 -1
  38. package/dist/components/parameters/common/widget/parameter-line-directory-items-input.js +1 -1
  39. package/dist/components/parameters/common/widget/parameter-line-slider.js +1 -1
  40. package/dist/components/parameters/index.js +2 -2
  41. package/dist/components/parameters/loadflow/constants.d.ts +1 -1
  42. package/dist/components/parameters/loadflow/constants.js +2 -2
  43. package/dist/components/parameters/loadflow/index.js +2 -2
  44. package/dist/components/parameters/loadflow/load-flow-general-parameters.js +5 -5
  45. package/dist/components/parameters/loadflow/load-flow-parameter-field.js +1 -1
  46. package/dist/components/parameters/loadflow/load-flow-parameters-content.js +1 -1
  47. package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +4 -4
  48. package/dist/components/parameters/loadflow/load-flow-parameters-form.js +1 -1
  49. package/dist/components/parameters/loadflow/load-flow-parameters-header.js +1 -1
  50. package/dist/components/parameters/loadflow/load-flow-parameters-utils.d.ts +4 -4
  51. package/dist/components/parameters/loadflow/load-flow-parameters-utils.js +3 -3
  52. package/dist/components/parameters/network-visualizations/network-area-diagram-parameters.js +1 -1
  53. package/dist/components/parameters/network-visualizations/network-visualizations-form.js +1 -1
  54. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-dialog.js +4 -4
  55. package/dist/components/parameters/network-visualizations/single-line-diagram-parameters.js +1 -1
  56. package/dist/components/parameters/pcc-min/pcc-min-form-utils.js +1 -1
  57. package/dist/components/parameters/pcc-min/pcc-min-parameters-dialog.js +4 -4
  58. package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +1 -1
  59. package/dist/components/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -1
  60. package/dist/components/parameters/security-analysis/security-analysis-parameters-form.js +2 -2
  61. package/dist/components/parameters/security-analysis/security-analysis-parameters-selector.js +1 -1
  62. package/dist/components/parameters/security-analysis/security-analysis-violations-hiding.js +1 -1
  63. package/dist/components/parameters/sensi/columns-definitions.js +2 -2
  64. package/dist/components/parameters/sensi/sensitivity-Flow-parameters.js +1 -1
  65. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -1
  66. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +1 -1
  67. package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +1 -1
  68. package/dist/components/parameters/sensi/table-cell.js +1 -1
  69. package/dist/components/parameters/sensi/utils.js +2 -2
  70. package/dist/components/parameters/short-circuit/short-circuit-icc-material-table-cell.js +1 -1
  71. package/dist/components/parameters/short-circuit/short-circuit-parameters-dialog.js +4 -4
  72. package/dist/components/parameters/short-circuit/short-circuit-parameters-form.js +1 -1
  73. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +32 -0
  74. package/dist/components/parameters/short-circuit/short-circuit-parameters-utils.js +1 -1
  75. package/dist/components/parameters/voltage-init/equipment-selection-parameters.js +1 -1
  76. package/dist/components/parameters/voltage-init/general-parameters.js +1 -1
  77. package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +1 -1
  78. package/dist/components/parameters/voltage-init/voltage-init-parameters-dialog.js +4 -4
  79. package/dist/components/parameters/voltage-init/voltage-init-parameters-form.js +1 -1
  80. package/dist/hooks/use-unique-name-validation.js +1 -1
  81. package/dist/hooks/useConfidentialityWarning.js +1 -1
  82. package/dist/hooks/useModificationLabelComputer.js +1 -1
  83. package/dist/index.js +8 -7
  84. package/dist/services/config.js +1 -1
  85. package/dist/services/index.js +2 -2
  86. package/dist/services/utils.d.ts +7 -2
  87. package/dist/services/utils.js +42 -37
  88. package/dist/utils/error.js +2 -5
  89. package/dist/utils/functions.d.ts +4 -0
  90. package/dist/utils/functions.js +4 -0
  91. package/dist/utils/index.js +4 -3
  92. package/dist/utils/types/CustomError.d.ts +2 -5
  93. package/dist/utils/types/CustomError.js +3 -14
  94. package/dist/utils/types/ProblemDetailError.d.ts +5 -2
  95. package/dist/utils/types/ProblemDetailError.js +14 -3
  96. package/dist/utils/types/index.js +2 -2
  97. package/package.json +1 -1
@@ -3,21 +3,21 @@ import { CustomMuiDialog } from "../../dialogs/customMuiDialog/CustomMuiDialog.j
3
3
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
4
4
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
5
5
  import "../../../utils/conversionUtils.js";
6
+ import "@mui/icons-material";
6
7
  import { ElementType } from "../../../utils/types/elementType.js";
7
8
  import "../../../utils/types/equipmentType.js";
8
- import "@mui/icons-material";
9
9
  import "../../../utils/yupConfig.js";
10
10
  import "react";
11
11
  import "@mui/material";
12
12
  import "react-intl";
13
13
  import "react-hook-form";
14
14
  import "../../treeViewFinder/TreeViewFinder.js";
15
- import "notistack";
16
- import { NameElementEditorForm } from "../common/name-element-editor/name-element-editor-form.js";
17
- import "../../overflowableText/OverflowableText.js";
18
15
  import "localized-countries";
19
16
  import "localized-countries/data/fr";
20
17
  import "localized-countries/data/en";
18
+ import "notistack";
19
+ import { NameElementEditorForm } from "../common/name-element-editor/name-element-editor-form.js";
20
+ import "../../overflowableText/OverflowableText.js";
21
21
  import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
22
22
  import "yup";
23
23
  import "../../inputs/reactHookForm/agGridTable/BottomRightButtons.js";
@@ -4,8 +4,8 @@ import { FormattedMessage } from "react-intl";
4
4
  import { getTabIndicatorStyle, getTabStyle } from "../parameters-style.js";
5
5
  import "../../overflowableText/OverflowableText.js";
6
6
  import "../../../utils/conversionUtils.js";
7
- import "../../../utils/types/equipmentType.js";
8
7
  import "@mui/icons-material";
8
+ import "../../../utils/types/equipmentType.js";
9
9
  import "../../../utils/yupConfig.js";
10
10
  import "react";
11
11
  import "react-hook-form";
@@ -2,9 +2,9 @@ import { useCallback, useEffect } from "react";
2
2
  import { useFormContext, useController } from "react-hook-form";
3
3
  import { FieldConstants } from "../utils/constants/fieldConstants.js";
4
4
  import "../utils/conversionUtils.js";
5
- import "../utils/types/equipmentType.js";
6
5
  import "react/jsx-runtime";
7
6
  import "@mui/icons-material";
7
+ import "../utils/types/equipmentType.js";
8
8
  import "../utils/yupConfig.js";
9
9
  import { useDebounce } from "./useDebounce.js";
10
10
  import { elementAlreadyExists } from "../services/directory.js";
@@ -1,9 +1,9 @@
1
1
  import { useState, useEffect } from "react";
2
2
  import { fetchEnv } from "../services/appsMetadata.js";
3
3
  import "../utils/conversionUtils.js";
4
- import "../utils/types/equipmentType.js";
5
4
  import "react/jsx-runtime";
6
5
  import "@mui/icons-material";
6
+ import "../utils/types/equipmentType.js";
7
7
  import "../utils/yupConfig.js";
8
8
  const useConfidentialityWarning = () => {
9
9
  const [confidentialityWarningKey, setConfidentialityWarningKey] = useState();
@@ -2,9 +2,9 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useIntl } from "react-intl";
3
3
  import { useCallback } from "react";
4
4
  import "../utils/conversionUtils.js";
5
+ import "@mui/icons-material";
5
6
  import { EquipmentType } from "../utils/types/equipmentType.js";
6
7
  import { MODIFICATION_TYPES } from "../utils/types/modificationType.js";
7
- import "@mui/icons-material";
8
8
  import "../utils/yupConfig.js";
9
9
  const getOperatingStatusModificationValues = (modification, formatBold) => {
10
10
  return {
package/dist/index.js CHANGED
@@ -156,7 +156,7 @@ import { CENTER_LABEL, COMPONENT_LIBRARY, DIAGONAL_LABEL, INTL_LINE_FLOW_MODE_OP
156
156
  import { MAP_BASEMAP_CARTO, MAP_BASEMAP_CARTO_NOLABEL, MAP_BASEMAP_ETALAB, MAP_BASEMAP_MAPBOX, NadPositionsGenerationMode, SubstationLayout } from "./components/parameters/network-visualizations/network-visualizations.types.js";
157
157
  import { NetworkVisualizationParametersInline } from "./components/parameters/network-visualizations/network-visualizations-parameters-inline.js";
158
158
  import { NetworkVisualizationsParametersEditionDialog } from "./components/parameters/network-visualizations/network-visualizations-parameters-dialog.js";
159
- import { BALANCE_TYPE, CONNECTED_COMPONENT_MODE, COUNTRIES_TO_BALANCE, DC, DC_POWER_FACTOR, DC_USE_TRANSFORMER_RATIO, DEFAULT_LIMIT_REDUCTION_VALUE, DISTRIBUTED_SLACK, HVDC_AC_EMULATION, MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION, MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION, PARAM_LIMIT_REDUCTION, PARAM_PROVIDER_OPENLOADFLOW, PHASE_SHIFTER_REGULATION_ON, READ_SLACK_BUS, SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, TWT_SPLIT_SHUNT_ADMITTANCE, USE_REACTIVE_LIMITS, VOLTAGE_INIT_MODE, WRITE_SLACK_BUS, alertThresholdMarks } from "./components/parameters/loadflow/constants.js";
159
+ import { BALANCE_TYPE, CONNECTED_MODE, COUNTRIES_TO_BALANCE, DC, DC_POWER_FACTOR, DC_USE_TRANSFORMER_RATIO, DEFAULT_LIMIT_REDUCTION_VALUE, DISTRIBUTED_SLACK, HVDC_AC_EMULATION, MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION, MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION, PARAM_LIMIT_REDUCTION, PARAM_PROVIDER_OPENLOADFLOW, PHASE_SHIFTER_REGULATION_ON, READ_SLACK_BUS, SHUNT_COMPENSATOR_VOLTAGE_CONTROL_ON, TWT_SPLIT_SHUNT_ADMITTANCE, USE_REACTIVE_LIMITS, VOLTAGE_INIT_MODE, WRITE_SLACK_BUS, alertThresholdMarks } from "./components/parameters/loadflow/constants.js";
160
160
  import { LoadFlowParametersInline } from "./components/parameters/loadflow/load-flow-parameters-inline.js";
161
161
  import { LoadFlowParametersEditionDialog } from "./components/parameters/loadflow/load-flow-parameters-dialog.js";
162
162
  import { InitialVoltage, PredefinedParameters, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_PREDEFINED_PARAMS, SHORT_CIRCUIT_VOLTAGE_RANGES, SHORT_CIRCUIT_WITH_FEEDER_RESULT, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, intlInitialVoltageProfileMode, intlPredefinedParametersOptions, onlyStartedGeneratorsOptions } from "./components/parameters/short-circuit/constants.js";
@@ -204,7 +204,7 @@ import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters,
204
204
  import { exportFilter, getAvailableComponentLibraries, getStudyNetworkVisualizationsParameters, getStudyShortCircuitParameters, setStudyNetworkVisualizationParameters, updateVoltageInitParameters } from "./services/study.js";
205
205
  import { getNetworkVisualizationsParameters } from "./services/study-config.js";
206
206
  import { fetchCurrentAnnouncement, fetchUserDetails } from "./services/userAdmin.js";
207
- import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, convertToCustomError, getRequestParamFromList } from "./services/utils.js";
207
+ import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse } from "./services/utils.js";
208
208
  import { getVoltageInitParameters, getVoltageInitUrl } from "./services/voltage-init.js";
209
209
  import { fetchShortCircuitParameters, getShortCircuitSpecificParametersDescription, updateShortCircuitParameters } from "./services/short-circuit-analysis.js";
210
210
  import { equalsArray } from "./utils/algos.js";
@@ -216,15 +216,15 @@ import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, P
216
216
  import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./utils/constants/filterConstant.js";
217
217
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./utils/conversionUtils.js";
218
218
  import { catchErrorHandler, snackWithFallback } from "./utils/error.js";
219
- import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./utils/functions.js";
219
+ import { areArrayElementsUnique, arraysContainIdenticalStrings, isObjectEmpty, keyGenerator } from "./utils/functions.js";
220
220
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./utils/langs.js";
221
221
  import { getFileIcon } from "./utils/mapper/getFileIcon.js";
222
222
  import { equipmentTypesForPredefinedPropertiesMapper } from "./utils/mapper/equipmentTypesForPredefinedPropertiesMapper.js";
223
223
  import { copyToClipboard } from "./utils/navigator-clipboard.js";
224
224
  import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./utils/constants/notificationsProvider.js";
225
225
  import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./utils/styles.js";
226
- import { CustomError, formatMessageValues } from "./utils/types/CustomError.js";
227
- import { ProblemDetailError } from "./utils/types/ProblemDetailError.js";
226
+ import { CustomError } from "./utils/types/CustomError.js";
227
+ import { ProblemDetailError, formatMessageValues } from "./utils/types/ProblemDetailError.js";
228
228
  import { NetworkTimeoutError } from "./utils/types/NetworkTimeoutError.js";
229
229
  import { ElementType } from "./utils/types/elementType.js";
230
230
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./utils/types/equipmentType.js";
@@ -332,7 +332,7 @@ export {
332
332
  COMMON_CONFIG_PARAMS_NAMES,
333
333
  COMMON_PARAMETERS,
334
334
  COMPONENT_LIBRARY,
335
- CONNECTED_COMPONENT_MODE,
335
+ CONNECTED_MODE,
336
336
  CONTINGENCY_LIST_EQUIPMENTS,
337
337
  CONVERTERS_MODE_OPTIONS,
338
338
  COUNTRIES_TO_BALANCE,
@@ -697,6 +697,7 @@ export {
697
697
  WRITE_SLACK_BUS,
698
698
  alertThresholdMarks,
699
699
  areArrayElementsUnique,
700
+ arraysContainIdenticalStrings,
700
701
  backendFetch,
701
702
  backendFetchFile,
702
703
  backendFetchJson,
@@ -712,7 +713,6 @@ export {
712
713
  componentsFr,
713
714
  convertInputValue,
714
715
  convertOutputValue,
715
- convertToCustomError,
716
716
  copyToClipboard,
717
717
  countRules,
718
718
  createFilter,
@@ -814,6 +814,7 @@ export {
814
814
  getVoltageInitParameters,
815
815
  getVoltageInitUrl,
816
816
  gridItem,
817
+ handleNotOkResponse,
817
818
  handleSigninCallback,
818
819
  handleSilentRenewCallback,
819
820
  hasElementPermission,
@@ -1,9 +1,9 @@
1
1
  import { backendFetch, backendFetchJson } from "./utils.js";
2
2
  import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES } from "../utils/constants/configConstants.js";
3
3
  import "../utils/conversionUtils.js";
4
- import "../utils/types/equipmentType.js";
5
4
  import "react/jsx-runtime";
6
5
  import "@mui/icons-material";
6
+ import "../utils/types/equipmentType.js";
7
7
  import "../utils/yupConfig.js";
8
8
  const PREFIX_CONFIG_QUERIES = `${"api/gateway"}/config`;
9
9
  function getAppName(appName, name) {
@@ -8,7 +8,7 @@ import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters,
8
8
  import { exportFilter, getAvailableComponentLibraries, getStudyNetworkVisualizationsParameters, getStudyShortCircuitParameters, setStudyNetworkVisualizationParameters, updateVoltageInitParameters } from "./study.js";
9
9
  import { getNetworkVisualizationsParameters } from "./study-config.js";
10
10
  import { fetchCurrentAnnouncement, fetchUserDetails } from "./userAdmin.js";
11
- import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, convertToCustomError, getRequestParamFromList } from "./utils.js";
11
+ import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList, handleNotOkResponse } from "./utils.js";
12
12
  import { getVoltageInitParameters, getVoltageInitUrl } from "./voltage-init.js";
13
13
  import { fetchShortCircuitParameters, getShortCircuitSpecificParametersDescription, updateShortCircuitParameters } from "./short-circuit-analysis.js";
14
14
  export {
@@ -18,7 +18,6 @@ export {
18
18
  backendFetchFile,
19
19
  backendFetchJson,
20
20
  backendFetchText,
21
- convertToCustomError,
22
21
  createFilter,
23
22
  createParameter,
24
23
  elementAlreadyExists,
@@ -61,6 +60,7 @@ export {
61
60
  getStudyUrl,
62
61
  getVoltageInitParameters,
63
62
  getVoltageInitUrl,
63
+ handleNotOkResponse,
64
64
  hasElementPermission,
65
65
  isStudyMetadata,
66
66
  safeEncodeURIComponent,
@@ -1,10 +1,15 @@
1
- import { CustomError } from '../utils/types/CustomError';
1
+ /**
2
+ * Copyright (c) 2024, RTE (http://www.rte-france.com)
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ */
2
7
  /** Optional convenience: allow per-call timeout override without crafting a signal manually. */
3
8
  type FetchInitWithTimeout = RequestInit & {
4
9
  /** If provided and no signal is set, use this as the timeout override (ms). */
5
10
  timeoutMs?: number;
6
11
  };
7
- export declare const convertToCustomError: (textError: string) => CustomError;
12
+ export declare const handleNotOkResponse: (response: Response) => Promise<never>;
8
13
  export declare const backendFetch: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<Response>;
9
14
  export declare const backendFetchJson: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<any>;
10
15
  export declare function backendFetchText(url: string, init?: FetchInitWithTimeout, token?: string): Promise<string>;
@@ -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,47 @@ 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
- }
39
- return new ProblemDetailError(
40
- errorJson.detail,
41
- errorJson.server,
42
- date,
43
- errorJson.traceId,
44
- errorJson.status,
45
- errorJson.businessErrorCode,
46
- errorJson.businessErrorValues
47
- );
24
+ const isProblemDetail = (error) => {
25
+ if (typeof error !== "object" || error === null) {
26
+ return false;
48
27
  }
49
- return new CustomError(
50
- errorJson.detail,
51
- errorJson.status,
52
- errorJson.businessErrorCode,
53
- errorJson.businessErrorValues
54
- );
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";
55
30
  };
56
- const handleError = (response) => {
57
- return response.text().then((text) => {
58
- throw convertToCustomError(text);
59
- });
31
+ const handleNotOkResponse = async (response) => {
32
+ let bodyText;
33
+ try {
34
+ bodyText = await response.text();
35
+ } catch (error) {
36
+ throw new CustomError(response.status, "Error in error: unable to read response body", {
37
+ cause: error
38
+ });
39
+ }
40
+ const contentType = response.headers.get("content-type") ?? "";
41
+ if (!contentType.includes("application/json")) {
42
+ throw new CustomError(response.status, bodyText);
43
+ }
44
+ let body;
45
+ try {
46
+ body = JSON.parse(bodyText);
47
+ } catch (error) {
48
+ throw new CustomError(response.status, `Error in error: unable to parse json response from text
49
+ ${bodyText}`, {
50
+ cause: error
51
+ });
52
+ }
53
+ if (isProblemDetail(body)) {
54
+ throw new ProblemDetailError(
55
+ body.status,
56
+ body.detail,
57
+ body.server,
58
+ body.timestamp,
59
+ body.traceId,
60
+ body.businessErrorCode,
61
+ body.businessErrorValues
62
+ );
63
+ }
64
+ throw new CustomError(response.status, bodyText);
60
65
  };
61
66
  const handleTimeoutError = (error) => {
62
67
  if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
@@ -65,7 +70,7 @@ const handleTimeoutError = (error) => {
65
70
  throw error;
66
71
  };
67
72
  const safeFetch = (url, initCopy) => {
68
- return fetch(url, initCopy).then((response) => response.ok ? response : handleError(response)).catch(handleTimeoutError);
73
+ return fetch(url, initCopy).then((response) => response.ok ? response : handleNotOkResponse(response)).catch(handleTimeoutError);
69
74
  };
70
75
  const backendFetch = (url, init, token) => {
71
76
  const initCopy = prepareRequest(init, token);
@@ -91,6 +96,6 @@ export {
91
96
  backendFetchFile,
92
97
  backendFetchJson,
93
98
  backendFetchText,
94
- convertToCustomError,
95
- getRequestParamFromList
99
+ getRequestParamFromList,
100
+ handleNotOkResponse
96
101
  };
@@ -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
@@ -9,5 +9,9 @@
9
9
  * @returns {number} key
10
10
  */
11
11
  export declare function keyGenerator(): () => number;
12
+ /**
13
+ * returns true if the two arrays contain exactly the same strings, regardless of the order
14
+ */
15
+ export declare function arraysContainIdenticalStrings(array1: string[] | undefined, array2: string[] | undefined): boolean;
12
16
  export declare const areArrayElementsUnique: (array: unknown[]) => boolean;
13
17
  export declare const isObjectEmpty: (object: object) => boolean;
@@ -5,6 +5,9 @@ function keyGenerator() {
5
5
  return key;
6
6
  };
7
7
  }
8
+ function arraysContainIdenticalStrings(array1, array2) {
9
+ return array1 !== void 0 && array2 !== void 0 && JSON.stringify([...array1].sort((a, b) => a.localeCompare(b))) === JSON.stringify([...array2].sort((a, b) => a.localeCompare(b)));
10
+ }
8
11
  const areArrayElementsUnique = (array) => {
9
12
  const uniqueValues = [...new Set(array)];
10
13
  return uniqueValues.length === array.length;
@@ -12,6 +15,7 @@ const areArrayElementsUnique = (array) => {
12
15
  const isObjectEmpty = (object) => object && Object.keys(object).length === 0;
13
16
  export {
14
17
  areArrayElementsUnique,
18
+ arraysContainIdenticalStrings,
15
19
  isObjectEmpty,
16
20
  keyGenerator
17
21
  };
@@ -7,15 +7,15 @@ import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, P
7
7
  import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./constants/filterConstant.js";
8
8
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
9
9
  import { catchErrorHandler, snackWithFallback } from "./error.js";
10
- import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions.js";
10
+ import { areArrayElementsUnique, arraysContainIdenticalStrings, isObjectEmpty, keyGenerator } from "./functions.js";
11
11
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
12
12
  import { getFileIcon } from "./mapper/getFileIcon.js";
13
13
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
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";
@@ -104,6 +104,7 @@ export {
104
104
  VSC,
105
105
  VoltageLevel,
106
106
  areArrayElementsUnique,
107
+ arraysContainIdenticalStrings,
107
108
  catchErrorHandler,
108
109
  convertInputValue,
109
110
  convertOutputValue,
@@ -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.156.0",
3
+ "version": "0.158.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",