@gridsuite/commons-ui 0.137.0 → 0.139.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 (88) hide show
  1. package/README.md +1 -1
  2. package/dist/components/cardErrorBoundary/CardErrorBoundary.d.ts +1 -1
  3. package/dist/components/dialogs/descriptionModificationDialog/DescriptionModificationDialog.js +2 -6
  4. package/dist/components/directoryItemSelector/DirectoryItemSelector.js +2 -4
  5. package/dist/components/elementSearch/hooks/useElementSearch.js +2 -4
  6. package/dist/components/filter/FilterCreationDialog.js +3 -16
  7. package/dist/components/filter/expert/ExpertFilterEditionDialog.js +4 -23
  8. package/dist/components/filter/expert/expertFilterUtils.d.ts +0 -1
  9. package/dist/components/filter/expert/expertFilterUtils.js +0 -11
  10. package/dist/components/filter/expert/index.js +1 -2
  11. package/dist/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js +3 -7
  12. package/dist/components/filter/explicitNaming/ExplicitNamingFilterForm.js +2 -4
  13. package/dist/components/filter/index.js +1 -2
  14. package/dist/components/filter/utils/filterApi.js +1 -1
  15. package/dist/components/index.js +4 -7
  16. package/dist/components/inputs/reactHookForm/DirectoryItemsInput.js +7 -4
  17. package/dist/components/inputs/reactHookForm/OverflowableChipWithHelperText.js +1 -1
  18. package/dist/components/parameters/common/parameters-creation-dialog.js +4 -9
  19. package/dist/components/parameters/common/widget/parameter-line-directory-items-input.d.ts +2 -1
  20. package/dist/components/parameters/common/widget/parameter-line-directory-items-input.js +4 -2
  21. package/dist/components/parameters/index.d.ts +1 -0
  22. package/dist/components/parameters/index.js +3 -5
  23. package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +3 -6
  24. package/dist/components/parameters/loadflow/use-load-flow-parameters-form.js +3 -5
  25. package/dist/components/parameters/network-visualizations/network-visualizations-parameters-inline.js +2 -5
  26. package/dist/components/parameters/network-visualizations/use-network-visualizations-parameters-form.js +4 -12
  27. package/dist/components/parameters/pcc-min/index.d.ts +7 -0
  28. package/dist/components/parameters/pcc-min/index.js +4 -0
  29. package/dist/components/parameters/pcc-min/pcc-min-form-utils.d.ts +4 -0
  30. package/dist/components/parameters/pcc-min/pcc-min-form-utils.js +54 -0
  31. package/dist/components/parameters/pcc-min/pcc-min-parameters-form.d.ts +29 -0
  32. package/dist/components/parameters/pcc-min/pcc-min-parameters-form.js +114 -0
  33. package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.d.ts +7 -0
  34. package/dist/components/parameters/pcc-min/pcc-min-parameters-inline.js +98 -0
  35. package/dist/components/parameters/pcc-min/use-pcc-min-parameters-form.d.ts +19 -0
  36. package/dist/components/parameters/pcc-min/use-pcc-min-parameters-form.js +104 -0
  37. package/dist/components/parameters/security-analysis/security-analysis-parameters-inline.js +2 -5
  38. package/dist/components/parameters/security-analysis/use-security-analysis-parameters-form.js +3 -5
  39. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +3 -9
  40. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +4 -12
  41. package/dist/components/parameters/sensi/utils.d.ts +1 -1
  42. package/dist/components/parameters/sensi/utils.js +1 -3
  43. package/dist/components/parameters/short-circuit/short-circuit-parameters-inline.js +2 -5
  44. package/dist/components/parameters/short-circuit/use-short-circuit-parameters-form.js +5 -16
  45. package/dist/components/parameters/voltage-init/constants.d.ts +0 -4
  46. package/dist/components/parameters/voltage-init/constants.js +0 -8
  47. package/dist/components/parameters/voltage-init/index.js +1 -5
  48. package/dist/components/parameters/voltage-init/use-voltage-init-parameters-form.js +6 -13
  49. package/dist/components/parameters/voltage-init/voltage-init-form-utils.js +2 -1
  50. package/dist/components/parameters/voltage-init/voltage-init-parameters-inline.js +3 -8
  51. package/dist/components/parameters/voltage-init/voltage-init.type.d.ts +2 -6
  52. package/dist/components/parameters/voltage-init/voltage-limits-parameters.js +2 -1
  53. package/dist/hooks/use-parameters-backend.js +10 -20
  54. package/dist/hooks/usePredefinedProperties.js +2 -3
  55. package/dist/hooks/useSnackMessage.d.ts +1 -2
  56. package/dist/index.js +16 -5
  57. package/dist/services/index.d.ts +1 -1
  58. package/dist/services/index.js +4 -4
  59. package/dist/services/pcc-min.d.ts +7 -0
  60. package/dist/services/pcc-min.js +25 -0
  61. package/dist/services/utils.d.ts +0 -1
  62. package/dist/services/utils.js +7 -10
  63. package/dist/translations/en/businessErrorsEn.d.ts +18 -0
  64. package/dist/translations/en/businessErrorsEn.js +19 -1
  65. package/dist/translations/en/equipmentShortEn.js +3 -3
  66. package/dist/translations/en/parameters.d.ts +3 -0
  67. package/dist/translations/en/parameters.js +4 -1
  68. package/dist/translations/fr/businessErrorsFr.d.ts +18 -0
  69. package/dist/translations/fr/businessErrorsFr.js +19 -1
  70. package/dist/translations/fr/equipmentShortFr.js +3 -3
  71. package/dist/translations/fr/parameters.d.ts +3 -0
  72. package/dist/translations/fr/parameters.js +4 -1
  73. package/dist/utils/constants/filterConstant.d.ts +9 -0
  74. package/dist/utils/constants/filterConstant.js +10 -0
  75. package/dist/utils/constants/index.d.ts +1 -0
  76. package/dist/utils/constants/index.js +5 -0
  77. package/dist/utils/error.d.ts +4 -0
  78. package/dist/utils/error.js +28 -0
  79. package/dist/utils/index.d.ts +2 -0
  80. package/dist/utils/index.js +14 -0
  81. package/dist/utils/labelUtils.d.ts +8 -0
  82. package/dist/utils/labelUtils.js +17 -0
  83. package/dist/{services/businessErrorCode.d.ts → utils/types/CustomError.d.ts} +3 -1
  84. package/dist/utils/types/CustomError.js +20 -0
  85. package/dist/utils/types/index.d.ts +1 -0
  86. package/dist/utils/types/index.js +3 -0
  87. package/package.json +1 -1
  88. package/dist/services/businessErrorCode.js +0 -10
@@ -1,5 +1,5 @@
1
1
  import { getUserToken } from "../redux/commonStore.js";
2
- import { CustomError } from "./businessErrorCode.js";
2
+ import { CustomError } from "../utils/types/CustomError.js";
3
3
  const DEFAULT_TIMEOUT_MS = 5e4;
4
4
  class NetworkTimeoutError extends Error {
5
5
  constructor(messageKey = "errors.network.timeout") {
@@ -38,7 +38,12 @@ const handleError = (response) => {
38
38
  const errorJson = parseError(text);
39
39
  let customError;
40
40
  if (errorJson?.businessErrorCode != null) {
41
- throw new CustomError(errorJson.message, errorJson.status, errorJson.businessErrorCode);
41
+ throw new CustomError(
42
+ errorJson.message,
43
+ errorJson.status,
44
+ errorJson.businessErrorCode,
45
+ errorJson.businessErrorValues
46
+ );
42
47
  }
43
48
  if (errorJson && errorJson.status && errorJson.error && errorJson.message) {
44
49
  customError = new CustomError(
@@ -82,19 +87,11 @@ const backendFetchFile = (url, init, token) => {
82
87
  const getRequestParamFromList = (paramName, params = []) => {
83
88
  return new URLSearchParams(params.map((param) => [paramName, param]));
84
89
  };
85
- const catchErrorHandler = (error, callback) => {
86
- if (error instanceof Object && "message" in error && typeof error.message === "string") {
87
- callback(error.message);
88
- } else {
89
- callback("unknown error");
90
- }
91
- };
92
90
  export {
93
91
  NetworkTimeoutError,
94
92
  backendFetch,
95
93
  backendFetchFile,
96
94
  backendFetchJson,
97
95
  backendFetchText,
98
- catchErrorHandler,
99
96
  getRequestParamFromList
100
97
  };
@@ -15,6 +15,24 @@ export declare const businessErrorsEn: {
15
15
  'explore.permissionDenied': string;
16
16
  'explore.maxElementsExceeded': string;
17
17
  'explore.incorrectCaseFile': string;
18
+ 'study.notFound': string;
19
+ 'study.computationRunning': string;
20
+ 'study.loadflowError': string;
21
+ 'study.notAllowed': string;
22
+ 'study.cantDeleteRootNode': string;
23
+ 'study.moveNetworkModificationForbidden': string;
24
+ 'study.badNodeType': string;
25
+ 'study.nodeNotBuilt': string;
26
+ 'study.nodeNameAlreadyExist': string;
27
+ 'study.timeSeriesBadType': string;
28
+ 'study.noVoltageInitResultsForNode': string;
29
+ 'study.maxNodeBuildsExceeded': string;
30
+ 'study.rootNetworkDeleteForbidden': string;
31
+ 'study.maximumRootNetworkByStudyReached': string;
32
+ 'study.maximumTagLengthExceeded': string;
33
+ 'study.networkExportFailed': string;
34
+ 'study.tooManyNadConfigs': string;
35
+ 'study.tooManyMapCards': string;
18
36
  'useradmin.permissionDenied': string;
19
37
  'useradmin.userNotFound': string;
20
38
  'useradmin.userAlreadyExists': string;
@@ -9,6 +9,24 @@ const businessErrorsEn = {
9
9
  "explore.permissionDenied": "You are not allowed to perform this action.",
10
10
  "explore.maxElementsExceeded": "The number of allowed elements has been exceeded.",
11
11
  "explore.incorrectCaseFile": "The provided case file is incorrect.",
12
+ "study.notFound": "Study was not found.",
13
+ "study.computationRunning": "The operation cannot be performed because a computation is running.",
14
+ "study.loadflowError": "Loadflow error.",
15
+ "study.notAllowed": "Operation not allowed.",
16
+ "study.cantDeleteRootNode": "A root node cannot be deleted.",
17
+ "study.moveNetworkModificationForbidden": "Impossible to move this network modification.",
18
+ "study.badNodeType": "Bad node type.",
19
+ "study.nodeNotBuilt": "Node not built.",
20
+ "study.nodeNameAlreadyExist": "Node name already exists.",
21
+ "study.timeSeriesBadType": "Bad timeseries type.",
22
+ "study.noVoltageInitResultsForNode": "No voltage initialization results found.",
23
+ "study.maxNodeBuildsExceeded": "Maximum number of built nodes exceeded.",
24
+ "study.rootNetworkDeleteForbidden": "Impossible to delete this root network.",
25
+ "study.maximumRootNetworkByStudyReached": "Maximum number of root network per study exceeded.",
26
+ "study.maximumTagLengthExceeded": "Tag length exceeded.",
27
+ "study.networkExportFailed": "Failed to export network.",
28
+ "study.tooManyNadConfigs": "Maximum number of NAD configuration exceeded.",
29
+ "study.tooManyMapCards": "Maximum number of cards exceeded.",
12
30
  "useradmin.permissionDenied": "You don't have permission to perform this action.",
13
31
  "useradmin.userNotFound": "User not found.",
14
32
  "useradmin.userAlreadyExists": "User already exists.",
@@ -18,7 +36,7 @@ const businessErrorsEn = {
18
36
  "useradmin.groupAlreadyExists": "User group already exists.",
19
37
  "useradmin.announcementInvalidPeriod": "The announcement has an invalid time period.",
20
38
  "useradmin.announcementOverlap": "The announcement period overlaps with an existing one.",
21
- "filter.filterCycleDetected": "Filter cycle detected."
39
+ "filter.filterCycleDetected": "Filter cycle detected: {filters}"
22
40
  };
23
41
  export {
24
42
  businessErrorsEn
@@ -11,11 +11,11 @@ const equipmentShortEn = {
11
11
  "equipment_short/svc": "Static var compensators",
12
12
  "equipment_short/hvdcLine": "HVDC",
13
13
  "equipment_short/hvdcStation": "HVDC stations",
14
- "equipment_short/vscConverterStation": "VSC",
15
- "equipment_short/lccConverterStation": "LCC",
14
+ "equipment_short/vscConverterStation": "VSC stations",
15
+ "equipment_short/lccConverterStation": "LCC stations",
16
16
  "equipment_short/busbarSection": "BBS",
17
17
  "equipment_short/bus": "Bus",
18
- "equipment_short/switch": "Switch",
18
+ "equipment_short/switch": "Switches",
19
19
  "equipment_short/danglingLine": "Dangling lines",
20
20
  "equipment_short/hvdcLineLcc": "HVDC LCC",
21
21
  "equipment_short/hvdcLineVsc": "HVDC VSC"
@@ -226,4 +226,7 @@ export declare const parametersEn: {
226
226
  updateSensitivityAnalysisProviderError: string;
227
227
  getSensitivityAnalysisFactorsCountError: string;
228
228
  resetLoadFlowParametersWarning: string;
229
+ PccMinParametersError: string;
230
+ updatePccMinParametersError: string;
231
+ pccMinParamFilter: string;
229
232
  };
@@ -224,7 +224,10 @@ const parametersEn = {
224
224
  updateSensitivityAnalysisProviderError: "An error occured when updating sensitivity analysis provider",
225
225
  getSensitivityAnalysisFactorsCountError: "An error occured while estimating sensitivity analysis computations",
226
226
  // Other
227
- resetLoadFlowParametersWarning: "Impossible to retrieve the load flow parameters defined in the user profile (default values are used)"
227
+ resetLoadFlowParametersWarning: "Impossible to retrieve the load flow parameters defined in the user profile (default values are used)",
228
+ PccMinParametersError: "An error occurred while updating the pcc min parameters",
229
+ updatePccMinParametersError: "An error occurred while updating the pcc min parameters",
230
+ pccMinParamFilter: "Definition of contingencies on voltage levels"
228
231
  };
229
232
  export {
230
233
  parametersEn
@@ -15,6 +15,24 @@ export declare const businessErrorsFr: {
15
15
  'explore.permissionDenied': string;
16
16
  'explore.maxElementsExceeded': string;
17
17
  'explore.incorrectCaseFile': string;
18
+ 'study.notFound': string;
19
+ 'study.computationRunning': string;
20
+ 'study.loadflowError': string;
21
+ 'study.notAllowed': string;
22
+ 'study.cantDeleteRootNode': string;
23
+ 'study.moveNetworkModificationForbidden': string;
24
+ 'study.badNodeType': string;
25
+ 'study.nodeNotBuilt': string;
26
+ 'study.nodeNameAlreadyExist': string;
27
+ 'study.timeSeriesBadType': string;
28
+ 'study.noVoltageInitResultsForNode': string;
29
+ 'study.maxNodeBuildsExceeded': string;
30
+ 'study.rootNetworkDeleteForbidden': string;
31
+ 'study.maximumRootNetworkByStudyReached': string;
32
+ 'study.maximumTagLengthExceeded': string;
33
+ 'study.networkExportFailed': string;
34
+ 'study.tooManyNadConfigs': string;
35
+ 'study.tooManyMapCards': string;
18
36
  'useradmin.permissionDenied': string;
19
37
  'useradmin.userNotFound': string;
20
38
  'useradmin.userAlreadyExists': string;
@@ -9,6 +9,24 @@ const businessErrorsFr = {
9
9
  "explore.permissionDenied": "Vous n'êtes pas autorisé à effectuer cette action.",
10
10
  "explore.maxElementsExceeded": "Le nombre d'éléments autorisés a été dépassé.",
11
11
  "explore.incorrectCaseFile": "Le fichier réseau fourni est incorrect.",
12
+ "study.notFound": "Étude non trouvée.",
13
+ "study.computationRunning": "L'opération ne peut être menée car un calcul est en cours.",
14
+ "study.loadflowError": "Erreur de calcul de répartition.",
15
+ "study.notAllowed": "Opération non permise.",
16
+ "study.cantDeleteRootNode": "Un noeud racine ne peut être supprimé.",
17
+ "study.moveNetworkModificationForbidden": "Impossible de déplacer cette modification de réseau.",
18
+ "study.badNodeType": "Mauvais type de noeud.",
19
+ "study.nodeNotBuilt": "Noeud non réalisé.",
20
+ "study.nodeNameAlreadyExist": "Ce nom de noeud existe déjà.",
21
+ "study.timeSeriesBadType": "Série temporelle de mauvais type.",
22
+ "study.noVoltageInitResultsForNode": "Pas de résultats pour l'initialisation du plan de tension.",
23
+ "study.maxNodeBuildsExceeded": "Nombre maximal de noeuds réalisés atteint.",
24
+ "study.rootNetworkDeleteForbidden": "Impossible de supprimer ce réseau racine.",
25
+ "study.maximumRootNetworkByStudyReached": "Nombre maximal de réseau racine par étude atteint.",
26
+ "study.maximumTagLengthExceeded": "Taille maximale d'étiquette atteinte.",
27
+ "study.networkExportFailed": "Échec de l'export de réseau.",
28
+ "study.tooManyNadConfigs": "Nombre maximal de configurations d'image nodale de zone atteint.",
29
+ "study.tooManyMapCards": "Nombre maximal de carte atteint.",
12
30
  "useradmin.permissionDenied": "Vous n'avez pas la permission d'effectuer cette action.",
13
31
  "useradmin.userNotFound": "Utilisateur introuvable.",
14
32
  "useradmin.userAlreadyExists": "L'utilisateur existe déjà.",
@@ -18,7 +36,7 @@ const businessErrorsFr = {
18
36
  "useradmin.groupAlreadyExists": "Le groupe d'utilisateurs existe déjà.",
19
37
  "useradmin.announcementInvalidPeriod": "La période de l'annonce est invalide.",
20
38
  "useradmin.announcementOverlap": "La période de l'annonce chevauche une autre annonce existante.",
21
- "filter.filterCycleDetected": "Cycle de filtre détecté."
39
+ "filter.filterCycleDetected": "Cycle de filtre détecté: {filters}"
22
40
  };
23
41
  export {
24
42
  businessErrorsFr
@@ -11,11 +11,11 @@ const equipmentShortFr = {
11
11
  "equipment_short/svc": "CSPR",
12
12
  "equipment_short/hvdcLine": "HVDC",
13
13
  "equipment_short/hvdcStation": "Stations HVDC",
14
- "equipment_short/vscConverterStation": "VSC",
15
- "equipment_short/lccConverterStation": "LCC",
14
+ "equipment_short/vscConverterStation": "Stations VSC",
15
+ "equipment_short/lccConverterStation": "Stations LCC",
16
16
  "equipment_short/busbarSection": "SJB",
17
17
  "equipment_short/bus": "Noeud",
18
- "equipment_short/switch": "Switch",
18
+ "equipment_short/switch": "OC",
19
19
  "equipment_short/danglingLine": "Frontières",
20
20
  "equipment_short/hvdcLineLcc": "HVDC LCC",
21
21
  "equipment_short/hvdcLineVsc": "HVDC VSC"
@@ -227,4 +227,7 @@ export declare const parametersFr: {
227
227
  updateSensitivityAnalysisProviderError: string;
228
228
  getSensitivityAnalysisFactorsCountError: string;
229
229
  resetLoadFlowParametersWarning: string;
230
+ PccMinParametersError: string;
231
+ updatePccMinParametersError: string;
232
+ pccMinParamFilter: string;
230
233
  };
@@ -225,7 +225,10 @@ const parametersFr = {
225
225
  updateSensitivityAnalysisProviderError: "Une erreur est survenue lors de la mise a jour du fournisseur courant d'analyse de sensibilité",
226
226
  getSensitivityAnalysisFactorsCountError: "Une erreur est survenue lors de l'estimation du nombre de calculs",
227
227
  // Other
228
- resetLoadFlowParametersWarning: "Impossible de récupérer les paramètres de calcul de répartition définis dans le profil utilisateur (les valeurs par défaut sont appliquées)"
228
+ resetLoadFlowParametersWarning: "Impossible de récupérer les paramètres de calcul de répartition définis dans le profil utilisateur (les valeurs par défaut sont appliquées)",
229
+ PccMinParametersError: "Erreur lors de la mise à jour des paramètres de pcc du min",
230
+ updatePccMinParametersError: "Une erreur est survenue lors de la mise a jour des paramètres de pcc min",
231
+ pccMinParamFilter: "Définition des postes en défaut"
229
232
  };
230
233
  export {
231
234
  parametersFr
@@ -0,0 +1,9 @@
1
+ import { UUID } from 'node:crypto';
2
+ export declare const FILTER_ID = "filterId";
3
+ export declare const FILTER_NAME = "filterName";
4
+ export declare const FILTERS = "filters";
5
+ export declare const ID = "id";
6
+ export type FilterIdentifier = {
7
+ [FILTER_ID]: UUID;
8
+ [FILTER_NAME]: string;
9
+ };
@@ -0,0 +1,10 @@
1
+ const FILTER_ID = "filterId";
2
+ const FILTER_NAME = "filterName";
3
+ const FILTERS = "filters";
4
+ const ID = "id";
5
+ export {
6
+ FILTERS,
7
+ FILTER_ID,
8
+ FILTER_NAME,
9
+ ID
10
+ };
@@ -9,3 +9,4 @@ export * from './fieldConstants';
9
9
  export * from './uiConstants';
10
10
  export * from './unitsConstants';
11
11
  export * from './configConstants';
12
+ export * from './filterConstant';
@@ -3,13 +3,18 @@ import { FieldConstants } from "./fieldConstants.js";
3
3
  import { MAX_CHAR_DESCRIPTION } from "./uiConstants.js";
4
4
  import { AMPERE, DEGREE, KILO_AMPERE, KILO_METER, KILO_VOLT, MEGA_VAR, MEGA_VOLT_AMPERE, MEGA_WATT, MICRO_SIEMENS, OHM, PERCENTAGE, SIEMENS } from "./unitsConstants.js";
5
5
  import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, PARAM_DEVELOPER_MODE, PARAM_LANGUAGE, PARAM_THEME } from "./configConstants.js";
6
+ import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./filterConstant.js";
6
7
  export {
7
8
  AMPERE,
8
9
  COMMON_APP_NAME,
9
10
  COMMON_CONFIG_PARAMS_NAMES,
10
11
  DEGREE,
12
+ FILTERS,
13
+ FILTER_ID,
14
+ FILTER_NAME,
11
15
  FetchStatus,
12
16
  FieldConstants,
17
+ ID,
13
18
  KILO_AMPERE,
14
19
  KILO_METER,
15
20
  KILO_VOLT,
@@ -0,0 +1,4 @@
1
+ import { SnackInputs, UseSnackMessageReturn } from '../hooks/useSnackMessage';
2
+ export type HeaderSnackInputs = Pick<SnackInputs, 'headerId' | 'headerTxt' | 'headerValues'>;
3
+ export declare function catchErrorHandler(error: unknown, callback: (message: string) => void): void;
4
+ export declare function snackWithFallback(snackError: UseSnackMessageReturn['snackError'], error: unknown, headerInputs?: HeaderSnackInputs): void;
@@ -0,0 +1,28 @@
1
+ import { CustomError, formatMessageValues } from "./types/CustomError.js";
2
+ function catchErrorHandler(error, callback) {
3
+ if (error instanceof Object && "message" in error && typeof error.message === "string") {
4
+ callback(error.message);
5
+ } else {
6
+ callback("unknown error");
7
+ }
8
+ }
9
+ function snackWithFallback(snackError, error, headerInputs) {
10
+ if (error instanceof CustomError && error.businessErrorCode) {
11
+ snackError({
12
+ messageId: error.businessErrorCode,
13
+ messageValues: error.businessErrorValues ? formatMessageValues(error.businessErrorValues) : void 0,
14
+ ...headerInputs
15
+ });
16
+ } else {
17
+ catchErrorHandler(error, (message) => {
18
+ snackError({
19
+ messageTxt: message,
20
+ ...headerInputs
21
+ });
22
+ });
23
+ }
24
+ }
25
+ export {
26
+ catchErrorHandler,
27
+ snackWithFallback
28
+ };
@@ -7,6 +7,7 @@
7
7
  export * from './algos';
8
8
  export * from './constants';
9
9
  export * from './conversionUtils';
10
+ export * from './error';
10
11
  export * from './functions';
11
12
  export * from './langs';
12
13
  export * from './mapper';
@@ -14,4 +15,5 @@ export * from './constants/notificationsProvider';
14
15
  export * from './styles';
15
16
  export * from './types';
16
17
  export * from './validation-functions';
18
+ export * from './labelUtils';
17
19
  export { default as yupConfig } from './yupConfig';
@@ -4,13 +4,16 @@ import { FieldConstants } from "./constants/fieldConstants.js";
4
4
  import { MAX_CHAR_DESCRIPTION } from "./constants/uiConstants.js";
5
5
  import { AMPERE, DEGREE, KILO_AMPERE, KILO_METER, KILO_VOLT, MEGA_VAR, MEGA_VOLT_AMPERE, MEGA_WATT, MICRO_SIEMENS, OHM, PERCENTAGE, SIEMENS } from "./constants/unitsConstants.js";
6
6
  import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, PARAM_DEVELOPER_MODE, PARAM_LANGUAGE, PARAM_THEME } from "./constants/configConstants.js";
7
+ import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./constants/filterConstant.js";
7
8
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
9
+ import { catchErrorHandler, snackWithFallback } from "./error.js";
8
10
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./functions.js";
9
11
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
10
12
  import { getFileIcon } from "./mapper/getFileIcon.js";
11
13
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
12
14
  import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS, PREFIX_DIRECTORY_NOTIFICATION_WS, PREFIX_STUDY_NOTIFICATION_WS } from "./constants/notificationsProvider.js";
13
15
  import { DARK_THEME, LIGHT_THEME, makeComposeClasses, mergeSx, toNestedGlobalSelectors } from "./styles.js";
16
+ import { CustomError, formatMessageValues } from "./types/CustomError.js";
14
17
  import { ElementType } from "./types/elementType.js";
15
18
  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";
16
19
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./types/equipmentTypes.js";
@@ -21,6 +24,7 @@ import { ParameterType } from "./types/parameters.type.js";
21
24
  import { SolverTypeInfos } from "./types/dynamic-simulation.type.js";
22
25
  import { DistributionType, SensitivityType } from "./types/sensitivity-analysis.type.js";
23
26
  import { toNumber, validateValueIsANumber } from "./validation-functions.js";
27
+ import { getEquipmentTypeShortLabel, getEquipmentTypeTagLabel } from "./labelUtils.js";
24
28
  import "./yupConfig.js";
25
29
  import * as yup from "yup";
26
30
  export {
@@ -33,6 +37,7 @@ export {
33
37
  BusBar,
34
38
  COMMON_APP_NAME,
35
39
  COMMON_CONFIG_PARAMS_NAMES,
40
+ CustomError,
36
41
  DARK_THEME,
37
42
  DEGREE,
38
43
  DanglingLine,
@@ -40,6 +45,9 @@ export {
40
45
  ElementType,
41
46
  EquipmentType,
42
47
  ExtendedEquipmentType,
48
+ FILTERS,
49
+ FILTER_ID,
50
+ FILTER_NAME,
43
51
  FetchStatus,
44
52
  FieldConstants,
45
53
  FieldType,
@@ -47,6 +55,7 @@ export {
47
55
  Generator,
48
56
  Hvdc,
49
57
  HvdcType,
58
+ ID,
50
59
  KILO_AMPERE,
51
60
  KILO_METER,
52
61
  KILO_VOLT,
@@ -90,11 +99,15 @@ export {
90
99
  VSC,
91
100
  VoltageLevel,
92
101
  areArrayElementsUnique,
102
+ catchErrorHandler,
93
103
  convertInputValue,
94
104
  convertOutputValue,
95
105
  equalsArray,
96
106
  equipmentStyles,
97
107
  equipmentTypesForPredefinedPropertiesMapper,
108
+ formatMessageValues,
109
+ getEquipmentTypeShortLabel,
110
+ getEquipmentTypeTagLabel,
98
111
  getEquipmentsInfosForSearchBar,
99
112
  getFileIcon,
100
113
  isBlankOrEmpty,
@@ -106,6 +119,7 @@ export {
106
119
  microUnitToUnit,
107
120
  roundToDefaultPrecision,
108
121
  roundToPrecision,
122
+ snackWithFallback,
109
123
  toNestedGlobalSelectors,
110
124
  toNumber,
111
125
  unitToKiloUnit,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025, 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
+ */
7
+ export declare function getEquipmentTypeShortLabel(equipmentType: string | undefined): string;
8
+ export declare function getEquipmentTypeTagLabel(equipmentType: string | undefined): string;
@@ -0,0 +1,17 @@
1
+ import { ALL_EQUIPMENTS } from "./types/equipmentType.js";
2
+ function getEquipmentTypeShortLabel(equipmentType) {
3
+ if (!equipmentType) {
4
+ return "";
5
+ }
6
+ return ALL_EQUIPMENTS[equipmentType]?.shortLabel ?? "";
7
+ }
8
+ function getEquipmentTypeTagLabel(equipmentType) {
9
+ if (!equipmentType) {
10
+ return "";
11
+ }
12
+ return ALL_EQUIPMENTS[equipmentType]?.tagLabel ?? "";
13
+ }
14
+ export {
15
+ getEquipmentTypeShortLabel,
16
+ getEquipmentTypeTagLabel
17
+ };
@@ -7,5 +7,7 @@
7
7
  export declare class CustomError extends Error {
8
8
  status: number;
9
9
  businessErrorCode?: string;
10
- constructor(message: string, status: number, businessErrorCode?: string);
10
+ businessErrorValues?: Record<string, unknown>;
11
+ constructor(message: string, status: number, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
11
12
  }
13
+ export declare function formatMessageValues(properties: Record<string, unknown>): Record<string, string>;
@@ -0,0 +1,20 @@
1
+ class CustomError extends Error {
2
+ constructor(message, status, businessErrorCode, businessErrorValues) {
3
+ super(message);
4
+ this.status = status;
5
+ this.businessErrorCode = businessErrorCode;
6
+ this.businessErrorValues = businessErrorValues;
7
+ }
8
+ }
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
+ export {
18
+ CustomError,
19
+ formatMessageValues
20
+ };
@@ -4,6 +4,7 @@
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
+ export * from './CustomError';
7
8
  export * from './elementType';
8
9
  export * from './equipmentType';
9
10
  export * from './equipmentTypes';
@@ -1,3 +1,4 @@
1
+ import { CustomError, formatMessageValues } from "./CustomError.js";
1
2
  import { ElementType } from "./elementType.js";
2
3
  import { ALL_EQUIPMENTS, BASE_EQUIPMENTS, EquipmentType, ExtendedEquipmentType, HvdcType, OperatingStatus, SEARCH_EQUIPMENTS, TYPE_TAG_MAX_SIZE, VL_TAG_MAX_SIZE, equipmentStyles, getEquipmentsInfosForSearchBar } from "./equipmentType.js";
3
4
  import { Battery, BusBar, DanglingLine, Generator, Hvdc, LCC, Line, Load, SVC, ShuntCompensator, Substation, ThreeWindingTransfo, TwoWindingTransfo, VSC, VoltageLevel } from "./equipmentTypes.js";
@@ -14,6 +15,7 @@ export {
14
15
  BASE_EQUIPMENTS,
15
16
  Battery,
16
17
  BusBar,
18
+ CustomError,
17
19
  DanglingLine,
18
20
  DistributionType,
19
21
  ElementType,
@@ -43,5 +45,6 @@ export {
43
45
  VSC,
44
46
  VoltageLevel,
45
47
  equipmentStyles,
48
+ formatMessageValues,
46
49
  getEquipmentsInfosForSearchBar
47
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.137.0",
3
+ "version": "0.139.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",
@@ -1,10 +0,0 @@
1
- class CustomError extends Error {
2
- constructor(message, status, businessErrorCode) {
3
- super(message);
4
- this.status = status;
5
- this.businessErrorCode = businessErrorCode;
6
- }
7
- }
8
- export {
9
- CustomError
10
- };