@gridsuite/commons-ui 0.144.0 → 0.145.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.
|
@@ -57,6 +57,16 @@ const useModificationLabelComputer = () => {
|
|
|
57
57
|
case MODIFICATION_TYPES.CREATE_VOLTAGE_LEVEL_SECTION.type:
|
|
58
58
|
case MODIFICATION_TYPES.MOVE_VOLTAGE_LEVEL_FEEDER_BAYS.type:
|
|
59
59
|
return modificationMetadata.voltageLevelId;
|
|
60
|
+
case MODIFICATION_TYPES.VOLTAGE_INIT_MODIFICATION.type:
|
|
61
|
+
if (modificationMetadata.rootNetworkName && modificationMetadata.nodeName && modificationMetadata.computationDate) {
|
|
62
|
+
const computedDateFormatted = new Intl.DateTimeFormat(intl.locale, {
|
|
63
|
+
dateStyle: "long",
|
|
64
|
+
timeStyle: "long",
|
|
65
|
+
hour12: false
|
|
66
|
+
}).format(new Date(modificationMetadata.computationDate));
|
|
67
|
+
return `: ${modificationMetadata.rootNetworkName} / ${modificationMetadata.nodeName} / ${computedDateFormatted}`;
|
|
68
|
+
}
|
|
69
|
+
return "";
|
|
60
70
|
default:
|
|
61
71
|
return modificationMetadata.equipmentId || "";
|
|
62
72
|
}
|
package/dist/index.js
CHANGED
|
@@ -203,7 +203,7 @@ import { fetchDefaultSecurityAnalysisProvider, fetchSecurityAnalysisParameters,
|
|
|
203
203
|
import { exportFilter, getAvailableComponentLibraries, getStudyNetworkVisualizationsParameters, getStudyShortCircuitParameters, setStudyNetworkVisualizationParameters, updateVoltageInitParameters } from "./services/study.js";
|
|
204
204
|
import { getNetworkVisualizationsParameters } from "./services/study-config.js";
|
|
205
205
|
import { fetchCurrentAnnouncement, fetchUserDetails } from "./services/userAdmin.js";
|
|
206
|
-
import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, getRequestParamFromList } from "./services/utils.js";
|
|
206
|
+
import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, convertToCustomError, getRequestParamFromList } from "./services/utils.js";
|
|
207
207
|
import { getVoltageInitParameters, getVoltageInitUrl } from "./services/voltage-init.js";
|
|
208
208
|
import { fetchShortCircuitParameters, getShortCircuitSpecificParametersDescription, updateShortCircuitParameters } from "./services/short-circuit-analysis.js";
|
|
209
209
|
import { equalsArray } from "./utils/algos.js";
|
|
@@ -709,6 +709,7 @@ export {
|
|
|
709
709
|
componentsFr,
|
|
710
710
|
convertInputValue,
|
|
711
711
|
convertOutputValue,
|
|
712
|
+
convertToCustomError,
|
|
712
713
|
copyToClipboard,
|
|
713
714
|
countRules,
|
|
714
715
|
createFilter,
|
package/dist/services/index.js
CHANGED
|
@@ -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, getRequestParamFromList } from "./utils.js";
|
|
11
|
+
import { backendFetch, backendFetchFile, backendFetchJson, backendFetchText, convertToCustomError, getRequestParamFromList } 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,6 +18,7 @@ export {
|
|
|
18
18
|
backendFetchFile,
|
|
19
19
|
backendFetchJson,
|
|
20
20
|
backendFetchText,
|
|
21
|
+
convertToCustomError,
|
|
21
22
|
createFilter,
|
|
22
23
|
createParameter,
|
|
23
24
|
elementAlreadyExists,
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
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
|
-
*/
|
|
1
|
+
import { CustomError } from '../utils/types/CustomError';
|
|
7
2
|
/** Optional convenience: allow per-call timeout override without crafting a signal manually. */
|
|
8
3
|
type FetchInitWithTimeout = RequestInit & {
|
|
9
4
|
/** If provided and no signal is set, use this as the timeout override (ms). */
|
|
10
5
|
timeoutMs?: number;
|
|
11
6
|
};
|
|
7
|
+
export declare const convertToCustomError: (response: string) => CustomError;
|
|
12
8
|
export declare const backendFetch: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<Response>;
|
|
13
9
|
export declare const backendFetchJson: (url: string, init?: FetchInitWithTimeout, token?: string) => Promise<any>;
|
|
14
10
|
export declare function backendFetchText(url: string, init?: FetchInitWithTimeout, token?: string): Promise<string>;
|
package/dist/services/utils.js
CHANGED
|
@@ -27,31 +27,24 @@ const prepareRequest = (init, token) => {
|
|
|
27
27
|
initWithSignal.headers.append("Authorization", `Bearer ${tokenCopy}`);
|
|
28
28
|
return initWithSignal;
|
|
29
29
|
};
|
|
30
|
+
const convertToCustomError = (response) => {
|
|
31
|
+
const errorJson = parseError(response);
|
|
32
|
+
if (errorJson?.businessErrorCode) {
|
|
33
|
+
return new CustomError(
|
|
34
|
+
`Server error: ${errorJson.detail}`,
|
|
35
|
+
errorJson.status,
|
|
36
|
+
errorJson.businessErrorCode,
|
|
37
|
+
errorJson.businessErrorValues
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (errorJson?.detail) {
|
|
41
|
+
return new CustomError(`Server error: ${errorJson.detail}`, errorJson.status);
|
|
42
|
+
}
|
|
43
|
+
return new CustomError(errorJson);
|
|
44
|
+
};
|
|
30
45
|
const handleError = (response) => {
|
|
31
46
|
return response.text().then((text) => {
|
|
32
|
-
|
|
33
|
-
const errorJson = parseError(text);
|
|
34
|
-
let customError;
|
|
35
|
-
if (errorJson?.businessErrorCode != null) {
|
|
36
|
-
throw new CustomError(
|
|
37
|
-
errorJson.detail,
|
|
38
|
-
errorJson.status,
|
|
39
|
-
errorJson.businessErrorCode,
|
|
40
|
-
errorJson.businessErrorValues
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
if (errorJson && errorJson.status && errorJson.error && errorJson.detail) {
|
|
44
|
-
customError = new CustomError(
|
|
45
|
-
`${errorName + errorJson.status} ${errorJson.error}, message : ${errorJson.detail}`,
|
|
46
|
-
errorJson.status
|
|
47
|
-
);
|
|
48
|
-
} else {
|
|
49
|
-
customError = new CustomError(
|
|
50
|
-
`${errorName + response.status} ${response.statusText}, message : ${text}`,
|
|
51
|
-
response.status
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
throw customError;
|
|
47
|
+
throw convertToCustomError(text);
|
|
55
48
|
});
|
|
56
49
|
};
|
|
57
50
|
const handleTimeoutError = (error) => {
|
|
@@ -87,5 +80,6 @@ export {
|
|
|
87
80
|
backendFetchFile,
|
|
88
81
|
backendFetchJson,
|
|
89
82
|
backendFetchText,
|
|
83
|
+
convertToCustomError,
|
|
90
84
|
getRequestParamFromList
|
|
91
85
|
};
|
|
@@ -5,9 +5,9 @@
|
|
|
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
|
-
status
|
|
8
|
+
status?: number;
|
|
9
9
|
businessErrorCode?: string;
|
|
10
10
|
businessErrorValues?: Record<string, unknown>;
|
|
11
|
-
constructor(message: string, status
|
|
11
|
+
constructor(message: string, status?: number, businessErrorCode?: string, businessErrorValues?: Record<string, unknown>);
|
|
12
12
|
}
|
|
13
13
|
export declare function formatMessageValues(properties: Record<string, unknown>): Record<string, string>;
|